public void SaveModel(string dsmFilename, bool compressFile, IProgress <ProgressInfo> progress) { Logger.LogDataModelMessage($"Save data model file={dsmFilename} compresss={compressFile}"); _metaDataModel.AddMetaDataItemToDefaultGroup("Total elements found", $"{GetExportedElementCount()}"); DsmModelFile dsmModelFile = new DsmModelFile(dsmFilename, _metaDataModel, _elementsDataModel, _relationsDataModel, _actionsDataModel); dsmModelFile.Save(compressFile, progress); ModelFilename = dsmFilename; }
public void LoadModel(string dsmFilename, IProgress <ProgressInfo> progress) { Logger.LogDataModelMessage($"Load data model file={dsmFilename}"); Clear(); DsmModelFile dsmModelFile = new DsmModelFile(dsmFilename, _metaDataModel, _elementsDataModel, _relationsDataModel, _actionsDataModel); dsmModelFile.Load(progress); IsCompressed = dsmModelFile.IsCompressedFile(); ModelFilename = dsmFilename; }
public void TestSaveModel() { string inputFile = "DsmSuite.DsmViewer.Model.Test.Input.dsm"; string outputFile = "DsmSuite.DsmViewer.Model.Test.Output.dsm"; FillModelData(); DsmModelFile writtenModelFile = new DsmModelFile(outputFile, this, this, this, this); writtenModelFile.Save(false, null); Assert.IsFalse(writtenModelFile.IsCompressedFile()); Assert.IsTrue(File.ReadAllBytes(outputFile).SequenceEqual(File.ReadAllBytes(inputFile))); }
public void TestLoadModel() { string inputFile = "DsmSuite.DsmViewer.Model.Test.Input.dsm"; DsmModelFile readModelFile = new DsmModelFile(inputFile, this, this, this, this); readModelFile.Load(null); Assert.IsFalse(readModelFile.IsCompressedFile()); Assert.AreEqual(2, _metaData.Count); Assert.AreEqual(2, _metaData["group1"].Count); Assert.AreEqual("item1", _metaData["group1"][0].Name); Assert.AreEqual("value1", _metaData["group1"][0].Value); Assert.AreEqual("item2", _metaData["group1"][1].Name); Assert.AreEqual("value2", _metaData["group1"][1].Value); Assert.AreEqual(2, _metaData["group2"].Count); Assert.AreEqual("item3", _metaData["group2"][0].Name); Assert.AreEqual("value3", _metaData["group2"][0].Value); Assert.AreEqual("item4", _metaData["group2"][1].Name); Assert.AreEqual("value4", _metaData["group2"][1].Value); Assert.AreEqual(3, _rootElement.Children.Count); IDsmElement a = _rootElement.Children[0]; Assert.AreEqual(11, a.Id); Assert.AreEqual(1, a.Order); Assert.AreEqual("", a.Type); Assert.AreEqual("a", a.Name); Assert.AreEqual("a", a.Fullname); Assert.IsTrue(a.IsExpanded); Assert.AreEqual(2, a.Children.Count); IDsmElement a1 = a.Children[0]; Assert.AreEqual(12, a1.Id); Assert.AreEqual(2, a1.Order); Assert.AreEqual("eta", a1.Type); Assert.AreEqual("a1", a1.Name); Assert.AreEqual("a.a1", a1.Fullname); Assert.IsFalse(a1.IsExpanded); IDsmElement a2 = a.Children[1]; Assert.AreEqual(13, a2.Id); Assert.AreEqual(3, a2.Order); Assert.AreEqual("eta", a2.Type); Assert.AreEqual("a2", a2.Name); Assert.AreEqual("a.a2", a2.Fullname); Assert.IsFalse(a2.IsExpanded); IDsmElement b = _rootElement.Children[1]; Assert.AreEqual(14, b.Id); Assert.AreEqual(4, b.Order); Assert.AreEqual("", b.Type); Assert.AreEqual("b", b.Name); Assert.AreEqual("b", b.Fullname); Assert.IsFalse(b.IsExpanded); Assert.AreEqual(2, b.Children.Count); IDsmElement b1 = b.Children[0]; Assert.AreEqual(15, b1.Id); Assert.AreEqual(5, b1.Order); Assert.AreEqual("etb", b1.Type); Assert.AreEqual("b1", b1.Name); Assert.AreEqual("b.b1", b1.Fullname); Assert.IsFalse(b1.IsExpanded); IDsmElement b2 = b.Children[1]; Assert.AreEqual(16, b2.Id); Assert.AreEqual(6, b2.Order); Assert.AreEqual("etb", b2.Type); Assert.AreEqual("b2", b2.Name); Assert.AreEqual("b.b2", b2.Fullname); Assert.IsFalse(b2.IsExpanded); IDsmElement c = _rootElement.Children[2]; Assert.AreEqual(17, c.Id); Assert.AreEqual(7, c.Order); Assert.AreEqual("", c.Type); Assert.AreEqual("c", c.Name); Assert.AreEqual("c", c.Fullname); Assert.IsFalse(c.IsExpanded); Assert.AreEqual(2, b.Children.Count); IDsmElement c1 = c.Children[0]; Assert.AreEqual(18, c1.Id); Assert.AreEqual(8, c1.Order); Assert.AreEqual("etc", c1.Type); Assert.AreEqual("c1", c1.Name); Assert.AreEqual("c.c1", c1.Fullname); Assert.IsFalse(c1.IsExpanded); IDsmElement c2 = c.Children[1]; Assert.AreEqual(19, c2.Id); Assert.AreEqual(9, c2.Order); Assert.AreEqual("etc", c2.Type); Assert.AreEqual("c2", c2.Name); Assert.AreEqual("c.c2", c2.Fullname); Assert.IsFalse(c2.IsExpanded); Assert.AreEqual(91, _relations[0].Id); Assert.AreEqual(a1.Id, _relations[0].ConsumerId); Assert.AreEqual(b1.Id, _relations[0].ProviderId); Assert.AreEqual("ra", _relations[0].Type); Assert.AreEqual(1000, _relations[0].Weight); Assert.AreEqual(92, _relations[1].Id); Assert.AreEqual(a2.Id, _relations[1].ConsumerId); Assert.AreEqual(b1.Id, _relations[1].ProviderId); Assert.AreEqual("ra", _relations[1].Type); Assert.AreEqual(200, _relations[1].Weight); Assert.AreEqual(93, _relations[2].Id); Assert.AreEqual(a1.Id, _relations[2].ConsumerId); Assert.AreEqual(b2.Id, _relations[2].ProviderId); Assert.AreEqual("ra", _relations[2].Type); Assert.AreEqual(30, _relations[2].Weight); Assert.AreEqual(94, _relations[3].Id); Assert.AreEqual(a2.Id, _relations[3].ConsumerId); Assert.AreEqual(b2.Id, _relations[3].ProviderId); Assert.AreEqual("ra", _relations[3].Type); Assert.AreEqual(4, _relations[3].Weight); Assert.AreEqual(95, _relations[4].Id); Assert.AreEqual(a1.Id, _relations[4].ConsumerId); Assert.AreEqual(c2.Id, _relations[4].ProviderId); Assert.AreEqual("ra", _relations[4].Type); Assert.AreEqual(5, _relations[4].Weight); Assert.AreEqual(96, _relations[5].Id); Assert.AreEqual(b2.Id, _relations[5].ConsumerId); Assert.AreEqual(a1.Id, _relations[5].ProviderId); Assert.AreEqual("rb", _relations[5].Type); Assert.AreEqual(1, _relations[5].Weight); Assert.AreEqual(97, _relations[6].Id); Assert.AreEqual(b2.Id, _relations[6].ConsumerId); Assert.AreEqual(a2.Id, _relations[6].ProviderId); Assert.AreEqual("rb", _relations[6].Type); Assert.AreEqual(2, _relations[6].Weight); Assert.AreEqual(98, _relations[7].Id); Assert.AreEqual(c1.Id, _relations[7].ConsumerId); Assert.AreEqual(a2.Id, _relations[7].ProviderId); Assert.AreEqual("rc", _relations[7].Type); Assert.AreEqual(4, _relations[7].Weight); Assert.AreEqual(2, _actions.Count); Assert.AreEqual(1, _actions[0].Id); Assert.AreEqual("Action1", _actions[0].Type); Assert.AreEqual("value1a", _actions[0].Data["key1a"]); // Assert.AreEqual("value1b", _actions[0].Data["key1b"]); Assert.AreEqual(2, _actions[1].Id); Assert.AreEqual("Action2", _actions[1].Type); Assert.AreEqual("value2a", _actions[1].Data["key2a"]); Assert.AreEqual("value2b", _actions[1].Data["key2b"]); Assert.AreEqual("value2c", _actions[1].Data["key2c"]); }