private string GetStatusText(WfProcessCurrentInfo atp, UserIMAddressCollection extendInfo) { string result = DefaultStatusText; switch (DisplayMode) { case WfStatusDisplayMode.ProcessStatus: result = HttpUtility.HtmlEncode(EnumItemDescriptionAttribute.GetDescription(atp.Status)); break; case WfStatusDisplayMode.CurrentUsers: if (EnableUserPresence == false) { result = GetAllAssigneesStatusHtmlWithoutPresence(atp); } else { result = GetAllAssigneesStatusHtmlWithPresence(atp, IsHtmlRender, extendInfo, this.ClientID); } break; } return(result); }
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); } } } }
private Control CreateStatusDisplayControl(WfProcessCurrentInfo atp, UserIMAddressCollection extendInfo) { HtmlGenericControl Container = new HtmlGenericControl("span"); HtmlGenericControl firstLine = new HtmlGenericControl("span"); Container.Controls.Add(firstLine); HtmlAnchor statusAnchor = new HtmlAnchor(); firstLine.Controls.Add(statusAnchor); statusAnchor.InnerHtml = GetStatusText(atp, extendInfo); statusAnchor.HRef = "#"; string deptName = atp.Department.DisplayName; statusAnchor.Title = GetAllAssigneesStatusText(atp); statusAnchor.Attributes["onclick"] = "onWfStatusLinkClick()"; HtmlGenericControl seperator = new HtmlGenericControl("span"); firstLine.Controls.Add(seperator); seperator.InnerHtml = " "; PageRenderMode mode = WebUtility.GetRequestPageRenderMode(); if (mode.IsHtmlRender) { HtmlAnchor traceAnchor = new HtmlAnchor(); firstLine.Controls.Add(traceAnchor); HtmlImage logo = new HtmlImage(); traceAnchor.Controls.Add(logo); logo.Style["border"] = "none"; logo.Alt = Translator.Translate(Define.DefaultCulture, "流程跟踪..."); logo.Style["vertical-align"] = "middle"; logo.Src = GetImageByStatus(atp.Status); InitTraceControlEntry(traceAnchor, atp.ResourceID, atp.InstanceID); } HtmlGenericControl secondLine = new HtmlGenericControl("div"); Container.Controls.Add(secondLine); secondLine.Controls.Add(CreateDetailControl(atp, extendInfo)); secondLine.Style["display"] = "none"; return(Container); }
/// <summary> /// 查询用户的即时消息地址 /// </summary> /// <param name="ids"></param> /// <returns></returns> public UserIMAddressCollection QueryUsersIMAddress(params string[] ids) { UserInfoExtendCollection extendedInfo = QueryUsersExtendedInfo(ids); UserIMAddressCollection result = new UserIMAddressCollection(); extendedInfo.ForEach(eu => result.Add(new UserIMAddress(eu.ID, eu.IMAddress))); return(result); }
private Control CreateDetailControl(WfProcessCurrentInfo atp, UserIMAddressCollection extendInfo) { HtmlGenericControl subContainer = new HtmlGenericControl("div"); HtmlGenericControl divActivtity = new HtmlGenericControl("div"); subContainer.Controls.Add(divActivtity); HtmlGenericControl divUserInfo = new HtmlGenericControl("div"); subContainer.Controls.Add(divUserInfo); divUserInfo.InnerHtml = GetAllAssigneesStatusHtmlWithPresence(atp, IsHtmlRender, extendInfo, this.ClientID + "_DETAIL"); return(subContainer); }
private static UserIMAddressCollection GetAllAssigneesExtendInfo(WfProcessCurrentInfoCollection atpc) { UserIMAddressCollection result = (UserIMAddressCollection)HttpContext.Current.Items[atpc]; if (result == null) { List <string> userIDs = new List <string>(); foreach (WfProcessCurrentInfo atp in atpc) { atp.Assignees.ForEach(u => userIDs.Add(u.User.ID)); } result = UserOUControlSettings.GetConfig().UserOUControlQuery.QueryUsersIMAddress(userIDs.ToArray()); HttpContext.Current.Items[atpc] = result; } return(result); }
private void RenderStatus(WfProcessCurrentInfoCollection atpc, UserIMAddressCollection extendInfo, HtmlTextWriter writer) { WfProcessCurrentInfo atp = null; if (this.ProcessID.IsNotEmpty()) { atp = atpc.Find(a => string.Compare(a.InstanceID, this.ProcessID, true) == 0); } else { if (this.ResourceID.IsNotEmpty()) { atp = atpc.Find(a => string.Compare(a.ResourceID, this.ResourceID, true) == 0); } } if (atp != null) { writer.Write(WebControlUtility.GetControlHtml(CreateStatusDisplayControl(atp, extendInfo))); } }
public UserIMAddressCollection QueryUsersIMAddress(params string[] ids) { //新实现,从权限中心获取用户SIP地址 OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, ids); UserIMAddressCollection result = new UserIMAddressCollection(); foreach (IUser user in users) { if (result.ContainsKey(user.ID) == false) { UserIMAddress item = new UserIMAddress( user.ID, DictionaryHelper.GetValue(user.Properties, "Sip", string.Empty)); result.Add(item); } } return(result); }
protected override void Render(HtmlTextWriter writer) { if (DesignMode) { writer.Write("Wf Status"); } else { UserIMAddressCollection extendInfo = null; if (EnableUserPresence && IsHtmlRender) { extendInfo = GetAllAssigneesExtendInfo(AppTraceProcesses); } else { extendInfo = new UserIMAddressCollection(); } RenderStatus(AppTraceProcesses, extendInfo, writer); } }
private static string GetAllAssigneesStatusHtmlWithPresence(WfProcessCurrentInfo atp, bool showStatusImage, UserIMAddressCollection extendInfo, string idPrefix) { HtmlGenericControl span = new HtmlGenericControl("span"); int i = 0; foreach (var assignee in atp.Assignees) { span.InnerHtml += UserPresence.GetUsersPresenceHtml(assignee.User.ID, assignee.User.DisplayName.IsNullOrEmpty() ? assignee.User.Name : assignee.User.DisplayName, idPrefix + "_img_" + i, showStatusImage, false, true, StatusImageType.Ball, "", extendInfo); string topOUName = GetUserTopOUName(assignee.User); if (topOUName.IsNotEmpty()) { span.InnerHtml += string.Format("({0})", HttpUtility.HtmlEncode(topOUName)); } i++; } return(WebControlUtility.GetControlHtml(span)); }
private static string GetAllAssigneesStatusHtmlWithPresence(WfProcessCurrentInfo atp, bool showStatusImage, UserIMAddressCollection extendInfo, string idPrefix) { HtmlGenericControl span = new HtmlGenericControl("span"); int i = 0; foreach (var assignee in atp.Assignees) { span.InnerHtml += UserPresence.GetUsersPresenceHtml(assignee.User.ID, assignee.User.DisplayName.IsNullOrEmpty() ? assignee.User.Name : assignee.User.DisplayName, idPrefix + "_img_" + i, showStatusImage, false, true, StatusImageType.Ball, "", extendInfo); string topOUName = GetUserTopOUName(assignee.User); if (topOUName.IsNotEmpty()) span.InnerHtml += string.Format("({0})", HttpUtility.HtmlEncode(topOUName)); i++; } return WebControlUtility.GetControlHtml(span); }
public static void RenderUsersPresence(string userID, string userName, string uniqueID, bool showStatusImage, bool showUserIcon, bool showUserName, StatusImageType statusImageType, string userIconUrl, UserIMAddressCollection uiec, HtmlTextWriter writer, bool accountDisabled = false) { writer.Write(GetUsersPresenceHtml(userID, userName, uniqueID, showStatusImage, showUserIcon, showUserName, statusImageType, userIconUrl, uiec, accountDisabled)); }
/// <summary> /// 得到当前显示用户状态的Html /// </summary> /// <param name="userID">用户ID</param> /// <param name="userName">用户的显示名称</param> /// <param name="uniqueID"></param> /// <param name="showStatusImage">是否显示状态图标</param> /// <param name="uiec">用户扩展信息的结构</param> /// <returns></returns> public static string GetUsersPresenceHtml(string userID, string userName, string uniqueID, bool showStatusImage, UserIMAddressCollection uiec) { return(GetUsersPresenceHtml(userID, userName, uniqueID, showStatusImage, false, true, StatusImageType.Ball, "", uiec)); }
public static void RenderUsersPresence(string userID, string userName, string uniqueID, bool showStatusImage, bool showUserIcon, bool showUserName, StatusImageType statusImageType, string userIconUrl, UserIMAddressCollection uiec, HtmlTextWriter writer, bool accountDisabled = false) { writer.Write(GetUsersPresenceHtml(userID, userName, uniqueID, showStatusImage, showUserIcon, showUserName, statusImageType, userIconUrl, uiec, accountDisabled)); }
private void RenderStatus(WfProcessCurrentInfoCollection atpc, UserIMAddressCollection extendInfo, HtmlTextWriter writer) { WfProcessCurrentInfo atp = null; if (this.ProcessID.IsNotEmpty()) { atp = atpc.Find(a => string.Compare(a.InstanceID, this.ProcessID, true) == 0); } else { if (this.ResourceID.IsNotEmpty()) atp = atpc.Find(a => string.Compare(a.ResourceID, this.ResourceID, true) == 0); } if (atp != null) writer.Write(WebControlUtility.GetControlHtml(CreateStatusDisplayControl(atp, extendInfo))); }
/// <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="uiec">用户扩展信息的结构</param> /// <returns></returns> public static string GetUsersPresenceHtml(string userID, string userName, string uniqueID, bool showStatusImage, UserIMAddressCollection uiec) { return GetUsersPresenceHtml(userID, userName, uniqueID, showStatusImage, false, true, StatusImageType.Ball, "", uiec); }
private Control CreateStatusDisplayControl(WfProcessCurrentInfo atp, UserIMAddressCollection extendInfo) { HtmlGenericControl Container = new HtmlGenericControl("span"); HtmlGenericControl firstLine = new HtmlGenericControl("span"); Container.Controls.Add(firstLine); HtmlAnchor statusAnchor = new HtmlAnchor(); firstLine.Controls.Add(statusAnchor); statusAnchor.InnerHtml = GetStatusText(atp, extendInfo); statusAnchor.HRef = "#"; string deptName = atp.Department.DisplayName; statusAnchor.Title = GetAllAssigneesStatusText(atp); statusAnchor.Attributes["onclick"] = "onWfStatusLinkClick()"; HtmlGenericControl seperator = new HtmlGenericControl("span"); firstLine.Controls.Add(seperator); seperator.InnerHtml = " "; PageRenderMode mode = WebUtility.GetRequestPageRenderMode(); if (mode.IsHtmlRender) { HtmlAnchor traceAnchor = new HtmlAnchor(); firstLine.Controls.Add(traceAnchor); HtmlImage logo = new HtmlImage(); traceAnchor.Controls.Add(logo); logo.Style["border"] = "none"; logo.Alt = Translator.Translate(Define.DefaultCulture, "流程跟踪..."); logo.Style["vertical-align"] = "middle"; logo.Src = GetImageByStatus(atp.Status); InitTraceControlEntry(traceAnchor, atp.ResourceID, atp.InstanceID); } HtmlGenericControl secondLine = new HtmlGenericControl("div"); Container.Controls.Add(secondLine); secondLine.Controls.Add(CreateDetailControl(atp, extendInfo)); secondLine.Style["display"] = "none"; return Container; }
private string GetStatusText(WfProcessCurrentInfo atp, UserIMAddressCollection extendInfo) { string result = DefaultStatusText; switch (DisplayMode) { case WfStatusDisplayMode.ProcessStatus: result = HttpUtility.HtmlEncode(EnumItemDescriptionAttribute.GetDescription(atp.Status)); break; case WfStatusDisplayMode.CurrentUsers: if (EnableUserPresence == false) result = GetAllAssigneesStatusHtmlWithoutPresence(atp); else result = GetAllAssigneesStatusHtmlWithPresence(atp, IsHtmlRender, extendInfo, this.ClientID); break; } return result; }
/// <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()); }
protected override void Render(HtmlTextWriter writer) { if (DesignMode) writer.Write("Wf Status"); else { UserIMAddressCollection extendInfo = null; if (EnableUserPresence && IsHtmlRender) extendInfo = GetAllAssigneesExtendInfo(AppTraceProcesses); else extendInfo = new UserIMAddressCollection(); RenderStatus(AppTraceProcesses, extendInfo, writer); } }
private Control CreateDetailControl(WfProcessCurrentInfo atp, UserIMAddressCollection extendInfo) { HtmlGenericControl subContainer = new HtmlGenericControl("div"); HtmlGenericControl divActivtity = new HtmlGenericControl("div"); subContainer.Controls.Add(divActivtity); HtmlGenericControl divUserInfo = new HtmlGenericControl("div"); subContainer.Controls.Add(divUserInfo); divUserInfo.InnerHtml = GetAllAssigneesStatusHtmlWithPresence(atp, IsHtmlRender, extendInfo, this.ClientID + "_DETAIL"); return subContainer; }