Esempio n. 1
0
        protected override void Execute(CodeActivityContext context)
        {
            string configurationFile = ConfigurationFile.Get(context);
            var    serverConfig      = Helper.GetServerConfig(configurationFile);
            string sourcePath        = ReferencesFolder.Get(context);

            context.TrackBuildMessage("Deploying references to client and server");

            if (System.IO.Directory.Exists(sourcePath))
            {
                string clientBasePath        = string.Format(@"{0}\Microsoft\Dynamics Ax", System.Environment.GetEnvironmentVariable("localappdata"));
                IEnumerable <string> folders = System.IO.Directory.EnumerateDirectories(clientBasePath, "VSAssemblies*");
                string serverPath            = string.Format(@"{0}\VSAssemblies", serverConfig.AlternateBinDirectory);

                if (!System.IO.Directory.Exists(serverPath))
                {
                    System.IO.Directory.CreateDirectory(serverPath);
                }

                IEnumerable <string> files = System.IO.Directory.EnumerateFiles(sourcePath, "*");
                foreach (string file in files)
                {
                    foreach (string folder in folders)
                    {
                        System.IO.File.Copy(file, string.Format(@"{0}\{1}", folder, System.IO.Path.GetFileName(file)));
                    }
                    System.IO.File.Copy(file, string.Format(@"{0}\{1}", serverPath, System.IO.Path.GetFileName(file)));
                }
            }
            else
            {
                context.TrackBuildWarning(string.Format("Folder '{0}' containing reference files does not exist", sourcePath));
            }
        }
Esempio n. 2
0
        protected override void Execute(CodeActivityContext context)
        {
            string configurationFile = ConfigurationFile.Get(context);
            string modelName, publisher, layer;

            CodeCrib.AX.Manage.ModelStore.ExtractModelInfo(ModelManifestFile.Get(context), out publisher, out modelName, out layer);
            var serverConfig = Helper.GetServerConfig(configurationFile);

            CodeCrib.AX.Manage.ModelStore store = null;
            if (serverConfig.AOSVersionOrigin.Substring(0, 3) == "6.0")
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}", serverConfig.Database));
            }
            else
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}_model", serverConfig.Database));
            }

            context.TrackBuildMessage(string.Format("Uninstalling all models from layer {0}", layer));
            store.UninstallAllLayerModels(layer);
            if (SetNoInstallMode.Get(context))
            {
                store.SetNoInstallMode();
            }
        }
Esempio n. 3
0
        protected override void Execute(CodeActivityContext context)
        {
            string configurationFile = ConfigurationFile.Get(context);
            string manifestFile      = ModelManifestFile.Get(context);
            string version           = VersionOverride.Get(context);
            string description       = DescriptionOverride.Get(context);
            var    serverConfig      = Helper.GetServerConfig(configurationFile);

            CodeCrib.AX.Manage.ModelStore store = null;
            if (serverConfig.AOSVersionOrigin.Substring(0, 3) == "6.0")
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}", serverConfig.Database));
            }
            else
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}_model", serverConfig.Database));
            }

            if (!string.IsNullOrEmpty(version) || !string.IsNullOrEmpty(description))
            {
                store.CreateModel(manifestFile, version, description);
            }
            else
            {
                store.CreateModel(manifestFile);
            }

            if (SetNoInstallMode.Get(context))
            {
                store.SetNoInstallMode();
            }
        }
Esempio n. 4
0
        protected override void Execute(CodeActivityContext context)
        {
            string configurationFile = ConfigurationFile.Get(context);
            string modelFile         = ModelFile.Get(context);
            var    serverConfig      = Helper.GetServerConfig(configurationFile);
            bool   overwrite         = OverwriteExisting.Get(context);

            CodeCrib.AX.Manage.ModelStore store = null;
            if (serverConfig.AOSVersionOrigin.Substring(0, 3) == "6.0")
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}", serverConfig.Database));
            }
            else
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}_model", serverConfig.Database));
            }

            if (overwrite)
            {
                store.InstallModelOverwrite(modelFile);
            }
            else
            {
                store.InstallModel(modelFile);
            }
            if (SetNoInstallMode.Get(context))
            {
                store.SetNoInstallMode();
            }
        }
