Exemple #1
0
        private static void CreateRoadmapGroup()
        {
            _errors = 0;

            WriteLine("\nEnter a name for the Roadmap");
            var name = ReadLine();

            WriteLine("Enter start year: ");
            var startYear = int.Parse(ReadLine());

            WriteLine("Enter end year: ");
            var endYear = int.Parse(ReadLine());

            var xmlStream = GetFileDialog(FileTypes.xml.ToString());

            if (xmlStream == null)
            {
                WriteLine("Action was cancelled");

                return;
            }

            Vehicles = VehiclesInfo.GetVehicles(xmlStream);

            CheckComponentsForVehicles();

            var roadmap = RoadmapGroupEdit.CreateRoadmapGroup();

            roadmap.RoadmapName  = name;
            roadmap.CreationTime = DateTime.Now;
            roadmap.StartYear    = startYear;
            roadmap.EndYear      = endYear;
            roadmap.ConvertToVehicleInputStatusValue = ConvertToVehicleInputStatus.Pending;

            //string msg = string.Empty;

            //if (_errors != 0) {
            //  msg = $"Missing Components in database. Found {_errors} errors in Xml-file.";
            //  msg += "\nRoadmap Group created but no Xml uploaded";
            //  roadmap.ValidationStatusValue = ValidationStatus.ValidatedWithFailures;
            //}
            //else {
            //  roadmap.Xml = GetXml(xmlStream);
            //  roadmap.ValidationStatusValue = ValidationStatus.ValidatedWithSuccess;
            //  msg = "Roadmap created successfully!!";
            //}

            var msg = CheckForErrors(xmlStream, roadmap);

            roadmap = roadmap.Save();

            WriteLine(msg);
        }
Exemple #2
0
        private static void CreateRoadmapGroupWRules()
        {
            var roadmap = RoadmapGroupEdit.CreateRoadmapGroup();

            WriteLine("\nEnter a name for the Roadmap");
            roadmap.RoadmapName = ReadLine();
            WriteLine("Enter start year: ");
            var s = ReadLine();

            roadmap.StartYear = string.IsNullOrEmpty((s)) ? 0 : int.Parse(s);
            WriteLine("Enter end year: ");
            s = ReadLine();
            roadmap.EndYear = string.IsNullOrEmpty(s) ? 0 : int.Parse(s);

            if (roadmap.BrokenRulesCollection.Count() > 0)
            {
                foreach (var error in roadmap.BrokenRulesCollection)
                {
                    WriteLine(error.Description);
                }

                return;
            }

            var xmlStream = GetFileDialog(FileTypes.xml.ToString());

            if (xmlStream == null)
            {
                WriteLine("Action was cancelled");

                return;
            }

            roadmap.CreationTime = DateTime.Now;
            WriteLine($"Checking components...");
            roadmap.Xml = GetContent(xmlStream);
            roadmap.ConvertToVehicleInputStatusValue = ConvertToVehicleInputStatus.Pending;

            if (roadmap.IsSavable)
            {
                WriteLine($"Start saving at: {DateTime.Now.ToString("hh:mm:ss.fff")}");
                roadmap = roadmap.Save();
                WriteLine($"End saving at: {DateTime.Now.ToString("hh:mm:ss.fff")}");
                if (roadmap.ValidationStatusValue == ValidationStatus.ValidatedWithSuccess)
                {
                    WriteLine("Roadmap Group successfully saved!");
                }
                else
                {
                    foreach (var item in roadmap.BrokenRulesCollection)
                    {
                        WriteLine(item.Description);
                    }
                }
            }
            else
            {
                foreach (var error in roadmap.BrokenRulesCollection)
                {
                    WriteLine(error.Description);
                }
            }
        }