Beispiel #1
0
        async Task <string> sendsmsloginAsync(web_db.TblCustomer c)
        {
            var sms  = Models.cl._conf.Any(a => a.Key == web_db.TblConf.KeyEnum.Main_ActiceSms && a.Value == true.ToString());
            var us   = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_UserSms) ?? new web_db.TblConf()).Value;
            var pass = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_PassSms) ?? new web_db.TblConf()).Value;
            var num  = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_NumSms) ?? new web_db.TblConf()).Value;

            web_lib.sms s = new web_lib.sms {
                numfrom = num, password = pass, username = us
            };
            return(await s.sendsmsAsync(c.Mob, @"سردخانه میوه طلایی
ورود موفق
" + DateTime.Now.ToPersianDateTime()));
        }
Beispiel #2
0
        private async Task <string> sendsmsloginAsync(web_db._queu.TblQueu c)
        {
            var sms  = Models.cl._conf.Any(a => a.Key == web_db.TblConf.KeyEnum.Main_ActiceSms && a.Value == true.ToString());
            var us   = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_UserSms) ?? new web_db.TblConf()).Value;
            var pass = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_PassSms) ?? new web_db.TblConf()).Value;
            var num  = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_NumSms) ?? new web_db.TblConf()).Value;


            web_lib.sms s = new web_lib.sms {
                numfrom = num, password = pass, username = us
            };
            return(await s.sendsmsAsync(c.mob, settings.GetValue <string>("txtPortagesms") + @$ "
 شماره پیگیری درخواست شما : {c.Code}
زمان ثبت :{DateTime.Now.ToPersianDateTime()}
"));
        }
Beispiel #3
0
        private async Task <string> sendsmsAsync(web_db._queu.TblQueu c)
        {
            c.codesend     = new Random().Next(11001, 99999);
            c.datecodesend = DateTime.Now;

            var sms  = Models.cl._conf.Any(a => a.Key == web_db.TblConf.KeyEnum.Main_ActiceSms && a.Value == true.ToString());
            var us   = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_UserSms) ?? new web_db.TblConf()).Value;
            var pass = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_PassSms) ?? new web_db.TblConf()).Value;
            var num  = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_NumSms) ?? new web_db.TblConf()).Value;


            web_lib.sms s = new web_lib.sms {
                numfrom = num, password = pass, username = us
            };
            return(await s.sendsmsAsync(c.mob, settings.GetValue <string>("txtPortagesms") + @"
کد ثبت درخواست: " + c.codesend));
        }
Beispiel #4
0
        async Task <string> sendsmsAsync(web_db.TblCustomer c)
        {
            c.Password         = new Random().Next(11001, 99999).ToString();
            c.Datesendpassword = DateTime.Now;

            var sms  = Models.cl._conf.Any(a => a.Key == web_db.TblConf.KeyEnum.Main_ActiceSms && a.Value == true.ToString());
            var us   = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_UserSms) ?? new web_db.TblConf()).Value;
            var pass = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_PassSms) ?? new web_db.TblConf()).Value;
            var num  = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_NumSms) ?? new web_db.TblConf()).Value;


            web_lib.sms s = new web_lib.sms {
                numfrom = num, password = pass, username = us
            };
            return(await s.sendsmsAsync(c.Mob, @"سردخانه میوه طلایی
کد ورود به سایت: " + c.Password));
        }
Beispiel #5
0
        public static async Task sendsmsNoteAsync(IConfiguration _mySettings, CancellationToken stoppingToken = default)
        {
            web_db.sardweb_Context db = new web_db.sardweb_Context();
            {
                var sms  = Models.cl._conf.Any(a => a.Key == web_db.TblConf.KeyEnum.Main_ActiceSms && a.Value == true.ToString());
                var user = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_UserSms) ?? new web_db.TblConf()).Value;
                var pass = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_PassSms) ?? new web_db.TblConf()).Value;
                var num  = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_NumSms) ?? new web_db.TblConf()).Value;


                web_lib.sms s = new web_lib.sms {
                    numfrom = num, password = pass, username = user
                };


                var x  = db.TblNoteRows.Where(a => a.SendSms && a.Date == DateTime.Now.Date).Include(a => a.TblNote).AsEnumerable().GroupBy(a => a.TblNote);
                var us = db.TblUsers.Where(a => a.IsActive && a.IsDel == false).AsEnumerable();
                foreach (var mes in x)
                {
                    foreach (var item in us.Where(a => mes.Any(s => s.ForUserId.GetValueOrDefault() == a.Id || (string.IsNullOrWhiteSpace(s.ForUserroll) == false? a.Roles.Contains(s.ForUserroll ?? ""):false))))
                    {
                        var txt = new StringBuilder();
                        txt.AppendLine(_mySettings.GetValue <string>("txtPortagesms"));
                        txt.AppendLine($"یاداوری");

                        txt.AppendLine($"در مورخه : " + (DateTime.Now.Date).ToPersianDate());

                        txt.AppendLine(mes.Key.Caption);

                        try
                        {
                            var v = await s.sendsmsAsync(item.Mob, txt.ToString(), stoppingToken);
                        }
                        catch
                        {
                        }
                    }
                }
            };
        }
