public void ReplaceCalculatedMembersStrings(string replaceFrom, string replaceTo)
        {
            string pattern = RegxUtils.CreateExactMatchWholeWordRegExpression(replaceFrom);

            string[] keysArray = new string[_calculatedMembersDictionary.Count];
            _calculatedMembersDictionary.Keys.CopyTo(keysArray, 0);
            CalculatedMember calculatedMember;

            foreach (string key in keysArray)
            {
                string newKey = Regex.Replace(key, pattern, replaceTo, RegexOptions.IgnoreCase);
                if (newKey.ToUpper() != key.ToUpper())
                {
                    if (_calculatedMembersDictionary.ContainsKey(newKey.ToUpper()))
                    {
                        _calculatedMembersDictionary.Remove(key.ToUpper());
                    }
                    else
                    {
                        calculatedMember = _calculatedMembersDictionary[key.ToUpper()];
                        _calculatedMembersDictionary.Remove(key.ToUpper());
                        calculatedMember.ReplaceText(replaceFrom, replaceTo);
                        if (!_calculatedMembersDictionary.ContainsKey(calculatedMember.Name.ToUpper())) //should not happend but just in case
                        {
                            _calculatedMembersDictionary.Add(calculatedMember.Name.ToUpper(), calculatedMember);
                        }
                    }
                }
                else //No problem on the name just the text
                {
                    calculatedMember = _calculatedMembersDictionary[key];  //check if after the replace the dictionary updated
                    calculatedMember.ReplaceText(replaceFrom, replaceTo);
                }
            }
        }
        public void ReplaceText(string replaceFrom, string replaceTo)
        {
            string pattern = RegxUtils.CreateExactMatchWholeWordRegExpression(replaceFrom);

            if (!string.IsNullOrEmpty(Name))
            {
                Name = Regex.Replace(Name, pattern, replaceTo, RegexOptions.IgnoreCase);
            }
            if (!string.IsNullOrEmpty(Text))
            {
                Text = Regex.Replace(Text, pattern, replaceTo, RegexOptions.IgnoreCase);
            }
            if (!string.IsNullOrEmpty(Expression))
            {
                Expression = Regex.Replace(Expression, pattern, replaceTo, RegexOptions.IgnoreCase);
            }
        }
        private void UpdateRelevantPropertiesOnXml(DirectoryInfo targetDirectory, Dictionary <string, object> lastExecutorStepData)
        {
            string pattern;

            foreach (FileInfo file in targetDirectory.GetFiles())
            {
                if (file.Name.ToLower() == "schema.xml" || file.Name.ToLower() == "properties.xml" || file.Name.ToLower() == "refreshbook")
                {
                    continue;
                }
                else
                {
                    string fileString = string.Empty;
                    using (StreamReader reader = new StreamReader(file.FullName))
                    {
                        fileString = reader.ReadToEnd();
                        //channge CubeAdress,CubeName,CubeDB atributes
                    }
                    pattern = RegxUtils.CreateExactMatchWholeWordRegExpression(accountWizardSettings.Get("Panorama.ServerToReplace")); //replace server
                    //CubeAdress
                    fileString = Regex.Replace(fileString, pattern, accountWizardSettings.Get("AnalysisServer.ConnectionString").Replace("DataSource=", string.Empty), RegexOptions.IgnoreCase);
                    //CubeName //few options here

                    pattern = RegxUtils.CreateExactMatchWholeWordRegExpression(accountWizardSettings.Get("Panorama.ContentCubeToReplace"));//ContentCubeToReplace

                    fileString = Regex.Replace(fileString, pattern, accountWizardSettings.Get("Cube.Content.Name.Perfix") + lastExecutorStepData["AccountSettings.CubeName"].ToString(), RegexOptions.IgnoreCase);

                    pattern    = RegxUtils.CreateExactMatchWholeWordRegExpression(accountWizardSettings.Get("Panorama.BoCubeToReplace")); //BoCubeToReplace
                    fileString = Regex.Replace(fileString, pattern, accountWizardSettings.Get("Cube.BO.Name.Perfix") + lastExecutorStepData["AccountSettings.CubeName"].ToString(), RegexOptions.IgnoreCase);


                    pattern    = RegxUtils.CreateExactMatchWholeWordRegExpression(accountWizardSettings.Get("Panorama.CubeDbtoReplace"));//CubeDbtoReplace
                    fileString = Regex.Replace(fileString, pattern, accountWizardSettings.Get("AnalysisServer.Database"), RegexOptions.IgnoreCase);

                    //Replace client specific measures +Acquisitions +target AcquisitionS

                    foreach (KeyValuePair <string, object> input in lastExecutorStepData)
                    {
                        if (input.Value is Replacment)
                        {
                            Replacment replacment = (Replacment)input.Value;
                            if (input.Key.StartsWith(AccSettClientSpecific, true, null))//measures
                            {
                                pattern    = RegxUtils.CreateExactMatchWholeWordRegExpression(replacment.ReplaceFrom);
                                fileString = Regex.Replace(fileString, pattern, replacment.ReplaceTo, RegexOptions.IgnoreCase);
                            }
                            else if (input.Key.StartsWith("AccountSettings.StringReplacment."))//String ReplaceMent
                            {
                                pattern    = RegxUtils.CreateExactMatchWholeWordRegExpression(replacment.ReplaceFrom);
                                fileString = Regex.Replace(fileString, pattern, replacment.ReplaceTo, RegexOptions.IgnoreCase);
                            }
                            else if (input.Key.StartsWith(C_AccSettACQ))// Acquisitions
                            {
                                if (input.Value.ToString() != " ")
                                {
                                    string[] acquisitions = accountWizardSettings.Get(input.Key).Split(',');
                                    foreach (string acquisition in acquisitions)
                                    {
                                        pattern    = @"\b" + acquisition + @"\b";
                                        fileString = Regex.Replace(fileString, pattern, replacment.ReplaceTo, RegexOptions.IgnoreCase);
                                    }
                                }
                            }
                            else if (input.Key.StartsWith(C_AccSettTargetACQ)) //TARGET Acquisitions
                            {
                                if (input.Value.ToString() != " ")
                                {
                                    string[] targetAcquisitions = accountWizardSettings.Get(input.Key).Split(',');
                                    foreach (string targetAcquisition in targetAcquisitions)
                                    {
                                        pattern    = @"\b" + targetAcquisition + @"\b";
                                        fileString = Regex.Replace(fileString, pattern, replacment.ReplaceTo, RegexOptions.IgnoreCase);
                                    }
                                }
                            }
                        }
                    }

                    using (StreamWriter writer = new StreamWriter(file.FullName, false))
                    {
                        writer.Write(fileString);
                    }
                }
            }
        }