Beispiel #1
0
        public static void SendSms(object sender, ApproveEventArgs args)
        {
            ISMS    sms    = ctx["SMS"] as ISMS;
            IWorker worker = ctx["Worker"] as IWorker;

            //string title = string.Format("{0}(表单号:{1})被否决", args.FlowName, args.FlowNo);

            string content = string.Format("您于{0}申请的{1}(表单号:{2})已经被否决。",
                                           args.BeginDate.ToString("yyyy/MM/dd HH:mm"),
                                           args.FlowName,
                                           args.FlowNo);

            B_WORKER w = worker.GetWorkerById(args.ApplyerId);

            if (w != null && !string.IsNullOrEmpty(w.Mobile))
            {
                sms.SendSMG(new List <string> {
                    w.Mobile
                }, content, "99999");

                //if (!innerCommBLL.SendSMG(new List<string> { w.Mobile }, content, "99999"))
                //{
                //    throw new Exception(string.Format("短信发送失败,flowId{0},flowNo{1},AppValue{2}", args.FlowId, args.FlowNo, args.AppValue));
                //}
            }
        }
 /// <summary>
 /// 统一提交
 /// </summary>
 /// <param name="message">请求对象</param>
 /// <param name="sendType">请求类型,1:单发,2:相同内容群发,3:不同类型群发,4:获取上行,5:获取状态报告,6:获取账号余额</param>
 /// <returns></returns>
 private string submit(MWMessage message, int sendtype)
 {
     try
     {
         ISMS sms = null;
         if (messageType == 0)
         {
             sms = new UrlEncdoeSend();
         }
         else if (messageType == 1)
         {
             sms = new JsonSend();
         }
         else if (messageType == 2)
         {
             //sms = new XMLSend();
         }
         account.Ip            = "114.67.62.211";
         account.Port          = 7901;
         account.MasterIPState = 0;
         String ipport = getIpPortByAccount(account);
         if (string.IsNullOrEmpty(ipport))
         {
             return("没有可用的IP端口");
         }
         return(sms.execute(message, sendtype, ipport, authenticationMode, this.isKeepAlive));
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Sends an SMS Message to the given destination
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='subscriptionId'>
 /// </param>
 /// <param name='source'>
 /// </param>
 /// <param name='destination'>
 /// </param>
 /// <param name='message'>
 /// </param>
 /// <param name='webhook'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SMSResponseModel> SendSmsAsync(this ISMS operations, string subscriptionId, string source, string destination, string message, string webhook = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.SendSmsWithHttpMessagesAsync(subscriptionId, source, destination, message, webhook, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #4
0
        protected void btnSend_Click(object sender, System.EventArgs e)
        {
            string @string = WebUtils.GetString(this.TextBox5.Text);
            ISMS   iSMS    = SMSProvider.Create(PageBase.config.SMSClass);

            if (iSMS == null)
            {
                base.ShowMsg("短信接口配置不正确");
            }
            else if (!ValidateUtils.IsMobilePhone(@string))
            {
                base.ShowMsg("无效的手机号码");
            }
            else
            {
                string value = iSMS.SendMsg(@string, "这是一条测试短信,如果您收到此短信,表示短信服务有效![" + PageBase.config.SiteName + "]");
                if (iSMS.IsSuccess)
                {
                    base.ShowMsg("测试短信发送成功");
                }
                else
                {
                    base.ShowMsg(WebUtils.GetString(value));
                }
            }
        }
Beispiel #5
0
 public static async Task <IList <SMSQueueItem> > GetSmsQueueAsync(this ISMS operations, string numberId, string subscriptionId, string id, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetSmsQueueWithHttpMessagesAsync(numberId, subscriptionId, id, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #6
0
        public static int SendSMS(string strToMobile, string strType, string strContent, string strValidateCode, ref string retResult)
        {
            int  result = 0;
            ISMS iSMS   = SMSProvider.Create();

            if (iSMS != null)
            {
                iSMS.Mobile     = strToMobile;
                iSMS.SMSContent = strContent;
                retResult       = iSMS.SendMsg();
                if (iSMS.IsSuccess)
                {
                    SMSInfo entity = new SMSInfo
                    {
                        SMSMob        = iSMS.Mobile,
                        SMSText       = iSMS.SMSContent,
                        SMSType       = strType,
                        ValidateCode  = strValidateCode,
                        ReturnMsg     = retResult,
                        Status        = 1,
                        AutoTimeStamp = DateTime.Now
                    };
                    result = BLL.SMS.Add(entity);
                }
            }
            return(result);
        }
Beispiel #7
0
        private string SendSMSToMutiUser(string strCont, string strCondition)
        {
            ISMS   iSMS  = SMSProvider.Create();
            string text  = string.Empty;
            string text2 = " SELECT AutoID,UserName,Email,Mobile FROM cms_User WHERE Mobile<>'' ";

            if (!strCondition.IsNullOrEmpty())
            {
                text2 = text2 + " AND " + strCondition;
            }
            DataTable dataTable = PageBase.dbo.GetDataTable(text2);

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    string text3 = dataRow["Mobile"].ToString();
                    if (!string.IsNullOrEmpty(text3) && text3.Length.Equals(11))
                    {
                        if (MsgService.SendSMS(text3, strCont) == 0)
                        {
                            text = text + "发送" + text3 + "短信失败;";
                        }
                    }
                }
            }
            return(text);
        }
Beispiel #8
0
        public async Task TestQCloudSMS()
        {
            /*
             * 账户->访问管理->访问密钥->API密钥管理里查看,如果没有就新建
             * SecretId: AKIDoJuEHS81PfgXsz11111111111
             * SecretKey: ay9lokbSCkFd3NRI0Z0000000000000
             *
             * 短信->应用管理里面查看
             * SDK AppID : 1400370664
             */
            ISMS sms = SMSProvider.Create("QcloudSMS");

            sms.Config = new SMSConfig()
            {
                SMSUId   = "AKIDoJuEHS81PfgXszA1111111111111",  //私人账号信息有所改动
                SMSPwd   = "ay9lokbSCkFd3NRI0ZHo0000000000000", //私人账号信息有所改动
                APPID    = "1400370664",
                EndPoint = "sms.tencentcloudapi.com",
                SignName = "singootop",
                RegionId = "ap-guangzhou"
            };

            var result = await sms.SendMsgAsync("17788760902", "850464", "123456");

            Assert.AreEqual(result.isSuccess, true);
        }
Beispiel #9
0
 public virtual bool Update(CDriver.Progress progress)
 {
     this.InvalidateChildren();
     this.MedSmsFolder.CacheControl(2);
     if (this.MedSmsFolder != null)
     {
         IOperation operation = this.MedSmsFolder.Cache() as IOperation;
         if (!CDriver.OperationToProgress(operation, progress, 0, 500))
         {
             return(false);
         }
         int streamCount = this.MedSmsFolder.StreamCount;
         for (int i = 1; i <= streamCount; i++)
         {
             ISMS iSMS = this.MedSmsFolder.GetStream(i) as ISMS;
             if (iSMS.Empty == 0 && iSMS.Type != 5)
             {
                 base.AddLast(new CSmsItem(this, iSMS));
             }
             if (!progress(1000 * i / streamCount / 2 + 500))
             {
                 return(false);
             }
         }
     }
     return(progress(1000));
 }
Beispiel #10
0
 /// <summary>
 /// Returns the SMS Log for the given Subscription Id
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='subscriptionId'>
 /// </param>
 /// <param name='take'>
 /// </param>
 /// <param name='skip'>
 /// </param>
 /// <param name='messageId'>
 /// </param>
 /// <param name='destination'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IList <SmsCdrEntry> > GetSmsLogAsync(this ISMS operations, string subscriptionId, int?take = default(int?), int?skip = default(int?), string messageId = default(string), string destination = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetSmsLogWithHttpMessagesAsync(subscriptionId, take, skip, messageId, destination, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #11
0
 public static async Task <object> GetSmsFromQueueAsync(this ISMS operations, string id, string entryId, string subscriptionId, string messageId, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetSmsFromQueueWithHttpMessagesAsync(id, entryId, subscriptionId, messageId, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #12
0
        public bool SendMsg(List <string> TelList, string Content)
        {
            IApplicationContext ctx = ContextRegistry.GetContext();
            ISMS sms = ctx["SMS"] as ISMS;

            sms.SendSMG(TelList, Content, "99999");
            return(true);
        }
 public AccountController(
     IUsersService usersService,
     IMembershipService membershipService,
     ISMS smsService)
 {
     _usersService = usersService;
     _membershipService = membershipService;
     _smsService = smsService;
 }
Beispiel #14
0
        /// <summary>
        /// Act as sms was sent. Log event to console
        /// </summary>
        /// <param name="toPhone"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <bool> SendSMS(string toPhone, ISMS data)
        {
            try
            {
                if (string.IsNullOrEmpty(toPhone))
                {
                    throw new ArgumentException(localizer["Phone must not be empty"].Value);
                }

                if (data is null)
                {
                    throw new ArgumentNullException(localizer["SMS data must not be empty"].Value);
                }

                var token = await GetToken();

                logger.LogInformation($"Sending SMS message to {toPhone}");
                var request = new RestRequest("api/v1/messages", Method.POST, DataFormat.Json);

                var text = data.GetText();
                if (text.Length >= 70)
                {
                    // zrus diakritiku
                    text = Helpers.Text.RemoveDiacritism(text);
                }

                if (text.Length > 160)
                {
                    text = text.Substring(0, 158) + "..";
                }

                request.AddJsonBody(new GoSMSSendMessage()
                {
                    channel    = settings.Value.Channel,
                    message    = text,
                    recipients = toPhone
                });
                request.AddHeader("Authorization", $"Bearer {token}");

                logger.LogInformation($"Sending SMS {Helpers.Hash.GetSHA256Hash(settings.Value.CoHash + toPhone)}");
                var response = await smsApiRestClient.ExecuteAsync(request);

                if (response.IsSuccessful)
                {
                    logger.LogInformation($"Sending SMS OK {Helpers.Hash.GetSHA256Hash(settings.Value.CoHash + toPhone)}");
                    return(true);
                }
                logger.LogError($"Error sending sms: {response.Content}");
                return(false);
            }
            catch (Exception exc)
            {
                logger.LogError(exc, $"Error sending SMS to: {toPhone} {exc.Message}");
                return(false);
            }
        }
Beispiel #15
0
        public JsonResult GetSMSCaptcha(string mobile)
        {
            var captcha = RandomHelper.Number(6);

            Session.Set(CustomConfig.CaptchaSession, captcha);
            ISMS sms    = WebIoc.Container.Resolve <ISMS>();
            var  result = sms.sendOnce(mobile, string.Format(CustomConfig.PhoneCapTemp, captcha));

            return(Json(result));
        }
        /// <summary>
        /// Act as sms was sent. Log event to console
        /// </summary>
        /// <param name="toPhone"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <bool> SendSMS(string toPhone, ISMS data)
        {
            try
            {
                try
                {
                    var text = data.GetText();
                    if (text.Length >= 70)
                    {
                        text = Helpers.Text.RemoveDiacritism(text);
                    }

                    if (text.Length > 160)
                    {
                        text = text.Substring(0, 158) + "..";
                    }

                    var msg = new RabbitSMSMessage()
                    {
                        Phone   = toPhone,
                        Message = text,
                        User    = settings.Value.GatewayUser
                    };
                    var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(msg));


                    var factory = new ConnectionFactory()
                    {
                        HostName    = settings.Value.HostName,
                        UserName    = settings.Value.RabbitUserName,
                        Password    = settings.Value.RabbitPassword,
                        VirtualHost = settings.Value.VirtualHost
                    };
                    using var connection = factory.CreateConnection();
                    using var channel    = connection.CreateModel();
                    channel.BasicPublish(exchange: settings.Value.Exchange,
                                         routingKey: settings.Value.QueueName,
                                         body: body);
                    logger.LogInformation($"Sent SMS to {settings.Value.HostName}/{settings.Value.VirtualHost}/{settings.Value.QueueName} {Helpers.Hash.GetSHA256Hash(settings.Value.CoHash + toPhone)}");

                    return(true);
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, $"Failed to PostMessagesAsync to rabbit sms queue. Exception: {ex.Message}");
                    throw;
                }
            }
            catch (Exception exc)
            {
                logger.LogError(exc, $"Error sending SMS to: {toPhone} {exc.Message}");
                return(false);
            }
        }
 public RequestsController(
     ITripsService tripsService,
     IUsersService usersService,
     IRequestsService requestsService,
     ISMS smsService)
 {
     _tripsService = tripsService;
     _usersService = usersService;
     _requestsService = requestsService;
     _smsService = smsService;
 }
Beispiel #18
0
        private void sendButtonClicked(object sender, EventArgs ea)
        {
            Toast.MakeText(this, "Sending SMS...", ToastLength.Short).Show();

            TextView fromView = FindViewById <TextView>(Resource.Id.editTextFrom);
            TextView toView   = FindViewById <TextView>(Resource.Id.editTextTo);

            String from = fromView.Text;
            String to   = toView.Text;

            RadioGroup radios = FindViewById <RadioGroup>(Resource.Id.radioGroup1);

            switch (radios.CheckedRadioButtonId)
            {
            case Resource.Id.radioButtonNexmo:
                service = new Nexmo(
                    this,
                    "[Nexmo Client ID]",
                    "[Nexmo Client Secret]"
                    );
                break;

            case Resource.Id.radioButtonTwilio:
                service = new Twilio(
                    this,
                    "[Twilio Client ID]",
                    "[Twilio Client Secret]"
                    );
                break;

            case Resource.Id.radioButtonTwizo:
                service = new Twizo(
                    this,
                    "[Twizo Key]"
                    );
                break;
            }


            new System.Threading.Thread(new System.Threading.ThreadStart(() =>
            {
                // run in background

                service.SendSMS(
                    from,
                    to,
                    "CloudRail is awesome!"
                    );
                RunOnUiThread(() => {
                    Toast.MakeText(this, "SMS was send", ToastLength.Short).Show();
                });
            })).Start();
        }
Beispiel #19
0
 public ParseData(IWSSendData sendData, //ICache cache,
                  IEquipment_status_logsRepository logsRepo, IBirdhouseRepository birdhouse, IEquipmentRepository equipment, ISMS sms, ICALL call, IWECHAT wechat)
 {
     _sendData = sendData;
     //_cache = cache;
     _equipment = equipment;
     _logsRepo  = logsRepo;
     _sms       = sms;
     _call      = call;
     _wechat    = wechat;
     _birdhouse = birdhouse;
 }
Beispiel #20
0
 internal CSmsItem(CItem parent, ISMS medSms) : base(parent)
 {
     if (!(parent is CSmsItems))
     {
         throw new Exception("Internal error");
     }
     this.MedSms = medSms;
     this.Text   = medSms.Text;
     this.Type   = (CSmsItem.EType)medSms.Type;
     this.State  = (CSmsItem.EState)medSms.State;
     this.Number = "";
     if (this.Type == CSmsItem.EType.StatusReport || this.Type == CSmsItem.EType.Submit)
     {
         this.Number = medSms.ToNumber;
     }
     if (this.Type == CSmsItem.EType.Deliver)
     {
         this.Number = medSms.FromNumber;
     }
     this.ServiceCenter = medSms.ServiceCenter;
     if (this.Type == CSmsItem.EType.StatusReport)
     {
         this.Status = medSms.Status;
     }
     this.ReceivedTimezone = medSms.ReceivedTimezone;
     this.ReceivedTime     = DateTime.MinValue;
     try
     {
         int num;
         this.ReceivedTime = medSms.GetReceivedTimestamp(out num);
         if (num == 0)
         {
             this.ReceivedTime = DateTime.MinValue;
         }
     }
     catch
     {
     }
     this.SentTime = DateTime.MinValue;
     try
     {
         int num;
         this.SentTime = medSms.GetSentTimestamp(out num);
         if (num == 0)
         {
             this.SentTime = DateTime.MinValue;
         }
     }
     catch
     {
     }
 }
Beispiel #21
0
        /// <summary>
        /// 分配工作(关卡参与人)
        /// </summary>
        /// <param name="listWorker"></param>
        /// <returns></returns>
        public void AssignWork()
        {
            //解析参与人
            IList <int> listWorkerId = this.Activity.ParseParticipant(this.FlowInstance.FlowDefine.ID,
                                                                      this.FlowInstance.FlowNo);

            if (listWorkerId.Count > 0)
            {
                //分配工作
                foreach (int workerId in listWorkerId)
                {
                    WorkItemInstance item = new WorkItemInstance();
                    item.Create(m_ActivityInstanceId, workerId);
                    m_ListWorkItemInstance.Add(item);
                }

                //发送提醒短信
                if (this.Activity.IsSms == "Y")
                {
                    List <string> listMobile = new List <string>();

                    foreach (int workerId in listWorkerId)
                    {
                        IWorker worker = ctx["Worker"] as IWorker;

                        string mobile = worker.GetWorkerById(workerId).Mobile;

                        if (!string.IsNullOrEmpty(mobile))
                        {
                            listMobile.Add(mobile);
                        }
                    }

                    if (listMobile.Count > 0)
                    {
                        ISMS sms = ctx["SMS"] as ISMS;

                        string content = string.Format("您有一笔{0}需要审核", FlowInstance.FlowDefine.Name);

                        Log4Net.LogInfo(content);

                        sms.SendSMG(listMobile, content, "99999");
                    }
                }
            }
            else
            {
                throw new Exception(string.Format("关卡({0})无签核人", this.Activity.Name));
            }
        }
Beispiel #22
0
        /// <summary>
        /// Send an sms using Twilio services
        /// </summary>
        /// <param name="anonymous">Show the twilio phone number to the recipient or send as an alphanumeric senderID </param>
        /// <param name="sms">ISMS object</param>
        /// <returns>Status of the sms send attempt</returns>
        private MessageResource.StatusEnum SendSms(bool anonymous, ISMS sms)
        {
            string accountSid = _smsSettings.accountSid;
            string authToken  = _smsSettings.authToken;

            TwilioClient.Init(accountSid, authToken);
            var from = anonymous ? _smsSettings.anonymousName : new Twilio.Types.PhoneNumber(_smsSettings.from);

            var response = MessageResource.Create(
                body: sms.Message,
                from: from,
                to: new Twilio.Types.PhoneNumber(sms.To)
                );

            return(response.Status);
        }
Beispiel #23
0
        /**
	 * 
	 * @description 单条发送
	 * @param ISMS
	 *            短信处理对象,在这个方法中调用发送短信功能
	 * @param userid
	 *            用户账号
	 */
        static int singleSend(ISMS sms, string userid, string phoneNum, string content)
        {
            try
            {
                // 参数类
                com.montnets.mwgate.common.Message message = new com.montnets.mwgate.common.Message();
                // 设置用户账号 指定用户账号发送,需要填写用户账号,不指定用户账号发送,无需填写用户账号
                message.UserId = userid;
                // 设置手机号码 此处只能设置一个手机号码
                message.Mobile = phoneNum;
                // 设置内容
                message.Content = content;
                // 设置扩展号
                message.ExNo = "11";
                // 用户自定义流水编号
                message.CustId = "20160929194950100001";
                // 自定义扩展数据
                message.ExData = "abcdef";
                // 业务类型
                message.SvrType = "SMS001";
                // 返回的流水号
                string returnValue = string.Empty;
                // 返回值
                int result = -310099;
                // 发送短信
                result = sms.singleSend(message, out returnValue);
                // result为0:成功
                if (result == 0)
                {
                   // MessageBox.Show("单条发送提交成功!");
                  //  MessageBox.Show(returnValue);
                    return 0;
                }
                // result为非0:失败
                else
                {
                    return -3;
                   // MessageBox.Show("短信验证消息错误!单条发送提交失败,错误码:" + result);
                }
            }
            catch
            {
                // 异常处理
               // MessageBox.Show(e.Message);
                return -4;
            }
        }
Beispiel #24
0
        public async Task TestAliyunSMS()
        {
            ISMS sms = SMSProvider.Create("AliYunSMS");

            sms.Config = new SMSConfig()
            {
                SMSUId   = "LTAI3R1111111",               //私人账号信息有所改动
                SMSPwd   = "1DnnagtroDvcka91L0000000000", //私人账号信息有所改动
                EndPoint = "dysmsapi.aliyuncs.com",
                SignName = "新谷",
                RegionId = "cn-hangzhou"
            };

            var result = await sms.SendMsgAsync("17788760902,18296860929", "SMS_25585959", "code:123456");

            Assert.AreEqual(result.isSuccess, true);
        }
        /// <summary>
        /// Act as sms was sent. Log event to console
        /// </summary>
        /// <param name="toPhone"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <bool> SendSMS(string toPhone, ISMS data)
        {
            try
            {
                try
                {
                    var text = data.GetText();
                    if (text.Length >= 70)
                    {
                        text = Helpers.Text.RemoveDiacritism(text);
                    }

                    if (text.Length > 160)
                    {
                        text = text.Substring(0, 158) + "..";
                    }

                    var msg = new GoSMSSendMessage()
                    {
                        channel    = settings.Value.Channel,
                        message    = text,
                        recipients = toPhone
                    };

                    var sendMessageRequest = new SendMessageRequest
                    {
                        QueueUrl    = settings.Value.QueueURL,
                        MessageBody = JsonConvert.SerializeObject(msg)
                    };
                    logger.LogInformation($"Sending SMS {Helpers.Hash.GetSHA256Hash(settings.Value.CoHash + toPhone)}");
                    await amazonSQSClient.SendMessageAsync(sendMessageRequest);

                    return(true);
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, $"Failed to PostMessagesAsync to sms queue. Exception: {ex.Message}");
                    throw;
                }
            }
            catch (Exception exc)
            {
                logger.LogError(exc, $"Error sending SMS to: {toPhone} {exc.Message}");
                return(false);
            }
        }
Beispiel #26
0
        public int GetBalance(string IOC_Class_Alias)
        {
            try
            {
                //注入实例
                instance = container.Resolve <ISMS>(IOC_Class_Alias);
            }
            catch (Exception e)
            {
                Common.LogIt(e.ToString());
                throw;
            }

            int result = instance.GetBalance(IOC_Class_Alias);

            return(result);
        }
Beispiel #27
0
        public async Task TestQCloudSMS()
        {
            ISMS sms = SMSProvider.Create("QcloudSMS");

            sms.Config = new SMSConfig()
            {
                SMSUId   = "AKIDoJuEHS81PfgXszA1111111111111",  //私人账号信息有所改动
                SMSPwd   = "ay9lokbSCkFd3NRI0ZHo0000000000000", //私人账号信息有所改动
                APPID    = "1400370664",
                EndPoint = "sms.tencentcloudapi.com",
                SignName = "singootop",
                RegionId = "ap-guangzhou"
            };

            var result = await sms.SendMsgAsync("17788760902", "850464", "123456");

            Assert.AreEqual(result.isSuccess, true);
        }
Beispiel #28
0
        public TraceEntity Send(SMSEntity entity)
        {
            TraceEntity result;

            try
            {
                //注入实例
                instance = container.Resolve <ISMS>(entity.IOC_Class_Alias);
            }
            catch (Exception e)
            {
                Common.LogIt(e.ToString());
                throw;
            }

            result = instance.Send(entity);
            return(result);
        }
Beispiel #29
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="sender">短信发送者对象,需要在控制器内注入得到后再传过来</param>
        /// <param name="mobile">手机号码</param>
        /// <param name="content">短信内容</param>
        /// <param name="sendFor">发送目的,你为什么要短信?比如注册、忘记密码,同时也可以让注册和忘记密码短信互不干扰</param>
        /// <param name="sendFor">短信验证码,如果是发的短信验证码,就记录一下</param>
        protected bool SmsSend(ISMS sender, string mobile, string content, string sendFor, string smsCode = "")
        {
            var sendRes = sender.Send(mobile, content);
            var log     = new SMSLog()
            {
                AddTime    = DateTime.Now,
                Code       = smsCode,
                Content    = content,
                Mobile     = mobile,
                Platform   = sendRes.Platform,
                ResultStr  = sendRes.ResStr,
                SendFor    = sendFor,
                Success    = sendRes.Success,
                UpdateTime = DateTime.Now
            };

            db.SMSLog.Add(log);
            db.SaveChanges();
            return(sendRes.Success);
        }
Beispiel #30
0
        public ActionResult MessageSave()
        {
            BLL.Notice.NoticeList notice = new BLL.Notice.NoticeList();
            ISMS sms = ctx["SMS"] as ISMS;

            string content = Request.Form["content"];
            string Tel     = Request.Form["telList"];

            List <string> TelList = Tel.Split(',').Distinct().ToList();

            int    WorkerID = int.Parse(User.Identity.Name.Split('|')[0]);
            string empNo    = notice.GetEmpNoByWorkerID(WorkerID); //获取发送人的工号

            if (sms.SendSMG(TelList, content, empNo))
            {
                return(Json(new { IsSuccess = true, Message = "发送成功" }, "text/html", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { IsSuccess = false, Message = "发送失败" }, "text/html", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #31
0
 public DriverController(TaxiContext context, ICoreLogger logger, ISMS <List <SendResult> > notify)
 {
     _context = context;
     _logger  = logger;
     _notify  = notify;
 }
Beispiel #32
0
    public string SendSMS(string UserName, string UserPass, string Destination, string SMContent)
    {
        string[] dest;

        if (UserName == "")
        {
            return(_ERR_USERISEMPTY);
        }

        if (UserPass == "")
        {
            return(_ERR_PASSISEMPTY);
        }

        if (Destination == "")
        {
            return(_ERR_DESTISEMPTY);
        }
        else
        {
            dest = Regex.Split(Destination, ",");
            if (dest.Count() > 100)
            {
                return(_ERR_DESTTOLONG);
            }
        }

        ISMS interface_sms = (ISMS)Activator.GetObject(typeof(ISMS), ConfigurationManager.AppSettings["Pretreatment"]);
        SMS  model_sms     = new SMS();

        // 是否审核
        model_sms.Audit = AuditType.Manual;
        // 是否过滤
        model_sms.Filter = FilterType.Failure;
        // 消息级别
        model_sms.Level = LevelType.Level0;
        // 用户名
        model_sms.Account = UserName;
        // 短信内容
        model_sms.Content  = SMContent;
        model_sms.SPNumber = "";
        // 接收短信的号码
        List <string> num = new List <string>();

        foreach (string destnum in dest)
        {
            num.Add(destnum);
        }
        model_sms.Number       = num;
        model_sms.SendTime     = DateTime.Now;
        model_sms.SerialNumber = Guid.NewGuid();
        // 是否需要短信报告
        model_sms.StatusReport = StatusReportType.Enabled;
        // 通道类型
        model_sms.Channel = ChannelType.Industry;

        // 发送短信
        RPCResult <Guid> r = interface_sms.SendSMS(model_sms);

        SendSMSResult ret = new SendSMSResult();

        ret.Result = r.Message;
        ret.MsgId  = r.Value.ToString();
        string data = JsonSerialize.Serialize <SendSMSResult>(ret);

        return(data);
    }