示例#1
0
        private static void UpdateConfig()
        {
            NotifyConfigArray array = ReadConfigInfo();

            if (array != null && array.configs != null && array.configs.Length > 0)
            {
                Dictionary <string, NotifyConfig>           configs  = new Dictionary <string, NotifyConfig>();
                Dictionary <string, NotifyExectorContainer> exectors = new Dictionary <string, NotifyExectorContainer>();
                foreach (NotifyConfig cfg in array.configs)
                {
                    if (string.IsNullOrWhiteSpace(cfg.code))
                    {
                        continue;
                    }

                    //将编码关键字全部处理为小写,方便后续做匹配查询
                    cfg.code = cfg.code.Trim().ToLower();
                    if (cfg.code == Const_SysConfig)
                    {
                        //todo:有效性检查
                    }
                    else
                    {
                        if (cfg.items == null || cfg.items.Length == 0)
                        {
                            continue;
                        }
                        //todo:有效性检查

                        List <NotifyExector> list = new List <NotifyExector>();
                        foreach (NotifyConfigItem cfgItem in cfg.items)
                        {
                            cfgItem.type = cfgItem.type.Trim().ToLower();

                            NotifyExector exec = NotifyExector.GetExector(cfgItem);
                            if (exec != null)
                            {
                                list.Add(exec);
                            }
                        }
                        exectors[cfg.code] = list == null ? null : new NotifyExectorContainer(list);
                    }
                    configs[cfg.code] = cfg;
                }


                lock (sLock)
                {
                    sConfigs  = configs;
                    sExectors = exectors;
                }
            }
            else
            {
                sConfigs  = null;
                sExectors = null;
            }
        }
示例#2
0
 public void Append(NotifyExector exec)
 {
     if (exec != null)
     {
         if (exec.IsDismatchFilter)
         {
             if (m4Dismatch == null)
             {
                 m4Dismatch = new List <NotifyExector>();
             }
             m4Dismatch.Add(exec);
         }
         else
         {
             if (m4Match == null)
             {
                 m4Match = new List <NotifyExector>();
             }
             m4Match.Add(exec);
         }
     }
 }