コード例 #1
0
        protected override void ExecuteMain()
        {
            try
            {
                this.Status = StepStatusEnum.Executing;
                string log    = "";
                string cmd    = Properties.Settings.Default.DownloadRiMEConfigCommand;
                int    result = ThirdPartyProgramBLL.EnhancedRunCommand(out log, cmd, Properties.Settings.Default.DownloadRiMEConfigReferencedList.ToArray());

                switch (result)
                {
                case 0:
                    if (!log.Contains("Error occured. The remote name could not be resolved: ", StringComparison.InvariantCultureIgnoreCase))
                    {
                        this.Status       = StepStatusEnum.Pass;
                        this.ResultDetail = new StepResultDetail("Successfully ran the command: {0}.".FormatWith(cmd));
                    }
                    else
                    {
                        this.Status       = StepStatusEnum.Failed;
                        this.ResultDetail = new StepResultDetail("The command '{0}' failed.".FormatWith(cmd));
                    }
                    break;

                case -1073741510:
                    this.Status       = StepStatusEnum.Cancelled;
                    this.ResultDetail = new StepResultDetail("User cancelled the command: {0}.".FormatWith(cmd));
                    break;

                case -532462766:
                    this.Status       = StepStatusEnum.Warning;
                    this.ResultDetail = new StepResultDetail("This step has run successfully, but some exceptions had been thrown by that step during running. Please check log file for more detailed information.");
                    break;

                default:
                    this.Status       = StepStatusEnum.Failed;
                    this.ResultDetail = new StepResultDetail("Command didn't run successfully, please check log for more detailed information.");
                    break;
                }
            }
            catch (Exception ex)
            {
                this.Status       = StepStatusEnum.Failed;
                this.ResultDetail = new StepResultDetail("Error has occurred, please check log.", ExceptionHelper.CentralProcessSingle2(ex));
            }
            finally
            {
                if (this.ResultDetail != null)
                {
                    Log.Info(this.ResultDetail.Message);
                }
            }
        }
コード例 #2
0
        protected override void ExecuteMain()
        {
            string       log          = string.Empty;
            Impersonator impersonator = null;

            try
            {
                this.Status = StepStatusEnum.Executing;

                //foreach (string changeGroupXmlFile in Properties.Settings.Default.ChangeGroupXmlFiles)
                //{
                //    Properties.Settings.Default.DownloadRiMEConfigReferencedList.Add(changeGroupXmlFile);
                //}

                bool pass = true;
                this.ResultDetail = new StepResultDetail("Started.");

                string cmd = Properties.Settings.Default.ApplyChangeGroupCommand;
                impersonator = new Impersonator(
                    Properties.Settings.Default.DomainUserName,
                    Properties.Settings.Default.Domain,
                    Properties.Settings.Default.DomainPassword);

                foreach (string sourceFile in Properties.Settings.Default.ChangeGroupXmlFiles)
                {
                    string fileName = Path.GetFileName(sourceFile);
                    File.Copy(sourceFile, Path.Combine(Directory.GetCurrentDirectory(), fileName), true);
                    cmd = cmd.FormatWith(fileName);

                    int result = ThirdPartyProgramBLL.EnhancedRunCommand(out log, cmd);

                    switch (result)
                    {
                    case 0:
                        if (!log.Contains("Error occured. The remote name could not be resolved: ", StringComparison.InvariantCultureIgnoreCase))
                        {
                            this.ResultDetail.Message += "\r\nSuccessfully ran the command: {0}.".FormatWith(cmd);
                            pass = true;
                        }
                        else
                        {
                            this.Status = StepStatusEnum.Failed;
                            this.ResultDetail.Message += "\r\nThe command '{0}' failed.".FormatWith(cmd);
                            pass = false;
                        }
                        break;

                    case -1073741510:
                        this.Status = StepStatusEnum.Cancelled;
                        this.ResultDetail.Message += "\r\nUser cancelled the command: {0}.".FormatWith(cmd);
                        pass = false;
                        break;

                    case -532462766:
                        this.Status = StepStatusEnum.Warning;
                        this.ResultDetail.Message += "\r\nThis step has run successfully, but some exceptions had been thrown by that step during running. Please check log file for more detailed information.";
                        pass = false;
                        break;

                    default:
                        this.Status = StepStatusEnum.Failed;
                        this.ResultDetail.Message += "\r\nCommand didn't run successfully, please check log for more detailed information.";
                        pass = false;
                        break;
                    }

                    if (!pass)
                    {
                        break;
                    }
                }

                if (pass)
                {
                    this.Status = StepStatusEnum.Pass;
                }
            }
            catch (Exception ex)
            {
                this.Status       = StepStatusEnum.Failed;
                this.ResultDetail = new StepResultDetail("Error has occurred, please check log.", ExceptionHelper.CentralProcessSingle2(ex));
            }
            finally
            {
                if (this.ResultDetail != null)
                {
                    Log.Info(this.ResultDetail.Message);
                }

                if (impersonator != null)
                {
                    impersonator.Undo();
                }
            }
        }
