/// <summary> ///获取过期的冠名广告 /// </summary> /// <returns></returns> public static List <SeatManage.ClassModel.TitleAdvertInfo> GetTitleAdvertOverTime() { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.GetTitleAdOverTime()); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取过期的冠名广告失败:" + ex.Message); return(new List <ClassModel.TitleAdvertInfo>()); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 根据类型获取对应的程序信息 /// </summary> /// <param name="programType"></param> /// <returns></returns> public static AdvertManage.Model.ProgramUpgradeModel GetProgramInfoByProgramType(Model.Enum.SeatManageSubsystem programType) { IWCFService.IAdvertManageService advertService = WcfAccessProxy.AMS_ServiceProxy.CreateChannelAdvertManageService(); bool error = false; try { return(advertService.GetProgramInfoByProgramType(programType)); } catch (Exception ex) { error = true; SeatManage.SeatManageComm.WriteLog.Write(string.Format("根据类型获取对应的程序信息失败 ,异常来自:{0};信息:{1}", ex.Source, ex.Message)); throw ex; } finally { ICommunicationObject ICommObjectService = advertService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 添加冠名广告 /// </summary> /// <param name="model"></param> /// <returns></returns> public static EnumType.HandleResult AddTitleAdvert(SeatManage.ClassModel.TitleAdvertInfo model) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.AddTitleAdvert(model)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("添加冠名广告失败:" + ex.Message); return(EnumType.HandleResult.Failed); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 删除 /// </summary> /// <param name="model"></param> /// <returns></returns> public static SeatManage.EnumType.HandleResult DeleteRollTitles(string Num) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.DeleteRollTitle(Num)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("删除滚动广告失败:" + ex.Message); throw ex; } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
public static TitleAdvertInfo GetTitleModel(string Num) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.GetTitleModel(Num)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("删除冠名广告失败:" + ex.Message); return(null); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
public static void ReleaseCommunicationObject(ICommunicationObject comm, TimeSpan?timeout) { if (comm != null) { if (comm.State != CommunicationState.Faulted) { try { if (timeout.HasValue) { comm.Close(timeout.Value); } else { comm.Close(); } } catch { comm.Abort(); } } else { comm.Abort(); } } }
/// <summary> /// 判断阅览室编号是否重复 /// </summary> /// <param name="ReadingRoomNo"></param> /// <returns></returns> public static bool ReadingRoomIsExists(string ReadingRoomNo) { IWCFService.ISeatManageService SeatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(SeatService.ReadingRoomIsExists(ReadingRoomNo)); } catch (Exception ex) { error = true; WriteLog.Write("查询阅览室失败:" + ex.Message); return(false); } finally { ICommunicationObject ICommObjectService = SeatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 更新座位布局 /// </summary> /// <param name="seatLayout"></param> /// <returns></returns> public static SeatManage.EnumType.HandleResult UpdateSeatLayout(SeatLayout seatLayout) { IWCFService.ISeatManageService SeatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(SeatService.UpdateSeatLayout(seatLayout)); } catch (Exception ex) { error = true; WriteLog.Write("查询阅览室失败:" + ex.Message); return(EnumType.HandleResult.Failed); } finally { ICommunicationObject ICommObjectService = SeatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 获取硬广 /// </summary> /// <returns></returns> public static List <AdvertManage.Model.AMS_HardAdModel> GetHardAdList() { IWCFService.IAdvertManageService advertService = WcfAccessProxy.AMS_ServiceProxy.CreateChannelAdvertManageService(); bool error = false; try { return(advertService.GetHardAdList()); } catch (Exception ex) { error = true; SeatManage.SeatManageComm.WriteLog.Write(string.Format("获取硬广遇到异常,异常模块:{0};信息:{1}", ex.Source, ex.Message)); throw ex; } finally { ICommunicationObject ICommObjectService = advertService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 根据条件获取阅览室信息 /// </summary> /// <param name="roomNum">阅览室编号</param> /// <param name="libraryNum">图书馆编号</param> /// <param name="schoolNum">校区编号</param> /// <returns></returns> public static List <ReadingRoomInfo> GetReadingRooms(List <string> roomNum, List <string> libraryNum, List <string> schoolNum) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.GetReadingRooms(roomNum, libraryNum, schoolNum)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取阅览室信息失败:" + ex.Message); return(new List <ReadingRoomInfo>()); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 根据学号模糊查询,获取进出记录 /// </summary> /// <param name="cardNo"></param> /// <param name="roomNum"></param> /// <param name="seatNo"></param> /// <param name="beginTime"></param> /// <param name="endTime"></param> /// <returns></returns> public static List <EnterOutLogInfo> GetEnterOutLogs_ByFuzzySearch(string cardNo, string roomNum, string seatNo, DateTime beginTime, DateTime endTime) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.GetEnterOutLogs_ByFuzzySearch(cardNo, roomNum, seatNo, beginTime.ToString(), endTime.ToString())); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取进出记录失败:" + ex.Message); return(new List <EnterOutLogInfo>()); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
public static List <EnterOutLogInfo> GetUsingSeatEnterOutLogInfo(string roomNum) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.GetUsingSeatEnterOutLogInfo(roomNum)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取进出记录失败:" + ex.Message); return(null); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 更新同步设置 /// </summary> /// <param name="set"></param> /// <returns></returns> public static bool UpdateStuLibSync(StuLibSyncSetting set) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.UpdateStuLibSync(set)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取设置失败:" + ex.Message); return(false); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 根据进出记录编号查出对应的列表 /// </summary> /// <param name="enterOutNo">编号</param> /// <param name="logType">记录类型</param> /// <param name="top">最后几条</param> /// <returns></returns> public static List <EnterOutLogInfo> GetEnterOutLogByNo(string enterOutNo, List <EnterOutLogType> logType, int top) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.GetEnterOutLogsByNo(enterOutNo, logType, top)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取进出记录失败:" + ex.Message); return(new List <EnterOutLogInfo>()); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 保存消息设置 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool SaveMsgPushSet(PushMsssageSetting model) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); try { return(seatService.SaveMsgPushSet(model)); } catch (Exception ex) { SeatManageComm.WriteLog.Write("消息推送设置保存失败:" + ex.Message); throw ex; } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 修改手机网站设置 /// </summary> /// <returns></returns> public static bool UpdatePecketWebSetting(PecketBookWebSetting model) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); try { return(seatService.UpdatePecketBookWebSetting(model)); } catch (Exception ex) { SeatManageComm.WriteLog.Write("更新手机网站设置失败:" + ex.Message); return(false);; } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary>Disposes the service client. </summary> /// <param name="service">The service client. </param> /// <param name="isDisposed">The reference to a value indicating whether the service is disposed. </param> public static void Dispose(ICommunicationObject service, ref bool isDisposed) { if (isDisposed) return; try { if (service.State == CommunicationState.Faulted) service.Abort(); else { try { service.Close(); } catch (Exception closeException) { try { service.Abort(); } catch (Exception abortException) { throw new AggregateException(closeException, abortException); } throw; } } } finally { isDisposed = true; } }
/// <summary> /// 根据编号获取学校信息 /// </summary> /// <param name="schoolNum"></param> /// <returns></returns> public static AMS.Model.AMS_School GetSchoolInfoByNum(string schoolNum) { AMS.IBllService.IAdvertManageBllService bllService = AMS.ServiceConnectChannel.AdvertManageBllServiceChannel.CreateServiceChannel(); bool error = false; try { return(bllService.GetSchoolInfoByNum(schoolNum)); } catch (Exception ex) { error = true; SeatManage.SeatManageComm.WriteLog.Write(string.Format("根据学校编号获取设备列表遇到错误,异常来自:{0};信息:{1}", ex.Source, ex.Message)); throw ex; } finally { ICommunicationObject ICommObjectService = bllService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 获取选座次数排行榜 /// </summary> /// <param name="top"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="type"></param> /// <returns></returns> public static DataTable TopSeatCountList(int top, string startDate, string endDate, int type) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.TopSeatCountList(top, startDate, endDate, type)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取用户权限失败:" + ex.Message); return(null); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// Clean up and close proxy. /// </summary> public virtual void CloseProxy() { if (proxy != null) { proxy.Cleanup(); ICommunicationObject channel = proxy as ICommunicationObject; if (channel != null) { try { channel.Close(); } catch (TimeoutException) { channel.Abort(); } catch (CommunicationException) { channel.Abort(); } } proxy = null; } }
/// <summary> /// 获取读者信息 /// </summary> /// <param name="school"></param> /// <param name="reader"></param> /// <returns></returns> public ClassModel.ReaderInfo GetReaderInfo(AMS.Model.AMS_School school, ClassModel.ReaderInfo reader) { SeatManage.IPocketBespeakBllService.IPocketBespeakBllService pocketBespeak = BespeakServiceConnProxy.BespeakServiceConnProxy.CreateChannelPocketBespeakBllService(school.ConnectionString); try { return(pocketBespeak.GetReaderInfo(reader.CardNo)); } catch (ReaderHandlerFailed ex) { throw ex; } catch (Exception ex) { throw new RemoteServiceLinkFailed(); } finally { ICommunicationObject ICommObjectService = pocketBespeak as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 根据编号获取校区信息 /// </summary> /// <param name="number"></param> /// <returns></returns> public static Model.AMS_CampusModel GetCampusInfoByNum(string number) { IWCFService.IAdvertManageService advertService = WcfAccessProxy.AMS_ServiceProxy.CreateChannelAdvertManageService(); bool error = false; try { return(advertService.GetCampusInfoByNum(number)); } catch (Exception ex) { error = true; SeatManage.SeatManageComm.WriteLog.Write(string.Format("根据编号获取校区信息失败,异常来自:{0};信息:{1}", ex.Source, ex.Message)); throw ex; } finally { ICommunicationObject ICommObjectService = advertService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 续时 /// </summary> /// <param name="school"></param> /// <param name="reader"></param> /// <returns></returns> public string DelaySeatUsedTime(AMS.Model.AMS_School school, ReaderInfo reader) { SeatManage.IPocketBespeakBllService.IPocketBespeakBllService pocketBespeak = BespeakServiceConnProxy.BespeakServiceConnProxy.CreateChannelPocketBespeakBllService(school.ConnectionString); try { return(pocketBespeak.DelaySeatUsedTime(reader)); } catch (ReaderHandlerFailed ex) { throw ex; } catch (Exception ex) { throw ex; } finally { ICommunicationObject ICommObjectService = pocketBespeak as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
public string SelectSeat(AMS.Model.AMS_School school, string cardNo, string seatNum, string readingRoomNum) { SeatManage.IPocketBespeakBllService.IPocketBespeakBllService pocketBespeak = BespeakServiceConnProxy.BespeakServiceConnProxy.CreateChannelPocketBespeakBllService(school.ConnectionString); try { return(pocketBespeak.SelectSeat(cardNo, seatNum, readingRoomNum)); } catch (Exception ex) { throw ex; } finally { ICommunicationObject ICommObjectService = pocketBespeak as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 执行带返回值的服务调用 /// </summary> /// <typeparam name="TChannel">泛型表示的服务接口</typeparam> /// <typeparam name="TResult">泛型表示的返回值</typeparam> /// <param name="function">服务接口为参数的、带返回值的泛型委托</param> /// <param name="proxy">服务接口</param> /// <returns></returns> public static TResult Invoke <TChannel, TResult>(Func <TChannel, TResult> function, TChannel proxy) { ICommunicationObject channel = proxy as ICommunicationObject; if (channel == null) { throw new ArgumentException("The proxy is not a valid channel implementing the ICommunicationObject interface", "proxy"); } // 打开服务通道 channel.Open(); try { // 执行服务操作 return(function(proxy)); } catch (TimeoutException) { // 操作超时 channel.Abort(); throw; } catch (CommunicationException) { // 通信错误 channel.Abort(); throw; } finally { // 关闭服务通道 channel.Close(); } }
/// <summary> /// 获取阅览室状态 /// </summary> /// <param name="school"></param> /// <returns></returns> public Dictionary <string, ReadingRoomSeatUsedState_Ex> GetAllRoomSeatUsedState(AMS.Model.AMS_School school) { SeatManage.IPocketBespeakBllService.IPocketBespeakBllService pocketBespeak = BespeakServiceConnProxy.BespeakServiceConnProxy.CreateChannelPocketBespeakBllService(school.ConnectionString); try { return(pocketBespeak.GetAllRoomSeatUsedState()); } catch (ReaderHandlerFailed ex) { throw ex; } catch (Exception ex) { throw new RemoteServiceLinkFailed(); } finally { ICommunicationObject ICommObjectService = pocketBespeak as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 根据NUM查 /// </summary> /// <param name="Num"></param> /// <returns></returns> public static SeatManage.ClassModel.RollTitlesInfo GetModelByNum(string Num) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.GetModelByNum(Num)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取获取滚动广告失败:" + ex.Message); throw ex; } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 添加阅览室使用记录 /// </summary> /// <param name="model"></param> /// <returns></returns>] public static bool AddRoomUsageStatistics(RoomUsageStatistics model) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.AddRoomUsageStatistics(model)); } catch (Exception ex) { error = true; WriteLog.Write("添加阅览室使用记录失败:" + ex.Message); return(false); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 获取阅览室使用情况记录 /// </summary> /// <param name="roomsNo"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> public static List <RoomUsageStatistics> GetRoomUsageStatisticsList(List <string> roomsNo, DateTime startDate, DateTime endDate) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); try { return(seatService.GetRoomUsageStatisticsList(roomsNo, startDate, endDate)); } catch (Exception ex) { WriteLog.Write("获取阅览室使用情况记录失败:" + ex.Message); throw ex; } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 根据座位编号获取座位信息 /// </summary> /// <param name="seatNo"></param> /// <returns></returns> public static Seat GetSeatInfoBySeatNo(string seatNo) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool isError = false; try { return(seatService.GetSeatInfoBySeatNum(seatNo)); } catch (Exception EX) { isError = true; WriteLog.Write("获取座位信息出错:" + EX.Message); return(null); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 根据阅览室编号获取座位 /// </summary> /// <param name="roomNum">阅览室编号</param> /// <param name="lockstat">是否锁定</param> /// <returns></returns> public static List <Seat> GetSeatListByRoomNum(string roomNum, bool lockstat) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.GetSeatListByReadingRoom(roomNum, lockstat)); } catch (Exception ex) { error = true; SeatManageComm.WriteLog.Write("获取阅览室编号错误:" + ex.Message); return(new List <Seat>()); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
public OrationiSlave() { Binding binding = new NetTcpBinding(SecurityMode.None); EndpointAddress defaultEndpointAddress = new EndpointAddress("net.tcp://localhost:57344/Orationi/Master/v1/"); EndpointAddress discoveredEndpointAddress = DiscoverMaster(); ContractDescription contractDescription = ContractDescription.GetContract(typeof(IOrationiMasterService)); ServiceEndpoint serviceEndpoint = new ServiceEndpoint(contractDescription, binding, discoveredEndpointAddress ?? defaultEndpointAddress); var channelFactory = new DuplexChannelFactory<IOrationiMasterService>(this, serviceEndpoint); try { channelFactory.Open(); } catch (Exception ex) { channelFactory?.Abort(); } try { _masterService = channelFactory.CreateChannel(); _communicationObject = (ICommunicationObject)_masterService; _communicationObject.Open(); } catch (Exception ex) { if (_communicationObject != null && _communicationObject.State == CommunicationState.Faulted) _communicationObject.Abort(); } }
private static void CloseClient(ICommunicationObject client) { if (client.State == CommunicationState.Opened) { try { client.Close(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } } }
internal static void Abort(ICommunicationObject commObj, object identifier) { if (TD.RoutingServiceAbortingChannelIsEnabled()) { TD.RoutingServiceAbortingChannel(identifier != null ? identifier.ToString() : string.Empty); } //The Exception contract for ICommunicationObject.Abort is to never throw, anything else is a fatal error. commObj.Abort(); }
public static void CloseClient(ICommunicationObject client) { if (client != null && client.State == CommunicationState.Faulted) { client.Abort(); } else { client.Close(); } }
public static void Close(ICommunicationObject co) { if (co == null) { return; } try { switch (co.State) { case CommunicationState.Closed: case CommunicationState.Closing: break; case CommunicationState.Faulted: co.Abort(); break; case CommunicationState.Created: case CommunicationState.Opened: case CommunicationState.Opening: co.Close(); break; default: co.Abort(); break; } } catch (Exception e) { s_Logger.Fatal(co, e); // ReSharper disable EmptyGeneralCatchClause try { co.Abort(); } catch { } // ReSharper restore EmptyGeneralCatchClause } }
private void CloseProxy(ICommunicationObject proxy) { if (proxy == null) { throw new ArgumentNullException(); } if (proxy.State == CommunicationState.Faulted) { proxy.Abort(); } else { proxy.Close(); } }
private void CompleteClose(ICommunicationObject communicationObject, IAsyncResult result) { Exception closeException = null; try { communicationObject.EndClose(result); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (Fx.IsFatal(e)) { throw; } closeException = e; communicationObject.Abort(); } Decrement(result.CompletedSynchronously, closeException); }
static void KillChannel(ICommunicationObject channel) { if (channel == null) return; if (channel.State == CommunicationState.Faulted) { channel.Abort(); channel = null; return; } // TODO: закрытие channel = null; }
/// <summary> /// Tries to gracefully close communication object. /// </summary> private static void TryCloseCommunicationObject(ICommunicationObject commObj) { if (commObj.State == CommunicationState.Faulted) { commObj.Abort(); } else if (commObj.State != CommunicationState.Closed) { try { commObj.Close(); } catch (CommunicationException) { commObj.Abort(); } } }
/// <summary> /// Closes the specified communication object, calling the /// <see cref="ICommunicationObject.Abort"/> method if it is in the faulted state. /// </summary> /// <param name="co">The communication object to close.</param> protected void SafeClose(ICommunicationObject co) { if (co == null) return; if (co.State == CommunicationState.Faulted) co.Abort(); else co.Close(); }
public static void CloseCommunicationObject(ICommunicationObject communicationObject, TimeSpan timeout) { if (communicationObject == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("communicationObject"); } bool flag = true; try { if (communicationObject.State == CommunicationState.Opened) { communicationObject.Close(timeout); flag = false; } } catch (CommunicationException communicatioException) { DiagnosticUtility.TraceHandledException(communicatioException, TraceEventType.Information); } catch (TimeoutException timeoutException) { DiagnosticUtility.TraceHandledException(timeoutException, TraceEventType.Information); } finally { if (flag) { communicationObject.Abort(); } } }
private static void Close(ICommunicationObject client) { try { if (client.State != CommunicationState.Faulted) { client.Close(); } } finally { if (client.State != CommunicationState.Closed) { client.Abort(); } } }
/// <summary> /// </summary> /// <param name="channel"> /// The channel. /// </param> private static void CloseChannel(ICommunicationObject channel) { try { channel.Close(); } catch (Exception ex) { throw; } finally { channel.Abort(); } }
private void CleanupCommunicationObject(ICommunicationObject communicationObject) { if (communicationObject != null) { communicationObject.Faulted -= CommunicationObject_Faulted; communicationObject.Closing -= CommunicationObject_Closing; if (communicationObject.State == CommunicationState.Faulted) { communicationObject.Abort(); } else { communicationObject.Close(); } } }
private static void AbortServiceChannel( ICommunicationObject communicationObject ) { try { communicationObject.Abort(); LocalServiceClient = null; } catch (Exception) { // ignored } }
private void CloseProxy(ICommunicationObject proxy) { if (proxy != null) { if (proxy.State == CommunicationState.Faulted) { proxy.Abort(); } else { proxy.Close(); } } }
private static async Task CloseAsync(ICommunicationObject commObj) { try { await Task.Factory.FromAsync( (c, s) => ((ICommunicationObject)s).BeginClose(c, s), r => ((ICommunicationObject)r.AsyncState).EndClose(r), commObj); commObj = null; } catch (CommunicationException) { } catch (TimeoutException) { } if (commObj != null) { commObj.Abort(); } }