Hi JJallad,
Please try the example page below, it shows you how to get the online agent and this agent's department.
- <%@ Page Language="C#" %>
-
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
- <script runat="server">
- protected override void OnLoad(EventArgs e)
- {
- CuteChat.ChatPortal portal = CuteChat.ChatSystem.Instance.GetCurrentPortal();
- lock (portal)
- {
- if (portal.IsPlaceStarted("SupportAgent"))
- {
- CuteChat.SupportAgentChannel sac = (CuteChat.SupportAgentChannel)portal.GetPlace("SupportAgent");
- foreach (CuteChat.ChatPlaceUser user in sac.GetAllUsers())
- {
- if (user != null)
- {
- label1.Text += "user name: ";
- label1.Text += user.DisplayName;
- label1.Text += "<br/>";
- label1.Text += "department: ";
- CuteChat.SupportDepartment[] supportDepartments = CuteChat.ChatSystem.Instance.GetCurrentPortal().DataManager.GetDepartments();
- for (int i = 0; i < supportDepartments.Length; i++)
- {
- for (int j = 0; j < supportDepartments[i].Agents.Length; j++)
- {
- if (user.Identity.UniqueId == supportDepartments[i].Agents[j].UserId)
- {
- label1.Text += supportDepartments[i].Name;
- label1.Text += ",";
- }
- }
-
- }
-
- }
- }
-
- }
- }
- base.OnLoad(e);
- }
- </script>
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>Untitled Page</title>
- </head>
- <body>
- <form id="form1" runat="server">
- <asp:Label ID="label1" runat="server"></asp:Label>
- </form>
- </body>
- </html>
Regards,
Ken