using System.Collections.Generic; using System.Configuration; using WebApp.Models.Hub; namespace WebApp.Hubs { public class HubsTool { #region GetAppSettings /// /// 獲取WebService的配置信息 /// /// appSettings中配置的Key值 /// /// appSettings中配置的value值 public static string GetAppSettings(string sKey) { return ConfigurationManager.AppSettings[sKey].ToString(); } #endregion GetAppSettings #region GetConnectionId /// /// 獲取人員連線id /// /// todo: describe orgId parameter on GetConnectionId /// todo: describe userId parameter on GetConnectionId /// /// appSettings中配置的value值 public static string GetConnectionId(string orgId, string userId) { var sConnectionId = ""; foreach (UserInfo user in MsgHub.Euro_Online.Users) { if (userId == user.UserId && orgId == user.OrgId) { sConnectionId = user.ConnectionId; break; } } return sConnectionId; } #endregion GetConnectionId #region GetConnectionIds /// /// 獲取多人員連線id /// /// todo: describe userIds parameter on GetConnectionIds /// /// appSettings中配置的value值 public static IList GetConnectionIds(IList userIds) { var ConnectionIds = new List(); foreach (UserInfo user in MsgHub.Euro_Online.Users) { if (userIds.Contains(user.OrgId + user.UserId)) { ConnectionIds.Add(user.ConnectionId); } } return ConnectionIds; } #endregion GetConnectionIds #region GetConnectionIdsByOrgID /// /// 獲取多人員連線id /// /// 組織ID /// /// appSettings中配置的value值 public static IList GetConnectionIdsByOrgID(string OrgID) { var ConnectionIds = new List(); foreach (UserInfo user in MsgHub.Euro_Online.Users) { if (user.OrgId == OrgID) { ConnectionIds.Add(user.ConnectionId); } } return ConnectionIds; } #endregion GetConnectionIdsByOrgID } }