コード例 #3
0
        protected override void ExecuteMain()
        {
            this.Status = StepStatusEnum.Executing;
            string log = string.Empty;

            try
            {
                Impersonator impersonator = new Impersonator(
                    Properties.Settings.Default.DomainUserName,
                    Properties.Settings.Default.Domain,
                    Properties.Settings.Default.DomainPassword);

                Properties.Settings.Default.ChangeGroupXmlFiles.Clear();
                for (int i = 0; i < Properties.Settings.Default.ChangeGroupLinks.Count; i++)
                {
                    string cmd = @"\\bedtransfer\transfer\RulePerf\MergeChangeGroupTool.exe Merge /retrieveFromRCM:false /isEnforceRefresh:true /Links:{0}".FormatWith(
                        Properties.Settings.Default.ChangeGroupLinks[i]
                        );

                    int result = ThirdPartyProgramBLL.EnhancedRunCommand(
                        out log,
                        cmd,
                        Properties.Settings.Default.ChangeGroupDownloadingReferencedList.ToArray()
                        );

                    switch (result)
                    {
                    case 0:
                        string fileName = log.Replace('\r', ' ').Replace('\n', ' ');
                        fileName = Regex.Replace(fileName, @".*Merge File: (\\\\bedtransfer\\transfer\\RulePerf\\MergeResult\\.+\.xml)\s*.*$", "$1");

                        Log.Info("Downloaded change group from {0} to {1}".FormatWith(
                                     Properties.Settings.Default.ChangeGroupLinks[i],
                                     fileName
                                     ));

                        string downloadedXmlFile = Path.Combine(Properties.Settings.Default.ChangeGroupDownloadTo, Path.GetFileName(fileName));
                        File.Copy(fileName, downloadedXmlFile, true);

                        Log.Info("Copied change group from {0} to {1}".FormatWith(
                                     fileName, downloadedXmlFile
                                     ));

                        Properties.Settings.Default.ChangeGroupXmlFiles.Add(downloadedXmlFile);
                        break;

                    default:
                        throw new Exception("Command didn't run successfully.{0}".FormatWith(log));
                    }
                }

                Properties.Settings.Default.RuleIds.Clear();

                List <string> ruleIds = new List <string>();

                for (int i = 0; i < Properties.Settings.Default.ChangeGroupXmlFiles.Count; i++)
                {
                    ruleIds.AddRange(GetRulesFromXmlFile(Properties.Settings.Default.ChangeGroupXmlFiles[i]));
                }

                foreach (string ruleId in ruleIds)
                {
                    Properties.Settings.Default.RuleIds.Add(ruleId);
                }

                Properties.Settings.Default.RiskAPICaller_Description = Path.GetFileNameWithoutExtension(Properties.Settings.Default.ChangeGroupXmlFiles[0]);

                SettingEntityModel.SaveAll();

                this.Status       = StepStatusEnum.Pass;
                this.ResultDetail = new StepResultDetail("");
                for (int i = 0; i < Properties.Settings.Default.ChangeGroupLinks.Count; i++)
                {
                    this.ResultDetail.Message += "\r\n" + "Successfully downloaded {0} to {1}".FormatWith(
                        Properties.Settings.Default.ChangeGroupLinks[i],
                        Properties.Settings.Default.ChangeGroupXmlFiles[i]
                        );
                }

                impersonator.Undo();
            }
            catch (Exception ex)
            {
                this.Status       = StepStatusEnum.Failed;
                this.ResultDetail = new StepResultDetail("Error has occurred, please check log.", ExceptionHelper.CentralProcessSingle2(ex));
            }
            finally
            {
                if (this.ResultDetail != null)
                {
                    Log.Info(this.ResultDetail.Message);
                }
            }
        }