예제 #1
0
        public static decimal GetSendPrice(Guid userGuid, SmsTypes smsType, int smsPartCount, Guid privateNumberGuid, Dictionary <int, int> operatorNumberCount)
        {
            decimal smsPrice = 0;

            Common.PrivateNumber       privateNumber        = Facade.PrivateNumber.LoadNumber(privateNumberGuid);
            List <DataRow>             lstOperatorRatio     = Facade.SmsSenderAgent.GetAgentRatio(privateNumber.SmsSenderAgentGuid).AsEnumerable().ToList();
            Dictionary <Guid, decimal> dictionaryAgentRatio = Facade.GroupPrice.GetAgentRatio(userGuid);

            smsPartCount = privateNumber.Type == (int)Business.TypePrivateNumberAccesses.Bulk ? smsPartCount : 1;

            switch (smsType)
            {
            case SmsTypes.Farsi:
                foreach (KeyValuePair <int, int> opt in operatorNumberCount)
                {
                    smsPrice += opt.Value * GetOperatorRatio(lstOperatorRatio, opt.Key, SmsTypes.Farsi) * smsPartCount;
                }
                break;

            case SmsTypes.Latin:
                foreach (KeyValuePair <int, int> opt in operatorNumberCount)
                {
                    smsPrice += opt.Value * GetOperatorRatio(lstOperatorRatio, opt.Key, SmsTypes.Latin) * smsPartCount;
                }
                break;
            }

            smsPrice *= dictionaryAgentRatio.ContainsKey(privateNumber.SmsSenderAgentGuid) ? Helper.GetDecimal(dictionaryAgentRatio[privateNumber.SmsSenderAgentGuid]) : 1;
            return(smsPrice);
        }
예제 #2
0
 public bool UpdateTrafficRelay(Common.PrivateNumber privateNumber)
 {
     return(ExecuteSPCommand("UpdateTrafficRelay",
                             "@Guid", privateNumber.NumberGuid,
                             "@SmsTrafficRelayGuid", privateNumber.SmsTrafficRelayGuid,
                             "@DeliveryTrafficRelay", privateNumber.DeliveryTrafficRelayGuid));
 }
예제 #3
0
        public static Common.PrivateNumber LoadNumber(Guid numberGuid)
        {
            Business.PrivateNumber privateNumberController = new Business.PrivateNumber();
            Common.PrivateNumber   privateNumber           = new Common.PrivateNumber();

            privateNumberController.Load(numberGuid, privateNumber);
            return(privateNumber);
        }
        private void InitializePage()
        {
            btnPayment.Text = Language.GetString(btnPayment.Text);
            btnCancel.Text  = Language.GetString(btnCancel.Text);

            privateNumber    = Facade.PrivateNumber.LoadNumber(PrivateNumberGuid);
            txtPrice.Text    = Helper.FormatDecimalForDisplay(privateNumber.Price);
            txtPrice.Enabled = false;
        }
예제 #5
0
        ///// New 8-3-2019
        public static string GetDeliveryURL(Guid pNumber)
        {
            Common.PrivateNumber privateNumber   = new Common.PrivateNumber();
            DeliveryMessage      deliveryMessage = new DeliveryMessage();

            privateNumber = Facade.PrivateNumber.LoadNumber(pNumber);
            deliveryMessage.DeliveryRelayGuid = privateNumber.DeliveryTrafficRelayGuid;

            return(Facade.TrafficRelay.LoadUrl(deliveryMessage.DeliveryRelayGuid).Url);
        }
예제 #6
0
 public bool AssignSubRangeNumberToUser(Common.PrivateNumber privateNumber, string keyword)
 {
     return(ExecuteSPCommand("AssignSubRangeNumberToUser",
                             "@Number", privateNumber.Number,
                             "@Range", privateNumber.Range,
                             "@Regex", privateNumber.Regex,
                             "@ParentGuid", privateNumber.ParentGuid,
                             "@OwnerGuid", privateNumber.OwnerGuid,
                             "@Keyword", keyword,
                             "@Price", privateNumber.Price,
                             "@ExpireDate", privateNumber.ExpireDate));
 }
예제 #7
0
        public static bool UpdateNumber(Common.PrivateNumber privatenumber)
        {
            Business.PrivateNumber privateNumberController = new Business.PrivateNumber();

            try
            {
                return(privateNumberController.UpdateNumber(privatenumber));
            }
            catch
            {
                throw;
            }
        }
