/// <summary> /// 把数据增加数据中间层的Cache 中。 /// 根据实体的状态决定操作的方式。 /// </summary> /// <param name="dataInDocType">在单据中的数据类型,默认为主表的数据。</param> /// <param name="entity">需要增加的实体。</param> /// <param name="propertys">需要增加的该实体的指定属性。</param> /// <returns></returns> public virtual int AddToCache(System.ServiceModel.ICommunicationObject serverRuleProxy, int dataInDocType, object entity, bool isDelete, string[] propertys) { IClientChannel channel = MyReflection.Instance.InvokePropertyForGet(serverRuleProxy, "InnerChannel") as IClientChannel; using (OperationContextScope scope = new OperationContextScope(channel)) { //增加消息表头信息 MessageHeaderHelper.AppendUserLoginInfo(); object[] pars = new object[] { dataInDocType, entity, isDelete, propertys }; object re = MB.WcfServiceLocator.WcfClientHelper.Instance.InvokeServerMethod(serverRuleProxy, "AddToCache", pars); return(MB.Util.MyConvert.Instance.ToInt(re)); } }
private void disposeServiceClient(System.ServiceModel.ICommunicationObject client) { if (client != null) { try { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } catch (Exception) { } client = null; } }
public void Refresh(string removedKey, object expiredValue, CacheItemRemovedReason removalReason) { System.ServiceModel.ICommunicationObject obj = expiredValue as System.ServiceModel.ICommunicationObject; if (obj != null) { try { obj.Close(); } catch (CommunicationException) { obj.Abort(); } catch (TimeoutException) { obj.Abort(); } catch (Exception) { obj.Abort(); throw; } } }
/// <summary> /// 提示中间层服务期端执行永久化的操作并清空缓存中的数据。 /// </summary> public virtual int Flush(System.ServiceModel.ICommunicationObject serverRuleProxy) { object re = MB.WcfServiceLocator.WcfClientHelper.Instance.InvokeServerMethod(serverRuleProxy, "Flush"); return(MB.Util.MyConvert.Instance.ToInt(re)); }