コード例 #1
0
        private static List <PublishServiceObject> LoadXML()
        {
            List <PublishServiceObject> _serviceList = new List <PublishServiceObject>();

            try
            {
                XmlDocument xmlDoc = new System.Xml.XmlDocument();
                xmlDoc.Load(publishSubscibefile);

                XmlNodeList pubservicelist = xmlDoc.DocumentElement.SelectNodes("Publish/service");
                foreach (XmlNode xe in pubservicelist)
                {
                    PublishServiceObject serviceObj = new PublishServiceObject();
                    serviceObj.whether            = xe.Attributes["switch"].Value == "1" ? true : false;
                    serviceObj.publishServiceName = xe.Attributes["servicename"].Value;
                    serviceObj.explain            = xe.Attributes["explain"].Value;
                    serviceObj.pluginname         = xe.Attributes["pluginname"].Value;
                    serviceObj.controller         = xe.Attributes["controller"].Value;
                    serviceObj.method             = xe.Attributes["method"].Value;
                    serviceObj.argument           = xe.Attributes["argument"].Value;
                    _serviceList.Add(serviceObj);
                }
            }
            catch (Exception e)
            {
                MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "加载定时任务配置文件错误!");
                MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, e.Message);
            }

            return(_serviceList);
        }
コード例 #2
0
        /// <summary>
        /// 客户端执行订阅服务
        /// </summary>
        /// <param name="_clientLink"></param>
        public static void ProcessPublishService(string publishServiceName, ClientLink _clientLink)
        {
            switch (publishServiceName)
            {
            case "DistributedCache":    //分布式缓存服务
                List <CacheIdentify> ciList = DistributedCacheClient.GetCacheIdentifyList();
                List <CacheObject>   coList = _clientLink.GetDistributedCacheData(ciList);
                if (coList.Count > 0)
                {
                    DistributedCacheClient.SetCacheObjectList(coList);
                }
                break;

            case "RemotePlugin":    //远程插件服务
                LocalPlugin localPlugin = RemotePluginClient.GetLocalPlugin();
                if (localPlugin.PluginDic.Count > 0)
                {
                    _clientLink.RegisterRemotePlugin(WcfGlobal.Identify, localPlugin.PluginDic.Keys.ToArray());
                }
                break;

            case "UpgradeClient":    //客户端升级
                ClientUpgradeManager.DownLoadUpgrade();
                break;

            case "UpgradeServer":    //中间件升级
                break;

            case "MongodbSync":    //同步Mongodb数据
                break;

            case "MiddlewareMonitor":    //中间件集群监控服务
                break;

            case "MiddlewareCmd":    //中间件命令服务
                break;

            default:
                PublishServiceObject pso = psoList.Find(x => x.publishServiceName == publishServiceName);
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Blue, string.Format("正在执行服务{0}/{1}/{2}/{3}", pso.pluginname, pso.controller, pso.method, pso.argument));
                ServiceResponseData retjson = InvokeWcfService(
                    pso.pluginname
                    , pso.controller
                    , pso.method
                    , (ClientRequestData request) =>
                {
                    request.SetJsonData(pso.argument);
                });
                string txtResult = retjson.GetJsonData();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Blue, string.Format("服务执行完成,返回结果:{0}", txtResult));
                break;
            }

            ShowHostMsg(Color.Blue, DateTime.Now, "执行“" + publishServiceName + "”订阅服务成功!");
        }
コード例 #3
0
 /// <summary>
 /// 增加服务
 /// </summary>
 public static void AddPublishService(PublishServiceObject serviceObj)
 {
     if (serviceObj == null)
     {
         return;
     }
     if (serviceList.FindIndex(x => x.publishServiceName == serviceObj.publishServiceName) == -1)
     {
         serviceList.Add(serviceObj);
     }
 }
コード例 #4
0
        /// <summary>
        /// 移除服务
        /// </summary>
        public static void RemovePublishService(string psName)
        {
            if (string.IsNullOrEmpty(psName))
            {
                return;
            }
            PublishServiceObject pso = serviceList.Find(x => x.publishServiceName == psName);

            if (pso != null)
            {
                serviceList.Remove(pso);
            }
        }
コード例 #5
0
        public static Action UpgradeVersionChangeEvent;//升级包版本改变触发事件

        /// <summary>
        /// 开始升级包程序
        /// </summary>
        public static void Start()
        {
            string publishServiceName = "UpgradeManage";
            //将升级包管理作为服务添加到发布订阅服务列表
            PublishServiceObject pso = new PublishServiceObject();

            pso.publishServiceName = publishServiceName;
            pso.explain            = "升级包程序";
            PublisherManage.AddPublishService(pso);
            //触发通知
            UpgradeManage.UpgradeVersionChangeEvent = (() =>
            {
                PublisherManage.SendNotify(publishServiceName);//订阅服务发送通知
            });
        }
コード例 #6
0
        public static Action CacheChangeEvent;     //缓存改变触发事件

        /// <summary>
        /// 开始缓存
        /// </summary>
        public static void Start()
        {
            CacheNameList = new List <string>();//缓存列表

            string publishServiceName = "DistributedCache";
            //将分布式缓存作为服务添加到发布订阅服务列表
            PublishServiceObject pso = new PublishServiceObject();

            pso.publishServiceName = publishServiceName;
            pso.explain            = "分布式缓存";
            PublisherManage.AddPublishService(pso);
            //触发通知
            DistributedCacheManage.CacheChangeEvent = (() =>
            {
                PublisherManage.SendNotify(publishServiceName);//订阅服务发送通知
            });
        }