예제 #1
0
        public void Save()
        {
            string            propertiesXmlPath = Path.Combine(Utilities.GetTempDir(), "ScenarioProperties.xml");
            XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();

            xmlWriterSettings.Indent      = true;
            xmlWriterSettings.IndentChars = "\t";
            xmlWriterSettings.Encoding    = new UTF8Encoding(false);

            FileStream stream = new FileStream(propertiesXmlPath, FileMode.Create);

            using (XmlWriter writer = XmlWriter.Create(stream, xmlWriterSettings))
            {
                ScenarioProperties.Save(writer);
            }
            stream.Flush();
            stream.Close();

            TsSerializer.Save(ScenarioXml, Path.Combine(Utilities.GetTempDir(), "Scenario.bin"));

            var timestamp                        = DateTime.Now.ToString("yyyyMMdd-HHmmss");
            var scenarioFileName                 = Path.Combine(ScenarioDirectory, "Scenario.bin");
            var scenarioBackupFileName           = Path.Combine(ScenarioDirectory, string.Format("ScenarioBackup-{0}.bin", timestamp));
            var scenarioPropertiesFileName       = Path.Combine(ScenarioDirectory, "ScenarioProperties.xml");
            var scenarioPropertiesBackupFileName = Path.Combine(ScenarioDirectory, string.Format("ScenarioPropertiesBackup-{0}.xml", timestamp));

            File.Copy(scenarioFileName, scenarioBackupFileName);
            File.Copy(scenarioPropertiesFileName, scenarioPropertiesBackupFileName);

            File.Copy(Path.Combine(Utilities.GetTempDir(), "Scenario.bin"), scenarioFileName, true);
            File.Copy(propertiesXmlPath, scenarioPropertiesFileName, true);
        }
예제 #2
0
        public void ReadScenario(IProgress <int> progress = null)
        {
            progress?.Report(10);

            ScenarioXml = TsSerializer.Load(Path.Combine(ScenarioDirectory, "Scenario.bin"));

            progress?.Report(100);
        }