Beispiel #1
0
        public void OnDataSyncFromPartner(string ResourceName, string ExchangeData)
        {
            if (Mode != RedundancyMode.Slave) //Dongmin 20191109
            {
                return;
            }

            //LOG.Debug(string.Format("RedundancyServer:从主站资源{0}同步数据",ResourceName));

            try
            {
                /*var sw=new Stopwatch();
                 * sw.Start();*/

                IResource resource = ResourceManager.GetResource(ResourceName);

                if (resource is IRedundancy)
                {
                    IRedundancy res = (IRedundancy)resource;

                    if (res.NeedDataSync)
                    {
                        res.ExtractSyncData(ExchangeData);
                    }
                }

                /*sw.Stop();
                 * LOG.Info($"冗餘数据同步執行時間:{sw.ElapsedMilliseconds}ms");*/
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("获得主站资源:{0}出错:{1}", ResourceName, ex));
            }
        }
        public string CallResourceService(string resourceName, string serviceName, string strParameter)
        {
            try
            {
                //LOG.Debug(string.Format("客户端{0}调用接口{1}.", ResourceName, ServiceName));

                var resource = ResourceManager.GetResource(resourceName);
                var export   = resource.GetExportService();

                var strResult = export.CallExportService(serviceName, strParameter);
                return(strResult);
            }
            catch (Exception ex)
            {
                Log.Error($"调用ResourceService异常报错: 资源名:{resourceName},服务方法:{serviceName},参数:{strParameter}" + ex);
                return(null);
            }
        }
        public List <ResourceServiceModel> GetResourceService(string resourceName)
        {
            try
            {
                Log.Debug($"客户端{resourceName}获取接口服务列表.");

                var resource = ResourceManager.GetResource(resourceName);
                var export   = resource.GetExportService();

                var result = export.GetExportServices();
                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("ResourceService异常报错" + ex);
                return(null);
            }
        }