Exemplo n.º 1
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            bool   updateXRef     = UpdateCrossReference.Get(context);
            int    timeOutMinutes = TimeOutMinutes.Get(context);
            string clientExePath  = ClientExecutablePath.Get(context);

            string configurationFile = ConfigurationFile.Get(context);

            context.TrackBuildMessage(string.Format("Compiling application {0} cross-reference update.", updateXRef ? "with" : "without"));

            Client.Commands.Compile compile = new Client.Commands.Compile()
            {
                Minimize             = true,
                LazyClassLoading     = true,
                LazyTableLoading     = true,
                UpdateCrossReference = updateXRef
            };

            if (!string.IsNullOrEmpty(configurationFile))
            {
                compile.ConfigurationFile = configurationFile;
            }

            StringList layerCodes = LayerCodes.Get(context);

            if (layerCodes != null)
            {
                string modelManifest = ModelManifestFile.Get(context);
                if (!string.IsNullOrEmpty(modelManifest))
                {
                    string model;
                    string publisher;
                    string layer;
                    string layerCode;

                    Helper.ExtractClientLayerModelInfo(configurationFile, layerCodes, modelManifest, out model, out publisher, out layer, out layerCode);

                    compile.Model          = model;
                    compile.ModelPublisher = publisher;
                    compile.Layer          = layer;
                    compile.LayerCode      = layerCode;
                }
            }

            Process process = null;

            if (string.IsNullOrEmpty(clientExePath))
            {
                process = Client.Client.StartCommand(compile);
            }
            else
            {
                process = Client.Client.StartCommand(clientExePath, compile);
            }

            var clientConfig = Helper.GetClientConfig(configurationFile);

            Func <int, int, Exception> processWaitDelegate = new Func <int, int, Exception>(CommandContext.WaitForProcess);

            context.UserState = new CommandContext {
                Delegate = processWaitDelegate, Process = process, AutoRun = null, AutoRunFile = null, LogFile = string.Format(@"{0}\{1}", Environment.ExpandEnvironmentVariables(clientConfig.LogDirectory), "AxCompileAll.html")
            };
            return(processWaitDelegate.BeginInvoke(process.Id, timeOutMinutes, callback, state));
        }
Exemplo n.º 2
0
        protected override void Execute(CodeActivityContext context)
        {
            bool   updateXRef     = UpdateCrossReference.Get(context);
            int    timeOutMinutes = TimeOutMinutes.Get(context);
            string clientExePath  = ClientExecutablePath.Get(context);

            StringList aotCompilePaths = AOTCompilePaths.Get(context);

            if (aotCompilePaths == null ||
                aotCompilePaths.Count == 0)
            {
                // Nothing to do.
                return;
            }

            string configurationFile = ConfigurationFile.Get(context);

            Client.Commands.AutoRun command = new Client.Commands.AutoRun
            {
                LazyClassLoading = true,
                LazyTableLoading = true,
                Minimize         = true
            };

            if (!string.IsNullOrEmpty(configurationFile))
            {
                command.ConfigurationFile = configurationFile;
            }

            StringList layerCodes = LayerCodes.Get(context);

            if (layerCodes != null)
            {
                string modelManifest = ModelManifestFile.Get(context);
                if (!string.IsNullOrEmpty(modelManifest))
                {
                    string model;
                    string publisher;
                    string layer;
                    string layerCode;

                    Helper.ExtractClientLayerModelInfo(configurationFile, layerCodes, modelManifest, out model, out publisher, out layer, out layerCode);

                    command.Model          = model;
                    command.ModelPublisher = publisher;
                    command.Layer          = layer;
                    command.LayerCode      = layerCode;
                }
            }

            Client.AutoRun.AxaptaAutoRun axaptaAutoRun = new Client.AutoRun.AxaptaAutoRun()
            {
                ExitWhenDone = true
            };

            foreach (string path in aotCompilePaths)
            {
                axaptaAutoRun.Steps.Add(new Client.AutoRun.CompileApplication()
                {
                    UpdateCrossReference = false,
                    Node = path
                });
            }

            string autorunFilename = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Client.AutoRun.AxaptaAutoRun.SerializeAutoRun(axaptaAutoRun, autorunFilename);
            command.Filename = autorunFilename;

            context.TrackBuildMessage("Compiling individual AOT nodes");

            if (string.IsNullOrEmpty(clientExePath))
            {
                Client.Client.ExecuteCommand(command, timeOutMinutes);
            }
            else
            {
                Client.Client.ExecuteCommand(clientExePath, command, timeOutMinutes);
            }

            // Compile log is not parsed at this point.  We expect to
            // run a full compile at a later step to get the compile results.
        }