Example #1
0
        public static bool SendFutureSmsForUsers(SmsSenderAgentReference smsSenderAgentRefrence, Guid userGuid,
                                                 Guid smsSentGuid, Guid sentboxGuid, int smsPartCount, Encoding encoding)
        {
            //Business.Sms smsController = new Business.Sms();
            //Dictionary<Business.Operators, int> operatorCountNumberDictionary = User.GetCountUserNumberOfOperators(userGuid);

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

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

            //  if (!smsController.SendFutureSmsForUsers(sentboxGuid))
            //    throw new Exception(Language.GetString("ErrorRecord"));

            //  smsController.CommitTransaction();
            //  return true;
            //}
            //catch (Exception ex)
            //{
            //  smsController.RollbackTransaction();
            //  throw ex;
            //}
            return(false);
        }
Example #2
0
 public void ChangeStatus(SmsSenderAgentReference smsSenderAgentRefrence, bool isSendActive, bool isRecieveActive, bool isSendBulkActive)
 {
     base.ExecuteSPCommand("UpdateStatus", "@SmsSenderAgentReference", (int)smsSenderAgentRefrence,
                           "@IsSendActive", isSendActive,
                           "@IsRecieveActive", isRecieveActive,
                           "@IsSendBulkActive", isSendBulkActive);
 }
Example #3
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;
            }
        }
Example #4
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;
            }
        }
        public ScheduledThread(int timeOut, SmsSenderAgentReference agent)
            : base(timeOut)
        {
            this.SenderAgentRefrence = agent;

            this.ThreadException += new System.Threading.ThreadExceptionEventHandler(SendThread_ThreadException);

            threadCount         = Helper.GetInt(ConfigurationManager.GetSetting("ThreadCount"));
            lstScheduledMessage = new List <ScheduledMessage>();
        }
Example #6
0
 public bool UpdateBlackListSms(Guid userGuid, Guid smsSentGuid, SmsSenderAgentReference agent,
                                Operators operators, int smsPartCount, SmsSendType smsSendType, int encoding)
 {
     return(ExecuteSPCommand("UpdateBlackListSms", "@UserGuid", userGuid,
                             "@SmsSentGuid", smsSentGuid,
                             "@Agent", (int)agent,
                             "@Operator", (int)operators,
                             "@SmsPartCount", smsPartCount,
                             "@TypeSend", (int)smsSendType,
                             "@Encoding", encoding));
 }
Example #7
0
 private static string FormatSmsRate(List <UserSmsRateInfo> smsRates, SmsSenderAgentReference agent, Operators operators, SmsTypes smsType)
 {
     if (smsRates.Any(rate => rate.Agent == agent && rate.Operator == operators && rate.SmsType == smsType))
     {
         return(smsRates.Where(rate => rate.Agent == agent && rate.Operator == operators && rate.SmsType == smsType).First().Rate.ToString());
     }
     else
     {
         return("------");
     }
 }
Example #8
0
 public decimal GetCredit(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     try
     {
         return((decimal)WinServiceHandler.SmsSendWinServiceHandlerChannel().GetCredit(smsSenderAgentRefrence));
     }
     catch
     {
         return(0);
     }
 }
Example #9
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;
            }
        }
Example #10
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;
            }
        }
Example #11
0
        public static ISmsServiceManager GetSmsServiceManager(SmsSenderAgentReference agent)
        {
            switch (agent)
            {
            case SmsSenderAgentReference.Asanak:
                return(new AsanakSmsServiceManager());

            case SmsSenderAgentReference.RahyabRG:
                return(new RahyabRGSmsServiceManager());

            case SmsSenderAgentReference.RahyabPG:
                return(new RahyabPGSmsServiceManager());
            }

            throw new Exception("Sms Sender Agent Not Defined!!!");
        }
Example #12
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;
            }
        }
Example #13
0
        public static void GetAgentInfo(SmsSenderAgentReference smsSenderAgentRefrence, out bool isSendActive, out bool isRecieveActive, out bool isSendBulkActive, out bool checkMessageID)
        {
            Business.SmsSenderAgent smsSenderAgentController = new Business.SmsSenderAgent();
            DataTable smsSenderAgentInfo = smsSenderAgentController.GetSmsSenderAgentInfo(smsSenderAgentRefrence);

            if (smsSenderAgentInfo.Rows.Count > 0)
            {
                isSendActive     = Helper.GetBool(smsSenderAgentInfo.Rows[0]["IsSendActive"]);
                isRecieveActive  = Helper.GetBool(smsSenderAgentInfo.Rows[0]["IsRecieveActive"]);
                isSendBulkActive = Helper.GetBool(smsSenderAgentInfo.Rows[0]["IsSendBulkActive"]);
                checkMessageID   = Helper.GetBool(smsSenderAgentInfo.Rows[0]["checkMessageID"]);
            }
            else
            {
                isSendActive     = false;
                isRecieveActive  = false;
                isSendBulkActive = false;
                checkMessageID   = false;
            }
        }
