Exemplo n.º 1
0
        private static void SendUserMessage(DataRow dr, string strMsg)
        {
            Action send = (() =>
            {
                //根据设备 编号取得对应小区的发送人
                //string strPhone = "13476116775";
                DevInfoBLL devinfo = new DevInfoBLL();
                DataTable userDt = devinfo.GetUserByDev(dr["devID"].ToString());

                if (userDt != null && userDt.Rows.Count > 0)
                {
                    string strPhones = string.Empty;
                    foreach (DataRow userDr in userDt.Rows)
                    {
                        strPhones += userDr["mobile"].ToString() + ",";
                    }
                    strPhones = strPhones.TrimEnd(',');
                    Dictionary <string, object> resultDic = YunRongSDK.SendBatchSMS(strPhones, strMsg);
                    SendMessageBLL msg = new SendMessageBLL();
                    SendMessageModel model = new SendMessageModel();
                    model.devID = Convert.ToInt32(dr["devID"].ToString());
                    model.alarmCode = dr["alarmCode"].ToString();
                    model.alarmState = Convert.ToInt32(dr["alarmState"]);
                    model.content = strMsg;
                    model.mobile = strPhones;
                    if (resultDic != null && resultDic["statusCode"].ToString() == "0")
                    {
                        model.sendResult = "发送成功";
                    }
                    else
                    {
                        model.sendResult = resultDic["statusMsg"].ToString();
                    }
                    model.createTime = DateTime.Now;
                    msg.Add(model);
                }
            });

            Task.Factory.StartNew(send);
        }