Esempio n. 5
0
        protected override void Execute(CodeActivityContext context)
        {
            string configurationFile  = ConfigurationFile.Get(context);
            string modelStoreFile     = ModelStoreFile.Get(context);
            string axutilFolder       = AxUtilBinaryFolder.Get(context);
            var    serverConfig       = Helper.GetServerConfig(configurationFile);
            bool   compressModelStore = CompressModelStore.Get(context);

            CodeCrib.AX.Manage.ModelStore store = null;
            if (serverConfig.AOSVersionOrigin.Substring(0, 3) == "6.0")
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}", serverConfig.Database), axutilFolder);
            }
            else
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}_model", serverConfig.Database), axutilFolder);
            }

            store.ExportModelStore(modelStoreFile);

            if (compressModelStore)
            {
                Helper.CompressFile(new FileInfo(modelStoreFile));
            }
        }
Esempio n. 6
0
        protected override void Execute(CodeActivityContext context)
        {
            bool   leaveXppIL        = LeaveXppIL.Get(context);
            string configurationFile = ConfigurationFile.Get(context);
            var    serverConfig      = Helper.GetServerConfig(configurationFile);

            context.TrackBuildMessage("Cleaning server label artifacts");
            CleanFolder(string.Format(@"{0}\Application\Appl\Standard", serverConfig.AlternateBinDirectory), "ax*.al?");

            if (!leaveXppIL)
            {
                context.TrackBuildMessage("Cleaning server XppIL artifacts");
                CleanFolder(string.Format(@"{0}\XppIL", serverConfig.AlternateBinDirectory), "*");
            }

            context.TrackBuildMessage("Cleaning server VSAssemblies artifacts");
            CleanFolder(string.Format(@"{0}\VSAssemblies", serverConfig.AlternateBinDirectory), "*");

            context.TrackBuildMessage("Cleaning client cache artifacts");
            CleanFolder(System.Environment.GetEnvironmentVariable("localappdata"), "ax_*.auc");
            CleanFolder(System.Environment.GetEnvironmentVariable("localappdata"), "ax*.kti");

            context.TrackBuildMessage("Cleaning client VSAssemblies artifacts");
            CleanFolders(string.Format(@"{0}\{1}", System.Environment.GetEnvironmentVariable("localappdata"), @"Microsoft\Dynamics Ax"), "VSAssemblies*", "*");
        }
Esempio n. 7
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            int    timeoutMinutes    = TimeOutMinutes.Get(context);
            string configurationFile = ConfigurationFile.Get(context);

            var clientConfig = Helper.GetClientConfig(configurationFile);

            Client.AutoRun.AxaptaAutoRun autoRun = new Client.AutoRun.AxaptaAutoRun()
            {
                ExitWhenDone = true, LogFile = string.Format(@"{0}\SynchronizeLog-{1}.xml", Environment.ExpandEnvironmentVariables(clientConfig.LogDirectory), Guid.NewGuid())
            };
            autoRun.Steps.Add(new Client.AutoRun.Synchronize()
            {
                SyncDB = true, SyncRoles = true
            });

            string autoRunFile = string.Format(@"{0}\AutoRun-Synchronize-{1}.xml", Environment.GetEnvironmentVariable("temp"), Guid.NewGuid());

            Client.AutoRun.AxaptaAutoRun.SerializeAutoRun(autoRun, autoRunFile);

            Process process = Client.Client.StartCommand(new Client.Commands.AutoRun()
            {
                ConfigurationFile = configurationFile, Filename = autoRunFile
            });

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

            context.UserState = new CommandContext {
                Delegate = processWaitDelegate, Process = process, AutoRun = autoRun, AutoRunFile = autoRunFile, LogFile = autoRun.LogFile
            };
            return(processWaitDelegate.BeginInvoke(process.Id, timeoutMinutes, callback, state));
        }
