Пример #1
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));
        }