Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.Title = "Flake - OpenText Metastorm Assistant";


            General_Toolbox.PrintWelcomeMessage();

            try
            {
                General_Toolbox.ProcessArguments(args);
            }
            catch (Undefined_Element_Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Invokes Deploy.exe tool with provided commandline parameters. Currently only upload MBMP projects, excluding libraries.
        /// </summary>
        /// <param name="opentextPath">Path to folder containing Metastorm projects.
        /// All projects in the folder are recursively searched and then uploaded.</param>
        /// <param name="deployToolPath">Path to "deploy.exe: tool.</param>
        /// <param name="deploymentServiceConfigPath">Path to deployment service configuration file in XML.</param>
        /// <param name="performIntegratedUpdate">Flag indicating whether an update of libraries in projects should be performed.
        /// This update uses internal deploy.exe mechanism</param>
        public static void PerformDeploy(string opentextPath, string deployToolPath, string deploymentServiceConfigPath, bool performIntegratedUpdate)
        {
            if (!File_Toolbox.IsFileLocked(deployToolPath) && !File_Toolbox.IsFileLocked(deploymentServiceConfigPath))
            {
                Console.WriteLine();
                General_Toolbox.PrintContinouslyLine("Uruchamianie narzędzia DEPLOY.EXE z podanymi argumentami");
                General_Toolbox.PrintContinouslyLine("Narzędzie wyśle tylko projekty. Wysyłanie bibliotek jest obecnie wyłączone.");
                General_Toolbox.PrintContinouslyLine("Wysyłanie na środowisko DEV...");

                ProcessStartInfo processInfo = new ProcessStartInfo();

                string argumentsLine = "/dir;" + opentextPath + ";bpmproj" + " " + "/deploymentservice;" + deploymentServiceConfigPath + ";" + "flake;snowflake";

                if (performIntegratedUpdate)
                {
                    argumentsLine += " /forcelibmatch";
                    General_Toolbox.PrintContinouslyLine("Włączone użycie wewnętrzego mechanizmu aktualizacji bibliotek.");
                }
                else
                {
                    General_Toolbox.PrintContinouslyLine("Wyłączenie wewnętrzego mechanizmu aktualizacji bibliotek.");
                }

                processInfo.Arguments       = argumentsLine;
                processInfo.CreateNoWindow  = false;
                processInfo.ErrorDialog     = true;
                processInfo.UseShellExecute = true;
                processInfo.FileName        = deployToolPath;
                processInfo.WindowStyle     = ProcessWindowStyle.Normal;


                using (Process deployexe = Process.Start(processInfo))
                {
                    deployexe.WaitForExit();
                }
            }
            else
            {
                General_Toolbox.PrintContinouslyLine("Program Flake nie był w stanie wywołać narzędzia 'DEPLOY.EXE' ze względu na błędną konfigurację");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes commandline arguments according to the rules set in CMD_Parser_Options.
        /// </summary>
        /// <param name="srcArgs">Arguments taken from commandline.</param>
        public static void ProcessArguments(string[] srcArgs)
        {
            var options = new CMD_Parser_Options();

            if (Parser.Default.ParseArguments(srcArgs, options))
            {
                PrintContinously("Tryb pracy: ");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(options.SpecifiedWorkingMode);
                Console.ForegroundColor = ConsoleColor.White;

                switch (options.SpecifiedWorkingMode)
                {
                case WorkingMode.TRAC:

                    PrintContinously("Lokalizacja folderu OpenText: ");
                    Console.ForegroundColor = ConsoleColor.Yellow;


                    if (options.OpenTextFolderPath != null)
                    {
                        Console.WriteLine(options.OpenTextFolderPath.ToUpper());
                        Console.ForegroundColor = ConsoleColor.White;
                        try { Trac_Toolbox.MakeNote(options.OpenTextFolderPath); }
                        catch (Empty_Directory_Exception exc)
                        {
                            Console.WriteLine(exc.Message);
                        }
                        catch (IOException exc)
                        {
                            Console.WriteLine(exc.Message);
                        }
                    }
                    else
                    {
                        throw new Undefined_Element_Exception("Brak podanej lokalizacji folderu OpenText!");
                    }
                    break;

                case WorkingMode.DEPLOY:

                    PrintContinously("Lokalizacja folderu OpenText: ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(options.OpenTextFolderPath.ToUpper());
                    Console.ForegroundColor = ConsoleColor.White;

                    PrintContinously("Lokalizacja folderu z narzędziem DEPLOY.EXE: ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(options.DeploymentToolPath.ToUpper());
                    Console.ForegroundColor = ConsoleColor.White;

                    PrintContinouslyLine("Lokalizacja folderu z plikiem konfiguracyjnym Deploy Service Config: ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(options.DeploymentConfigPath.ToUpper());
                    Console.ForegroundColor = ConsoleColor.White;

                    if (options.OpenTextFolderPath == null)
                    {
                        throw new Undefined_Element_Exception("Brak podanej lokalizacji folderu OpenText!");
                    }

                    if (options.DeploymentToolPath == null)
                    {
                        throw new Undefined_Element_Exception("Brak podanej lokalizacji folderu z narzędziem DEPLOY.EXE!");
                    }

                    if (options.DeploymentConfigPath == null)
                    {
                        throw new Undefined_Element_Exception("Brak podanej lokalizacji folderu z plikiem konfiguracyjnym Deploy Service Config!");
                    }

                    bool forceLibMatch;

                    General_Toolbox.PrintContinouslyLine("Czy chcesz użyć wewnętrznego mechanizmu Metastorma do aktualizacji bilbiotek przed Deployem? TAK/NIE");
                    Console.Write(">>\t");
                    if (Console.ReadLine() == "TAK")
                    {
                        forceLibMatch = true;
                        try
                        { LibChange_Toolbox.PerformLibChange(options.OpenTextFolderPath, 1, 1); }
                        catch (Undefined_Element_Exception e)
                        { Console.WriteLine(e.Message); };
                    }
                    else
                    {
                        forceLibMatch = false;
                    }

                    Deploy_Toolbox.PerformDeploy(options.OpenTextFolderPath, options.DeploymentToolPath, options.DeploymentConfigPath, forceLibMatch);

                    break;


                case WorkingMode.UPDATE:

                    PrintContinously("Lokalizacja folderu OpenText: ");

                    if (options.OpenTextFolderPath != null)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine(options.OpenTextFolderPath.ToUpper());
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    else
                    {
                        throw new Undefined_Element_Exception("Brak podanej lokalizacji folderu OpenText!");
                    }

                    try { LibChange_Toolbox.PerformLibChange(options.OpenTextFolderPath,
                                                             Database_Toolbox.GetLibraryVersion("CommonLib"),
                                                             Database_Toolbox.GetLibraryVersion("CommonlibraryLib")); }
                    catch (Undefined_Element_Exception e)
                    { Console.WriteLine(e.Message); };
                    break;

                case WorkingMode.DOWNGRADE:

                    PrintContinously("Lokalizacja folderu OpenText: ");

                    if (options.OpenTextFolderPath != null)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine(options.OpenTextFolderPath.ToUpper());
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    else
                    {
                        throw new Undefined_Element_Exception("Brak podanej lokalizacji folderu OpenText!");
                    }

                    try
                    { LibChange_Toolbox.PerformLibChange(options.OpenTextFolderPath, 1, 1); }
                    catch (Undefined_Element_Exception e)
                    { Console.WriteLine(e.Message); }
                    ;
                    break;
                }
            }
            // else Console.WriteLine(options.GetUsage()); // doubles GetUsage() call

            PrintContinouslyLine("Program zakończył swoje działanie.");
        }
Ejemplo n.º 4
0
        /// <summary>
        ///  Creates a txt file in the project folder using data from source variable.
        /// </summary>
        /// <param name="folderPath">Source string to be put into the note.</param>

        public static void MakeNote(string folderPath)
        {
            General_Toolbox.PrintContinously("Sprawdzanie poprawności ścieżki: ");

            var directoryList = File_Toolbox.CollectFoldersList(folderPath, "Sol");

            // if directory is empty an exception is thrown - there is nothing to do
            if (!directoryList.Any())
            {
                General_Toolbox.PrintState(OperationState.FAILURE);
                throw new Empty_Directory_Exception("Brak projektów w folderze! Wyjątek wystąpił w Trac_Toolbox.MakeNote()");
            }

            General_Toolbox.PrintState(OperationState.SUCCESS);

            directoryList.Sort();

            General_Toolbox.PrintContinouslyLine("Znalezione solucje:");

            for (int index = 0; index < directoryList.Count; index++)
            {
                Console.WriteLine(index + ". " + directoryList[index]);
            }

            // trimming from unnecessary folder elements - libs

            Console.WriteLine();
            General_Toolbox.PrintContinouslyLine("Ignorowanie projektów bibliotek.");
            Console.WriteLine();

            directoryList.Remove("TestSVNSol");
            directoryList.Remove(".svn");
            directoryList.Remove("DSAAdministracjaSol");
            directoryList.Remove("CommonLibrarySol");
            directoryList.Remove("CommonSol");

            // generating a note and inserting it into every folder to cause track to redeploy whole solution
            General_Toolbox.PrintContinouslyLine("Notatki dla projektów: ");
            for (int index = 0; index < directoryList.Count; index++)
            {
                if (!File.Exists(folderPath + @"\" + directoryList[index] + @"\TracNote.txt"))
                {
                    // Create a file to write to.
                    using (StreamWriter sw = File.CreateText(folderPath + @"\" + directoryList[index] + @"\TracNote.txt"))
                    {
                        sw.WriteLine("Ostatnia modyfikacja dla narzędzia Trac: " + DateTime.Now.ToString());
                        sw.WriteLine("Utworzył: " + Environment.UserName);
                        sw.Close();
                        Console.WriteLine(index + ". " + directoryList[index]);
                    }
                }
                else if (!File_Toolbox.IsFileLocked(folderPath + @"\" + directoryList[index] + @"\TracNote.txt"))
                {
                    using (FileStream f = new FileStream(folderPath + @"\" + directoryList[index] + @"\TracNote.txt", FileMode.Append, FileAccess.Write))
                        using (StreamWriter sw = new StreamWriter(f))
                            sw.WriteLine("Ostatnia modyfikacja dla narzedzia TRAC: " + DateTime.Now.ToString());
                }
                else
                {
                    throw new IOException("Nie można uzyskać dostępu do plików.");
                }
            }
            General_Toolbox.PrintContinouslyLine("zostały utworzone.");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Changes the libraries versions in the project to those set by the parameters.
        /// Ignores non-project elements.
        /// </summary>
        /// <param name="folderPath"></param>
        /// <param name="commonLibVer"></param>
        /// <param name="commonLibraryLibVer"></param>
        public static void PerformLibChange(string folderPath, int commonLibVer, int commonLibraryLibVer)
        {
            List <string> projectDirectoryList = new List <string>();

            General_Toolbox.PrintContinously("Sprawdzanie poprawności ścieżki: ");

            List <string> solutionDirectoryList = File_Toolbox.CollectFoldersList(folderPath, "Sol");

            // if directory is empty an exception is thrown - there is nothing to do
            if (!solutionDirectoryList.Any())
            {
                General_Toolbox.PrintState((OperationState.FAILURE));
                throw new Empty_Directory_Exception("Brak projektów w folderze! Wyjątek wystąpił w Update_Toolbox.PerformUpdate()");
            }

            General_Toolbox.PrintState((OperationState.SUCCESS));
            solutionDirectoryList.Sort();

            General_Toolbox.PrintContinouslyLine("Znalezione solucje: " + solutionDirectoryList.Count());

            if (System.Diagnostics.Debugger.IsAttached)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.WriteLine("\nDEBUG INFO:");
                Console.ForegroundColor = ConsoleColor.White;
                for (int index = 0; index < solutionDirectoryList.Count; index++)
                {
                    Console.WriteLine(index + ". " + solutionDirectoryList[index]);
                }
            }
            // trimming from unnecessary folder elements - libs

            Console.WriteLine();
            General_Toolbox.PrintContinouslyLine("Ignorowanie projektów bibliotek i elementów pobocznych.");
            Console.WriteLine();

            solutionDirectoryList.Remove("TestSVNSol");
            solutionDirectoryList.Remove("CommonLibrarySol");
            solutionDirectoryList.Remove("CommonSol");
            solutionDirectoryList.Remove("DSAAdministracjaSol");

            General_Toolbox.PrintContinouslyLine("Biblioteka CommonLib w wersji V" + commonLibVer);
            General_Toolbox.PrintContinouslyLine("Biblioteka CommonLibraryLib w wersji V" + commonLibraryLibVer);
            Console.WriteLine();

            /* Preparing list of project folders in solution folders
             *
             * Assuming there is only one folder inside solution folder!
             */

            for (int i = 0; i < solutionDirectoryList.Count(); i++)
            {
                foreach (var index in System.IO.Directory.GetDirectories(folderPath + @"\" + solutionDirectoryList[i]))
                {
                    var dirName = new DirectoryInfo(index).Name;
                    projectDirectoryList.Add(dirName);

                    if (System.Diagnostics.Debugger.IsAttached) // check for DEBUG configuration
                    {
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine("\nDEBUG INFO:");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(solutionDirectoryList[i] + "---->" + projectDirectoryList[i]);
                        Console.WriteLine();
                    }
                }
            }

            for (int j = 0; j < projectDirectoryList.Count(); j++)
            {
                try
                {
                    XDocument    xDoc       = XDocument.Load(folderPath + @"\" + solutionDirectoryList[j] + @"\" + projectDirectoryList[j] + @"\" + projectDirectoryList[j] + @".BPMProj");
                    XNamespace   xNameSpace = "http://schema.metastorm.com/Metastorm.Common.Markup";
                    var          reader     = xDoc.CreateReader();
                    var          manager    = new XmlNamespaceManager(reader.NameTable);
                    const string expression = ".//x:Object[@x:Value and @x:Type='{pref_-1405111153:LibraryReference}']";

                    manager.AddNamespace("x", "http://schema.metastorm.com/Metastorm.Common.Markup");

                    var XNodeList = xDoc.XPathSelectElements(expression, manager);

                    //Console.WriteLine(XNodeList.First().Attributes());



                    //"{{http://schema.metastorm.com/Metastorm.Common.Markup}Value}"

                    foreach (var element in XNodeList)
                    {
                        bool CLLUpdated = false;
                        bool CLUpdated  = false;
                        var  attList    = element.Attributes().ToList();
                        var  oldAtt     = attList.Last();


                        if ((element.LastAttribute.Value).Contains(@"CommonLib;"))
                        {
                            if (oldAtt != null)
                            {
                                XAttribute newAtt = new XAttribute(attList.Last().Name,
                                                                   @"3eff89cc-982d-43c6-97e8-e2df5fc00e4a;Metastorm.Model.Projects.BpmLibrary, Metastorm.Model.Bpm;;dev axa;CommonLib;" + commonLibVer.ToString());
                                attList.Add(newAtt);
                                attList.Remove(oldAtt);
                                element.ReplaceAttributes(attList);
                                xDoc.Save(folderPath + @"\" + solutionDirectoryList[j] + @"\" + projectDirectoryList[j] + @"\" + projectDirectoryList[j] + @".BPMProj");
                                CLUpdated = true;
                            }
                            else
                            {
                                throw new Undefined_Element_Exception(@"Atrybut 'Value' dla CommonLib nie ma wartości. Plik może być uszkodzony.");
                            }
                        }
                        else if ((element.LastAttribute.Value).Contains(@"CommonLibraryLib;"))
                        {
                            if (oldAtt != null)
                            {
                                XAttribute newAtt = new XAttribute(attList.Last().Name,
                                                                   @"3eff89cc-982d-43c6-97e8-e2df5fc00e4a;Metastorm.Model.Projects.BpmLibrary, Metastorm.Model.Bpm;;dev axa;CommonLibraryLib;" + commonLibraryLibVer.ToString());
                                attList.Add(newAtt);
                                attList.Remove(oldAtt);
                                element.ReplaceAttributes(attList);
                                xDoc.Save(folderPath + @"\" + solutionDirectoryList[j] + @"\" + projectDirectoryList[j] + @"\" + projectDirectoryList[j] + @".BPMProj");
                                CLLUpdated = true;
                            }
                            else
                            {
                                throw new Undefined_Element_Exception(@"Atrybut 'Value' dla CommonLibraryLib nie ma wartości. Plik może być uszkodzony.");
                            }
                        }

                        General_Toolbox.PrintContinously("Zaktualizowano ");

                        if (CLUpdated && !CLLUpdated)
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.Write("CommonLib");
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        else if (!CLUpdated && CLLUpdated)
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.Write("CommonLibraryLib");
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        else if (CLLUpdated && CLLUpdated)
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.Write("CommonLib");
                            Console.ForegroundColor = ConsoleColor.White;
                            General_Toolbox.PrintContinously("oraz ");
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.Write("CommonLibraryLib");
                            Console.ForegroundColor = ConsoleColor.White;
                        }
                        else
                        {
                            General_Toolbox.PrintContinously("0 bibliotek");
                        }

                        General_Toolbox.PrintContinouslyLine(" w projekcie " + projectDirectoryList[j] + @".BPMProj");
                    }
                }
                catch (XmlException ex)
                { Console.WriteLine(ex.Message); }
                catch (Undefined_Element_Exception e)
                { Console.WriteLine(e.Message); };
            }
        }