private static void OccupyUserPresenceAddress(IEnumerable objs) { List <string> userIDs = new List <string>(); foreach (IOguObject obj in objs) { if (obj is IUser) { userIDs.Add(obj.ID); } } UserIMAddressCollection usersExtendedInfo = UserOUControlSettings.GetConfig().UserOUControlQuery.QueryUsersIMAddress(userIDs.ToArray()); foreach (OguBase obj in objs) { if (obj is IUser) { UserIMAddress userIMAddresses = usersExtendedInfo.Find(e => string.Compare(e.UserID, obj.ID, true) == 0); if (userIMAddresses != null && userIMAddresses.IMAddress.IsNotEmpty()) { obj.ClientContext["IMAddress"] = UserPresence.NormalizeIMAddress(userIMAddresses.IMAddress); } } } }
/// <summary> /// 得到当前显示用户状态的Html /// </summary> /// <param name="userID">用户ID</param> /// <param name="userName">用户的显示名称</param> /// <param name="uniqueID"></param> /// <param name="showStatusImage">是否显示状态图标</param> /// <param name="showUserIcon">是否显示用户图标</param> /// <param name="showUserName">是否显示用户名称</param> /// <param name="statusImageType">状态图片类型</param> /// <param name="userIconUrl">用户图片路径</param> /// <param name="uiec">用户扩展信息的结构</param> /// <returns></returns> public static string GetUsersPresenceHtml(string userID, string userName, string uniqueID, bool showStatusImage, bool showUserIcon, bool showUserName, StatusImageType statusImageType, string userIconUrl, UserIMAddressCollection uiec, bool accountDisabled = false) { StringBuilder strB = new StringBuilder(); if (string.IsNullOrEmpty(userID) == false) { if (showStatusImage) { HtmlGenericControl imageDiv = new HtmlGenericControl("div"); //imageDiv.Style["position"] = "relative"; var userIconContainerCss = ""; var userIconCss = ""; if (statusImageType == StatusImageType.Ball) { imageDiv.Attributes["class"] = "uc-ball"; } else if (statusImageType == StatusImageType.ShortBar) { imageDiv.Attributes["class"] = "uc-bar36"; userIconContainerCss = "uc-user-container-short"; userIconCss = "icon"; } else if (statusImageType == StatusImageType.LongBar) { imageDiv.Attributes["class"] = "uc-bar52"; userIconContainerCss = "uc-user-container-long"; userIconCss = "icon"; } HtmlImage image = new HtmlImage(); image.Src = ControlResources.UCStatusUrl; if (accountDisabled) { image.Alt = Translator.Translate(Define.DefaultCulture, "用户账号禁用"); image.Attributes["class"] = "uc-blocked"; //禁用 } else { image.Alt = Translator.Translate(Define.DefaultCulture, "无联机状态信息"); image.Attributes["class"] = "uc-hdr"; //默认 image.Attributes["ShowOfflinePawn"] = "true"; UserIMAddress extendInfo = uiec.Find(uie => uie.UserID == userID); if (extendInfo != null) { image.Attributes["sip"] = NormalizeIMAddress(extendInfo.IMAddress); } image.ID = string.Format("{0},type=sip", uniqueID); image.Attributes["name"] = "imnmark"; } imageDiv.Controls.Add(image); strB.Append(WebControlUtility.GetControlHtml(imageDiv)); if (showUserIcon) { HtmlGenericControl userIconDiv = new HtmlGenericControl("div"); //userIconDiv.Style["position"] = "relative"; userIconDiv.Attributes["class"] = userIconContainerCss; var subDiv = new HtmlGenericControl("div"); subDiv.Attributes["class"] = userIconCss; var img = new HtmlImage(); img.Src = userIconUrl; img.Border = 0; subDiv.Controls.Add(img); userIconDiv.Controls.Add(subDiv); if (showUserName) { HtmlGenericControl nameSpan = new HtmlGenericControl("span"); nameSpan.InnerText = userName; userIconDiv.Controls.Add(nameSpan); } //nameSpan.Attributes["class"] = "imnStatusText"; strB.Append(WebControlUtility.GetControlHtml(userIconDiv)); } } if (statusImageType == StatusImageType.Ball && showUserName) { HtmlGenericControl span = new HtmlGenericControl("span"); //span.Style["padding-left"] = "16px"; span.InnerText = userName; span.Attributes["class"] = "imnStatusText"; strB.Append(WebControlUtility.GetControlHtml(span)); } } return(strB.ToString()); }
/// <summary> /// 得到当前显示用户状态的Html /// </summary> /// <param name="userID">用户ID</param> /// <param name="userName">用户的显示名称</param> /// <param name="uniqueID"></param> /// <param name="showStatusImage">是否显示状态图标</param> /// <param name="showUserIcon">是否显示用户图标</param> /// <param name="showUserName">是否显示用户名称</param> /// <param name="statusImageType">状态图片类型</param> /// <param name="userIconUrl">用户图片路径</param> /// <param name="uiec">用户扩展信息的结构</param> /// <returns></returns> public static string GetUsersPresenceHtml(string userID, string userName, string uniqueID, bool showStatusImage, bool showUserIcon, bool showUserName, StatusImageType statusImageType, string userIconUrl, UserIMAddressCollection uiec, bool accountDisabled = false) { StringBuilder strB = new StringBuilder(); if (string.IsNullOrEmpty(userID) == false) { if (showStatusImage) { HtmlGenericControl imageDiv = new HtmlGenericControl("div"); //imageDiv.Style["position"] = "relative"; var userIconContainerCss = ""; var userIconCss = ""; if (statusImageType == StatusImageType.Ball) { imageDiv.Attributes["class"] = "uc-ball"; } else if (statusImageType == StatusImageType.ShortBar) { imageDiv.Attributes["class"] = "uc-bar36"; userIconContainerCss = "uc-user-container-short"; userIconCss = "icon"; } else if (statusImageType == StatusImageType.LongBar) { imageDiv.Attributes["class"] = "uc-bar52"; userIconContainerCss = "uc-user-container-long"; userIconCss = "icon"; } HtmlImage image = new HtmlImage(); image.Src = ControlResources.UCStatusUrl; if (accountDisabled) { image.Alt = Translator.Translate(Define.DefaultCulture, "用户账号禁用"); image.Attributes["class"] = "uc-blocked"; //禁用 } else { image.Alt = Translator.Translate(Define.DefaultCulture, "无联机状态信息"); image.Attributes["class"] = "uc-hdr"; //默认 image.Attributes["ShowOfflinePawn"] = "true"; UserIMAddress extendInfo = uiec.Find(uie => uie.UserID == userID); if (extendInfo != null) image.Attributes["sip"] = NormalizeIMAddress(extendInfo.IMAddress); image.ID = string.Format("{0},type=sip", uniqueID); image.Attributes["name"] = "imnmark"; } imageDiv.Controls.Add(image); strB.Append(WebControlUtility.GetControlHtml(imageDiv)); if (showUserIcon) { HtmlGenericControl userIconDiv = new HtmlGenericControl("div"); //userIconDiv.Style["position"] = "relative"; userIconDiv.Attributes["class"] = userIconContainerCss; var subDiv = new HtmlGenericControl("div"); subDiv.Attributes["class"] = userIconCss; var img = new HtmlImage(); img.Src = userIconUrl; img.Border = 0; subDiv.Controls.Add(img); userIconDiv.Controls.Add(subDiv); if (showUserName) { HtmlGenericControl nameSpan = new HtmlGenericControl("span"); nameSpan.InnerText = userName; userIconDiv.Controls.Add(nameSpan); } //nameSpan.Attributes["class"] = "imnStatusText"; strB.Append(WebControlUtility.GetControlHtml(userIconDiv)); } } if (statusImageType == StatusImageType.Ball && showUserName) { HtmlGenericControl span = new HtmlGenericControl("span"); //span.Style["padding-left"] = "16px"; span.InnerText = userName; span.Attributes["class"] = "imnStatusText"; strB.Append(WebControlUtility.GetControlHtml(span)); } } return strB.ToString(); }