/// <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(); }
/// <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); }