基于透明代理技术创建的WCF实例打开与关闭WCF通道
作者:C/S框架网  发布日期:2018/08/22 17:03:41
  基于透明代理技术创建的WCF实例打开与关闭WCF通道


C# Code:

private CSFrameworkV5.WCFContract.ISystemSecurityService client
{
   get { return WCFFactory.Create<CSFrameworkV5.WCFContract.ISystemSecurityService>(); }
}

#region IBridge_User Members

public bool SetLockState(string account, bool isLock)
{
   byte[] loginTicket = WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
   return client.U_SetLockState(loginTicket, account, isLock);
}

//来源:C/S框架网(www.csframework.com) QQ:23404761



ICommunicationObject.Open
ICommunicationObject.Close


关闭WCF通道:

C# Code:

public bool SetLockState(string account, bool isLock)
{
   ISystemSecurityService svc = this.client;
   try
   {
      byte[] loginTicket = WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
      return svc.U_SetLockState(loginTicket, account, isLock);
   }
   finally
   {
      (svc as ICommunicationObject).Close();
   }
}

//来源:C/S框架网(www.csframework.com) QQ:23404761


上一篇 下一篇