FormatCompilationResult() public static méthode

Allows to format a small text to explain the errors found in a file and the generated files...
public static FormatCompilationResult ( string sourceFilePath, List listErrorFiles, List listDeployedFiles ) : string
sourceFilePath string
listErrorFiles List
listDeployedFiles List
Résultat string
Exemple #1
0
        /// <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);
                }
            }
        }
Exemple #2
0
        /// <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");
            }
        }