Пример #1
0
        public int Execute()
        {
            string        modelName       = ModelName;
            string        modelPublisher  = ModelPublisher;
            string        configFile      = AXConfigurationFile;
            string        serverName      = ServerName;
            string        portNumber      = PortNumber.ToString();
            string        layer           = Layer;
            string        layerCode       = Layer;
            string        commandArgument = CommandArgument;
            List <string> parameterList   = new List <string>();

            int exitcode = 0;

            if (!String.IsNullOrEmpty(configFile))
            {
                parameterList.Add(String.Format("\"{0}\"", configFile));
            }
            else
            {
                // TODO: -AOS doesn't seem to be working!!
                if (!String.IsNullOrEmpty(serverName) && !String.IsNullOrEmpty(portNumber))
                {
                    parameterList.Add(String.Format("-aos={0}@{1}", serverName, portNumber));
                }
                else
                {
                    Console.WriteLine("No configuration file or server/port specified.");
                }

                if (!String.IsNullOrEmpty(layer))
                {
                    if (String.IsNullOrEmpty(layerCode) && layer.ToLower() != "usr" && layer.ToLower() != "usp")
                    {
                        throw new Exception("Missing layer code for layer different than USR/USP");
                    }

                    parameterList.Add(String.Format("-aol={0}", layer));
                    parameterList.Add(String.Format("-aolcode={0}", layerCode));
                }
            }

            if (!String.IsNullOrEmpty(ModelManifest))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(ModelManifest);

                modelName      = doc.DocumentElement.SelectSingleNode("Name").InnerText;
                modelPublisher = doc.DocumentElement.SelectSingleNode("Publisher").InnerText;
                string modelLayer = doc.DocumentElement.SelectSingleNode("Layer").InnerText;

                if (!String.IsNullOrEmpty(layer) && modelLayer.ToLower() != layer.ToLower())
                {
                    throw new Exception(String.Format("Trying to import into model {0} in layer {1}, but configuration file connects to layer {2}", modelName, modelLayer.ToLower(), layer.ToLower()));
                }
                // TODO: check against configuration file??!
            }

            if (!String.IsNullOrEmpty(modelName))
            {
                if (String.IsNullOrEmpty(modelPublisher) || String.IsNullOrEmpty(modelPublisher.Trim()))
                {
                    parameterList.Add(String.Format("\"-Model={0}\"", modelName));
                }
                else
                {
                    parameterList.Add(String.Format("\"-Model=({0},{1})\"", modelName, modelPublisher));
                }
            }

            parameterList.Add("-MINIMIZE");

            //if(LazyClassLoading.Get(context) == true)
            parameterList.Add("-LAZYCLASSLOADING");

            //if(LazyClassLoading.Get(context) == true)
            parameterList.Add("-LAZYTABLELOADING");

            string language;

            switch (Command)
            {
            case ClientCommand.IMPORTXPO:
                Console.WriteLine("Executing import of XPO file");
                if (NoCompileOnImport)
                {
                    parameterList.Add(String.Format("-NOCOMPILEONIMPORT"));
                }
                parameterList.Add(String.Format("\"-AOTIMPORTFILE={0}\"", commandArgument));

                exitcode = CallClient(parameterList);
                break;

            case ClientCommand.IMPORTLABELFOLDER:

                Console.WriteLine("Executing label folder import");

                if (NoCompileOnImport)
                {
                    parameterList.Add(String.Format("-NOCOMPILEONIMPORT"));
                }

                if (System.IO.Directory.Exists(commandArgument))
                {
                    IEnumerable <string> files = System.IO.Directory.EnumerateFiles(commandArgument, String.Format("*.ald"), System.IO.SearchOption.AllDirectories);
                    foreach (string file in files)
                    {
                        language = file.Substring(file.LastIndexOf('\\') + 6, file.Length - 4 - file.LastIndexOf('\\') - 6);

                        if (!AxApplicationFiles.IsEmptyLabelFile(file))
                        {
                            Console.WriteLine(String.Format("Importing labels for language {0}", language), BuildMessageImportance.High);

                            List <string> labelParameters = new List <string>();
                            labelParameters.AddRange(parameterList);
                            labelParameters.Add(String.Format("\"-StartupCmd=aldimport_{0}\"", file));

                            exitcode = CallClient(labelParameters);
                        }
                        else
                        {
                            Console.WriteLine(String.Format("Skipping label language {0} because it is empty", language));
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Label files folder not found, skipping label import.");
                }
                break;

            case ClientCommand.IMPORTLABELFILE:

                language = commandArgument.Substring(commandArgument.LastIndexOf('\\') + 6, commandArgument.Length - 4 - commandArgument.LastIndexOf('\\') + 6);

                if (AxApplicationFiles.IsEmptyLabelFile(commandArgument))
                {
                    Console.WriteLine(String.Format("Skipping label file language {0} because it is empty", language));
                }

                Console.WriteLine(String.Format("Executing label file import for language {0}", language), BuildMessageImportance.High);
                parameterList.Add(String.Format("\"-StartupCmd=aldimport_{0}\"", commandArgument));

                if (NoCompileOnImport)
                {
                    parameterList.Add(String.Format("-NOCOMPILEONIMPORT"));
                }

                exitcode = CallClient(parameterList);
                break;

            case ClientCommand.SYNCHRONIZE:
                Console.WriteLine("Executing data dictionary synchronize");
                parameterList.Add("-StartupCmd=Synchronize");

                exitcode = CallClient(parameterList);
                break;

            case ClientCommand.COMPILEXPP:
                if (!String.IsNullOrEmpty(commandArgument))
                {
                    Console.WriteLine("Executing full X++ compile with cross-reference update");
                    parameterList.Add("-StartupCmd=CompileAll_+");
                }
                else
                {
                    Console.WriteLine("Executing full X++ compile");
                    parameterList.Add("-StartupCmd=CompileAll");
                }
                #region RRB CU7 updates
                //CallClient(parameterList, context);
                CallAxBuild();
                #endregion
                break;

            case ClientCommand.GENERATECIL:
                Console.WriteLine("Executing CIL generation");
                parameterList.Add("-StartupCmd=CompileIL");

                exitcode = CallClient(parameterList);
                break;

            case ClientCommand.RUNTESTPROJECT:
                Console.WriteLine("Executing test project run");
                if (String.IsNullOrEmpty(commandArgument))
                {
                    throw new Exception("Expecting command argument containing the test project to run");
                }
                parameterList.Add(String.Format("-StartupCmd=RunTestProject_{0}", commandArgument));

                exitcode = CallClient(parameterList);
                break;

            case ClientCommand.XMLDOCUMENTATION:
                Console.WriteLine("Executing XML documentation");
                if (String.IsNullOrEmpty(commandArgument))
                {
                    throw new Exception("Expecting command argument containing xml documentation filename");
                }
                parameterList.Add(String.Format("\"-StartupCmd=xmldocumentation_{0}\"", commandArgument));

                exitcode = CallClient(parameterList);
                break;

            case ClientCommand.AUTORUN:
                Console.WriteLine(String.Format("Executing autorun script \"{0}\"", commandArgument));
                parameterList.Add("-nocompileonimport");
                parameterList.Add(String.Format("\"-StartupCmd=AutoRun_{0}\"", commandArgument));

                exitcode = CallClient(parameterList);
                break;

            case ClientCommand.STARTUPCMD:
                Console.WriteLine(String.Format("Executing startup command \"{0}\"", commandArgument));
                parameterList.Add(String.Format("\"-StartupCmd={0}\"", commandArgument));

                exitcode = CallClient(parameterList);
                break;
            }

            return(exitcode);
        }
Пример #2
0
        public void CreateLabelFlushXML(string sourcesFolder, bool recursive, string xmlFilename, bool append, string logFile)
        {
            string file;
            string label;
            string language;

            if (System.IO.Directory.Exists(sourcesFolder))
            {
                AutoRun.AxaptaAutoRun autoRun = null;
                if (append)
                {
                    autoRun = AutoRun.AxaptaAutoRun.FindOrCreate(xmlFilename);
                }
                else
                {
                    autoRun = new AutoRun.AxaptaAutoRun();
                }

                autoRun.ExitWhenDone = true;
                if (logFile != "")
                {
                    autoRun.LogFile = logFile;
                }
                autoRun.Version = "4.0";
                autoRun.Steps   = new List <AutoRun.AutorunElement>();

                List <string> files = new List <string>();

                GetProjectFiles(sourcesFolder, recursive, files, "*.ald");

                if (files.Count != 0)
                {
                    List <string> .Enumerator fileEnumerator = files.GetEnumerator();

                    while (fileEnumerator.MoveNext())
                    {
                        file = fileEnumerator.Current;
                        if (!AxApplicationFiles.IsEmptyLabelFile(file))
                        {
                            // We only care to flush languages that have entries.
                            language = file.Substring(file.LastIndexOf('\\') + 6, file.Length - 4 - file.LastIndexOf('\\') - 6);
                            label    = file.Substring(file.LastIndexOf('\\') + 3, 3);
                            autoRun.Steps.Add(new AutoRun.Run()
                            {
                                type = AutoRun.RunType.@class, name = "Label", method = "flush", parameters = string.Format("@'{0}', @'{1}'", label, language)
                            });
                        }
                    }

                    AutoRun.AxaptaAutoRun.SerializeAutoRun(autoRun, xmlFilename);
                }
                else
                {
                    Console.WriteLine("No label files found.");
                    // do not create autorun.xml file if there's nothing in it
                }
            }
            else
            {
                Console.WriteLine("No label files found.");
            }
        }