Exemplo n.º 1
0
        /// <summary>
        /// آیتم های جدید کارتابل را ارسال میکند
        /// </summary>
        /// <param name="readyForSendSms"></param>
        public void SendKartablSmss(IList <InfoServiceProxy> readyForSendSms)
        {
            try
            {
                ISearchPerson searchTool = new BPerson();
                var           ids        = from o in readyForSendSms
                                           select o.PersonId;
                IList <decimal> managerList = new ManagerRepository(false).GetAllManagerPersons(ids.ToList <decimal>());

                var readyPerson = from o in readyForSendSms
                                  where managerList.Contains(o.PersonId)
                                  select o;
                IKartablRequests bus     = new BKartabl();
                List <decimal>   itemIds = new List <decimal>();
                foreach (InfoServiceProxy proxy in readyPerson.ToList <InfoServiceProxy>())
                {
                    try
                    {
                        IList <ContractKartablProxy> pendingList = bus.GetAllRequests(proxy.PersonId);
                        IList <decimal> kartableIds     = new List <decimal>();
                        IList <decimal> notConfirmedids = new List <decimal>();

                        if (pendingList.Count > 0)
                        {
                            var list = from o in pendingList
                                       select o.ID;
                            kartableIds = list.ToList <decimal>();
                            kartableIds = this.GetNewNotifications(NotificationsServices.SmsKartabl, kartableIds);
                            if (kartableIds.Count > 0)
                            {
                                string message = this.BuildKartablSmsString(kartableIds, proxy);
                                string subject = String.Format("گزارش وضعیت کارتابل در ساعت {0}:{1} - مخصوص مدیران", DateTime.Now.TimeOfDay.Hours, DateTime.Now.TimeOfDay.Minutes);
                                SmsUtility.SendSMS(proxy.SmsNumber, message);
                                itemIds.AddRange(kartableIds);
                                logger.Info(String.Format("SMS webservice : person {0} had Sent kartabl sms {1} - {2}", proxy.PersonName, Utility.ToPersianDate(DateTime.Now), DateTime.Now.TimeOfDay));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(proxy.PersonCode, " SmsWebService :SendKartablSmss ->" + ex.Message, ex);
                        logger.Flush();
                    }
                }
                historyRep.InsertHistory(NotificationsServices.SmsKartabl, DateTime.Now.Date, itemIds);
            }
            catch (Exception ex)
            {
                logger.Error("", " SmsWebService :SendKartablSmss ->" + ex.Message, ex);
                logger.Flush();
            }
        }