示例#1
0
        protected override XProviderSettings LoadSettings()
        {
            var defaultSettings = new XProviderSettings {
                Id              = QuantBoxConst.PIdCtp,
                Name            = ProviderName,
                Url             = "www.quntbox.cn",
                Description     = "QuantBox Ctpse 插件",
                UserProductInfo = "OpenQuant",
                Connections     = new List <ConnectionInfo>(),
                Users           = new List <UserInfo>(),
                Servers         = new List <ServerInfo>(),
            };

            var settings = XProviderSettings.Load(QBHelper.GetConfigPath(base.GetSettingsFileName()));

            if (settings == null)
            {
                settings = defaultSettings;
            }
            else
            {
                settings.Id          = defaultSettings.Id;
                settings.Url         = defaultSettings.Url;
                settings.Description = defaultSettings.Description;
                settings.Name        = ProviderName;
            }
            return(IsThanfVersion() ? MergeSettings(settings) : settings);
        }
示例#2
0
        protected override XProviderSettings LoadSettings()
        {
            var defaultSettings = new XProviderSettings {
                Id              = 61,
                Name            = ProviderName,
                Url             = "www.thanf.com",
                Description     = "QuantBox CTP 插件",
                UserProductInfo = "OpenQuant",
                Connections     = new List <ConnectionInfo>(),
                Users           = new List <UserInfo>(),
                Servers         = new List <ServerInfo>(),
            };

            var settings = XProviderSettings.Load(QBHelper.GetConfigPath(GetSettingsFileName()));

            if (settings == null)
            {
                settings = defaultSettings;
            }
            else
            {
                settings.Id          = defaultSettings.Id;
                settings.Url         = defaultSettings.Url;
                settings.Description = defaultSettings.Description;
                settings.Name        = ProviderName;
            }
            return(settings);
        }
示例#3
0
 private static XProviderSettings MergeSettings(XProviderSettings settings)
 {
     //if (ProviderGlobals.AccountInfo != null) {
     //    MergeServers(settings);
     //    MergeUsers(settings);
     //}
     return(settings);
 }
示例#4
0
 private static void MergeServers(XProviderSettings settings)
 {
     //settings.Servers.Clear();
     //if (ProviderGlobals.Public.TryGet(CtpServers, out var value)) {
     //    MergeServers(settings, JToken.Parse(value));
     //}
     //if (ProviderGlobals.Private.TryGet(CtpServers, out value)) {
     //    MergeServers(settings, JToken.Parse(value));
     //}
 }
示例#5
0
        private static void MergeServers(XProviderSettings settings, JToken token)
        {
            var current = token.First;

            while (current != null)
            {
                var server = ServerInfo.Load(current);
                settings.Servers.Add(server);
                current = current.Next;
            }
        }
示例#6
0
        private static void MergeUsers(XProviderSettings settings)
        {
            //if (!ProviderGlobals.Private.TryGet(CtpUsers, out var value))
            //    return;

            //var current = JToken.Parse(value).First;
            //while (current != null) {
            //    var user = UserInfo.Load(current);
            //    var exists = settings.Users.Exists(n => n.UserId == user.UserId);
            //    if (!exists) {
            //        settings.Users.Insert(0, user);
            //    }
            //    current = current.Next;
            //}
        }