예제 #8
0
        public Guid InsertNumber(Common.PrivateNumber privateNumber)
        {
            try
            {
                Guid newGuid = Guid.Empty;

                newGuid = base.Insert(privateNumber);

                if (newGuid != Guid.Empty)
                {
                    OnPrivateNumberChange(privateNumber, null);
                }

                return(newGuid);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #9
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Common.PrivateNumber privateNumber = new Common.PrivateNumber();
            try
            {
                privateNumber.NumberGuid               = PrivateNumberGuid;
                privateNumber.SmsTrafficRelayGuid      = Helper.GetGuid(drpSmsTrafficRelay.SelectedValue);
                privateNumber.DeliveryTrafficRelayGuid = Helper.GetGuid(drpDeliveryTrafficRelay.SelectedValue);

                if (!Facade.PrivateNumber.UpdateTrafficRelay(privateNumber))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                Response.Redirect(string.Format("/PageLoader.aspx?c={0}", Helper.Encrypt((int)Arad.SMS.Gateway.Business.UserControls.UI_PrivateNumbers_UserPrivateNumber, Session)));
            }
            catch (Exception ex)
            {
                ShowMessageBox(ex.Message, string.Empty, "danger");
            }
        }
예제 #10
0
        private void InitializePage()
        {
            btnSave.Text   = Language.GetString(btnSave.Text);
            btnCancel.Text = Language.GetString(btnCancel.Text);

            int       resultCount    = 0;
            DataTable dtTrafficRelay = Facade.TrafficRelay.GetPagedTrafficRelays(UserGuid, "CreateDate", 0, 0, ref resultCount);

            drpSmsTrafficRelay.DataSource     = dtTrafficRelay;
            drpSmsTrafficRelay.DataTextField  = "Url";
            drpSmsTrafficRelay.DataValueField = "Guid";
            drpSmsTrafficRelay.DataBind();
            drpSmsTrafficRelay.Items.Insert(0, new ListItem(string.Empty, string.Empty));

            drpDeliveryTrafficRelay.DataSource     = dtTrafficRelay;
            drpDeliveryTrafficRelay.DataTextField  = "Url";
            drpDeliveryTrafficRelay.DataValueField = "Guid";
            drpDeliveryTrafficRelay.DataBind();
            drpDeliveryTrafficRelay.Items.Insert(0, new ListItem(string.Empty, string.Empty));

            Common.PrivateNumber privateNumber = Facade.PrivateNumber.LoadNumber(PrivateNumberGuid);
            drpSmsTrafficRelay.SelectedValue      = privateNumber.SmsTrafficRelayGuid.ToString();
            drpDeliveryTrafficRelay.SelectedValue = privateNumber.DeliveryTrafficRelayGuid.ToString();
        }
예제 #11
0
        public bool UpdateNumber(Common.PrivateNumber privateNumber)
        {
            bool updateCompleted = false;

            updateCompleted = base.ExecuteSPCommand("UpdateNumber",
                                                    "@Guid", privateNumber.NumberGuid,
                                                    "@Number", privateNumber.Number,
                                                    "@Price", privateNumber.Price,
                                                    "@ServiceID", privateNumber.ServiceID,
                                                    "@MTNServiceId", privateNumber.MTNServiceId,
                                                    "@AggServiceId", privateNumber.AggServiceId,
                                                    "@ServicePrice", privateNumber.ServicePrice,
                                                    "@ExpireDate", privateNumber.ExpireDate,
                                                    "@Type", privateNumber.Type,
                                                    "@Priority", privateNumber.Priority,
                                                    "@ReturnBlackList", privateNumber.ReturnBlackList,
                                                    "@SendToBlackList", privateNumber.SendToBlackList,
                                                    "@CheckFilter", privateNumber.CheckFilter,
                                                    "@DeliveryBase", privateNumber.DeliveryBase,
                                                    "@HasSLA", privateNumber.HasSLA,
                                                    "@TryCount", privateNumber.TryCount,
                                                    "@Range", privateNumber.Range,
                                                    "@Regex", privateNumber.Regex,
                                                    "@UseForm", privateNumber.UseForm,
                                                    "@IsRoot", privateNumber.IsRoot,
                                                    "@IsActive", privateNumber.IsActive,
                                                    "@IsPublic", privateNumber.IsPublic,
                                                    "@SmsSenderAgentGuid", privateNumber.SmsSenderAgentGuid);

            if (updateCompleted)
            {
                OnPrivateNumberChange(privateNumber, null);
            }

            return(updateCompleted);
        }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitializePage();
            }

            Common.FailedOnlinePayment failedOnlinePayment = new Common.FailedOnlinePayment();
            StringBuilder result = new StringBuilder();

            btnReturn.Text = Language.GetString(btnReturn.Text);
            DataTable fishInfo = new DataTable();

            try
            {
                string errorMessage = string.Empty;

                fishInfo = Facade.AccountInformation.GetAccountOfReferenceID(dicParams[OnlinePaymentParams.ReferenceId]);

                if (fishInfo.Rows.Count == 0)
                {
                    throw new Exception();
                }

                switch (Helper.GetInt(Request["bank"]))
                {
                case (int)Banks.Mellat:
                    BehPardakhtMellat behPardakht = new BehPardakhtMellat();

                    //if (dicParams[OnlinePaymentParams.Ip] != behPardakht.GatewayPaymentIP)
                    //	throw new Exception(string.Format("{0},InputIP={1},ValidIp={2}", Language.GetString("IPIsInvalid"), dicParams[OnlinePaymentParams.Ip], behPardakht.GatewayPaymentIP));

                    foreach (BehPardakhtMellat.ResCode resCodeList in Enum.GetValues(typeof(BehPardakhtMellat.ResCode)))
                    {
                        if (Helper.GetInt(dicParams[OnlinePaymentParams.ResCode]) == (int)resCodeList &&
                            resCodeList != (int)BehPardakhtMellat.ResCode.TransactionWasSuccessful)
                        {
                            throw new Exception(Language.GetString(resCodeList.ToString()));
                        }
                    }

                    behPardakht.TerminalID = Helper.GetLong(fishInfo.Rows[0]["TerminalID"]);
                    behPardakht.UserName   = fishInfo.Rows[0]["UserName"].ToString();
                    behPardakht.Password   = fishInfo.Rows[0]["Password"].ToString();
                    behPardakht.OrderID    = Helper.GetLong(dicParams[OnlinePaymentParams.SaleOrderId]);
                    behPardakht.VerifyRequest(Helper.GetLong(dicParams[OnlinePaymentParams.SaleReferenceId]));

                    isPaymentSuccessful = true;

                    break;

                case (int)Banks.Parsian:
                    ParsianPaymentGateway parsian = new ParsianPaymentGateway();

                    if (dicParams[OnlinePaymentParams.status] != ((int)ParsianPaymentGateway.Status.Successful).ToString())
                    {
                        throw new Exception();
                    }

                    parsian.Pin = fishInfo.Rows[0]["PinCode"].ToString();
                    parsian.VerifyRequest(Helper.GetLong(dicParams[OnlinePaymentParams.Token]));
                    dicParams[OnlinePaymentParams.SaleReferenceId] = dicParams[OnlinePaymentParams.RRN].ToString();

                    isPaymentSuccessful = true;

                    break;
                }

                if (!isPaymentSuccessful)
                {
                    throw new Exception();
                }

                if (Helper.GetBool(dicParams[OnlinePaymentParams.IsExtendedPanel]))
                {
                    Facade.Fish.UpdateDescription(Helper.GetGuid(fishInfo.Rows[0]["FishGuid"]), Language.GetString("ExtendedPanel"), FishStatus.Confirmed);
                    if (!Facade.User.UpdateExpireDate(Helper.GetGuid(fishInfo.Rows[0]["UserGuid"]), DateTime.Now.AddYears(1)))
                    {
                        throw new Exception(Language.GetString("ErrorRecord"));
                    }
                }
                else if (Helper.GetBool(dicParams[OnlinePaymentParams.IsExtendedNumber]))
                {
                    Common.PrivateNumber privateNumber = Facade.PrivateNumber.LoadNumber(Helper.GetGuid(fishInfo.Rows[0]["ReferenceGuid"]));
                    Facade.Fish.UpdateDescription(Helper.GetGuid(fishInfo.Rows[0]["FishGuid"]), string.Format("{0}-{1}", Language.GetString("ExtendedNumber"), privateNumber.Number), FishStatus.Confirmed);
                    if (!Facade.PrivateNumber.UpdateExpireDate(privateNumber.NumberGuid, DateTime.Now.AddYears(1)))
                    {
                        throw new Exception(Language.GetString("ErrorRecord"));
                    }
                }
                else if (Helper.GetInt(dicParams[OnlinePaymentParams.SalePackageId]) != 0)
                {
                    Facade.Fish.UpdateDescription(Helper.GetGuid(fishInfo.Rows[0]["FishGuid"]), Language.GetString("BuyPanel"), FishStatus.Confirmed);
                    DataTable dtRole = Facade.Role.GetPackage(Helper.GetInt(dicParams[OnlinePaymentParams.SalePackageId]));
                    Facade.User.UpdateUserRole(Helper.GetGuid(fishInfo.Rows[0]["UserGuid"]), Helper.GetGuid(dtRole.Rows[0]["Guid"]));
                }
                else
                {
                    Facade.Fish.ConfirmOnlineFish(Helper.GetGuid(fishInfo.Rows[0]["UserGuid"]),
                                                  Helper.GetLong(fishInfo.Rows[0]["SmsCount"]),
                                                  TypeCreditChanges.OnlinePayment,
                                                  string.Format(Language.GetString("OnlinePaymentTransaction"), dicParams[OnlinePaymentParams.SaleReferenceId]),
                                                  Helper.GetGuid(fishInfo.Rows[0]["FishGuid"]),
                                                  Helper.GetLong(dicParams[OnlinePaymentParams.SaleReferenceId]));
                }

                lblAmount.Text      = fishInfo.Rows[0]["Amount"].ToString();
                lblBillNumber.Text  = dicParams[OnlinePaymentParams.SaleReferenceId];
                lblDatePayment.Text = DateManager.GetSolarDate(DateTime.Now);

                pnlFailedPayment.Visible     = false;
                pnlSuccessfulPayment.Visible = true;
            }
            catch (Exception ex)
            {
                Log  log         = new Log();
                Guid refenceGuid = fishInfo.Rows.Count > 0 ? Helper.GetGuid(fishInfo.Rows[0]["FishGuid"]) : Guid.Empty;

                log.Type          = (int)LogType.Error;
                log.ReferenceGuid = refenceGuid;
                log.Source        = "RegisterFish";
                log.Name          = "OnlinePayment";
                log.Text          = ex.Message;
                log.CreateDate    = DateTime.Now;
                log.IPAddress     = Request.UserHostAddress;
                log.Browser       = Request.Browser.Browser;
                SQLHelper.InsertLogInfo(log);

                if (refenceGuid != Guid.Empty)
                {
                    Facade.Fish.UpdateDescription(refenceGuid, ex.Message, FishStatus.Rejected);
                }

                pnlSuccessfulPayment.Visible = false;
                pnlFailedPayment.Visible     = true;

                Label1.Text += "//" + ex.Message.ToString();
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Common.PrivateNumber privateNumber = new Common.PrivateNumber();
            try
            {
                Dictionary <string, string> patterns = new Dictionary <string, string>();
                patterns.Add("multiple", @"\b[1-9][0-9]{3,11}\*$");
                patterns.Add("single", @"\b[1-9][0-9]{3,12}\?{1,10}$");
                List <string> lstSampleNumbers = new List <string>();

                privateNumber.NumberGuid         = PrivateNumberGuid;
                privateNumber.SmsSenderAgentGuid = Helper.GetGuid(drpSmsSenderAgent.SelectedValue);
                privateNumber.Type            = Helper.GetInt(drpType.SelectedValue);
                privateNumber.Priority        = Helper.GetInt(drpPriority.SelectedValue);
                privateNumber.IsRoot          = chbIsRoot.Checked;
                privateNumber.IsActive        = chbIsActive.Checked;
                privateNumber.ReturnBlackList = chbReturnBlackList.Checked;
                privateNumber.SendToBlackList = chbSendToBlackList.Checked;
                privateNumber.CheckFilter     = chbCheckFilter.Checked;
                privateNumber.DeliveryBase    = chbDeliveryBase.Checked;
                privateNumber.HasSLA          = chbIsSla.Checked;
                privateNumber.TryCount        = chbIsSla.Checked ? Helper.GetInt(drpTryCount.SelectedValue) : 0;
                privateNumber.IsPublic        = chbIsPublic.Checked;
                privateNumber.CreateDate      = DateTime.Now;
                var dateTime = dtpExpireDate.FullDateTime;
                if (Session["Language"].ToString() == "fa")
                {
                    privateNumber.ExpireDate = DateManager.GetChristianDateTimeForDB(dateTime);
                }
                else
                {
                    privateNumber.ExpireDate = DateTime.Parse(dateTime);
                }
                //privateNumber.ExpireDate = DateManager.GetChristianDateTimeForDB(dtpExpireDate.FullDateTime);
                privateNumber.UserGuid   = UserGuid;
                privateNumber.ParentGuid = Guid.Empty;
                privateNumber.OwnerGuid  = ParentGuid == Guid.Empty ? UserGuid : ParentGuid;
                privateNumber.Price      = Helper.GetDecimal(txtPrice.Text);

                switch (Helper.GetInt(drpUseForm.SelectedValue))
                {
                case (int)PrivateNumberUseForm.OneNumber:
                    if (Helper.GetLong(txtNumber.Text) == 0)
                    {
                        throw new Exception("InvalidNumber");
                    }

                    privateNumber.UseForm = (int)PrivateNumberUseForm.OneNumber;
                    privateNumber.Number  = Helper.GetLocalPrivateNumber(txtNumber.Text);
                    privateNumber.Range   = privateNumber.Number;
                    privateNumber.Regex   = string.Format(@"(^|\s){0}(\s|$)", privateNumber.Number);
                    lstSampleNumbers.Add(privateNumber.Number);
                    if (!Facade.PrivateNumber.IsValidRange(lstSampleNumbers, privateNumber.Regex, privateNumber.NumberGuid, UserGuid))
                    {
                        throw new Exception(Language.GetString("DuplicateRange"));
                    }
                    break;

                case (int)PrivateNumberUseForm.Mask:
                    privateNumber.UseForm = (int)PrivateNumberUseForm.Mask;
                    privateNumber.Number  = txtMask.Text;
                    privateNumber.Range   = privateNumber.Number;
                    privateNumber.Regex   = string.Format(@"(^|\s){0}(\s|$)", privateNumber.Number);
                    lstSampleNumbers.Add(privateNumber.Number);
                    if (!Facade.PrivateNumber.IsValidRange(lstSampleNumbers, privateNumber.Regex, privateNumber.NumberGuid, UserGuid))
                    {
                        throw new Exception(Language.GetString("DuplicateRange"));
                    }
                    break;

                case (int)PrivateNumberUseForm.RangeNumber:
                    privateNumber.UseForm = (int)PrivateNumberUseForm.RangeNumber;
                    privateNumber.Range   = txtRange.Text;
                    bool   rangeIsValid = false;
                    int    count;
                    string sampleNumber = string.Empty;

                    if (Regex.IsMatch(txtRange.Text, patterns["multiple"]))
                    {
                        count = txtRange.Text.Substring(0, txtRange.Text.IndexOf('*')).ToCharArray().Length;
                        string number = txtRange.Text.Substring(0, txtRange.Text.IndexOf('*'));
                        lstSampleNumbers.Add(number);
                        for (int counter = 1; counter <= (14 - count); counter++)
                        {
                            sampleNumber += "0";
                            lstSampleNumbers.Add(number + sampleNumber);
                        }

                        privateNumber.Regex = @"(^|\s)" + txtRange.Text.Substring(0, txtRange.Text.IndexOf('*')) + "[0-9]{0," + (14 - count) + @"}(\s|$)";
                        rangeIsValid        = true;
                    }
                    if (Regex.IsMatch(txtRange.Text, patterns["single"]))
                    {
                        count = txtRange.Text.ToCharArray().Where(ch => ch == '?').Count();
                        string number = txtRange.Text.Substring(0, txtRange.Text.IndexOf('?'));
                        lstSampleNumbers.Add(number);
                        for (int counter = 1; counter <= count; counter++)
                        {
                            sampleNumber += "0";
                            lstSampleNumbers.Add(number + sampleNumber);
                        }

                        privateNumber.Regex = @"(^|\s)" + txtRange.Text.Substring(0, txtRange.Text.IndexOf('?')) + "[0-9]{" + count + @"}(\s|$)";
                        rangeIsValid        = true;
                    }

                    if (!rangeIsValid)
                    {
                        throw new Exception(Language.GetString("InvalidRange"));
                    }

                    if (!Facade.PrivateNumber.IsValidRange(lstSampleNumbers, privateNumber.Regex, privateNumber.NumberGuid, UserGuid))
                    {
                        throw new Exception(Language.GetString("DuplicateRange"));
                    }

                    break;
                }

                switch (privateNumber.Type)
                {
                case (int)TypePrivateNumberAccesses.Bulk:
                    privateNumber.ServiceID    = string.Empty;
                    privateNumber.MTNServiceId = string.Empty;
                    privateNumber.AggServiceId = string.Empty;
                    privateNumber.ServicePrice = 0;
                    break;

                default:
                    privateNumber.ServiceID    = txtServiceID.Text;
                    privateNumber.MTNServiceId = txtMTNServiceID.Text;
                    privateNumber.AggServiceId = txtAggServiceID.Text;
                    privateNumber.ServicePrice = Helper.GetDecimal(txtServicePrice.Text);
                    break;
                }

                if (privateNumber.HasError)
                {
                    throw new Exception(privateNumber.ErrorMessage);
                }

                switch (ActionType.ToLower())
                {
                case "edit":
                    if (!Facade.PrivateNumber.UpdateNumber(privateNumber))
                    {
                        throw new Exception("ErrorRecord");
                    }

                    break;

                case "insert":
                    if (!Facade.PrivateNumber.Insert(privateNumber))
                    {
                        throw new Exception("ErrorRecord");
                    }

                    break;
                }
                Response.Redirect(string.Format("/PageLoader.aspx?c={0}", Helper.Encrypt((int)UserControls.UI_PrivateNumbers_DefiningPrivateNumber, Session)));
            }
            catch (Exception ex)
            {
                ShowMessageBox(Language.GetString(ex.Message), string.Empty, "danger");
            }
        }
