コード例 #1
0
        public CINode BuiildNodesForCI(CINode node, int level = 0)
        {
            var children = _dbContext.DependencyItems.Where(di => di.BaseCiName == node.Value.Name)
                           .Select(di => new CINode {
                Value = di.DependencyCi
            }).ToList();

            if (children.Count() > 0)
            {
                var resultNodes = new List <CINode>();

                foreach (var ciNode in children)
                {
                    var fnode = BuiildNodesForCI(ciNode, level + 1);
                    if (fnode != null)
                    {
                        resultNodes.Add(fnode);
                    }
                    else
                    {
                        resultNodes.Add(ciNode);
                    }
                }

                node.Nodes = resultNodes;
            }

            if (level != 0)
            {
                return(null);
            }
            return(node);
        }
コード例 #2
0
        private CINode BuildNodesForCi(CINode node, int level)
        {
            var children = _dbContext.Dependencies.Where(di => di.DependencyCIName == node.Value.Name)
                           .Select(di => new CINode {
                Value = di.BaseCI
            }).ToList();

            if (children.Count > 0)
            {
                var resultNodes = new List <CINode>();

                foreach (var child in children)
                {
                    var foundNode = BuildNodesForCi(child, level + 1);
                    if (foundNode != null)
                    {
                        resultNodes.Add(foundNode);
                    }
                    else
                    {
                        resultNodes.Add(child);
                    }

                    node.Nodes = resultNodes;
                }
            }

            if (level != 0)
            {
                return(null);
            }

            return(node);
        }
コード例 #3
0
        public void DeprecateImpact()
        {
            _consoleManager.Header("Check impact to deprecate a CI");
            _configItemManager.MicroTableList();
            Console.Write("Write name of node: ");
            string name = Console.ReadLine()?.ToUpper();

            var foundCi = _dbContext.ConfigurationItems.Find(name);

            if (foundCi == null)
            {
                _consoleManager.PressAnyKeyMessage("CI was not found in the system...");
                _consoleManager.LoadFirstScreen();
            }
            Console.WriteLine();

            Console.WriteLine("HIERARCHY");
            CINode node = BuiildNodesForCI(new CINode {
                Value = foundCi
            });

            PrintNodeToDeprecate(node, node.Value.Name);
            Console.WriteLine();

            _consoleManager.PressAnyKeyMessage();
            _consoleManager.LoadFirstScreen();
        }
コード例 #4
0
        public void PrintNodeToDeprecate(CINode node, string original, int level = 0)
        {
            if (node == null)
            {
                return;
            }

            Console.Write('|');
            Console.Write(new string('-', level));
            Console.Write(new string('-', level));
            Console.Write(new string('-', level));
            Console.WriteLine(node.Value.DeprecateMessage(original));

            if (node.Nodes != null && !node.Nodes.Any())
            {
                return;
            }

            if (node.Nodes != null)
            {
                foreach (var ciNode in node.Nodes)
                {
                    PrintNodeToDeprecate(ciNode, original, level + 1);
                }
            }
        }
コード例 #5
0
        public void PrintNodeToEraseForCi(CINode node, int level = 0)
        {
            if (node == null)
            {
                return;
            }

            Console.Write('|');
            Console.Write(new string('-', level));
            Console.Write(new string('-', level));
            Console.Write(new string('-', level));
            Console.WriteLine(node.Value.ErasingMessage());

            if (node.Nodes != null && !node.Nodes.Any())
            {
                return;
            }

            if (node.Nodes != null)
            {
                foreach (var ciNode in node.Nodes)
                {
                    PrintNodeToEraseForCi(ciNode, level + 1);
                }
            }
        }
コード例 #6
0
        public CINode BuildNodesForCi(ConfigurationItem item)
        {
            CINode node = new CINode
            {
                Value = item
            };

            return(BuildNodesForCi(node, 0));
        }
コード例 #7
0
        private void PrintNodeTree(CINode node, int level)
        {
            if (node == null)
            {
                return;
            }

            Console.Write('|');
            Console.Write(new string('-', level * 2));
            Console.WriteLine($"{node.Value.Name}        PERSON RESPONSIBLE IS: {node.Value.Responsible}");

            if (node.Nodes != null && !node.Nodes.Any())
            {
                return;
            }

            if (node.Nodes != null)
            {
                foreach (var childNode in node.Nodes)
                {
                    PrintNodeTree(childNode, level + 1);
                }
            }
        }
コード例 #8
0
        public void PerfomCiUpgradeOrDowngrade()
        {
            Console.WriteLine("PERFOM UPGRADE/DOWNGRADE");
            Console.WriteLine(new string('-', 25));
            _configurationItemManager.ListCIWithVersion();
            Console.WriteLine(new string('-', 25));
            Console.Write("Select Configuration Item to Ugrade/Downgrade: ");

            string selectedCi = Console.ReadLine()?.ToUpper();

            var ci = _dbContext.ConfigurationItems.Find(selectedCi);

            if (ci == null)
            {
                _menuManager.PerformConsolePause("The given configuration item was not found in the database");
                return;
            }

            bool   versionValid   = false;
            string writtenVersion = "0.0.0";

            while (!versionValid)
            {
                Console.Write($"Enter new version ({ci.Version}): ");
                string version = Console.ReadLine()?.ToUpper();

                var match = Regex.Match(version, _semVerPattern, RegexOptions.IgnoreCase);

                if (match.Success)
                {
                    versionValid   = true;
                    writtenVersion = version;
                }
                else
                {
                    Console.Write("      YOU ENTERED AN INVALID SEMANTIC VERSION NUMBER");
                    Console.WriteLine();
                }
            }

            int[] newVersionChunks = writtenVersion.Split('.').Select(str => Int32.Parse(str)).ToArray();
            int[] oldVersionChunks = ci.Version.Split('.').Select(str => Int32.Parse(str)).ToArray();

            CINode node = _reportsManager.BuildNodesForCi(ci);

            //0 => Major //1 => Minor //2 => Patch
            if (oldVersionChunks[0] != newVersionChunks[0])
            {
                Console.WriteLine("Detected Major Change in versions");
                Console.WriteLine("Dangerous Action!");
                Console.WriteLine("Changes were not saved !");
                Console.WriteLine("HERE IS THE HIERARCHY TREE");
                _reportsManager.PrintNodeTree(node);
            }
            else if (oldVersionChunks[1] != newVersionChunks[1])
            {
                Console.WriteLine("Detected Minor Change in versions");
                Console.WriteLine("It is possible that certain Items may be affected");
                ci.Version = writtenVersion;
                _dbContext.Entry(ci).State = EntityState.Modified;
                _dbContext.SaveChanges();
                Console.WriteLine("HERE IS THE HIERARCHY TREE");
                _reportsManager.PrintNodeTree(node);
            }
            else if (oldVersionChunks[2] != newVersionChunks[2])
            {
                Console.WriteLine("Detected a patch change");
                ci.Version = writtenVersion;
                _dbContext.Entry(ci).State = EntityState.Modified;
                _dbContext.SaveChanges();
            }
            else
            {
                Console.WriteLine("No changes detected at all");
            }

            _menuManager.PerformConsolePause("Press any key to continue...");
        }
コード例 #9
0
 public void PrintNodeTree(CINode node)
 {
     PrintNodeTree(node, 0);
 }