示例#1
0
        public static bool SendPeriodFutureSingleSms(SmsSenderAgentReference smsSenderAgentRefrence, Guid userGuid, Guid smsSentGuid, DateTime sendDateTime,
                                                     Guid sentboxGuid, string reciever, DateTime startDateTime, DateTime endDateTime,
                                                     int period, SmsSentPeriodType periodType, int smsPartCount, Encoding encoding)
        {
            Business.Sms      smsController = new Business.Sms();
            Business.SmsTypes smsType       = encoding == Business.Encoding.Utf8 ? Business.SmsTypes.Farsi : Business.SmsTypes.Latin;

            smsController.BeginTransaction();
            try
            {
                DateTime nextDateTime = Helper.AddDate(periodType.ToString(), period, sendDateTime);
                bool     sendIsFinish = false;
                if (nextDateTime > endDateTime)
                {
                    sendIsFinish = true;
                }

                List <string> lstNumbers = reciever.Split(',').ToList();
                Dictionary <Business.Operators, int> operatorCountNumberDictionary = GetCountNumberOfOperators(lstNumbers);

                //Transaction.DecreaseCostOfSmsSend(userGuid, Business.SmsSendType.SendPeriodFutureSingleSms,
                //																	operatorCountNumberDictionary, smsPartCount, smsType, smsSenderAgentRefrence, smsSentGuid, smsController.DataAccessProvider);

                XDocument doc  = new XDocument();
                XElement  root = new XElement("NewDataSet");

                foreach (string number in lstNumbers)
                {
                    XElement element = new XElement("Table");
                    element.Add(new XElement("Reciever", number));
                    root.Add(element);
                }
                doc.Add(root);


                if (!smsController.SendPeriodFutureSingleSms(sentboxGuid, doc.ToString(), nextDateTime, sendIsFinish))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                smsController.CommitTransaction();
                return(true);
            }
            catch (InnerTransactionException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                smsController.RollbackTransaction();
                throw ex;
            }
        }
示例#2
0
        public static bool SendPeriodFutureGroupSms(SmsSenderAgentReference smsSenderAgentRefrence, Guid userGuid, Guid smsSentGuid,
                                                    string groupGuid, DateTime sendDateTime, Guid sentboxGuid, DateTime startDateTime, DateTime endDateTime,
                                                    int period, SmsSentPeriodType periodType, int smsPartCount, Encoding encoding)
        {
            Business.Sms      smsController = new Business.Sms();
            Business.SmsTypes smsType       = encoding == Business.Encoding.Utf8 ? Business.SmsTypes.Farsi : Business.SmsTypes.Latin;
            smsController.BeginTransaction();
            try
            {
                DateTime nextDateTime = Helper.AddDate(periodType.ToString(), period, sendDateTime);
                bool     sendIsFinish = false;
                if (nextDateTime > endDateTime)
                {
                    sendIsFinish = true;
                }

                Dictionary <Business.Operators, int> operatorCountNumberDictionary = PhoneNumber.GetCountNumberOfOperators(groupGuid, 0, 0, false);

                //Transaction.DecreaseCostOfSmsSend(userGuid, Business.SmsSendType.SendPeriodFutureGroupSms,
                //																	operatorCountNumberDictionary, smsPartCount, smsType, smsSenderAgentRefrence, smsSentGuid, smsController.DataAccessProvider);

                if (!smsController.SendPeriodFutureGroupSms(sentboxGuid, groupGuid, nextDateTime, sendIsFinish))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                smsController.CommitTransaction();
                return(true);
            }
            catch (InnerTransactionException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                smsController.RollbackTransaction();
                throw ex;
            }
        }