예제 #14
0
 public static bool UpdateTrafficRelay(Common.PrivateNumber privateNumber)
 {
     Business.PrivateNumber privateNumberController = new Business.PrivateNumber();
     return(privateNumberController.UpdateTrafficRelay(privateNumber));
 }
        private void InitializePage()
        {
            if (!IsMainAdmin)
            {
                return;
            }

            drpSmsSenderAgent.DataSource     = Facade.SmsSenderAgent.GetUserAgents(UserGuid);
            drpSmsSenderAgent.DataTextField  = "Name";
            drpSmsSenderAgent.DataValueField = "Guid";
            drpSmsSenderAgent.DataBind();

            foreach (TypePrivateNumberAccesses type in Enum.GetValues(typeof(TypePrivateNumberAccesses)))
            {
                drpType.Items.Add(new ListItem(type.ToString(), ((int)type).ToString()));
            }

            foreach (SendPriority priority in Enum.GetValues(typeof(SendPriority)))
            {
                drpPriority.Items.Add(new ListItem(priority.ToString(), ((int)priority).ToString()));
            }
            drpPriority.SelectedValue = Helper.GetString((int)SendPriority.Normal);

            foreach (PrivateNumberUseForm useForm in Enum.GetValues(typeof(PrivateNumberUseForm)))
            {
                drpUseForm.Items.Add(new ListItem(Language.GetString(useForm.ToString()), ((int)useForm).ToString()));
            }

            if (Session["Language"].ToString() == "fa")
            {
                dtpExpireDate.Value = DateManager.GetSolarDate(DateTime.Now.AddYears(1));
            }
            else
            {
                dtpExpireDate.Value = DateTime.Now.AddYears(1).ToShortDateString();
            }

            //dtpExpireDate.Value = DateManager.GetSolarDate(DateTime.Now.AddYears(1));

            if (ActionType.ToLower() == "edit")
            {
                Common.PrivateNumber privateNumber = Facade.PrivateNumber.LoadNumber(PrivateNumberGuid);
                drpSmsSenderAgent.SelectedValue = Helper.GetString(privateNumber.SmsSenderAgentGuid);
                drpType.SelectedValue           = Helper.GetString(privateNumber.Type);
                drpPriority.SelectedValue       = privateNumber.Priority.ToString();
                chbIsRoot.Checked          = privateNumber.IsRoot;
                chbIsActive.Checked        = privateNumber.IsActive;
                chbReturnBlackList.Checked = privateNumber.ReturnBlackList;
                chbSendToBlackList.Checked = privateNumber.SendToBlackList;
                chbCheckFilter.Checked     = privateNumber.CheckFilter;
                chbDeliveryBase.Checked    = privateNumber.DeliveryBase;
                chbIsSla.Checked           = privateNumber.HasSLA;
                drpTryCount.SelectedValue  = privateNumber.TryCount.ToString();
                chbIsPublic.Checked        = privateNumber.IsPublic;
                txtServiceID.Text          = privateNumber.ServiceID;
                txtMTNServiceID.Text       = privateNumber.MTNServiceId;
                txtAggServiceID.Text       = privateNumber.AggServiceId;
                txtServicePrice.Text       = Helper.FormatDecimalForDisplay(privateNumber.ServicePrice);
                dtpExpireDate.Value        = privateNumber.ExpireDate != DateTime.MinValue ? DateManager.GetSolarDate(privateNumber.ExpireDate) : string.Empty;
                txtPrice.Text = Helper.FormatDecimalForDisplay(privateNumber.Price);

                switch (privateNumber.UseForm)
                {
                case (int)PrivateNumberUseForm.OneNumber:
                    txtNumber.Text           = privateNumber.Number;
                    drpUseForm.SelectedValue = Helper.GetString((int)PrivateNumberUseForm.OneNumber);
                    break;

                case (int)PrivateNumberUseForm.Mask:
                    txtMask.Text             = privateNumber.Number;
                    drpUseForm.SelectedValue = Helper.GetString((int)PrivateNumberUseForm.Mask);
                    break;

                case (int)PrivateNumberUseForm.RangeNumber:
                    txtRange.Text            = privateNumber.Range;
                    drpUseForm.SelectedValue = Helper.GetString((int)PrivateNumberUseForm.RangeNumber);
                    break;
                }
            }

            btnSave.Text   = Language.GetString(btnSave.Text);
            btnCancel.Text = Language.GetString(btnCancel.Text);
            btnSave.Attributes["onclick"] = "return checkValidation();";
        }
