示例#1
0
        private string GetCFRBackupDataServerName(DataMartType dataMartType)
        {
            string localDataCenterName = Environment.MachineName.Substring(0, 3).ToUpper();
            string text   = string.Empty;
            string result = string.Empty;

            try
            {
                text = this.GetCFRBackupDataCenterNameByRegion("DataMartTenantsRegionNAM", "DataMartTenantsServersNAM", localDataCenterName);
                if (string.IsNullOrEmpty(text))
                {
                    text = this.GetCFRBackupDataCenterNameByRegion("DataMartTenantsRegionEUR", "DataMartTenantsServersEUR", localDataCenterName);
                }
                if (string.IsNullOrEmpty(text))
                {
                    text = this.GetCFRBackupDataCenterNameByRegion("DataMartTenantsRegionAPC", "DataMartTenantsServersAPC", localDataCenterName);
                }
                if (string.IsNullOrEmpty(text))
                {
                    result = DataMart.LoadSettingFromRegistry <string>("DataMartTenantsGlobalBackupServer");
                }
            }
            catch (Exception)
            {
                return(string.Empty);
            }
            string text2 = string.Empty;

            switch (dataMartType)
            {
            case DataMartType.Tenants:
                text2 = "cdm-tenantds";
                break;

            case DataMartType.TenantsScaled:
                text2 = "cdm-tenantds-scaled";
                break;
            }
            if (!string.IsNullOrEmpty(text))
            {
                return(string.Format(CultureInfo.InvariantCulture, "{0}.{1}.exmgmt.local", new object[]
                {
                    text2,
                    text
                }));
            }
            return(result);
        }
示例#2
0
 private static string GetConfiguration(DataMartType dataMartType, Dictionary <DataMartType, string> mapping, string key)
 {
     if (!mapping.ContainsKey(dataMartType))
     {
         lock (DataMart.SyncRoot)
         {
             if (!mapping.ContainsKey(dataMartType))
             {
                 string value = DataMart.LoadSettingFromRegistry <string>(key);
                 DataMart.ValidateNotEmptyString(key, value);
                 mapping[dataMartType] = value;
             }
         }
     }
     return(mapping[dataMartType]);
 }
示例#3
0
        private string GetCFRBackupDataCenterNameByRegion(string regionKey, string serversKey, string localDataCenterName)
        {
            string text = DataMart.LoadSettingFromRegistry <string>(regionKey);

            if (!text.Contains(localDataCenterName))
            {
                return(string.Empty);
            }
            string        text2 = DataMart.LoadSettingFromRegistry <string>(serversKey);
            List <string> list  = new List <string>(text2.Split(new char[]
            {
                ','
            }));

            list.Remove(localDataCenterName);
            if (list.Count == 0)
            {
                return(string.Empty);
            }
            Random random = new Random();

            return(list[random.Next(list.Count)]);
        }
示例#4
0
        public string GetConnectionString(DataMartType dataMartType, bool backup = false)
        {
            string result;

            try
            {
                string text = this.dataMartKeyMapping[dataMartType];
                string key  = string.Format(CultureInfo.InvariantCulture, "{0}Server", new object[]
                {
                    text
                });
                string text2 = DataMart.GetConfiguration(dataMartType, this.dataMartServerMapping, key);
                if (backup)
                {
                    text2 = this.GetBackupServer(dataMartType);
                    if (string.IsNullOrEmpty(text2))
                    {
                        return(string.Empty);
                    }
                }
                else
                {
                    string text3 = Environment.MachineName.Substring(0, 3).ToUpper();
                    if (text2.ToUpper().StartsWith("CDM-TENANTDS."))
                    {
                        text2 = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.exmgmt.local", new object[]
                        {
                            "CDM-TENANTDS",
                            text3
                        });
                    }
                    else if (text2.ToUpper().StartsWith("CDM-TENANTDS-SCALED."))
                    {
                        text2 = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.exmgmt.local", new object[]
                        {
                            "CDM-TENANTDS-SCALED",
                            text3
                        });
                    }
                }
                string key2 = string.Format(CultureInfo.InvariantCulture, "{0}Database", new object[]
                {
                    text
                });
                string configuration = DataMart.GetConfiguration(dataMartType, this.dataMartDatabaseMapping, key2);
                if (DataMart.connectionTimeout == -1)
                {
                    DataMart.connectionTimeout = DataMart.LoadSettingFromRegistry <int>("SQLConnectionTimeout");
                    DataMart.ValidateIntegerInRange("SQLConnectionTimeout", DataMart.connectionTimeout, 1, 180);
                }
                string text4 = string.Format(CultureInfo.InvariantCulture, "Server={0};Database={1};Integrated Security=SSPI;Connection Timeout={2}", new object[]
                {
                    text2,
                    configuration,
                    DataMart.connectionTimeout
                });
                result = text4;
            }
            catch (DataMartConfigurationException ex)
            {
                ExTraceGlobals.LogTracer.TraceError <DataMartConfigurationException>(0L, "Load data mart configuration error: {0}", ex);
                ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_DataMartConfigurationError, new string[]
                {
                    ex.Message
                });
                throw;
            }
            return(result);
        }