private void LoadSmslogs()
    {
        MultiView2.ActiveViewIndex = 0;
        string   vendorCode = ddlAreas.SelectedValue.ToString();
        string   phone      = phone_validity.Format(ddlPhone.Text);
        string   status     = ddlStatus.SelectedValue;
        DateTime from       = Process_file.ReturnDate(txtstartdate.Text.Trim(), 1);
        DateTime end        = Process_file.ReturnDate(txtenddate.Text.Trim(), 2);

        if (phone != "" && !phone_validity.NumberFormatIsValid(phone))
        {
            ShowMessage("Please Enter A valid Phone Number", true);
            txtstartdate.Focus();
        }
        else if (txtstartdate.Text.Equals(""))
        {
            ShowMessage("Please Enter Start Date for your Search", true);
            txtstartdate.Focus();
        }
        else
        {
            //get the SMS Report from SMS Client
            data_table           = data_file.GetSmsReportFromSMSClientDb(vendorCode, phone, status, from, end);
            DataGrid1.DataSource = data_table;
            DataGrid1.DataBind();

            Session["ResultTable"] = data_table;

            ShowMessage("Found [" + data_table.Rows.Count + "] Records", false);


            //old logic for getting vendor SMSs

            /*
             * data_table = data_file.GetArea(vendorCode);
             * if (data_table.Rows[0]["VendorType"].ToString().ToUpper() == "POSTPAID")
             * {
             *  data_table = data_file.GetPostPaidSMS(vendorCode, phone,status, from, end);
             *  DataGrid1.DataSource = data_table;
             *  DataGrid1.DataBind();
             *  ShowMessage("Found ["+data_table.Rows.Count+"] Records", false);
             * }
             * else if (data_table.Rows[0]["VendorType"].ToString().ToUpper() == "PREPAID")
             * {
             *  data_table = data_file.GetPrePaidSMS(vendorCode, phone,status, from, end);
             *  DataGrid1.DataSource = data_table;
             *  DataGrid1.DataBind();
             *  ShowMessage("Please Enter Start Date for your Search", true);
             *  ShowMessage("Found [" + data_table.Rows.Count + "] Records", false);
             * }
             * else
             * {
             *  ShowMessage("Vendor Details Not Found", true);
             * }
             */
        }
    }
Esempio n. 2
0
    public string LogSMS(string list_code, string prefix, string message, string otherPhones, string areaID)
    {
        string output = "";

        phone_validator = new PhoneValidator();
        int list_id = int.Parse(list_code);

        string[] ArrayPhones = otherPhones.Split(',');
        data_table = data_file.GetActiveListNumbers(list_id);

        if ((data_table.Rows.Count > 0) || (ArrayPhones.Length > 0))
        {
            string user  = HttpContext.Current.Session["Username"].ToString();
            string mask  = HttpContext.Current.Session["Mask"].ToString();
            int    i     = 0;
            int    count = 0;
            foreach (DataRow dr in data_table.Rows)
            {
                string phone = phone_validator.Format(dr["PhoneNumber"].ToString().Trim());
                string name  = dr["PhoneName"].ToString();
                string msg   = GetformatMessage(phone, name, prefix, message);
                data_file.InsertSmsToSend(phone, msg, mask, user, areaID);
                count++;

                Reduct_credit(list_id, message, mask, user, phone);
            }
            if (count > 0)
            {
                i = 1;
            }

            for (; i < ArrayPhones.Length; i++, count++)
            {
                string phone = phone_validator.Format(ArrayPhones[i].ToString().Trim());
                string msg   = GetformatMessage(phone, "", prefix, message);
                data_file.InsertSmsToSend(phone, msg, mask, user, areaID);

                Reduct_creditforOtherPhones(ArrayPhones, message, mask, user, "YES");
            }

            output = "A list of " + count + " has been logged Successfully";
        }
        else
        {
            output = "No Active Phone number(s) on list";
        }
        return(output);
    }
    private void UploadNumbers(string phone)
    {
        if (!FileUpload1.FileName.Trim().Equals(""))
        {
            ReadFile();
        }
        else
        {
            string name      = txtName.Text.Trim();
            string list_code = ddllists.SelectedValue.ToString();
            if (phone_validity.NumberFormatIsValid(phone))
            {
                string phoneNum = phone_validity.Format(phone);
                Process_file.SavePhoneNumber(phoneNum, name, list_code);

                txtName.Text        = "";
                txtPhoneNumber.Text = "";
                ShowMessage(phone + " Add to " + ddllists.SelectedItem.ToString() + "  Successfully", false);
            }
            else
            {
                ShowMessage(phone + " is not a valid Phone Number", true);
            }
        }
    }
    public string LogSMSCommaSeparatedList(string[] phonesArr, string message, string VendorCode, string mask)
    {
        var output = "";

        _phoneValidator = new PhoneValidator();

        var arrayPhones = phonesArr;

        //List has phone numbers
        if (arrayPhones.Length > 0)
        {
            var user = HttpContext.Current.Session["Username"].ToString();
            //var mask = HttpContext.Current.Session["Mask"].ToString();
            var mail      = HttpContext.Current.Session["Email"].ToString();
            int smscredit = GetUserCredit(VendorCode, user);
            if (arrayPhones.Length < smscredit)
            {
                string reduce = Reduct_credit(arrayPhones.Length);
                if (reduce == "SAVED")
                {
                    for (var i = 0; i < arrayPhones.Length; i++)
                    {
                        if (_phoneValidator.NumberFormatIsValid(arrayPhones[i].Trim()))
                        {
                            var phone = _phoneValidator.Format(arrayPhones[i].Trim());
                            _db.InsertSmsToSend(phone, message, mask, user, VendorCode);
                            output += "SMS to Phone Number" + arrayPhones[i].Trim() + " logged Successfully <br/>";
                        }
                        else
                        {
                            output += "Invalid Number " + arrayPhones[i].Trim() + " Was Provided and not processed <br/>";
                        }
                    }
                }
            }
            else
            {
                output = "Dear customer, Your Current SMS Limit is too low to send these SMS(s)";
            }
        }
        else
        {
            output = "No Active Phone number(s) Entered";
        }

        return(output);
    }
Esempio n. 5
0
    private int GetOtherPhonesinDetails(string[] OtherPhones, string indicator)
    {
        int x = 0;

        if (indicator.Equals("YES"))
        {
            x = 1;
        }
        int TotalCost = 0;

        for (; x < OtherPhones.Length; x++)
        {
            string Phone       = phone_validator.Format(OtherPhones[x].ToString());
            string NetworkCode = Phone.Substring(1, 3);
            int    Tarrif      = data_file.GetParticularTarrifWithCode(NetworkCode);
            TotalCost += Tarrif;
        }
        return(TotalCost);
    }