Esempio n. 1
0
 /// <summary>
 /// 建立WCF连接
 /// </summary>
 /// <returns></returns>
 public bool ConnectServer()
 {
     try
     {
         if (!string.IsNullOrEmpty(_ParkAdapterUri))
         {
             Binding binding = Ralid.GeneralLibrary.WCF.BindingFactory.CreateDualBinding(_ParkAdapterUri);
             if (binding != null)
             {
                 if (_ChannelFactory != null)
                 {
                     _ChannelFactory.Close();
                 }
                 _ChannelFactory = new DuplexChannelFactory <IParkingAdapter>(this, binding, new EndpointAddress(_ParkAdapterUri));
                 IParkingAdapter channel = _ChannelFactory.CreateChannel();
                 channel.Subscription();
                 _Channel = channel;
                 if (ParkApaterReconnected != null)
                 {
                     ParkApaterReconnected(this, EventArgs.Empty);
                 }
                 return(true);
             }
         }
         else
         {
             if (ParkAdapterConnectFail != null)
             {
                 ParkAdapterConnectFail(this, EventArgs.Empty);
             }
         }
     }
     catch (CommunicationException ex)
     {
         if (ParkAdapterConnectFail != null)
         {
             ParkAdapterConnectFail(this, EventArgs.Empty);
         }
     }
     catch (Exception ex)
     {
         ExceptionPolicy.HandleException(ex);
     }
     return(false);
 }
Esempio n. 2
0
 public bool Subscription()
 {
     try
     {
         if (_Channel != null)
         {
             return(_Channel.Subscription());
         }
     }
     catch (CommunicationException)
     {
         if (ParkAdapterConnectFail != null)
         {
             ParkAdapterConnectFail(this, EventArgs.Empty);
         }
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
     return(false);
 }