Esempio n. 8
0
        protected override void Execute(CodeActivityContext context)
        {
            int    timeOutMinutes    = TimeOutMinutes.Get(context);
            string configurationFile = ConfigurationFile.Get(context);
            var    aosNumber         = Helper.GetServerNumber(configurationFile);

            CodeCrib.AX.Manage.AOS aos = new Manage.AOS(aosNumber);
            aos.Start(timeOutMinutes);
        }
Esempio n. 9
0
        protected override void Execute(CodeActivityContext context)
        {
            string configurationFile = ConfigurationFile.Get(context);
            string database          = Database.Get(context);

            var serverConfig = Helper.GetServerConfig(configurationFile);

            serverConfig.Database = database;

            CodeCrib.AX.Config.Server.SaveConfigToRegistry(serverConfig.AOSNumberOrigin, serverConfig);
        }
Esempio n. 10
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            string     configurationFile = ConfigurationFile.Get(context);
            int        timeoutMinutes    = TimeOutMinutes.Get(context);
            string     xpoFile           = XPOFile.Get(context);
            StringList layerCodes        = LayerCodes.Get(context);
            string     modelManifest     = ModelManifestFile.Get(context);
            string     modelName;
            string     publisher;
            string     layer;
            string     layerCode;

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

            var clientConfig = Helper.GetClientConfig(configurationFile);

            Client.AutoRun.AxaptaAutoRun autoRun = new Client.AutoRun.AxaptaAutoRun()
            {
                ExitWhenDone = true, LogFile = string.Format(@"{0}\ImportLog-{1}.xml", Environment.ExpandEnvironmentVariables(clientConfig.LogDirectory), Guid.NewGuid())
            };
            autoRun.Steps.Add(new Client.AutoRun.XpoImport()
            {
                File = xpoFile
            });

            string autoRunFile = string.Format(@"{0}\AutoRun-ImportXPO-{1}.xml", Environment.GetEnvironmentVariable("temp"), Guid.NewGuid());

            Client.AutoRun.AxaptaAutoRun.SerializeAutoRun(autoRun, autoRunFile);

            context.TrackBuildMessage(string.Format("Importing XPO {0} into model {1}", xpoFile, modelName));
            Process process = Client.Client.StartCommand(new Client.Commands.AutoRun()
            {
                ConfigurationFile = configurationFile, Layer = layer, LayerCode = layerCode, Model = modelName, ModelPublisher = publisher, Filename = autoRunFile
            });

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

            context.UserState = new CommandContext {
                Delegate = processWaitDelegate, Process = process, AutoRun = autoRun, AutoRunFile = autoRunFile, LogFile = autoRun.LogFile
            };
            return(processWaitDelegate.BeginInvoke(process.Id, timeoutMinutes, callback, state));
        }
Esempio n. 11
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            int timeOutMinutes = TimeOutMinutes.Get(context);

            AXBuild.Commands.Compile compile = new AXBuild.Commands.Compile()
            {
                Workers = Workers.Get(context),
                LogPath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())).FullName
            };

            string configurationFile = ConfigurationFile.Get(context);
            string serverBinPath     = Helper.GetServerConfig(configurationFile).AlternateBinDirectory;

            if (string.IsNullOrEmpty(serverBinPath))
            {
                throw new Exception("Could not determine server binaries path");
            }

            string altBin = AlternateBinaryFolder.Get(context);

            if (string.IsNullOrEmpty(altBin))
            {
                altBin = Helper.GetClientConfig(configurationFile).BinaryDirectory;
            }

            compile.Compiler    = Path.Combine(serverBinPath, "Ax32Serv.exe");
            compile.AOSInstance = Helper.GetServerNumber(configurationFile).ToString("D2");
            compile.AltBinDir   = altBin;

            context.TrackBuildMessage("Compiling application using AXBuild", BuildMessageImportance.Normal);
            Process process = AXBuild.AXBuild.StartCommand(serverBinPath, compile);

            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 = Path.Combine(compile.LogPath, "AxCompileAll.html")
            };
            return(processWaitDelegate.BeginInvoke(process.Id, timeOutMinutes, callback, state));
        }
