Beispiel #1
0
        private static void LockAndCreate()
        {
            WriteLine("\nEnter the Roadmap Group you want to Lock and Create:");
            var id = ReadLine();

            var roadmap = RoadmapGroupEdit.GetRoadmapGroup(int.Parse(id));

            if (roadmap.ValidationStatusValue != ValidationStatus.ValidatedWithSuccess)
            {
                WriteLine("Failed! The Roadmap Group must be validated with success before you can do a Lock and Create.");
                return;
            }

            roadmap.ConvertToVehicleInputStatusValue = ConvertToVehicleInputStatus.Processing;
            roadmap = roadmap.Save();

            WriteLine("Roadmap locked and created with success!");
        }
Beispiel #2
0
        private static string CheckForErrors(Stream xmlStream, RoadmapGroupEdit roadmap)
        {
            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 = GetContent(xmlStream);
                roadmap.ValidationStatusValue = ValidationStatus.ValidatedWithSuccess;
                msg = "Roadmap created/updated successfully!!";
            }

            return(msg);
        }
Beispiel #3
0
        private static void DeleteRoadmapGroup()
        {
            WriteLine("\nEnter the RoadmapGroupId for the RoadmapGroup you want to delete: ");
            var id = ReadLine();

            if (RoadmapGroupEdit.Exists(int.Parse(id)))
            {
                WriteLine("Hit <Enter> to start deleting.");
            }
            else
            {
                WriteLine($"The given id ({id}) doesn't exist.");
                return;
            }

            ReadKey();
            RoadmapGroupEdit.DeleteRoadmapGroup(int.Parse(id));

            WriteLine("RoadmapGroup deleted successfully.");
        }
Beispiel #4
0
        private static void UpdateRoadmapGroup()
        {
            _errors = 0;

            WriteLine("\nEnter the RoadmapGroupId for the RoadmapGroup you want to change: ");
            var id      = ReadLine();
            var roadmap = RoadmapGroupEdit.GetRoadmapGroup(int.Parse(id));

            WriteLine($"Current start year is {roadmap.StartYear}");
            WriteLine("Enter a new start year: ");
            var startYear = int.Parse(ReadLine());

            WriteLine($"Current EndYear is {roadmap.EndYear}");
            WriteLine("Enter a new 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();

            roadmap.StartYear = startYear;
            roadmap.EndYear   = endYear;

            var msg = CheckForErrors(xmlStream, roadmap);

            roadmap = roadmap.Save();

            WriteLine(msg);
        }
Beispiel #5
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);
                }
            }
        }