Ejemplo n.º 1
0
        public static long SendSms(string pMessage, string pPhone)
        {
            var loSmsModel = new SmsModel
            {
                Message  = pMessage,
                Phones   = pPhone,
                Provider = 2, //Tescom
                Username = Common.SmsUsername,
                Password = Common.SmsPassword,
                Header   = Common.SmsHeader
            };

            var client  = new RestClient(Common.InfoUrl + "Information/SendSms");
            var request = new RestRequest(Method.POST);
            var loToken = GetToken("mesnetapi", "5158898A39CC7B544969DBF80261A0AF", Common.InfoUrl + "GetToken");

            request.AddHeader("Authorization", "Bearer " + loToken);
            request.AddHeader("Content-Type", "application/json");
            request.RequestFormat = DataFormat.Json;

            var loModel = JsonConvert.SerializeObject(loSmsModel);

            request.AddJsonBody(loModel);
            //var responseData = client.Execute(request).Content;
            var result          = client.Execute(request);
            var loGenericResult = JsonConvert.DeserializeObject <GenericResponseModel>(result.Content);

            if (loGenericResult != null && loGenericResult.Code == 200 && loGenericResult.Status == "Ok")
            {
                return((long)loGenericResult.Data);
            }

            return(0);
        }
        public CMSResult SendSMS(IEnumerable <SendAttendanceClass> resultGroup)
        {
            var cmsResult = new CMSResult();

            var i = 0;

            SmsModel[] smsModelsMessage = new SmsModel[resultGroup.Count()];
            foreach (var sms in resultGroup)
            {
                List <string> contactList = new List <string>();
                contactList.Add(sms.StudentContact);
                //contactList.Add(sms.ParentContact);
                var listOfContact = string.Join(",", contactList);
                var smsModel      = new SmsModel
                {
                    Message = sms.Message,
                    SendTo  = listOfContact
                };
                smsModelsMessage[i] = smsModel;
                i++;
            }
            HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => _smsService.StartProcessing(smsModelsMessage, cancellationToken));

            cmsResult.Results.Add(new Result {
                Message = "SMS Send Successfully", IsSuccessful = true
            });
            return(cmsResult);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutSmsModel([FromRoute] int id, [FromBody] SmsModel smsModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != smsModel.country_id)
            {
                return(BadRequest());
            }

            _context.Entry(smsModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SmsModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public static SmsModel InitializeModel(ActionExecutingContext filterContext)
        {
            var model = new SmsModel();

            model.CallSid = filterContext.HttpContext.Request.Params["CallSid"];
            model.To = filterContext.HttpContext.Request.Params["To"];
            model.From = filterContext.HttpContext.Request.Params["From"];
            model.AccountSid = filterContext.HttpContext.Request.Params["AccountSid"];
            model.CallStatus = filterContext.HttpContext.Request.Params["CallStatus"];
            model.FromCity = filterContext.HttpContext.Request.Params["FromCity"];
            model.FromState = filterContext.HttpContext.Request.Params["FromState"];
            model.FromZip = filterContext.HttpContext.Request.Params["FromZip"];
            model.FromCountry = filterContext.HttpContext.Request.Params["FromCountry"];
            model.ToCity = filterContext.HttpContext.Request.Params["ToCity"];
            model.ToState = filterContext.HttpContext.Request.Params["ToState"];
            model.ToZip = filterContext.HttpContext.Request.Params["ToZip"];
            model.ToCountry = filterContext.HttpContext.Request.Params["ToCountry"];
            model.Digits = filterContext.HttpContext.Request.Params["Digits"];
            model.SmsSid = filterContext.HttpContext.Request.Params["SmsSid"];
            model.Body = filterContext.HttpContext.Request.Params["Body"];
            //model.DateCreated = DateTime.Parse(filterContext.HttpContext.Request.Params["DateCreated"]);
            model.DateSent = DateTime.Now.ToUniversalTime();
            DateTime tmpDate = model.DateSent;
            if (DateTime.TryParse(filterContext.HttpContext.Request.Params["DateSent"], out tmpDate))
            {
                model.DateSent = new DateTime(2010, 11, 10, 0, 0, 0);// tmpDate;
            };

            return model;
        }
Ejemplo n.º 5
0
        public async Task <int> SendSmsMessage(SmsModel smsModel)
        {
            var messageStatus = 0;

            try
            {
                ASPSMS.SMS tASPSMS = new ASPSMS.SMS();
                tASPSMS.AddRecipient(smsModel.sender);
                tASPSMS.Originator  = smsModel.message;
                tASPSMS.MessageData = smsModel.number.ToString();

                await tASPSMS.SendTextSMS();

                if (tASPSMS.ErrorCode == 1)
                {
                    messageStatus = (int)MessageStatus.Success;
                }
                else
                {
                    messageStatus = (int)MessageStatus.Failed;
                    //ViewBag.Status = "Error: " + tASPSMS.ErrorCode + " " + tASPSMS.ErrorCodeDescription;
                }
            }
            catch (Exception ex)
            {
                // ViewBag.Status = "Error: " + ex.Message;
            }

            return(messageStatus);
        }
Ejemplo n.º 6
0
        public IActionResult AddSmsToQueue(SmsModel smsModel)
        {
            var sms = new SMS(smsModel.Id, smsModel.RecipientNumbers, smsModel.MessageText);

            _messageService.AddSmsToQueue(sms);
            return(Ok());
        }
Ejemplo n.º 7
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <object> CreateAsync(this ISMSAPIClient operations, SmsModel model, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(model, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            
            smsModel = SmsTwilioModel.InitializeModel(filterContext);

            base.OnActionExecuting(filterContext);
        }
Ejemplo n.º 9
0
        public string SendSms(SmsModel model)
        {
            var bulkSmsModel = GetSmsConfig();
            var request      = SetUpWebRequest(bulkSmsModel);

            RemoveLeadingZero(model);

            var myData = JsonConvert.SerializeObject(new
            {
                to   = model.SentTo,
                body = model.Body
            });

            var encoding    = new ASCIIEncoding();
            var encodedData = encoding.GetBytes(myData);

            var stream = request.GetRequestStream();

            stream.Write(encodedData, 0, encodedData.Length);
            stream.Close();
            try
            {
                request.GetResponse();
                return("sms sent successfully");
            }
            catch (WebException e)
            {
                Console.WriteLine("An error was found: " + e.Message);
                throw;
            }
        }
Ejemplo n.º 10
0
        public IActionResult SMSUpdate(SmsModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var message = _messageTemplateService.GetMessageTemplateById(model.MessageId);

            if (message != null)
            {
                _genericAttributeService.SaveAttribute(message, SendinBlueDefaults.UseSmsAttribute, true);
                _genericAttributeService.SaveAttribute(message, SendinBlueDefaults.SmsTextAttribute, model.Text);
                _genericAttributeService.SaveAttribute(message, SendinBlueDefaults.PhoneTypeAttribute, model.PhoneTypeId);
            }

            if (model.Id != model.MessageId)
            {
                SMSDelete(new SmsModel {
                    MessageId = model.Id
                });
            }

            return(new NullJsonResult());
        }
Ejemplo n.º 11
0
        // Added by Bharat on 09 June 2017
        public JsonResult GetUser(int BPartner_ID)
        {
            Ctx      ct    = Session["ctx"] as Ctx;
            SmsModel model = new SmsModel(ct);

            return(Json(JsonConvert.SerializeObject(model.GetUser(BPartner_ID)), JsonRequestBehavior.AllowGet));
        }
        public ResponseItem SmsQueue(SmsModel model)
        {
            ResponseItem result = new ResponseItem();

            result.Result = true;

            try
            {
                iqManager.SmsSend(model);
                result.Message = "Success";

                AppModel modelMongo = new AppModel
                {
                    Name        = model.Message,
                    Description = "SmsQueue",
                    Date        = DateTime.Now
                };
                _mongo.Create(modelMongo);
            }
            catch (Exception ex)
            {
                result.Result  = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 发送业务消息
        /// </summary>
        /// <param name="token"></param>
        /// <param name="mobile"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static SmsResult HDPostSmS(string token, string mobile, string msg)
        {
            SmsResult result = new SmsResult();

            try
            {
                SmsModel model = new SmsModel()
                {
                    extNo     = "888",
                    mobile    = mobile,
                    token     = token,
                    productId = "2",
                    msg       = msg,
                    time      = ""
                };
                string    postString = JsonConvert.SerializeObject(model);
                byte[]    postData   = Encoding.UTF8.GetBytes(postString);              //编码
                string    url        = "http://openapi.gateway.paasw.com/message/send"; //地址
                WebClient webClient  = new WebClient();
                webClient.Headers.Add("Content-Type", "application/json");
                byte[] responseData = webClient.UploadData(url, "POST", postData);
                result = JsonConvert.DeserializeObject <SmsResult>(Encoding.UTF8.GetString(responseData));//解码
            }
            catch { }
            return(result);
        }
Ejemplo n.º 14
0
        ///<summary>
        ///短信保存并发送
        ///</summary>
        ///<paramname="keyValue">主键值</param>
        ///<paramname="entity">实体对象</param>
        ///<returns></returns>
        public void SaveBySend(string MobileNumber, string MsgContent, string MsgValue)
        {
            try
            {
                SmsLogEntity entity = new SmsLogEntity();
                entity.MobileNumber = MobileNumber;
                entity.MsgContent   = MsgContent;
                entity.MsgValue     = MsgValue;

                SmsModel smsModel = new SmsModel();
                smsModel.account = Config.GetValue("SMSAccount");
                smsModel.pswd    = Config.GetValue("SMSPswd");
                smsModel.url     = Config.GetValue("SMSUrl");
                smsModel.mobile  = entity.MobileNumber;
                smsModel.msg     = Config.GetValue("SMSPrefix") + entity.MsgContent;
                var result = SmsHelper.SendSmsByYM(smsModel);
                entity.SendResultCode = result.code;
                entity.SendResultMsg  = result.msg;
                entity.IsDeleted      = false;
                entity.SendTime       = DateTime.Now;
                service.SaveForm(string.Empty, entity);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 15
0
        public ActionResult Receive()
        {
            SmsModel model = new SmsModel()
            {
                content = Request["content"],
                from    = long.Parse(Request["from"]),
                to      = long.Parse(Request["to"])
            };
            var command = model.content.ToLower().Trim();
            var text    = "";

            switch (command)
            {
            case "next":
                text = bookService.GetNext(model.from.ToString());
                smsService.Send(model.from.ToString(), text);
                return(Json(new object()));

            case "previous":
                text = bookService.GetPrevious(model.from.ToString());
                smsService.Send(model.from.ToString(), text);
                return(Json(new object()));

            default:
                throw new Exception("Invalid message.");
            }
        }
Ejemplo n.º 16
0
 static public void SendShortCode(SmsModel model)
 {
     using (SMSAPIClient client = GetSMSAPIClient())
     {
         client.Create(new SMSAPI.Models.SmsModel(Settings.SMS_API_SENDER, "+" + model.to, model.body));
     };
 }
Ejemplo n.º 17
0
        void New(SmsModel sms = null)
        {
            var schedule = DateTime.Now.AddMinutes(15);

            ErrorMessage = null;
            if (sms == null)
            {
                Sms = new SmsModel
                {
                    RepeatDaily = true,
                    Hour        = schedule.Hour,
                    Minute      = schedule.Minute,
                };

                //BindingOperations.EnableCollectionSynchronization(Sms.MobileNumbers, _lock);
            }
            else
            {
                if (sms.Id != 0)
                {
                    sms.Id += 1;
                }
                sms.RepeatDaily   = true;
                sms.Hour          = schedule.Hour;
                sms.Minute        = schedule.Minute;
                sms.MobileNumbers = new ExtendedObservableCollection <string>();
            }
        }
Ejemplo n.º 18
0
        public static SmsModel InitializeModel(ActionExecutingContext filterContext)
        {
            var model = new SmsModel();

            model.CallSid     = filterContext.HttpContext.Request.Params["CallSid"];
            model.To          = filterContext.HttpContext.Request.Params["To"];
            model.From        = filterContext.HttpContext.Request.Params["From"];
            model.AccountSid  = filterContext.HttpContext.Request.Params["AccountSid"];
            model.CallStatus  = filterContext.HttpContext.Request.Params["CallStatus"];
            model.FromCity    = filterContext.HttpContext.Request.Params["FromCity"];
            model.FromState   = filterContext.HttpContext.Request.Params["FromState"];
            model.FromZip     = filterContext.HttpContext.Request.Params["FromZip"];
            model.FromCountry = filterContext.HttpContext.Request.Params["FromCountry"];
            model.ToCity      = filterContext.HttpContext.Request.Params["ToCity"];
            model.ToState     = filterContext.HttpContext.Request.Params["ToState"];
            model.ToZip       = filterContext.HttpContext.Request.Params["ToZip"];
            model.ToCountry   = filterContext.HttpContext.Request.Params["ToCountry"];
            model.Digits      = filterContext.HttpContext.Request.Params["Digits"];
            model.SmsSid      = filterContext.HttpContext.Request.Params["SmsSid"];
            model.Body        = filterContext.HttpContext.Request.Params["Body"];
            //model.DateCreated = DateTime.Parse(filterContext.HttpContext.Request.Params["DateCreated"]);
            model.DateSent = DateTime.Now.ToUniversalTime();
            DateTime tmpDate = model.DateSent;

            if (DateTime.TryParse(filterContext.HttpContext.Request.Params["DateSent"], out tmpDate))
            {
                model.DateSent = new DateTime(2010, 11, 10, 0, 0, 0);// tmpDate;
            }
            ;

            return(model);
        }
Ejemplo n.º 19
0
 public async Task <IActionResult> Post([FromBody] SmsModel model)
 {
     try
     {
         var userId = User.Identity.Name;
         if (userId != null)
         {
             model.CreateUserId = Guid.Parse(userId);
             model.CreateDate   = DateTime.Now;
             model.ModifyUserId = Guid.Parse(userId);
             model.ModifyDate   = DateTime.Now;
             var message = _smsService.SendSms(model);
             if (message == null)
             {
                 return(BadRequest("Sending message resulted in an error, please contact system administrator!"));
             }
             return(Ok(message));
         }
         return(BadRequest("An error has occurred, please contact system administrator!"));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Ejemplo n.º 20
0
        public IActionResult GetInfoEmployee(string ficha)
        {
            //DatosAreaEmpleadoModelo resp = null;
            string token = "";

            try
            {
                SmsModel sms = new SmsModel()
                {
                    To  = "938104x748",
                    Msg = "Prueba"
                };
                return(Json(SMSService.Send(sms)));

                //return Json(IDMService.ResetPasswordAD("edalonzoh", "test"));

                //MailNotificationModel n = new MailNotificationModel();
                //n.to = "*****@*****.**";
                //n.body = "test";
                //n.subject = "subject";
                //MailService.Send(n);
                //return Json(HubApiService.GetDataEmployee(ficha));
                //resp = IDMService.GetDataEmployeeArea(ficha);
            }
            catch (Exception ex)
            {
                //Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }

            return(null);
            //return Json(resp);
        }
Ejemplo n.º 21
0
        public Result <dynamic> Send(string mobile, byte smsType)
        {
            int smsCode = GenerateSMSCode();
            var entity  = new SmsModel()
            {
                MobilePhone = mobile,
                SmsType     = smsType,
                SmsCode     = smsCode,
                SmsStatus   = 0,
                ExpireTime  = DateTime.Now.AddMinutes(10),
                CreateTime  = DateTime.Now
            };

            if (SmsRepository.Add(entity))
            {
                var account_id    = ConfigurationManager.AppSettings["SMS_Account_Sid"];
                var account_token = ConfigurationManager.AppSettings["SMS_Account_Token"];
                var app_Id        = ConfigurationManager.AppSettings["SMS_App_Id"];

                string result = string.Empty;

                CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK();
                bool init = api.init("sandboxapp.cloopen.com", "8883");
                api.setAccount(account_id, account_token);
                api.setAppId(app_Id);
                try
                {
                    if (init)
                    {
                        string[] param = { smsCode.ToString(), "10分钟" };
                        Dictionary <string, object> retApiData = api.SendTemplateSMS(mobile, "125246", param);
                        result = GetDictionaryData(retApiData);
                    }
                    else
                    {
                        return(new Result <dynamic>()
                        {
                            Code = ResultCode.Error,
                            Message = "初始化失败"
                        });
                    }
                }
                catch { }
                if (result.ToLower().Contains("statuscode=000000;statusmsg=成功"))
                {
                    /* 调用短信接口发送短信验证码 */
                    return(new Result <dynamic>()
                    {
                        Code = ResultCode.Success,
                        Message = "验证码发送成功"
                    });
                }
            }
            return(new Result <dynamic>()
            {
                Code = ResultCode.Error,
                Message = "验证码发送失败"
            });
        }
        public IActionResult SendAndStoreSMS([FromBody] SmsModel smsModel)
        {
            // TODO: return response from function
            notificationService.SendAndStoreSMS(smsModel);

            // TODO: return status codes based on response above i.e. 200, 400, etc.
            return(Ok());
        }
Ejemplo n.º 23
0
        public string SmsSend(SmsModel smsModel)
        {
            string responseResult = "";
            string phones         = GetPhone(smsModel);


            return(responseResult);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 更新状态回执
        /// </summary>
        /// <param name="msgid">msgid</param>
        /// <param name="reportstatus">状态</param>
        /// <returns></returns>
        private void UpdateReportState(string msgid, string srcnumber, string reportstatus)
        {
            string status = reportstatus;

            if (reportstatus.Equals("DELIVRD"))
            {
                status = "1";
            }
            else
            {
                status = "-1";
            }
            SmsModel sm = this.GetFormCache(msgid);

            string sql = string.Format("update t_smsmobile_t set ReportStatus='{0}' ,ErrorCode='{1}',SrcNo='{2}' where  MsgId='{3}' ", status, reportstatus, srcnumber, msgid);

            if (sm != null)
            {
                sql = string.Format("update t_smsmobile_t set ReportStatus='{0}' ,ErrorCode='{1}',SrcNo='{2}' where  Id='{3}' ", status, reportstatus, srcnumber, sm.id);
            }
            Random            rand = new Random();
            int               i    = rand.Next(0, _reportQueueNum + 1);
            SqlStatementModel sqlm = new SqlStatementModel();

            sqlm.MySqlCmdParms = null;
            sqlm.CmdTxt        = sql;
            sqlm.CmdType       = CommandType.Text;
            sqlm.ExecTimer     = 1;
            ReportQueue[i].AddSql(sqlm);

            string sqlstate = "";

            if (sm != null)
            {
                object[] obj = { sm.eprId, sm.userId, sm.mobile, sm.clientMsgId, status };
                sqlstate = string.Format("insert into t_pushsmsmsg(EprId,UserId,Mobile,ClientMsgId,Status,AddTime) values('{0}','{1}','{2}','{3}','{4}',now())", obj);
            }
            else
            {
                string    sel = string.Format("select * from t_smsmobile_t where MsgId='{0}'", msgid);
                DataTable dt  = MySqlDBExec.GetDateTable(sel, null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    object[] obj = { dt.Rows[0]["EprId"], dt.Rows[0]["UserId"], dt.Rows[0]["Mobile"], dt.Rows[0]["ClientMsgId"], status };
                    sqlstate = string.Format("insert into t_pushsmsmsg(EprId,UserId,Mobile,ClientMsgId,Status,AddTime) values('{0}','{1}','{2}','{3}','{4}',now())", obj);
                }
            }
            if (!string.IsNullOrEmpty(sqlstate))
            {
                SqlStatementModel seq = new SqlStatementModel();
                seq.MySqlCmdParms = null;
                seq.CmdTxt        = sqlstate;
                seq.CmdType       = CommandType.Text;
                seq.ExecTimer     = 1;
                ReportSeqQueue[i].AddSql(seq);
            }
        }
Ejemplo n.º 25
0
        private static void RemoveLeadingZero(SmsModel model)
        {
// check if 0 in number
            if (model.SentTo.Substring(0, 1) == "0")
            {
                var tempNumber = model.SentTo.Remove(0, 1);
                model.SentTo = "+27" + tempNumber;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="_"></param>
        /// <returns></returns>
        public string ModifyPassword(dynamic _)
        {
            //接收request数据
            var recdata = this.GetResquetData <LoginInModel>();

            //   WriteInfoLog("LoginModule", recdata.data.MobileCode, recdata.DeviceId, "测试::" + Json.ToJson(recdata));
            try
            {
                #region "接口调用验证"
                //bool flag = DataValidation(recdata.DateTime, recdata.Random, recdata.Sign);

                //if (!flag)
                //{
                //    return this.WriteValidationLog("LoginModule", recdata.DeviceId);
                //}
                #endregion

                //获取快捷登陆验证码是否正确
                CommonBusiness comBll = new CommonBusiness();
                SmsModel       smInfo = comBll.GetLastVerifiCode(recdata.data.MobileCode, "1002");
                if (smInfo == null)
                {
                    return(SendData("验证码不存在", ResponseType.Fail));
                }
                else if (smInfo.IsUser == 1)
                {
                    return(SendData("验证码已使用", ResponseType.Fail));
                }
                else if (smInfo.VerificationCode != recdata.data.VerificationCode)
                {
                    return(SendData("验证码不正确", ResponseType.Fail));
                }
                else
                {
                    int i = comBll.UpdateSmsUsingById(smInfo.Id);
                    if (i != 1)
                    {
                        return(SendData("验证码状态修改失败!", ResponseType.Fail));
                    }
                    LoginBusiness bl      = new LoginBusiness();
                    int           iUpdate = bl.ModifyPassword(recdata.data.MobileCode, recdata.data.Password);
                    if (iUpdate == 1)
                    {
                        WriteInfoLog("LoginModule", recdata.data.MobileCode, recdata.DeviceId, "密码修改成功!");
                        return(SendData("密码修改成功!", ResponseType.Success));
                    }
                    else
                    {
                        return(SendData("密码修改失败!", ResponseType.Fail));
                    }
                }
            }
            catch (Exception ex)
            {
                return(this.WriteExceptionLog("LoginModule", recdata.data.MobileCode, recdata.DeviceId, "密码修改异常:" + Json.ToJson(recdata) + "[异常信息:" + ex.Message + "]", "密码修改异常:" + ex.Message));
            }
        }
Ejemplo n.º 27
0
        public JsonResult SendSms(string sms, string format)
        {
            Ctx ctx = Session["ctx"] as Ctx;
            List <SmsHelper> smss   = JsonConvert.DeserializeObject <List <SmsHelper> >(sms);
            SmsModel         model  = new SmsModel(ctx);
            SmsResponse      result = model.Send(smss, format);

            return(Json(JsonConvert.SerializeObject(result), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 28
0
 public SmsService GetToBeSend()
 {
     Sms = _mongoProxy.GetAndUpdate <SmsModel>(
         a => a.Status == SmsEnums.SmsStatus.待处理 && a.TimeSendDateTime <= DateTime.Now,
         a => new SmsModel {
         Status = SmsEnums.SmsStatus.处理中
     });
     return(this);
 }
Ejemplo n.º 29
0
        void Refresh()
        {
            ErrorMessage = null;

            Gateways  = Shared.Instance.Database.GetCollection <SmsGatewayBase>().FindAll();
            Contacts  = new ContactModel().Get() as IEnumerable <ContactModel>;
            Templates = new TemplateModel().Get() as IEnumerable <TemplateModel>;
            Messages  = new SmsModel().Get() as IEnumerable <SmsModel>;
        }
        public async Task <IActionResult> GetSMSBody(SmsModel model)
        {
            string userId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            model.UserId = userId;
            return(Ok(new JObject
            {
                ["body"] = await _manager.GetSMSBody(model)
            }.ToString()));
        }
Ejemplo n.º 31
0
        public async Task <bool> SendSms(SmsModel model)
        {
            List <bool> tasks = new List <bool>();

            foreach (var item in model.ListOfNumbers)
            {
                await _proxy.SendSMS(item.Key, item.Value);
            }
            return(tasks.Any(x => x == false));
        }
Ejemplo n.º 32
0
        private static void OnNewSmsFileCreated(object sender, FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Created)
            {
                var sms = new SmsModel(e.FullPath);

                var context = GlobalHost.ConnectionManager.GetHubContext <SignalRHub>();
                context.Clients.All.newMessage(sms);
            }
        }
 public static List<SmsModel> getDummySmsList()
 {
     List<SmsModel> smsList = new List<SmsModel>();
     Random rand = new Random();
     for (int i = 0; i < 25; i++)
     {
         SmsModel smsModel = new SmsModel();
         smsModel.Name = "Celet " + rand.Next(100).ToString();
         smsModel.Description = "Wireless Router";
         smsModel.Group = "Celot";
         smsModel.Number = rand.Next(2000);
         smsModel.RouterIp = String.Format("{0}.{1}.{2}.{3}", rand.Next(255).ToString(), rand.Next(255).ToString(), rand.Next(255).ToString(), rand.Next(255).ToString());
         smsModel.Receive = rand.Next(100);
         smsModel.Send = rand.Next(100);
         smsList.Add(smsModel);
     }
     return smsList;
 }
Ejemplo n.º 34
0
 public void SendSms(SendSmsCommand command)
 {
     EnsureIsValid(command);
     try
     {
         if (_settings.UseLogger)
         {
             var smsModel = new SmsModel
             {
                 From = _settings.OutboundPhoneNumber,
                 Text = command.Text,
                 To = command.RecipientPhoneNumber
             };
             _deps.SmsLogger.Log(smsModel);
         }
         var client = _deps.TwilioClientFactory.Create();
         client.SendSmsMessage(_settings.OutboundPhoneNumber, command.RecipientPhoneNumber, command.Text);
     }
     catch (Exception ex)
     {
         throw new ServiceException("Can't send sms.", ex);
     }
 }
Ejemplo n.º 35
0
 public void Log(SmsModel sms)
 {
     _logger.Info("Going to send following sms message: {0}", sms);
     if (_settings.EmailAddresses.Count == 0)
     {
         _logger.Warn("No email addresses are configured for email logger.");
         return;
     }
     var emailBuilder = new StringBuilder();
     emailBuilder.AppendFormat("From: {0}", sms.From).AppendLine()
                 .AppendFormat("To:   {0}", sms.To).AppendLine()
                 .AppendFormat("Text: {0}", sms.Text).AppendLine();
     var email = new SendEmailCommand
     {
         From = new MailAddress("*****@*****.**", "SMS Logger"),
         Subject = string.Format("New SMS for {0}", sms.To),
         Text = emailBuilder.ToString()
     };
     foreach (var emailAddress in _settings.EmailAddresses)
     {
         email.To.Add(emailAddress);
     }
     _emailService.SendEmail(email);
 }