Example #1
0
        private void RefreshByConfig()
        {
            dataCenterInfos.Clear();
            dic_Uri_Config.Clear();
            dic_ID_Config.Clear();
            if (!File.Exists(configFilePath))
            {
                XmlDocument newdoc = new XmlDocument();
                XmlElement  elem   = newdoc.CreateElement("Config");
                newdoc.AppendChild(elem);
                newdoc.Save(configFilePath);
                return;
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(configFilePath);
            XmlElement root = doc.DocumentElement;

            this.defaultId = root.GetAttribute("Default");
            XmlNodeList xmlNode_DataCenter = root.GetElementsByTagName("DataCenter");

            foreach (XmlNode node in xmlNode_DataCenter)
            {
                XmlElement     elem   = (XmlElement)node;
                DataCenterInfo config = new DataCenterInfo();
                config.LoadXml(elem);
                dataCenterInfos.Add(config);
                dic_Uri_Config.Add(config.Uri.ToUpper(), config);
                dic_ID_Config.Add(config.Id.ToUpper(), config);
            }
        }
Example #2
0
 internal DataCenter(DataCenterInfo config)
 {
     this.dataStore                 = DataStoreFactory.CreateDataStore(this);
     this.dataReader                = DataReaderFactory.CreateDataReader(this);
     this.dataPackageFactory        = new DataPackageFactory(dataReader);
     this.codePackageFactory        = new CodePeriodFactory(dataReader);
     this.historyDataForwardFactory = new DataForwardFactory(this);
     this.dataNavigateFactory       = new DataNavigateFactory(this);
     this.accountFactory            = new AccountManager(this, this.dataStore.CreateAccountStore());
 }
Example #3
0
        /// <summary>
        /// 注册一个数据中心
        /// </summary>
        /// <param name="config"></param>
        public void RegisterDataCenter(DataCenterInfo config)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(configFilePath);
            XmlElement elemDataCenter = doc.CreateElement("DataCenter");

            doc.DocumentElement.AppendChild(elemDataCenter);
            config.SaveXml(elemDataCenter);
            doc.Save(configFilePath);
            RefreshByConfig();
        }
Example #4
0
        public static DataCenter Create(DataCenterInfo dataCenterInfo)
        {
            string uristr = dataCenterInfo.Uri;
            Uri    uri    = new Uri(uristr);

            if (uri.IsFile)
            {
                IDataStore  dataStore  = DataStoreFactory.CreateDataStore(uri.LocalPath);
                IDataReader dataReader = DataReaderFactory.CreateDataReader(uri.LocalPath);
                return(new DataCenter(dataCenterInfo, dataStore, dataReader));
            }
            return(null);
        }
Example #5
0
        public List <DataCenterInfo> GetConfigs(MarketType marketType)
        {
            List <DataCenterInfo> configs = new List <DataCenterInfo>();

            for (int i = 0; i < dataCenterInfos.Count; i++)
            {
                DataCenterInfo config = dataCenterInfos[i];
                if (config.MarketType == marketType)
                {
                    configs.Add(config);
                }
            }
            return(configs);
        }
Example #6
0
        public DataCenter GetDataCenterById(string id)
        {
            string upperId = id.ToUpper();

            if (!dic_ID_Config.ContainsKey(upperId))
            {
                return(null);
            }
            DataCenterInfo config = dic_ID_Config[upperId];
            DataCenter     dc     = DataCenter.Create(config);

            if (dc != null)
            {
                return(dc);
            }
            throw new ArgumentException("传入的数据中心ID不存在:" + id);
        }
Example #7
0
        /// <summary>
        /// 创建数据装载保存器
        /// </summary>
        /// <param name="dataCenterUri"></param>
        /// <returns></returns>
        public DataCenter GetDataCenterByUri(string dataCenterUri)
        {
            if (dataCenterUri == null)
            {
                return(null);
            }
            dataCenterUri = dataCenterUri.Replace(@"\", @"\");
            string upperUri = dataCenterUri.ToUpper();

            if (!dic_Uri_Config.ContainsKey(upperUri))
            {
                return(null);
            }
            DataCenterInfo config = dic_Uri_Config[upperUri];
            DataCenter     dc     = DataCenter.Create(config);

            if (dc != null)
            {
                return(dc);
            }
            throw new ArgumentException("传入的数据中心地址不正确:" + dataCenterUri);
        }