/// <summary>
        /// Get list of online users and set datasource to gridview.
        /// </summary>
        private void BindOnlineUsers()
        {
            try
            {
                LyncHelper      lyncHelper = new LyncHelper();
                List <O365User> userList   = lyncHelper.GetListOfOnlineUsers(contactMgr);

                if (UserList.InvokeRequired)
                {
                    BindOnlineUsersDelegate invoke = new BindOnlineUsersDelegate(BindOnlineUsers);
                    this.Invoke(invoke);
                }
                else
                {
                    UserList.DataSource = userList;
                    UserList.ClearSelection();

                    foreach (DataGridViewRow row in this.UserList.Rows)
                    {
                        row.Height = 40;
                        DataGridViewCell cell = UserList.Rows[row.Index].Cells[UserList.Columns["colColorStatus"].Index];

                        if (UserList.Rows[row.Index].Cells[UserList.Columns["colStatus"].Index].Value.ToString().Trim() == "Available")
                        {
                            cell.Style.BackColor = Color.LimeGreen;
                        }
                        else if (UserList.Rows[row.Index].Cells[UserList.Columns["colStatus"].Index].Value.ToString().Trim() == "Busy")
                        {
                            cell.Style.BackColor = Color.Red;
                        }
                        else if (UserList.Rows[row.Index].Cells[UserList.Columns["colStatus"].Index].Value.ToString().Trim() == "Do not disturb")
                        {
                            cell.Style.BackColor = Color.DarkRed;
                        }
                        else if (UserList.Rows[row.Index].Cells[UserList.Columns["colStatus"].Index].Value.ToString().Trim() == "Be right back" ||
                                 UserList.Rows[row.Index].Cells[UserList.Columns["colStatus"].Index].Value.ToString().Trim() == "Off work" ||
                                 UserList.Rows[row.Index].Cells[UserList.Columns["colStatus"].Index].Value.ToString().Trim() == "Away")
                        {
                            cell.Style.BackColor = Color.Yellow;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception on binding to on-line users " + ex.Message);
            }
        }
Ejemplo n.º 2
0
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        Guid?         toUserId = null;
        StringBuilder sb       = new StringBuilder();

        foreach (ListItem item in UserList.Items)
        {
            if (item.Selected)
            {
                if (!toUserId.HasValue)
                {
                    toUserId = new Guid(item.Value);
                }
                else
                {
                    sb.AppendFormat(", {0}", item.Text);
                }
            }
        }

        UserList.ClearSelection();

        if (sb.Length > 0)
        {
            sb.Remove(0, 2);
            sb.Insert(0, "This message additionally were sent to:<br />");
            if (!string.IsNullOrEmpty(MessageTextBox.Text))
            {
                sb.Insert(0, "<br /><br />--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br />");
            }
        }
        sb.Insert(0, MessageTextBox.Text);

        MessageProvider.InsertMessage(MessageList1.ParentMessageId, MessageList1.LocalObjectType, MessageList1.LocalObjectId, UserContext.Current.UserId, toUserId, "Tkt Response", sb.ToString());

        MessageList1.DataBind();

        MessageTextBox.Text = string.Empty;
    }