Esempio n. 1
0
 /// <summary>
 /// 按用户群发消息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSendToUsers_Click(object sender, EventArgs e)
 {
     if (cblUser.SelectedIndex >= 0)
     {
         string        userName = lbPublicAccount.SelectedValue;
         ErrorMessage  errorMessage;
         List <string> openIds = new List <string>();
         foreach (ListItem item in cblUser.Items)
         {
             if (item.Selected)
             {
                 openIds.Add(item.Value);
             }
         }
         string content = txtContent.Text;
         long   msgId   = MassMessage.Send(userName, openIds, MassMessageTypeEnum.text, content, out errorMessage);
         if (errorMessage.IsSuccess)
         {
             ltrMessage.Text = "群发消息成功。";
             rblMassMessage.Items.Add(new ListItem(string.Format("id:{0},text:{1}", msgId, content), msgId.ToString()));
         }
         else
         {
             ltrMessage.Text = string.Format("群发消息失败。{0}", errorMessage);
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 按分组群发消息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSendToGroup_Click(object sender, EventArgs e)
 {
     if (rblGroup.SelectedIndex >= 0)
     {
         string       userName = lbPublicAccount.SelectedValue;
         ErrorMessage errorMessage;
         bool         isToAll = string.IsNullOrWhiteSpace(rblGroup.SelectedValue);
         string       groupId = isToAll ? "" : rblGroup.SelectedValue;
         string       content = txtContent.Text;
         long         msgId   = MassMessage.Send(userName, isToAll, groupId, MassMessageTypeEnum.text, content, out errorMessage);
         if (errorMessage.IsSuccess)
         {
             ltrMessage.Text = "群发消息成功。";
             rblMassMessage.Items.Add(new ListItem(string.Format("id:{0},text:{1}", msgId, content), msgId.ToString()));
         }
         else
         {
             ltrMessage.Text = string.Format("群发消息失败。{0}", errorMessage);
         }
     }
 }