/// <summary> /// Deploy the current file, if it's a progress file then compile it, otherwise follow the transer rules of step 1 /// </summary> public static void DeployCurrentFile() { if (Abl.IsCurrentFileCompilable) { // then that's just a link to compilation StartProgressExec(ExecutionType.Compile); UserCommunication.Notify("Deploying a compilable file is strictly equal as compiling it<br>The deployment rules for step 0 are applied in both case!", MessageImg.MsgInfo, "Deploy a file", "Bypass to compilation", 2); } else { if (ProEnvironment.Current.Deployer.IsFilePassingFilters( Plug.CurrentFilePath, ProEnvironment.Current.Deployer.DeployFilterRules.Where(rule => rule.Step == 1 && rule.Include).ToList(), ProEnvironment.Current.Deployer.DeployFilterRules.Where(rule => rule.Step == 1 && !rule.Include).ToList())) { // deploy the file for STEP 1 var deployedFiles = ProEnvironment.Current.Deployer.DeployFiles(ProEnvironment.Current.Deployer.GetTransfersNeededForFile(Plug.CurrentFilePath, 1)); if (deployedFiles == null || deployedFiles.Count == 0) { UserCommunication.Notify("The current file doesn't match any transfer rules for the current environment and <b>step 1</b><br>You can modify the rules " + "here".ToHtmlLink(), MessageImg.MsgInfo, "Deploy a file", "No transfer rules", args => { Deployer.EditRules(); args.Handled = true; }, 5); } else { var hasError = deployedFiles.Exists(deploy => !deploy.IsOk); UserCommunication.NotifyUnique(Plug.CurrentFilePath, "Rules applied for <b>step 1</b>, was deploying :<br>" + ProCompilation.FormatCompilationResult(Plug.CurrentFilePath, null, deployedFiles), hasError ? MessageImg.MsgError : MessageImg.MsgOk, "Deploy a file", "Transfer results", null, hasError ? 0 : 5); } } else { UserCommunication.Notify("The current file didn't pass the deployment filters for the current environment and <b>step 1</b><br>You can modify the rules " + "here".ToHtmlLink(), MessageImg.MsgInfo, "Deploy a file", "Filtered by deployment rules", args => { Deployer.EditRules(); args.Handled = true; }, 5); } } }
/// <summary> /// Start the deployment! /// </summary> private void BtStartOnButtonPressed(object sender, EventArgs eventArgs) { SetDataFromFields(); SaveProfilesList(); if (string.IsNullOrEmpty(DeployProfile.Current.SourceDirectory) || !Directory.Exists(DeployProfile.Current.SourceDirectory)) { BlinkTextBox(fl_directory, ThemeManager.Current.GenericErrorColor); return; } // init screen btStart.Visible = false; btReset.Visible = false; progressBar.Visible = true; progressBar.Progress = 0; progressBar.Text = @"Please wait, the deployment is starting..."; btReport.Visible = false; lbl_report.Visible = false; _reportExportPath = null; Application.DoEvents(); // start the deployment Task.Factory.StartNew(() => { _proEnv = new ProEnvironment.ProEnvironmentObject(ProEnvironment.Current); _currentProfile = new DeployProfile(DeployProfile.Current); // new mass compilation _currentCompil = new ProCompilation { // check if we need to force the compiler to only use 1 process // (either because the user want to, or because we have a single user mode database) MonoProcess = _currentProfile.ForceSingleProcess || _proEnv.IsDatabaseSingleUser(), NumberOfProcessesPerCore = _currentProfile.NumberProcessPerCore, RFilesOnly = _currentProfile.OnlyGenerateRcode }; _currentCompil.OnCompilationEnd += OnCompilationEnd; var filesToCompile = _proEnv.Deployer.GetFilesList(new List<string> { _currentProfile.SourceDirectory }, _currentProfile.ExploreRecursively ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly, 0); _deploymentPercentage = 0; _currentStep = 0; _totalSteps = _proEnv.Deployer.DeployTransferRules.Count > 0 ? _proEnv.Deployer.DeployTransferRules.Max(rule => rule.Step) : 0; _filesToDeployPerStep.Clear(); _hookProcedureErrors.Clear(); if (filesToCompile.Count > 0 && _currentCompil.CompileFiles(filesToCompile)) { UpdateReport(""); UpdateProgressBar(); btCancel.SafeInvoke(button => button.Visible = true); this.SafeInvoke(page => { // start a recurrent event (every second) to update the progression of the compilation _progressTimer = new Timer(); _progressTimer.Interval = 500; _progressTimer.Tick += (o, args) => UpdateProgressBar(); _progressTimer.Start(); }); } else { if (filesToCompile.Count == 0) { UserCommunication.Notify("No compilable files found in the input directories,<br>the valid extensions for compilable Progress files are : " + Config.Instance.CompileKnownExtension, MessageImg.MsgInfo, "Multiple compilation", "No files found", 10); } // nothing started ResetScreen(); } }); }
/// <summary> /// Called after the execution of run/compile/check/prolint /// </summary> public static void OnSingleExecutionOk(ProExecution lastExec) { try { var treatedFile = lastExec.ListToCompile.First(); CurrentOperation currentOperation; if (!Enum.TryParse(lastExec.ExecutionType.ToString(), true, out currentOperation)) { currentOperation = CurrentOperation.Run; } var isCurrentFile = treatedFile.InputPath.EqualsCi(Plug.CurrentFilePath); var otherFilesInError = false; int nbWarnings = 0; int nbErrors = 0; // Read log info var errorList = lastExec.LoadErrorLog(); if (!errorList.Any()) { // the compiler messages are empty var fileInfo = new FileInfo(lastExec.LogPath); if (fileInfo.Length > 0) { // the .log is not empty, maybe something went wrong in the runner, display errors UserCommunication.Notify( "Something went wrong while " + currentOperation.GetAttribute <CurrentOperationAttr>().ActionText + " the following file:<br>" + treatedFile.InputPath.ToHtmlLink() + "<br>The progress compiler didn't return any errors but the log isn't empty, here is the content :" + Utils.ReadAndFormatLogToHtml(lastExec.LogPath), MessageImg.MsgError, "Critical error", "Action failed"); return; } } else { // count number of warnings/errors, loop through files > loop through errors in each file foreach (var keyValue in errorList) { foreach (var fileError in keyValue.Value) { if (fileError.Level <= ErrorLevel.StrongWarning) { nbWarnings++; } else { nbErrors++; } } otherFilesInError = otherFilesInError || !treatedFile.InputPath.EqualsCi(keyValue.Key); } } // Prepare the notification content var notifTitle = currentOperation.GetAttribute <CurrentOperationAttr>().Name; var notifImg = (nbErrors > 0) ? MessageImg.MsgError : ((nbWarnings > 0) ? MessageImg.MsgWarning : MessageImg.MsgOk); var notifTimeOut = (nbErrors > 0) ? 0 : ((nbWarnings > 0) ? 10 : 5); var notifSubtitle = lastExec.ExecutionType == ExecutionType.Prolint ? (nbErrors + nbWarnings) + " problem" + ((nbErrors + nbWarnings) > 1 ? "s" : "") + " detected" : (nbErrors > 0) ? nbErrors + " error" + (nbErrors > 1 ? "s" : "") + " found" : ((nbWarnings > 0) ? nbWarnings + " warning" + (nbWarnings > 1 ? "s" : "") + " found" : "Syntax correct"); // build the error list var errorsList = new List <FileError>(); foreach (var keyValue in errorList) { errorsList.AddRange(keyValue.Value); } // when compiling, transfering .r/.lst to compilation dir var listTransferFiles = new List <FileToDeploy>(); if (lastExec.ExecutionType == ExecutionType.Compile) { listTransferFiles = lastExec.CreateListOfFilesToDeploy(); listTransferFiles = lastExec.ProEnv.Deployer.DeployFiles(listTransferFiles); } // Notify the user, or not if (Config.Instance.CompileAlwaysShowNotification || !isCurrentFile || !Npp.GetFocus() || otherFilesInError) { UserCommunication.NotifyUnique(treatedFile.InputPath, "Was " + currentOperation.GetAttribute <CurrentOperationAttr>().ActionText + " :<br>" + ProCompilation.FormatCompilationResult(treatedFile.InputPath, errorsList, listTransferFiles), notifImg, notifTitle, notifSubtitle, null, notifTimeOut); } } catch (Exception e) { ErrorHandler.ShowErrors(e, "Error in OnExecutionOk"); } }