Esempio n. 1
0
        internal static void CreateModuleNamesFile(KnowledgeBase KB)
        {
            string             pathNvg = Path.Combine(Utility.SpcDirectory(KB), "NvgComparer");
            string             path    = pathNvg + "\\ModuleNames.txt";
            KBObjectDescriptor kbod    = KBObjectDescriptor.Get("Module");
            List <string>      lines   = new List <string>();

            foreach (KBObject obj in KB.DesignModel.Objects.GetAll(kbod.Id))
            {
                lines.Add(obj.QualifiedName.ToString());
            }
            File.WriteAllLines(path, SortModulesByLevel(lines).ToArray());
        }
Esempio n. 2
0
        internal static void PrepareComparerNavigation(KnowledgeBase KB, IOutputService output)
        {
            string title = "KBDoctor - Prepare Comparer Navigation Files";

            output.StartSection("KBDoctor", title);
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            string directoryArg = Utility.NvgComparerDirectory(KB);
            string fechahora    = String.Format("{0:yyyy-MM-dd-HHmm}", DateTime.Now);
            string newDir       = directoryArg + @"\NVG-" + fechahora + @"\";

            try
            {
                Directory.CreateDirectory(newDir);
                Utility.WriteXSLTtoDir(KB);
                string   pathspcdir = Utility.SpcDirectory(KB);
                string[] paths      = Directory.GetDirectories(Utility.SpcDirectory(KB), "NVG", System.IO.SearchOption.AllDirectories);
                foreach (string d in paths)
                {
                    KBDoctorOutput.Message("Procesando directorio: " + d);
                    string generator = d.Replace(Utility.SpcDirectory(KB), "");
                    generator = generator.Replace("NVG_", "");
                    generator = @"\" + generator.Replace(@"\", "_") + "_";
                    generator = generator.Replace("NVG_", "");

                    ProcesoDir(KB, d, newDir, generator, output);
                }

                stopWatch.Stop();
                // Get the elapsed time as a TimeSpan value.
                TimeSpan ts = stopWatch.Elapsed;

                // Format and display the TimeSpan value.
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                   ts.Hours, ts.Minutes, ts.Seconds,
                                                   ts.Milliseconds / 10);

                KBDoctorOutput.Message(title + " elepsed time: " + elapsedTime);
                output.EndSection("KBDoctor", title, true);
            }
            catch (Exception e) {
                output.AddErrorLine(e.Message);
            }
        }
Esempio n. 3
0
        internal static void ReplaceModulesInNVGFiles(KnowledgeBase KB, IOutputService output)
        {
            string pathNvg      = Path.Combine(Utility.SpcDirectory(KB), "NvgComparer");
            string fileWildcard = @"*.*";

            string[]      Files            = Directory.GetDirectories(pathNvg, fileWildcard);
            string[]      Last2directories = GetLast2Directorys(Files, output);
            List <string> replaces         = new List <string>();

            foreach (string line in File.ReadAllLines(Utility.GetModuleNamesFilePath(KB)))
            {
                if (!line.TrimStart().StartsWith("#"))
                {
                    replaces.Add(line + ".");
                }
            }
            RemoveTextInFiles(Last2directories[0], fileWildcard, replaces, output);
            RemoveTextInFiles(Last2directories[1], fileWildcard, replaces, output);
        }
Esempio n. 4
0
        internal static bool CompareLastNVGDirectories(KnowledgeBase KB, IOutputService output)
        {
            try
            {
                bool     isSuccess        = true;
                string   pathNvg          = Path.Combine(Utility.SpcDirectory(KB), "NvgComparer");
                string   fileWildcard     = @"*.*";
                string[] Files            = Directory.GetDirectories(pathNvg, fileWildcard);
                string[] Last2directories = GetLast2Directorys(Files, output);
                int      cant_error       = 0;
                if (Last2directories == null || Last2directories.Length != 2)
                {
                    output.AddErrorLine("Ocurrió un error procesando los directorios de navegaciones.");
                    output.AddErrorLine("Asegúrece de que existen al menos dos directorios con nombres en el formato válido (NVG-AAAA-MM-DD-HHMM)");
                }
                else
                {
                    KBDoctorOutput.Message("Se utilizarán los siguientes directorios para comparar:");
                    KBDoctorOutput.Message("-- " + Last2directories[0].ToString());
                    KBDoctorOutput.Message("-- " + Last2directories[1].ToString());
                    List <string> Diffs = EqualNavigationDirectories(Last2directories[0], Last2directories[1], output);
                    KBDoctorOutput.Message("-- Los directorios se procesaron correctamente.");
                    if (Diffs.Count > 0)
                    {
                        KBDoctorOutput.Message("-- Se encontraron diferencias en las navegaciones de los siguientes objetos:");
                        List <string> FilesDiff = new List <string>();
                        foreach (string x in Diffs)
                        {
                            string[]           objectnametype = Utility.ReadQnameTypeFromNVGFile(x, output);
                            string             filename       = Path.GetFileName(x);
                            string             objtype        = objectnametype[0];
                            string             objmodule      = objectnametype[1];
                            string             objname        = objectnametype[2];
                            KBObjectDescriptor kbod           = KBObjectDescriptor.Get(objtype);
                            QualifiedName      qname          = new QualifiedName(objmodule, objname);
                            //Null in HCIHisMo
                            KBObject obj = KB.DesignModel.Objects.Get(kbod.Id, qname);
                            if (obj != null)
                            {
                                if (obj.Timestamp <= Utility.GetDateTimeNVGDirectory(Last2directories[1].ToString()))
                                {
                                    FilesDiff.Add(filename);
                                    if (objmodule != "")
                                    {
                                        KBDoctorOutput.Message("-- ERROR " + objmodule + '.' + objname + " fue modificado en \t\t" + obj.Timestamp.ToString());
                                    }
                                    else
                                    {
                                        KBDoctorOutput.Message("-- ERROR " + objname + " fue modificado en \t\t" + obj.Timestamp.ToString());
                                    }

                                    isSuccess = false;
                                    cant_error++;
                                }
                                else
                                {
                                    if (objmodule != "")
                                    {
                                        KBDoctorOutput.Message("-- -- OK " + objmodule + '.' + objname + " fue modificado en \t\t" + obj.Timestamp.ToString());
                                    }
                                    else
                                    {
                                        KBDoctorOutput.Message("-- -- OK " + objname + " fue modificado en \t\t" + obj.Timestamp.ToString());
                                    }
                                }
                            }
                            else
                            {
                                KBDoctorOutput.Message("-- NO SE ENCONTRO EL OBJETO: " + qname.ToString());
                            }
                        }
                        CopyDifferences(FilesDiff, Last2directories[0], Last2directories[1], "NvgErrors");
                    }
                    else
                    {
                        DeleteDifferenceDir(KB);
                        KBDoctorOutput.Message("No se encontraron diferencias en las navegaciones");
                    }
                }
                if (cant_error > 0)
                {
                    output.AddErrorLine("Se encontraron " + cant_error + " errores en la comparación.");
                }
                return(isSuccess);
            }
            catch (Exception e)
            {
                KBDoctorOutput.Message(e.Message);
                return(false);
            }
        }
Esempio n. 5
0
        internal static string GetModuleNamesFilePath(KnowledgeBase KB)
        {
            string pathNvg = Path.Combine(Utility.SpcDirectory(KB), "NvgComparer");

            return(pathNvg + "\\ModuleNames.txt");
        }