Beispiel #1
0
        /// <summary>
        /// Gets a list of setting objects by their names
        /// </summary>
        /// <param name="settingNames">The setting names.</param>
        /// <returns>A list of setting objects.</returns>
        public static List <SettingEntityModel> Get(params string[] settingNames)
        {
            List <SettingEntityModel> settings = new List <SettingEntityModel>();

            foreach (string settingName in settingNames)
            {
                SettingEntityModel model = SettingEntityModel.GetSingle(settingName);
                if (model != null)
                {
                    settings.Add(model);
                }
            }

            return(settings);
        }
Beispiel #2
0
 /// <summary>
 /// Gets a single setting by its name.
 /// </summary>
 /// <param name="settingName">Name of the setting.</param>
 /// <returns>The setting object</returns>
 public static SettingEntityModel GetSingle(string settingName, bool escapeSpecialCharacters = false)
 {
     try
     {
         SettingEntityModel model = new SettingEntityModel();
         model.SettingName  = settingName;
         model.SettingType  = Properties.Settings.Default[settingName].GetType().ToString();
         model.SettingValue = ToSettingString(Properties.Settings.Default[settingName], escapeSpecialCharacters);
         return(model);
     }
     catch (Exception ex)
     {
         ExceptionHelper.CentralProcess(ex);
         return(null);
     }
 }
Beispiel #3
0
        public static List <SettingEntityModel> GetAllSettings(bool escapeSpecialCharacters = false)
        {
            List <SettingEntityModel> settings = new List <SettingEntityModel>();

            try
            {
                foreach (SettingsProperty property in Properties.Settings.Default.Properties)
                {
                    SettingEntityModel model = SettingEntityModel.GetSingle(property.Name, escapeSpecialCharacters);
                    if (model != null)
                    {
                        settings.Add(model);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHelper.CentralProcess(ex);
                return(null);
            }

            return(settings);
        }
        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);
                }
            }
        }