Esempio n. 12
0
        protected override void Execute(CodeActivityContext context)
        {
            string configurationFile = ConfigurationFile.Get(context);
            string modelFile = ModelFile.Get(context);
            string axutilFolder = AxUtilBinaryFolder.Get(context);
            string modelName, publisher, layer;

            CodeCrib.AX.Manage.ModelStore.ExtractModelInfo(ModelManifestFile.Get(context), out publisher, out modelName, out layer);
            string keyFile      = StrongNameKeyFile.Get(context);
            var    serverConfig = Helper.GetServerConfig(configurationFile);

            CodeCrib.AX.Manage.ModelStore store = null;
            if (serverConfig.AOSVersionOrigin.Substring(0, 3) == "6.0")
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}", serverConfig.Database), axutilFolder);
            }
            else
            {
                store = new Manage.ModelStore(serverConfig.DatabaseServer, string.Format("{0}_model", serverConfig.Database), axutilFolder);
            }

            context.TrackBuildMessage(string.Format("Exporting model {0} ({1})", modelName, publisher));
            store.ExportModel(modelName, publisher, modelFile, keyFile);
        }
Esempio n. 13
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));
        }
Esempio n. 14
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.
        }
Esempio n. 15
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            string     configurationFile = ConfigurationFile.Get(context);
            int        timeoutMinutes    = TimeOutMinutes.Get(context);
            string     vsProjectsFolder  = VSProjectsFolder.Get(context);
            StringList layerCodes        = LayerCodes.Get(context);

            if (!Directory.Exists(vsProjectsFolder))
            {
                context.TrackBuildMessage(string.Format("VS Projects folder {0} not found.", vsProjectsFolder));

                // TODO Is there a better way with this? can we just return null or something?
                Func <int, int, Exception> bogusDelegate = new Func <int, int, Exception>(CommandContext.WaitForProcess);
                context.UserState = new CommandContext {
                    Delegate = bogusDelegate, Process = null, AutoRun = null, AutoRunFile = null
                };
                return(bogusDelegate.BeginInvoke(0, 0, callback, state));
            }

            string modelName;
            string publisher;
            string layer;
            string layerCode;
            string modelManifest = ModelManifestFile.Get(context);

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

            var clientConfig = Helper.GetClientConfig(configurationFile);


            Client.AutoRun.AxaptaAutoRun autoRun = new Client.AutoRun.AxaptaAutoRun()
            {
                ExitWhenDone = true, LogFile = string.Format(@"{0}\VSImportLog-{1}.xml", Environment.ExpandEnvironmentVariables(clientConfig.LogDirectory), Guid.NewGuid())
            };

            var filesToProcess = from filter in new[] { "*.csproj", "*.dynamicsproj", "*.vbproj" }
            select Directory.GetFiles(vsProjectsFolder, filter, SearchOption.AllDirectories);

            foreach (string filename in filesToProcess.SelectMany(f => f))
            {
                autoRun.Steps.Add(new Client.AutoRun.Run()
                {
                    Type = Client.AutoRun.RunType.@class, Name = "SysTreeNodeVSProject", Method = "importProject", Parameters = string.Format("@'{0}'", filename)
                });
            }

            string autoRunFile = string.Format(@"{0}\AutoRun-VSImport-{1}.xml", Environment.GetEnvironmentVariable("temp"), Guid.NewGuid());

            Client.AutoRun.AxaptaAutoRun.SerializeAutoRun(autoRun, autoRunFile);

            context.TrackBuildMessage(string.Format("Importing VS Projects from folder {0} into model {1}", vsProjectsFolder, modelName));
            Process process = Client.Client.StartCommand(new Client.Commands.AutoRun()
            {
                ConfigurationFile = configurationFile, Layer = layer, LayerCode = layerCode, Model = modelName, ModelPublisher = publisher, Filename = autoRunFile
            });

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

            context.UserState = new CommandContext {
                Delegate = processWaitDelegate, Process = process, AutoRun = autoRun, AutoRunFile = autoRunFile, LogFile = autoRun.LogFile
            };
            return(processWaitDelegate.BeginInvoke(process.Id, timeoutMinutes, callback, state));
        }