예제 #16
0
 public static bool Insert(Common.PrivateNumber privateNumber)
 {
     Business.PrivateNumber privateNumberController = new Business.PrivateNumber();
     return(privateNumberController.InsertNumber(privateNumber) != Guid.Empty ? true : false);
 }
예제 #17
0
 public static bool AssignSubRangeNumberToUser(Common.PrivateNumber privateNumber, string keyword)
 {
     Business.PrivateNumber privateNumberController = new Business.PrivateNumber();
     return(privateNumberController.AssignSubRangeNumberToUser(privateNumber, keyword));
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Common.PrivateNumber savePrivateNumber = new Common.PrivateNumber();

                string   selectedNumber = drpNumber.SelectedValue;
                int      numberType     = Helper.GetInt(selectedNumber.Split(';')[0]);
                Guid     numberGuid     = Helper.GetGuid(selectedNumber.Split(';')[1]);
                string   keyword        = txtKeyword.Text.Trim();
                decimal  price          = Helper.GetDecimal(txtPrice.Text);
                var      dateTime       = dtpExpireDate.FullDateTime;
                DateTime expireDate     = new DateTime();
                if (Session["Language"].ToString() == "fa")
                {
                    expireDate = DateManager.GetChristianDateTimeForDB(dateTime);
                }
                else
                {
                    expireDate = DateTime.Parse(dateTime);
                }
                //DateTime expireDate = DateManager.GetChristianDateTimeForDB(dtpExpireDate.FullDateTime);

                Common.PrivateNumber privateNumber = Facade.PrivateNumber.LoadNumber(numberGuid);

                Dictionary <string, string> patterns = new Dictionary <string, string>();
                patterns.Add("multiple", @"\b[1-9][0-9]{3,11}\*$");
                patterns.Add("single", @"\b[1-9][0-9]{3,12}\?{1,10}$");

                switch (numberType)
                {
                case (int)PrivateNumberUseForm.OneNumber:
                case (int)PrivateNumberUseForm.Mask:
                    if (!Facade.PrivateNumber.AssignNumberToUser(numberGuid, UserGuid, keyword, price, expireDate))
                    {
                        throw new Exception("ErrorRecord");
                    }
                    break;

                case (int)PrivateNumberUseForm.RangeNumber:
                    bool   rangeIsValid = false;
                    int    count;
                    string sampleNumber = string.Empty;
                    string regex        = string.Empty;

                    if (txtRange.Text == privateNumber.Number)
                    {
                        if (!Facade.PrivateNumber.AssignNumberToUser(numberGuid, UserGuid, keyword, price, expireDate))
                        {
                            throw new Exception("ErrorRecord");
                        }
                    }
                    else if (txtRange.Text == privateNumber.Range)
                    {
                        if (!Facade.PrivateNumber.AssignRangeNumberToUser(numberGuid, UserGuid, price, expireDate))
                        {
                            throw new Exception("ErrorRecord");
                        }
                    }
                    else
                    {
                        savePrivateNumber.Price      = price;
                        savePrivateNumber.ExpireDate = expireDate;
                        if (Regex.IsMatch(txtRange.Text, patterns["multiple"]))
                        {
                            count = txtRange.Text.Substring(0, txtRange.Text.IndexOf('*')).ToCharArray().Length;
                            for (int counter = 1; counter <= (14 - count); counter++)
                            {
                                sampleNumber += "0";
                            }

                            sampleNumber = txtRange.Text.Substring(0, txtRange.Text.IndexOf('*')) + sampleNumber;

                            regex = @"(^|\s)" + txtRange.Text.Substring(0, txtRange.Text.IndexOf('*')) + "[0-9]{0," + (14 - count) + @"}(\s|$)";
                            if (Regex.IsMatch(sampleNumber, privateNumber.Regex) && Regex.IsMatch(sampleNumber, regex))
                            {
                                rangeIsValid                 = true;
                                savePrivateNumber.Number     = string.Empty;
                                savePrivateNumber.Range      = txtRange.Text;
                                savePrivateNumber.Regex      = regex;
                                savePrivateNumber.ParentGuid = numberGuid;
                                savePrivateNumber.OwnerGuid  = UserGuid;
                                keyword = string.Empty;
                            }
                        }
                        else if (Regex.IsMatch(txtRange.Text, patterns["single"]))
                        {
                            count = txtRange.Text.ToCharArray().Where(ch => ch == '?').Count();
                            for (int counter = 1; counter <= count; counter++)
                            {
                                sampleNumber += "0";
                            }

                            sampleNumber = txtRange.Text.Substring(0, txtRange.Text.IndexOf('?')) + sampleNumber;

                            regex = @"(^|\s)" + txtRange.Text.Substring(0, txtRange.Text.IndexOf('?')) + "[0-9]{" + count + @"}(\s|$)";
                            if (Regex.IsMatch(sampleNumber, privateNumber.Regex) && Regex.IsMatch(sampleNumber, regex))
                            {
                                rangeIsValid                 = true;
                                savePrivateNumber.Number     = string.Empty;
                                savePrivateNumber.Range      = txtRange.Text;
                                savePrivateNumber.Regex      = regex;
                                savePrivateNumber.ParentGuid = numberGuid;
                                savePrivateNumber.OwnerGuid  = UserGuid;
                                keyword = string.Empty;
                            }
                        }
                        else if (Regex.IsMatch(txtRange.Text, privateNumber.Regex))
                        {
                            sampleNumber                 = txtRange.Text;
                            rangeIsValid                 = true;
                            savePrivateNumber.Number     = txtRange.Text;
                            savePrivateNumber.Range      = txtRange.Text;
                            savePrivateNumber.Regex      = regex = string.Format(@"(^|\s){0}(\s|$)", txtRange.Text);
                            savePrivateNumber.ParentGuid = numberGuid;
                            savePrivateNumber.OwnerGuid  = UserGuid;
                            keyword = txtKeyword.Text;
                        }

                        if (!rangeIsValid)
                        {
                            throw new Exception(Language.GetString("InvalidRange"));
                        }

                        if (!Facade.PrivateNumber.IsValidSubRange(sampleNumber, numberGuid, regex, keyword))
                        {
                            throw new Exception(Language.GetString("DuplicateRange"));
                        }

                        if (!Facade.PrivateNumber.AssignSubRangeNumberToUser(savePrivateNumber, keyword))
                        {
                            throw new Exception("ErrorRecord");
                        }
                    }
                    break;
                }
                Response.Redirect(string.Format("/PageLoader.aspx?c={0}&UserGuid={1}", Helper.Encrypt((int)Arad.SMS.Gateway.Business.UserControls.UI_PrivateNumbers_AssignPrivateNumberToUsers, Session), UserGuid));
            }
            catch (Exception ex)
            {
                ClientSideScript = string.Format("saveFailed('{0}');", Language.GetString(ex.Message));
            }
        }
