Пример #1
0
        private void SetTableToList(DataTable dt, string configName, ImportDataType dataType)
        {
            var arr    = (dataType == ImportDataType.交割单) ? deliPropertyNames : softPropertyNames;
            var config = CommonUtils.GetConfig(configName);

            if (string.IsNullOrEmpty(config))
            {
                NotMatchConfigData.Add(dt);
            }
            else
            {
                bool isFitConfig = true;

                var dict = config.FromJson <Dictionary <string, string> >();
                foreach (var item in arr)
                {
                    isFitConfig = isFitConfig && (!dict.ContainsKey(item) || dt.Columns.Contains(dict[item]));
                }

                if (isFitConfig)
                {
                    MatchConfigData.Add(dt);
                }
                else
                {
                    NotMatchConfigData.Add(dt);
                }
            }
        }
 protected override void ReceiveMessage(NotificationMessageType messageType)
 {
     switch(messageType.MessageType)
     {
         case NotificationMessageEnum.SaveDepthImportView:
             ImportDataType = _dataContext.IsArithmeticAverageChecked ? ImportDataType.AverageChecked : ImportDataType.ExactOrCloserValue;
             IsSaved = true;
             Close();
             break;
     }
 }
Пример #3
0
        private string GetNameByType(ImportDataType type, string property)
        {
            string header = string.Empty;

            if (type == ImportDataType.交割单)
            {
                header = "cbDelivery";
            }
            else if (type == ImportDataType.软件委托)
            {
                header = "cbSoft";
            }
            return(header + property);
        }
Пример #4
0
        private Dictionary <string, string> GetConfigDefault(DataTable dt, ImportDataType importDataType, string configName, bool isSave = true)
        {
            var dict = new Dictionary <string, string>();

            var arr = importDataType == ImportDataType.交割单 ? deliPropertyNames : softPropertyNames;

            foreach (var propertyName in arr)
            {
                var mappedColumn = GetColumnByProperty(propertyName, dt);
                dict.Add(propertyName, mappedColumn);
            }

            if (!string.IsNullOrEmpty(configName) && isSave)
            {
                CommonUtils.SetConfig(configName, dict.ToJson());
            }
            return(dict);
        }
Пример #5
0
        private Dictionary <string, string> GetPageConfig(ImportDataType type)
        {
            var dict = new Dictionary <string, string>();
            var arr  = type == ImportDataType.交割单 ? deliPropertyNames : softPropertyNames;

            foreach (var propertyName in arr)
            {
                var cbBox = this.FindName(GetNameByType(type, propertyName)) as ComboBox;
                if (cbBox != null && cbBox.SelectedIndex > -1)
                {
                    dict.Add(propertyName, cbBox.Text);
                }
                //else if (type == ImportDataType.交割单 &&  propertyName == "组合号" && !string.IsNullOrEmpty(txtDelivery组合号.Text))
                //{
                //    dict.Add(propertyName, txtDelivery组合号.Text);
                //}
            }

            return(dict);
        }
Пример #6
0
        /// <summary>
        /// 运行程序。
        /// </summary>
        /// <returns></returns>
        private int Run()
        {
            int        exitCode = 0;
            IAppLogger logger   = AppLogger.SingleInstance;

            Debug.Assert(logger != null);

            string text = string.Empty;
            string importDataTypeValue = ConfigurationManager.AppSettings["ImportDataType"];

            if (string.IsNullOrEmpty(importDataTypeValue))
            {
                text = String.Format("导入数据类型为空");
                logger.WriteError(text);
                USeConsole.WriteLine(text);
                return(-1);
            }


            ImportDataType importDataType = (ImportDataType)Enum.Parse(typeof(ImportDataType), importDataTypeValue);
            ImportServices importServices = null;

            switch (importDataType)
            {
            case ImportDataType.DayKLine:
                importServices = new KLineImportServices(USeCycleType.Day, logger);
                break;

            case ImportDataType.Min1KLine:
                importServices = new KLineImportServices(USeCycleType.Min1, logger);
                break;

            case ImportDataType.ClosePrice2:
                importServices = new ClosePrice2ImportServices(logger);
                break;

            case ImportDataType.ContractIndex:
                importServices = new ContractIndexImportServices(logger);
                break;

            case ImportDataType.MainContractKLine:
                importServices = new MainContractKLineImportServices(logger);
                break;

            default:
            {
                string error = string.Format("未知的数据导入类型:{0}", importDataType);
                logger.WriteError(error);
                USeConsole.WriteLine(text);
                return(-1);
            }
            }
            try
            {
                if (importServices.Initialize() == false)
                {
                    return(-1);
                }
                importServices.Run();
            }
            catch (Exception ex)
            {
                text = String.Format("导入数据失败,错误:{0}", ex.Message);
                logger.WriteError(text);
                USeConsole.WriteLine(text);
                return(-1);
            }

            return(exitCode);
        }
Пример #7
0
 internal static string GetGroupConfig(string group, ImportDataType type)
 {
     return(GetConfig(group + Enum.GetName(typeof(ImportDataType), type)));
 }