Beispiel #6
0
        public static async Task sendsmsAllAsync(IConfiguration _mySettings, CancellationToken stoppingToken = default)
        {
            {
                var sms  = Models.cl._conf.Any(a => a.Key == web_db.TblConf.KeyEnum.Main_ActiceSms && a.Value == true.ToString());
                var us   = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_UserSms) ?? new web_db.TblConf()).Value;
                var pass = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_PassSms) ?? new web_db.TblConf()).Value;
                var num  = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_NumSms) ?? new web_db.TblConf()).Value;
                var site = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.US_UrlSite) ?? new web_db.TblConf()).Value;

                var txtsmsUp   = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_txtSmsUp) ?? new web_db.TblConf()).Value;
                var txtsmsDown = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Main_txtSmsDown) ?? new web_db.TblConf()).Value;


                web_lib.sms s = new web_lib.sms {
                    numfrom = num, password = pass, username = us
                };
                web_db.sardweb_Context db = new web_db.sardweb_Context();

                var x = db.TblPortages.Where(a => a.IsEnd && a.IsDel == false && a.SmsOk == null).Include(a => a.FkCustomerNavigation).Include(a => a.FkContracttypeNavigation)
                        .Include(a => a.TblPortageRows).ThenInclude(a => a.FkContractNavigation);
                await db.SaveChangesAsync(stoppingToken);

                foreach (var itemm in x)
                {
                    if (itemm.FkContracttypeNavigation.KindCotractType == web_db._Weighing.TblContractType.KindCotractTypeEnum.ASardKhane)
                    {
                        var txt = new StringBuilder();
                        txt.AppendLine(txtsmsUp);

                        txt.AppendLine($"شماره برگه : " + itemm.Code.ToString() + " " + itemm.KindTitle);

                        foreach (var item in itemm.TblPortageRows.GroupBy(a => a.FkContractNavigation.Code).Select(a => new { a.Key, count = a.Sum(s => s.Count) }))
                        {
                            txt.AppendLine($"کد مشتری :" + item.Key);
                            txt.AppendLine($"تعداد :" + item.count.gadrmotlagh());
                        }

                        if (itemm.FkContracttypeNavigation.KindCotractType == web_db._Weighing.TblContractType.KindCotractTypeEnum.ASardKhane)
                        {
                            txt.AppendLine($"خالص :" + itemm.WeightNet.gadrmotlagh().ToKilo());
                        }


                        txt.AppendLine($"زمان :" + itemm.Date2.ToPersianDateTime());
                        txt.AppendLine($"راننده :" + itemm.CarRanande);

                        if (site.IsEmpty() == false)
                        {
                            txt.AppendLine("");

                            txt.AppendLine("سامانه مشتری : ");


                            txt.AppendLine(site);
                        }
                        txt.AppendLine(txtsmsDown);


                        try
                        {
                            var v = await s.sendsmsAsync(itemm.FkCustomerNavigation.Mob, txt.ToString(), stoppingToken);

                            itemm.SmsVaziat = v;
                            itemm.SmsOk     = v.Contains("OK");
                        }
                        catch
                        {
                            itemm.SmsVaziat = "خطا";
                        }
                    }
                    else
                    if (itemm.FkContracttypeNavigation.KindCotractType == web_db._Weighing.TblContractType.KindCotractTypeEnum.ASabad)

                    {
                        var txt = new StringBuilder();
                        txt.AppendLine(txtsmsUp);


                        txt.AppendLine($"شماره برگه : " + itemm.Code.ToString());

                        foreach (var item in itemm.TblPortageRows.GroupBy(a => a.FkContractNavigation.Code).Select(a => new { a.Key, count = a.Sum(s => s.Count) }))
                        {
                            txt.AppendLine($"کد مشتری :" + item.Key);
                            txt.AppendLine($"تعداد :" + item.count.gadrmotlagh());
                        }

                        txt.AppendLine($"زمان :" + itemm.Date2.ToPersianDateTime());
                        txt.AppendLine($"راننده :" + itemm.CarRanande);
                        txt.AppendLine("");
                        txt.AppendLine("سامانه مشتری : ");


                        txt.AppendLine(site);
                        txt.AppendLine(txtsmsDown);

                        try
                        {
                            var v = await s.sendsmsAsync(itemm.FkCustomerNavigation.Mob, txt.ToString(), stoppingToken);

                            itemm.SmsVaziat = v;
                            itemm.SmsOk     = v.Contains("OK");
                        }
                        catch
                        {
                            itemm.SmsVaziat = "خطا";
                        }
                    }
                }
                await db.SaveChangesAsync(stoppingToken);

                foreach (var item in db.TblContracts.Include(a => a.FkCustomerNavigation).Where(a => a.SendSms == true))
                {
                    var txt = new StringBuilder();
                    txt.AppendLine(txtsmsUp);

                    txt.AppendLine($"قرارداد شماره : " + item.Code.ToString());
                    txt.AppendLine($"در مورخه : " + (item.Dateedit.HasValue ? item.Dateedit.Value : item.Dateadd).ToPersianDateTime());
                    if (item.Dateedit.HasValue)
                    {
                        txt.AppendLine($"اصلاح گردید");
                    }
                    else
                    {
                        txt.AppendLine($"بنام شما ثبت گردید");
                    }
                    txt.AppendLine(txtsmsDown);

                    try
                    {
                        var v = await s.sendsmsAsync(item.FkCustomerNavigation.Mob, txt.ToString(), stoppingToken);

                        item.SendSms = false;
                    }
                    catch
                    {
                    }
                }
                await db.SaveChangesAsync(stoppingToken);


                foreach (var item in cl._listSmsForSend)
                {
                    var txt = new StringBuilder();
                    txt.AppendLine(txtsmsUp);

                    txt.AppendLine(item.txt);
                    txt.AppendLine(txtsmsDown);

                    var v = await s.sendsmsAsync(item.number, txt.ToString(), stoppingToken);

                    cl._listSmsForSend.Remove(item);
                }
            };
        }