Example #14
0
        private void GetDeliveryFromWebService(BatchMessage batchMessage)
        {
            try
            {
                this.SenderAgentRefrence = (SmsSenderAgentReference)batchMessage.SmsSenderAgentReference;

                this.ServiceManager = SmsServiceFactory.GetSmsServiceManager((SmsSenderAgentReference)batchMessage.SmsSenderAgentReference);

                ServiceManager.GetDeliveryStatus(batchMessage);
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("\r\n<--<--<--<--<--<--<--<--<--<--<--"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("\r\nGetDeleviry : StackTrace : {0}", ex.StackTrace));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("\r\nGetDeleviry : Message : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("\r\n<--<--<--<--<--<--<--<--<--<--<--"));
            }
        }
Example #15
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;
            }
        }
Example #16
0
 public DataTable GetGiveBackCreditSms(SmsSenderAgentReference smsSenderAgentReference)
 {
     return(FetchSPDataTable("GetGiveBackCreditSms", "@SmsSenderAgentReference", (int)smsSenderAgentReference));
 }
Example #17
0
 public DataTable GetFailedSms(SmsSenderAgentReference smsSenderAgentRefrence, int count)
 {
     return(FetchSPDataTable("GetFailedSms", "@SmsSenderAgentRefrence", smsSenderAgentRefrence,
                             "@Count", count));
 }
Example #18
0
 public static void ChangeStatus(SmsSenderAgentReference smsSenderAgentRefrence, bool isSendActive, bool isRecieveActive, bool isSendBulkActive)
 {
     Business.SmsSenderAgent smsSenderAgentController = new Business.SmsSenderAgent();
     smsSenderAgentController.ChangeStatus(smsSenderAgentRefrence, isSendActive, isRecieveActive, isSendBulkActive);
 }
Example #19
0
 public static decimal GetCredit(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     Business.SmsSenderAgent smsSenderAgentController = new Business.SmsSenderAgent();
     return(smsSenderAgentController.GetCredit(smsSenderAgentRefrence));
 }
Example #20
0
 public DataTable GetBulksByPriority(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     return(FetchSPDataTable("GetBulkByPriority", "@SmsSenderAgentRefrence", (int)smsSenderAgentRefrence));
 }
Example #21
0
 public static DataTable GetUncertainDeleviryStatusBulk(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     Business.Bulk bulkController = new Business.Bulk();
     return(bulkController.GetUncertainDeleviryStatusBulk(smsSenderAgentRefrence));
 }
Example #22
0
 public static DataTable GetUncertainDeliveryStatusSmsTable(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     Business.OutboxNumber smsController = new Business.OutboxNumber();
     return(smsController.GetUncertainDeliveryStatusSms(smsSenderAgentRefrence));
 }
Example #23
0
 public static DataTable GetSendQueue(SmsSenderAgentReference smsSenderAgentRefrence, int agentQueueSize, int threadCount)
 {
     Business.Outbox outboxController = new Business.Outbox();
     return(outboxController.GetSendQueue(smsSenderAgentRefrence, agentQueueSize, threadCount));
 }
Example #24
0
 public static DataTable GetQueue(int count, SmsSenderAgentReference senderAgentRefrence)
 {
     Business.ScheduledSms scheduledSmsController = new Business.ScheduledSms();
     return(scheduledSmsController.GetQueue(count, senderAgentRefrence));
 }
Example #25
0
 public DataTable GetSentboxQueue(SmsSenderAgentReference smsSenderAgentRefrence, int agentQueueSize, int threadCount)
 {
     return(FetchSPDataTable("GetSentboxQueue", "@SmsSenderAgentRefrence", smsSenderAgentRefrence,
                             "@Count", agentQueueSize,
                             "@ThreadCount", threadCount));
 }
Example #26
0
 public DataTable GetUncertainDeleviryStatusBulk(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     return(FetchSPDataTable("GetUncertainDeleviryStatusBulk", "@SmsSenderAgentRefrence", smsSenderAgentRefrence));
 }
Example #27
0
 public DataTable GetUncertainDeliveryStatusSms(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     return(FetchSPDataTable("GetUncertainDeliveryStatusSms", "@SmsSenderAgentRefrence", (int)smsSenderAgentRefrence));
 }
Example #28
0
 public static DataTable GetBulksByPriority(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     Business.Bulk bulkController = new Business.Bulk();
     return(bulkController.GetBulksByPriority(smsSenderAgentRefrence));
 }
Example #29
0
 public DataTable GetQueue(int count, SmsSenderAgentReference senderAgentRefrence)
 {
     return(FetchSPDataTable("GetQueue",
                             "@Count", count,
                             "@SmsSenderAgentReference", (int)senderAgentRefrence));
 }
Example #30
0
 public DataTable GetSmsSenderAgentInfo(SmsSenderAgentReference smsSenderAgentRefrence)
 {
     return(base.FetchSPDataTable("GetSmsSenderAgentInfo", "@SmsSenderAgentRefrence", (int)smsSenderAgentRefrence));
 }