Esempio n. 16
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            int        timeoutMinutes    = TimeOutMinutes.Get(context);
            string     configurationFile = ConfigurationFile.Get(context);
            StringList layerCodes        = LayerCodes.Get(context);
            string     labelFilesFolder  = LabelFilesFolder.Get(context);

            if (!Directory.Exists(labelFilesFolder))
            {
                context.TrackBuildWarning(string.Format("Label file folder {0} not found.", labelFilesFolder));

                // TODO Is there a better way with this? can we just return null or something?
                Func <int, int, Exception> bogusDelegate = new Func <int, int, Exception>(CommandContext.WaitForProcess);
                context.UserState = new CommandContext {
                    Delegate = bogusDelegate, Process = null, AutoRun = null, AutoRunFile = null
                };
                return(bogusDelegate.BeginInvoke(0, 0, callback, state));
            }

            string modelName;
            string publisher;
            string layer;
            string layerCode;
            string modelManifest = ModelManifestFile.Get(context);

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

            var clientConfig = Helper.GetClientConfig(configurationFile);

            Client.AutoRun.AxaptaAutoRun autoRun = new Client.AutoRun.AxaptaAutoRun()
            {
                ExitWhenDone = true, LogFile = string.Format(@"{0}\LabelFlushLog-{1}.xml", Environment.ExpandEnvironmentVariables(clientConfig.LogDirectory), Guid.NewGuid())
            };
            Client.Commands.ImportLabelFile importCommand = new Client.Commands.ImportLabelFile()
            {
                ConfigurationFile = configurationFile, Layer = layer, LayerCode = layerCode, Model = modelName, ModelPublisher = publisher
            };

            foreach (string filename in Directory.GetFiles(labelFilesFolder, "*.ald"))
            {
                if (!IsEmptyLabelFile(filename))
                {
                    context.TrackBuildMessage(string.Format("Importing label file {0} into model {1} ({2})", filename, modelName, publisher));
                    importCommand.Filename = filename;
                    Client.Client.ExecuteCommand(importCommand, timeoutMinutes);

                    string labelFile     = Path.GetFileNameWithoutExtension(filename).Substring(2, 3);
                    string labelLanguage = Path.GetFileNameWithoutExtension(filename).Substring(5);

                    autoRun.Steps.Add(new Client.AutoRun.Run()
                    {
                        Type = Client.AutoRun.RunType.@class, Name = "Global", Method = "info", Parameters = string.Format("strFmt(\"Flush label {0} language {1}: %1\", Label::flush(\"{0}\",\"{1}\"))", labelFile, labelLanguage)
                    });
                }
            }

            string autoRunFile = string.Format(@"{0}\AutoRun-LabelFlush-{1}.xml", Environment.GetEnvironmentVariable("temp"), Guid.NewGuid());

            Client.AutoRun.AxaptaAutoRun.SerializeAutoRun(autoRun, autoRunFile);
            context.TrackBuildMessage(string.Format("Flushing imported label files"));
            Process process = Client.Client.StartCommand(new Client.Commands.AutoRun()
            {
                ConfigurationFile = configurationFile, Layer = layer, LayerCode = layerCode, Model = modelName, ModelPublisher = publisher, Filename = autoRunFile
            });

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

            context.UserState = new CommandContext {
                Delegate = processWaitDelegate, Process = process, AutoRun = autoRun, AutoRunFile = autoRunFile, LogFile = autoRun.LogFile
            };
            return(processWaitDelegate.BeginInvoke(process.Id, timeoutMinutes, callback, state));
        }