diff --git a/NAV Source Control Test Host/NAV Source Control Test Host.csproj b/NAV Source Control Test Host/NAV Source Control Test Host.csproj index b0c1c2b..2f48893 100644 --- a/NAV Source Control Test Host/NAV Source Control Test Host.csproj +++ b/NAV Source Control Test Host/NAV Source Control Test Host.csproj @@ -54,6 +54,8 @@ + + diff --git a/NAV Source Control Test Host/Program.cs b/NAV Source Control Test Host/Program.cs index c0fec8d..d89e7c6 100644 --- a/NAV Source Control Test Host/Program.cs +++ b/NAV Source Control Test Host/Program.cs @@ -4,6 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using log4net; +using System.Runtime.Serialization; +using System.Xml; +using System.Data.Linq; +using NavScm; +using NavScm.NavInterface; +using System.IO; namespace NavScm.TestHost { @@ -17,6 +23,47 @@ namespace NavScm.TestHost log.Info("Starting up..."); + var context = new NavSQLDataContext("Data Source=tbrt-sql-erp-01;Initial Catalog=\"TERRABIT 2015 DEV\";Integrated Security=True"); + var NavSqlObjects = context.NavObject; + + log.InfoFormat("{0} total entries in NavSqlObjects", NavSqlObjects.Count()); + + var query = from sql in NavSqlObjects + where sql.Modified == 1 + select sql; + + int count = query.Count(); + + log.InfoFormat("{0} modified objects detected, reading them...", count); + + var foundObjects = new Dictionary(count); + + int i = 1; + foreach (NavObject o in query) + { + log.DebugFormat("Row {6}/{7}: Type {0}, ID {1}, Name {2}, Modified {3} {4}, Version {5}", + o.Type, o.ID, o.Name, o.Date.ToShortDateString(), o.Time.ToShortTimeString(), o.Version_List, i++, count); + + foundObjects.Add(String.Format("{0}.{1}", o.Type, o.ID), o); + } + + log.InfoFormat("Collection has {0} entries, writing to cache.xml", foundObjects.Count); + + FileStream writer = new FileStream("cache.xml", FileMode.Create); + DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary)); + serializer.WriteObject(writer, foundObjects); + writer.Close(); + + log.Info("Reloading these entries"); + FileStream reader = new FileStream("cache.xml", FileMode.Open); + XmlDictionaryReader xmlReader = XmlDictionaryReader.CreateTextReader(reader, new XmlDictionaryReaderQuotas()); + var loadedObjects = (Dictionary)serializer.ReadObject(xmlReader, true); + + log.Debug("Dumping sample object 1.82004"); + + NavObject o2 = loadedObjects["1.82004"]; + log.DebugFormat("Type {0}, ID {1}, Name {2}, Modified {3} {4}, Version {5}", + o2.Type, o2.ID, o2.Name, o2.Date.ToShortDateString(), o2.Time.ToShortTimeString(), o2.Version_List); log.Info("Shutting down..."); diff --git a/NAVSCM Library/App.config b/NAVSCM Library/App.config new file mode 100644 index 0000000..b23f3ba --- /dev/null +++ b/NAVSCM Library/App.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/NAVSCM Library/NAVSCM Library.csproj b/NAVSCM Library/NAVSCM Library.csproj index 150372a..1bc22d1 100644 --- a/NAVSCM Library/NAVSCM Library.csproj +++ b/NAVSCM Library/NAVSCM Library.csproj @@ -37,7 +37,11 @@ True + + + + @@ -46,13 +50,41 @@ + + True + True + NavSQL.dbml + + + + + True + True + Settings.settings + + + + MSLinqToSQLGenerator + NavSQL.designer.cs + Designer + + + SettingsSingleFileGenerator + Settings.Designer.cs + - + + + + + + NavSQL.dbml +