/// <summary>
        /// 发送短信验证码
        /// <para>作    者:蔡亚康</para>
        /// <para>创建时间:2019-03-06</para>
        /// </summary>
        public void Send()
        {
            HssLoginSms config     = ClientConfigManager.HssConfig.HssLoginSms; //"HSS-LOGIN"
            string      smsCode    = this.GetSmsCode();
            string      smsMessage = string.Format(config.SmsContentFormat, smsCode, config.EffectiveTime);

            //启用新的线程发送短信
            Task.Run(() =>
            {
                try
                {
                    SmsServices smsService = new SmsServices();
                    Receiver receiver      = new Receiver()
                    {
                        Id   = this._mobile,
                        Type = ReceiverType.TelCode
                    };
                    smsService.SendVerifyCode(receiver, smsCode, smsMessage, config.SenderId, BussinessId, config.DepartId, TimeSpan.FromMinutes(config.EffectiveTime));
                }
                catch (Exception ex)
                {
                    LogWriter.Write(this, ex.Message, LoggerType.Error);
                }
            });
        }
Example #2
0
        public HttpStatusCodeResult SendActivity([ModelBinder(typeof(DevExpressEditorsBinder))] int?activityId)
        {
            var activities = unitOfWork.ActivitiesRepo.Find(m => m.Id == activityId);

            if (activities == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable, "No Activity Id Found"));
            }
            SmsServices smsServices = new SmsServices();

            if (activities.Groups?.PersonalInformations != null)
            {
                foreach (var i in activities.Groups?.PersonalInformations)
                {
                    if (i.ContactNumber != null)
                    {
                        smsServices.Send(i.ContactNumber,
                                         "Subject:" + activities?.Subject + Environment.NewLine + "Date:" +
                                         activities?.ActivityDate + Environment.NewLine +
                                         "Description:" + activities?.Description);
                    }
                }
            }

            activities.IsSend = true;
            unitOfWork.Save();
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
Example #3
0
        protected static void SendSms()
        {
            SmsBrandnameSoapClient smsClient = new SmsBrandnameSoapClient();

            foreach (var agency in DepartmentServices.GetList().Where(ag => !string.IsNullOrEmpty(ag.PhoneNumber?.Trim())))
            {
                var    soLieu     = RequestServices.LaySoLieuThongKe(MaDonVi: agency.DepartmentID);
                string smsContent = $"[YKCD] {agency.DepartmentName.ToUnsign()} co : {soLieu.NotPerform} ykcd chua thuc hien ({soLieu.NotPerformOutTerm} qua han); {soLieu.Performing} ykcd dang thuc hien ({soLieu.PerformingOutTerm} qua han).";

                foreach (var phoneNumber in agency.PhoneNumber.Split(';'))
                {
                    if (!string.IsNullOrEmpty(phoneNumber))
                    {
                        smsClient.GuiMotNoiDungNhieuSo(string.Empty, phoneNumber, smsContent, "ubnd_pdien", "Pd@3552374", 43);

                        SmsServices.Create(new Sms
                        {
                            ReceiverNumber = phoneNumber,
                            SmsContent     = smsContent,
                            SendTime       = DateTime.Now
                        });
                    }
                }
            }
        }
        /// <summary>
        /// 校验短信验证码
        /// <para>作    者:蔡亚康</para>
        /// <para>创建时间:2019-03-06</para>
        /// </summary>
        /// <param name="smsCode"></param>
        /// <returns></returns>
        public bool Validate(string smsCode)
        {
            Receiver receiver = new Receiver()
            {
                Id   = this._mobile,
                Type = ReceiverType.TelCode
            };

            SmsServices smsService = new SmsServices();

            return(smsService.IsVerifyCode(receiver, smsCode, BussinessId));
        }
Example #5
0
        protected static void SendSms()
        {
            SmsBrandnameSoapClient smsClient = new SmsBrandnameSoapClient();

            foreach (var agency in DepartmentServices.GetList().Where(ag => !string.IsNullOrEmpty(ag.PhoneNumber?.Trim())))
            {
                var dsYkcd = RequestServices.GetList(MaDonViThucHien: agency.DepartmentID, TrangThai: TrangThai.ChuaThucHien).Where(item => item.RequiredDate.AddDays(-2) >= DateTime.Now.Date);

                foreach (var ykcd in dsYkcd)
                {
                    string smsContent = $"[YKCD] {agency.DepartmentName.ToUnsign()} co van ban so {ykcd.DocumentCode} chua bao cao. Thoi han: {ykcd.RequiredDate.ToDateString()}.";

                    foreach (var phoneNumber in agency.PhoneNumber.Split(';'))
                    {
                        if (!string.IsNullOrEmpty(phoneNumber))
                        {
                            smsClient.GuiMotNoiDungNhieuSo(string.Empty, phoneNumber, smsContent, "syt_tthue", "u2AuWJ7ZNNTR8ge2v7b4CQ", 18);

                            SmsServices.Create(new Sms
                            {
                                ReceiverNumber = phoneNumber,
                                SmsContent     = smsContent,
                                SendTime       = DateTime.Now
                            });
                        }
                    }
                }

                dsYkcd = RequestServices.GetList(MaDonViThucHien: agency.DepartmentID, TrangThai: TrangThai.DangThucHien).Where(item => item.RequiredDate.AddDays(-2) >= DateTime.Now.Date);

                foreach (var ykcd in dsYkcd)
                {
                    string smsContent = $"[YKCD] {agency.DepartmentName.ToUnsign()} co van ban so {ykcd.DocumentCode} chua bao cao. Thoi han: {ykcd.RequiredDate.ToDateString()}.";

                    foreach (var phoneNumber in agency.PhoneNumber.Split(';'))
                    {
                        if (!string.IsNullOrEmpty(phoneNumber))
                        {
                            smsClient.GuiMotNoiDungNhieuSo(string.Empty, phoneNumber, smsContent, "syt_tthue", "u2AuWJ7ZNNTR8ge2v7b4CQ", 18);

                            SmsServices.Create(new Sms
                            {
                                ReceiverNumber = phoneNumber,
                                SmsContent     = smsContent,
                                SendTime       = DateTime.Now
                            });
                        }
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Initializes and configures instance of <see cref="IContainer"/>.
        /// </summary>
        public ApiConfig ConfigureAufacMiddleware()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <FooService>().As <IFooService>();
            var smsServices = new SmsServices(path: HttpRuntime.BinDirectory);

            builder.RegisterInstance(smsServices)
            .As <ISmsServices>()
            .ExternallyOwned();

            //builder.RegisterType<YandexSearch>().As<IYandexSearch>();
            builder.RegisterType <ChromiumSettings>().As <IChromiumSettings>().WithParameter("chromiumPath", HttpRuntime.BinDirectory);


            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());

            var container = builder.Build();

            _configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
            _app.UseAutofacMiddleware(container);

            return(this);
        }