コード例 #1
0
        /// <summary>
        /// 调用控件线程方法
        /// </summary>
        /// <param name="args">参数</param>
        public void OnInvoke(object args)
        {
            CMessage message = (CMessage)args;
            List <SecurityFilterTemplate> templates = new List <SecurityFilterTemplate>();

            SecurityFilterService.GetTemplates(templates, message.m_body, message.m_bodyLength);
            int templatesSize = templates.Count;

            switch (message.m_functionID)
            {
            case SecurityFilterService.FUNCTIONID_SECURITYFILTER_ADDTEMPLATES:
                AddTemplatesToGrid(templates);
                break;

            case SecurityFilterService.FUNCTIONID_SECURITYFILTER_DELETETEMPLATES:
            {
                Dictionary <String, GridRow> templateRowsMap = GetTemplateRows();
                for (int i = 0; i < templatesSize; i++)
                {
                    SecurityFilterTemplate template = templates[i];
                    if (templateRowsMap.ContainsKey(template.m_templateID))
                    {
                        m_gridTemplate.RemoveRow(templateRowsMap[template.m_templateID]);
                    }
                }
                m_gridTemplate.Update();
                break;
            }

            case SecurityFilterService.FUNCTIONID_SECURITYFILTER_UPDATETEMPLATES:
            {
                Dictionary <String, GridRow> templateRowsMap = GetTemplateRows();
                for (int i = 0; i < templatesSize; i++)
                {
                    SecurityFilterTemplate template = templates[i];
                    if (templateRowsMap.ContainsKey(template.m_templateID))
                    {
                        templateRowsMap[template.m_templateID].GetCell(1).Text = template.m_name;
                    }
                }
                break;
            }
            }
            m_window.Invalidate();
        }
コード例 #2
0
 /// <summary>
 /// 条件选股回调方法
 /// </summary>
 /// <param name="message">消息</param>
 public void OnSecurityFilterDataCallBack(CMessage message)
 {
     if (message.m_bodyLength > 0)
     {
         int currentBatch = 0, totalBatch = 1;
         if (m_runningState != -1)
         {
             Dictionary <String, double[]> datas = new Dictionary <String, double[]>();
             SecurityFilterService.GetFilterResults(datas, ref currentBatch, ref totalBatch, message.m_body, message.m_bodyLength);
             if (datas.Count > 0)
             {
                 foreach (String code in datas.Keys)
                 {
                     double[] result = datas[code];
                     if (m_infos.ContainsKey(code))
                     {
                         SecurityFilterInfo info = m_infos[code];
                         if (result != null)
                         {
                             int pos = 0;
                             foreach (String name in m_indicator.MainVariables.Keys)
                             {
                                 double value = result[pos];
                                 info.SetValue(name, value);
                                 if (name == "FILTER" && value == 1)
                                 {
                                     m_matchCount++;
                                 }
                                 pos++;
                             }
                         }
                         m_runningState++;
                         info.Completed = true;
                     }
                 }
             }
             datas.Clear();
         }
         if (currentBatch == totalBatch)
         {
             m_runningState = -1;
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// 接收消息方法
        /// </summary>
        /// <param name="message">消息</param>
        public override void OnReceive(CMessage message)
        {
            if (message.m_functionID != SecurityFilterService.FUNCTIONID_SECURITYFILTER_STARTFILTER &&
                message.m_functionID != SecurityFilterService.FUNCTIONID_SECURITYFILTER_STOPFILTER)
            {
                if (message.m_functionID != FUNCTIONID_SECURITYFILTER_GETTEMPLATES)
                {
                    message.m_requestID = m_operatorRequestID;
                }
                List <SecurityFilterTemplate> templates = new List <SecurityFilterTemplate>();
                SecurityFilterService.GetTemplates(templates, message.m_body, message.m_bodyLength);
                int templatesSize = templates.Count;
                switch (message.m_functionID)
                {
                case FUNCTIONID_SECURITYFILTER_GETTEMPLATES:
                {
                    m_templates = templates;
                    m_loaded    = true;
                    break;
                }

                case FUNCTIONID_SECURITYFILTER_ADDTEMPLATES:
                {
                    bool add = false;
                    for (int i = 0; i < templatesSize; i++)
                    {
                        SecurityFilterTemplate template = null;
                        if (!GetTemplate(templates[i].m_templateID, ref template))
                        {
                            m_templates.Add(templates[i]);
                            add = true;
                        }
                    }
                    if (!add)
                    {
                        return;
                    }
                    break;
                }

                case FUNCTIONID_SECURITYFILTER_DELETETEMPLATES:
                {
                    for (int i = 0; i < templatesSize; i++)
                    {
                        SecurityFilterTemplate template = null;
                        if (GetTemplate(templates[i].m_templateID, ref template))
                        {
                            m_templates.Remove(template);
                        }
                    }
                    break;
                }

                case FUNCTIONID_SECURITYFILTER_UPDATETEMPLATES:
                {
                    for (int i = 0; i < templatesSize; i++)
                    {
                        SecurityFilterTemplate updateTemplate = templates[i];
                        int curTemplatesSize = m_templates.Count;
                        for (int j = 0; j < curTemplatesSize; j++)
                        {
                            SecurityFilterTemplate sfTemplate = m_templates[j];
                            if (sfTemplate.m_templateID == updateTemplate.m_templateID)
                            {
                                m_templates[j] = updateTemplate;
                                break;
                            }
                        }
                    }
                    break;
                }
                }
            }
            base.OnReceive(message);
        }