Ejemplo n.º 1
0
        public static void processMsg_params_updated(string sMsg)
        {
            try
            {
                CEvent_ParamChanged.g_bChanged = true;
                CEvent_ParamChanged.g_params.Clear();

                string[] sVals = sMsg.Split('@');
                CEvent_ParamChanged.g_sLogicID = sVals[0];

                string[] sSubVals;
                for (int i = 1; i < sVals.Length; i++)
                {
                    sSubVals = sVals[i].Split(',');
                    if (sSubVals.Length < 2)
                    {
                        continue;
                    }
                    CEvent_ParamChanged.g_params.Add(sSubVals[0], sSubVals[1]);
                }
            }
            catch
            {
                CFATLogger.output_proc("Error : processMsg_params_updated");
            }
        }
Ejemplo n.º 2
0
        public static bool load_config_workTime(ref List <TWorkTimeInterval> workTimes)
        {
            CFATLogger.output_proc("load worktime config --------->");
            workTimes.Clear();
            string sConfig = Path.Combine(Application.StartupPath, CFATCommon.CONFIG_WORKTIME);

            if (!File.Exists(sConfig))
            {
                return(true);
            }
            CIniFile iniFile = new CIniFile(sConfig);
            int      nCnt    = Convert.ToInt32(iniFile.Read("count", "WORK_TIME"));
            string   sKey    = "";

            TWorkTimeInterval workTimeInterval;

            for (int i = 0; i < nCnt; i++)
            {
                workTimeInterval = new TWorkTimeInterval();

                sKey = string.Format("start_{0}", (i + 1).ToString());
                workTimeInterval.m_nStart = Convert.ToInt32(iniFile.Read(sKey, "WORK_TIME"));

                sKey = string.Format("end_{0}", (i + 1).ToString());
                workTimeInterval.m_nEnd = Convert.ToInt32(iniFile.Read(sKey, "WORK_TIME"));

                workTimes.Add(workTimeInterval);
            }
            CFATLogger.output_proc("load worktime config <---------");
            return(true);
        }
Ejemplo n.º 3
0
        public static bool load_config_logic(ref List <Dictionary <string, string> > configLogics)
        {
            //load logic config
            CFATLogger.output_proc("load logic config ----------->");
            try
            {
                string   sConfig = Path.Combine(Application.StartupPath, CFATCommon.CONFIG_LOGIC);
                CIniFile iniFile = new CIniFile(sConfig);

                string sSection;
                Dictionary <string, string> dicItem;

                int    nCnt    = Convert.ToInt32(iniFile.Read("logic_count", "COMMON"));
                int    nSubCnt = 0;
                string sKey    = "";
                string sVal    = "";
                for (int i = 0; i < nCnt; i++)
                {
                    dicItem  = new Dictionary <string, string>();
                    sSection = string.Format("LOGIC_{0}", i + 1);

                    dicItem.Add("name", iniFile.Read("name", sSection));
                    dicItem.Add("logic_id", iniFile.Read("logic_id", sSection));
                    dicItem.Add("mode", iniFile.Read("mode", sSection));

                    sVal    = iniFile.Read("param_count", sSection);
                    nSubCnt = Convert.ToInt32(sVal);
                    dicItem.Add("param_count", nSubCnt.ToString());
                    for (int k = 0; k < nSubCnt; k++)
                    {
                        sKey = string.Format("param_{0}", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));
                    }

                    nSubCnt = Convert.ToInt32(iniFile.Read("product_count", sSection));
                    dicItem.Add("product_count", nSubCnt.ToString());
                    for (int k = 0; k < nSubCnt; k++)
                    {
                        sKey = string.Format("product_{0}_site", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));

                        sKey = string.Format("product_{0}_symbol", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));
                    }

                    configLogics.Add(dicItem);
                }
            }
            catch
            {
                CFATLogger.output_proc("Error : load logic config!");
                return(false);
            }
            CFATLogger.output_proc("load logic config <-----------");
            return(true);
        }
Ejemplo n.º 4
0
 public static void publish_msg(string sMsg, string sTopic)
 {
     try
     {
         CMQClient.m_bus.Publish(sMsg, x => x.WithTopic(sTopic));
     }
     catch
     {
         CFATLogger.output_proc("publish_msg Error !");
     }
 }
Ejemplo n.º 5
0
        public static bool load_config_site(ref List <Dictionary <string, string> > configSites)
        {
            // load site config
            CFATLogger.output_proc("load site config ----------->");
            try
            {
                string sConfig = Path.Combine(Application.StartupPath, CFATCommon.CONFIG_SITE);

                CIniFile iniFile = new CIniFile(sConfig);
                int      nCnt    = Convert.ToInt32(iniFile.Read("site_count", "COMMON"));

                string sSection, sVal, sKey;
                Dictionary <string, string> dicItem;
                int nSymCnt = 0;

                for (int i = 0; i < nCnt; i++)
                {
                    dicItem  = new Dictionary <string, string>();
                    sSection = string.Format("SITE_{0}", (i + 1).ToString());

                    dicItem.Add("name", iniFile.Read("name", sSection));
                    dicItem.Add("id", iniFile.Read("id", sSection));
                    dicItem.Add("pwd", iniFile.Read("pwd", sSection));
                    dicItem.Add("pipe1", iniFile.Read("pipe1", sSection));
                    dicItem.Add("pipe2", iniFile.Read("pipe2", sSection));
                    dicItem.Add("pipe_rate", iniFile.Read("pipe_rate", sSection));
                    dicItem.Add("pipe_order", iniFile.Read("pipe_order", sSection));

                    sVal = iniFile.Read("sym_count", sSection);
                    dicItem.Add("sym_count", sVal);
                    nSymCnt = Convert.ToInt32(sVal);

                    for (int k = 0; k < nSymCnt; k++)
                    {
                        sKey = string.Format("sym_{0}", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));

                        sKey = string.Format("c_size_{0}", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));

                        sKey = string.Format("commission_{0}", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));
                    }

                    //For Fix info
                    if (iniFile.Read("fix", sSection) != "1")
                    {
                        configSites.Add(dicItem);
                        continue;
                    }

                    dicItem.Add("fix", "1");
                    sVal = iniFile.Read("sym_fix_count", sSection);
                    dicItem.Add("sym_fix_count", sVal);
                    nSymCnt = Convert.ToInt32(sVal);

                    for (int k = 0; k < nSymCnt; k++)
                    {
                        sKey = string.Format("sym_fix_{0}", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));

                        sKey = string.Format("min_fix_{0}", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));

                        sKey = string.Format("max_fix_{0}", k + 1);
                        dicItem.Add(sKey, iniFile.Read(sKey, sSection));
                    }

                    dicItem.Add("config_data", iniFile.Read("config_data", sSection));
                    dicItem.Add("config_trade", iniFile.Read("config_trade", sSection));
                    dicItem.Add("fix_acc", iniFile.Read("fix_acc", sSection));

                    configSites.Add(dicItem);
                }
            }
            catch
            {
                CFATLogger.output_proc("Error : load site config!");
                return(false);
            }
            CFATLogger.output_proc("load site config <-----------");
            return(true);
        }