Exemplo n.º 1
0
        public static bool SendPostalCodeSms(SmsSenderAgentReference smsSenderAgentRefrence, Guid userGuid, Guid smsSentGuid,
                                             int recipientNumberCount, Guid sentboxGuid, int smsPartCount, Encoding encoding)
        {
            Business.Sms smsController = new Business.Sms();
            Dictionary <Business.Operators, int> operatorCountNumberDictionary = new Dictionary <Operators, int>();

            operatorCountNumberDictionary.Add(Operators.MCI, recipientNumberCount);

            Business.SmsTypes smsType = encoding == Business.Encoding.Utf8 ? Business.SmsTypes.Farsi : Business.SmsTypes.Latin;

            smsController.BeginTransaction();
            try
            {
                //Transaction.DecreaseCostOfSmsSend(userGuid, Business.SmsSendType.SendPostalCodeSms, operatorCountNumberDictionary,
                //																	smsPartCount, smsType, smsSenderAgentRefrence, smsSentGuid, smsController.DataAccessProvider);

                if (!smsController.SendPostalCodeSms(sentboxGuid))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                smsController.CommitTransaction();
                return(true);
            }
            catch (InnerTransactionException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                smsController.RollbackTransaction();
                throw ex;
            }
        }
Exemplo n.º 2
0
        public static void GiveBackCreditToUser(Guid userGuid, SmsSendType smsSendType, Business.Operators operators,
                                                int smsPartCount, int encoding,
                                                int smsCount, Business.SmsSenderAgentReference agent, Guid smsSentGuid)
        {
            Business.Sms smsController = new Business.Sms();

            Business.SmsTypes smsType = encoding == (int)Business.Encoding.Utf8 ? Business.SmsTypes.Farsi : Business.SmsTypes.Latin;

            smsController.BeginTransaction();
            try
            {
                Transaction.IncreaseCostOfFaildSend(userGuid, smsSendType, operators, smsPartCount, smsType, smsCount, agent, smsSentGuid, smsController.DataAccessProvider);

                if (!smsController.UpdateBlackListSms(userGuid, smsSentGuid, agent, operators, smsPartCount, smsSendType, encoding))
                {
                    throw new Exception("ErrorRecord");
                }
                smsController.CommitTransaction();
            }
            catch (InnerTransactionException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                smsController.RollbackTransaction();
                throw ex;
            }
        }
Exemplo n.º 3
0
        public static bool SendAdvancedSpecialGroupFutureSms(SmsSenderAgentReference smsSenderAgentRefrence, Guid userGuid, Guid smsSentGuid,
                                                             Guid sentboxGuid, string groupGuid, int downRange, int upRange, 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
            {
                Dictionary <Business.Operators, int> operatorCountNumberDictionary = GeneralNumber.GetCountNumberOfOperators(groupGuid, downRange, upRange);

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

                if (!smsController.SendAdvancedSpecialGroupFutureSms(sentboxGuid, groupGuid, downRange, upRange))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                smsController.CommitTransaction();
                return(true);
            }
            catch (InnerTransactionException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                smsController.RollbackTransaction();
                throw ex;
            }
        }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
0
        public static void SendSmsForUsers(SmsSenderAgentReference smsSenderAgentRefrence, Guid userGuid,
                                           string userRoleGuid, Guid smsSentGuid, Guid sentboxGuid, string xmlSmsBody, bool decreaseFromUser, ref Guid SmsBodyGuid)
        {
            Business.Sms      smsController = new Business.Sms();
            Business.SmsTypes smsType;
            string            smsBody = string.Empty;

            try
            {
                DataView dvXmlSmsBody = new DataView(Helper.DeSerializeXml(xmlSmsBody));
                dvXmlSmsBody.RowFilter = string.Format(" CONVERT(SendDate,System.DateTime) <= '{0}' ", Helper.GetDateTimeForDB(DateTime.Now));

                for (int counterXmlNode = 0; counterXmlNode < dvXmlSmsBody.Count; counterXmlNode++)
                {
                    smsController.BeginTransaction();
                    try
                    {
                        smsBody     = dvXmlSmsBody[counterXmlNode]["SmsBody"].ToString();
                        SmsBodyGuid = Helper.GetGuid(dvXmlSmsBody[counterXmlNode]["Guid"]);
                        if (!decreaseFromUser)
                        {
                            Dictionary <Business.Operators, int> operatorCountNumberDictionary = User.GetCountRoleNumberOfOperators(userGuid, Helper.GetGuid(userRoleGuid));
                            smsType = Helper.HasUniCodeCharacter(smsBody) ? Business.SmsTypes.Farsi : Business.SmsTypes.Latin;
                            //Transaction.DecreaseCostOfSmsSend(userGuid, Business.SmsSendType.SendSmsForUsers,
                            //																	operatorCountNumberDictionary,
                            //																	Helper.GetSmsCount(smsBody),
                            //																	smsType, smsSenderAgentRefrence,
                            //																	smsSentGuid, smsController.DataAccessProvider);
                        }
                        //smsController.SendSmsForUsers(sentboxGuid, Helper.GetGuid(dvXmlSmsBody[counterXmlNode]["Guid"]), Helper.GetGuid(userRoleGuid),
                        //															decreaseFromUser, (int)Business.SmsSendType.SendSingleFutureSms);
                        smsController.CommitTransaction();
                    }
                    catch (InnerTransactionException ex)
                    {
                        throw ex;
                    }
                    catch (Exception ex)
                    {
                        smsController.RollbackTransaction();
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 6
0
        public static bool SendFutureSmsFormat(SmsSenderAgentReference smsSenderAgentRefrence, Guid userGuid, Guid smsSentGuid,
                                               Guid sentboxGuid, string groupGuid, Guid formatGuid, int smsPartCount, Encoding encoding)
        {
            Business.Sms smsController = new Business.Sms();
            Dictionary <Business.Operators, int> operatorCountNumberDictionary = new Dictionary <Operators, int>();

            Business.SmsTypes smsType;

            smsController.BeginTransaction();
            try
            {
                DataTable dataTableSmsInfo = Facade.PhoneNumber.GetCountNumberOfOperatorsForSendSmsFormat(formatGuid, groupGuid);

                foreach (DataRow row in dataTableSmsInfo.Rows)
                {
                    operatorCountNumberDictionary.Add((Business.Operators)Helper.GetInt(row["Operator"]), Helper.GetInt(row["Count"]));
                    smsType = Helper.GetInt(row["Encoding"]) == 1 ? Business.SmsTypes.Farsi : Business.SmsTypes.Latin;

                    //Transaction.DecreaseCostOfSmsSend(userGuid, Business.SmsSendType.SendFutureSmsFormat,
                    //																	operatorCountNumberDictionary,
                    //																	Helper.GetInt(row["SmsPartCount"]),
                    //																	smsType, smsSenderAgentRefrence, smsSentGuid, smsController.DataAccessProvider);
                    operatorCountNumberDictionary.Clear();
                }

                if (!smsController.SendFutureSmsFormat(sentboxGuid, groupGuid, formatGuid))
                {
                    throw new Exception("ErrorRecord");
                }

                smsController.CommitTransaction();
                return(true);
            }
            catch (InnerTransactionException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                smsController.RollbackTransaction();
                throw ex;
            }
        }
Exemplo n.º 7
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;
            }
        }