/// <summary> /// متد ارسال پیام برای استفاده در برنامه /// </summary> /// <param name="text">متن پیام</param> /// <param name="number">شماره گیرنده</param> /// <returns></returns> public static string SendSmsNik(string text, List <string> numbers) { NikSmsWebServiceClient helper = new NikSmsWebServiceClient(); var task = helper.SendGroup("blacklist", numbers, text); task.Wait(); var result = task.Result; var messageRes = SendSmsStatusHandling(result.Status); return(messageRes); }
static void Main(string[] args) { TimeSpan timer = TimeSpan.FromMinutes(30); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("program started..."); var numbers = new List <string>() { "09124254257", "09122196672", "09128639319", "09122010861", "09126046937", "09124598925", "09126904936", "09361604970", "09354047788" }; //var numbers = new List<string>() { "09354047788" }; NikSmsWebServiceClient.SendSmsNik("همکار گرامی؛\n لطفا اطلاعات فروش وزنی شعبه را در پنل کاربری به روز نمایید.\n با تشکر", numbers); Console.WriteLine("text messages sent..."); System.Threading.Thread.Sleep(timer); Console.WriteLine("waited 30 minutes..."); using (var db = new KiaGalleryMainContextEntities()) { Console.WriteLine("runnig rest of the codes...."); var data = db.BranchGolds.Where(x => x.CreateDate >= DateTime.Today).GroupBy(x => x.Branches).Select(y => new { weight = y.OrderByDescending(x => x.Id).Select(x => x.Weight).FirstOrDefault(), price = y.OrderByDescending(x => x.Id).Select(x => x.Price).FirstOrDefault(), branch = y.Key.Name, }).ToList(); var persianDate = DateUtility.GetPersianDate(DateTime.Now); double sum = data.Sum(x => x.weight); long priceSum = data.Sum(x => x.price); var rate = priceSum / sum * 4.3318; string message = persianDate + " \n جمع کل: " + sum + " گرم " + " \n جمع قیمت: " + Core.ToSeparator(priceSum) + " ریال " + " \n میانگین مظنه: " + Core.ToSeparator(rate) + " ریال " + "\n"; foreach (var item in data) { message += "شعبه " + item.branch + ": " + item.weight + " گرم " + Core.ToSeparator(item.price) + " ریال \n"; } var managerNumber = new List <string>() { "09124516569", "09126304190", "09124254257", "09123430339", "09128069061", "09127799048", "09359120525", "09354047788" }; //var managerNumber = new List<string>() { "09354047788" }; NikSmsWebServiceClient.SendSmsNik(message.Trim(), managerNumber); } Console.WriteLine("Job Done!"); }