예제 #19
0
        public static decimal GetSendFormatPrice(Guid userGuid, Guid formatGuid, Guid privateNumberGuid, ref string numbersInfo)
        {
            decimal smsPrice = 0;
            int     recipientCount;

            DataTable dtOperators = Operator.GetOperators();

            Common.PrivateNumber       privateNumber        = PrivateNumber.LoadNumber(privateNumberGuid);
            List <DataRow>             lstOperatorRatio     = SmsSenderAgent.GetAgentRatio(privateNumber.SmsSenderAgentGuid).AsEnumerable().ToList();
            Dictionary <Guid, decimal> dictionaryAgentRatio = GroupPrice.GetAgentRatio(userGuid);

            List <DataRow>        lstInfo             = SmsFormat.GetFormatSmsInfo(formatGuid).AsEnumerable().ToList();
            Dictionary <int, int> operatorNumberCount = new Dictionary <int, int>();

            int countUnicode = 0;
            int countLatin   = 0;

            int mciCount   = 0;
            int mtnCount   = 0;
            int otherCount = 0;

            if (privateNumber.Type == (int)TypePrivateNumberAccesses.Bulk)
            {
                foreach (DataRow opt in dtOperators.Rows)
                {
                    operatorNumberCount.Add(Helper.GetInt(opt["ID"]), lstInfo.Where(row => Helper.GetInt(row["Operator"]) == Helper.GetInt(opt["ID"])).Select(row => Helper.GetInt(row["Count"])).Sum());

                    countUnicode = lstInfo.Where(row => Helper.GetInt(row["Operator"]) == Helper.GetInt(opt["ID"]) &&
                                                 Helper.GetInt(row["Encoding"]) == 1).Select(row => Helper.GetInt(row["SmsPartCount"]) * Helper.GetInt(row["Count"])).Sum();

                    smsPrice += countUnicode * GetOperatorRatio(lstOperatorRatio, Helper.GetInt(opt["ID"]), SmsTypes.Farsi);

                    countLatin = lstInfo.Where(row => Helper.GetInt(row["Operator"]) == Helper.GetInt(opt["ID"]) &&
                                               Helper.GetInt(row["Encoding"]) == 0).Select(row => Helper.GetInt(row["SmsPartCount"]) * Helper.GetInt(row["Count"])).Sum();

                    smsPrice += countLatin * GetOperatorRatio(lstOperatorRatio, Helper.GetInt(opt["ID"]), SmsTypes.Latin);

                    if (Helper.GetInt(opt["ID"]) == 1)                    //MCI
                    {
                        mciCount = countUnicode + countLatin;
                    }
                    else if (Helper.GetInt(opt["ID"]) == 2)                    //MTN
                    {
                        mtnCount = countUnicode + countLatin;
                    }
                    else
                    {
                        otherCount += countUnicode + countLatin;
                    }
                }
            }
            else
            {
                foreach (DataRow opt in dtOperators.Rows)
                {
                    operatorNumberCount.Add(Helper.GetInt(opt["ID"]), lstInfo.Where(row => Helper.GetInt(row["Operator"]) == Helper.GetInt(opt["ID"])).Select(row => Helper.GetInt(row["Count"])).Sum());

                    countUnicode = lstInfo.Where(row => Helper.GetInt(row["Operator"]) == Helper.GetInt(opt["ID"]) &&
                                                 Helper.GetInt(row["Encoding"]) == 1).Select(row => Helper.GetInt(row["Count"])).Sum();

                    smsPrice += countUnicode * GetOperatorRatio(lstOperatorRatio, Helper.GetInt(opt["ID"]), SmsTypes.Farsi);

                    countLatin = lstInfo.Where(row => Helper.GetInt(row["Operator"]) == Helper.GetInt(opt["ID"]) &&
                                               Helper.GetInt(row["Encoding"]) == 0).Select(row => Helper.GetInt(row["Count"])).Sum();

                    smsPrice += countLatin * GetOperatorRatio(lstOperatorRatio, Helper.GetInt(opt["ID"]), SmsTypes.Latin);

                    if (Helper.GetInt(opt["ID"]) == 1)                    //MCI
                    {
                        mciCount = countUnicode + countLatin;
                    }
                    else if (Helper.GetInt(opt["ID"]) == 2)                    //MTN
                    {
                        mtnCount = countUnicode + countLatin;
                    }
                    else
                    {
                        otherCount += countUnicode + countLatin;
                    }
                }
            }

            smsPrice *= dictionaryAgentRatio.ContainsKey(privateNumber.SmsSenderAgentGuid) ? Helper.GetDecimal(dictionaryAgentRatio[privateNumber.SmsSenderAgentGuid]) : 1;

            recipientCount = lstInfo.Select(row => Helper.GetInt(row["Count"])).Sum();

            int totalCount = mciCount + mtnCount + otherCount;

            numbersInfo = "RecipientCount{(" + recipientCount + ")}TotalCount{(" + totalCount + ")}MCI{(" + mciCount + ")}MTN{(" + mtnCount + ")}Other{(" + otherCount + ")}Price{(" + smsPrice + ")}";

            return(smsPrice);
        }