Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Common.User user = new Common.User();
                user.UserGuid               = UserGuid;
                user.FirstName              = txtFirstName.Text;
                user.LastName               = txtLastName.Text;
                user.FatherName             = txtFatherName.Text;
                user.NationalCode           = txtNationalCode.Text;
                user.ShCode                 = txtShCode.Text;
                user.Email                  = txtEmail.Text;
                user.Phone                  = txtPhone.Text;
                user.Mobile                 = Helper.GetLocalMobileNumber(txtMobile.Text);
                user.Address                = txtAddress.Text;
                user.BirthDate              = DateManager.GetChristianDateForDB(dtpBirthDate.Value);
                user.FaxNumber              = txtFax.Text;
                user.ZoneGuid               = Helper.GetGuid(drpCity.SelectedValue);
                user.ZipCode                = txtZipCode.Text;
                user.Type                   = userType;
                user.CompanyName            = txtCompanyName.Text;
                user.CompanyNationalId      = txtCompanyNationalID.Text;
                user.EconomicCode           = txtEconomicCode.Text;
                user.CompanyCEOName         = txtCompanyCEOName.Text;
                user.CompanyCEONationalCode = txtCompanyCEONationalCode.Text;
                user.CompanyCEOMobile       = Helper.GetLocalMobileNumber(txtCompanyCEOMobile.Text);
                user.CompanyPhone           = txtCompanyPhone.Text;
                user.CompanyZipCode         = txtCompanyZipCode.Text;
                user.CompanyAddress         = txtCompanyAddress.Text;

                //if (Helper.IsCellPhone(user.Mobile) != 1)
                //	throw new Exception(Language.GetString("InvalidMobile"));

                if (!Facade.User.UpdateProfile(user))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                if (EditUser)
                {
                    Response.Redirect(string.Format("/PageLoader.aspx?c={0}", Helper.Encrypt((int)Arad.SMS.Gateway.Business.UserControls.UI_Users_User, Session)));
                }
                else
                {
                    ClientSideScript = string.Format("result('ok','{0}');", Language.GetString("InsertRecord"));
                }
            }
            catch (Exception ex)
            {
                ClientSideScript = string.Format("result('error','{0}');", ex.Message);
            }
        }
Beispiel #2
0
        protected void btnSavePanelInfo_Click(object sender, EventArgs e)
        {
            Common.User user = new Common.User();

            try
            {
                if (!Facade.User.CheckUserNameValid(txtUserName.Text, Guid.Empty))
                {
                    throw new Exception(Language.GetString("UserNameIsDuplicate"));
                }

                user.UserName        = txtUserName.Text;
                hdnUserName.Value    = user.UserName;
                hdnPassword.Value    = Helper.Encrypt(txtPassword.Text);
                user.Password        = txtUserPassword.Text;
                user.ParentGuid      = Facade.User.GetGuidOfParent(UserGuid, DomainName);
                user.RoleGuid        = Helper.GetGuid(drpRole.SelectedValue);
                user.PriceGroupGuid  = Helper.GetGuid(drpGroupPrice.SelectedValue);
                user.IsFixPriceGroup = chbIsFixGroupPrice.Checked;
                user.IsActive        = chbIsActive.Checked;
                if (Session["Language"].ToString() == "fa")
                {
                    user.ExpireDate = DateManager.GetChristianDateForDB(dtpExpireDate.Value);
                }
                else
                {
                    user.ExpireDate = Convert.ToDateTime(dtpExpireDate.Value);
                }
                user.IsAdmin             = true;
                user.MaximumAdmin        = Helper.GetInt(txtMaximumAdmin.Text);
                user.MaximumUser         = Helper.GetInt(txtMaximumUser.Text);
                user.MaximumEmailAddress = -1;
                user.MaximumPhoneNumber  = -1;
                user.PanelPrice          = Helper.GetDecimal(txtPanelPrice.Text);
                user.DomainGuid          = Facade.Domain.GetDomainGuid(DomainName);

                Guid createdUserGuid = Facade.User.InsertAccount(user);
                if (createdUserGuid == Guid.Empty)
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                hdnCreatedUserGuid.Value = createdUserGuid.ToString();
                btnSavePanelInfo.Enabled = false;
                ClientSideScript         = string.Format("result('step1','','OK','{0}');", Language.GetString("InsertRecord"));
            }
            catch (Exception ex)
            {
                ClientSideScript = string.Format("result('step1','','Error','{0}');", ex.Message);
            }
        }
Beispiel #3
0
        protected void btnSaveProfile_Click(object sender, EventArgs e)
        {
            Common.User user = new Common.User();
            try
            {
                user.UserGuid               = Helper.GetGuid(hdnCreatedUserGuid.Value);
                user.FirstName              = txtFirstName.Text;
                user.LastName               = txtLastName.Text;
                user.FatherName             = txtFatherName.Text;
                user.NationalCode           = txtNationalCode.Text;
                user.ShCode                 = txtShCode.Text;
                user.BirthDate              = DateManager.GetChristianDateForDB(dtpBirthDate.Value);
                user.Email                  = txtEmail.Text;
                user.Mobile                 = Helper.GetLocalMobileNumber(txtMobile.Text);
                user.Phone                  = txtPhone.Text;
                user.FaxNumber              = txtFax.Text;
                user.ZoneGuid               = Helper.GetGuid(drpCity.SelectedValue);
                user.ZipCode                = txtZipCode.Text;
                user.Address                = txtAddress.Text;
                user.Type                   = Helper.GetInt(hdnUserType.Value);
                user.CompanyName            = txtCompanyName.Text;
                user.CompanyNationalId      = txtCompanyNationalID.Text;
                user.EconomicCode           = txtEconomicCode.Text;
                user.CompanyCEOName         = txtCompanyCEOName.Text;
                user.CompanyCEONationalCode = txtCompanyCEONationalCode.Text;
                user.CompanyCEOMobile       = Helper.GetLocalMobileNumber(txtCompanyCEOMobile.Text);
                user.CompanyPhone           = txtCompanyPhone.Text;
                user.CompanyZipCode         = txtCompanyZipCode.Text;
                user.CompanyAddress         = txtCompanyAddress.Text;

                if (Helper.IsCellPhone(user.Mobile) == 0)
                {
                    throw new Exception(Language.GetString("InvalidMobile"));
                }

                if (!Facade.User.UpdateProfile(user))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                Facade.User.SendUserAccountInfo(Helper.Decrypt(hdnPassword.Value), DomainName, user.UserGuid);

                Response.Redirect(string.Format("/PageLoader.aspx?c={0}", Helper.Encrypt((int)UserControls.UI_Users_User, Session)));
            }
            catch (Exception ex)
            {
                ClientSideScript = string.Format("result('step2','{0}','Error','{1}');", Helper.GetInt(hdnUserType.Value) == 1 ? "actual" : "legal", ex.Message);
            }
        }
Beispiel #4
0
        protected void btnSaveFishPayment_Click(object sender, EventArgs e)
        {
            bool decreaseTax = true;

            Common.Fish fish = new Common.Fish();
            try
            {
                decimal basePrice = Facade.GroupPrice.GetUserBaseSmsPrice(UserGuid, ParentGuid, Helper.GetLong(txtSmsCount.Text), ref decreaseTax);
                decimal tax       = 0;
                if (decreaseTax)
                {
                    tax = Facade.Transaction.ComputeTax(Helper.GetDecimal(basePrice * Helper.GetInt(txtSmsCount.Text)));
                }

                fish.CreateDate             = DateTime.Now;
                fish.BillNumber             = txtSerialNumber.Text;
                fish.SmsCount               = Helper.GetLong(txtSmsCount.Text);
                fish.Amount                 = Helper.GetDecimal(txtAccountAmount.Text);
                fish.PaymentDate            = DateManager.GetChristianDateForDB(dtpPaymentDate.Value);
                fish.Description            = txtDescription.Text;
                fish.Type                   = (int)TypeFish.Account;
                fish.Status                 = (int)FishStatus.Checking;
                fish.AccountInformationGuid = Helper.GetGuid(drpAccount.SelectedValue);
                fish.UserGuid               = UserGuid;

                if (!Facade.Fish.InsertFishPayment(fish))
                {
                    throw new Exception(Language.GetString("InsertRecord"));
                }

                ClientSideScript = string.Format("saveResult('account','ok','{0}')", Language.GetString("InsertRecord"));
            }
            catch (Exception ex)
            {
                ClientSideScript = string.Format("saveResult('account','error','{0}')", ex.Message);
            }
        }
        private void SetCustomFieldValue(Common.PhoneNumber phoneNumber, int customFieldId, string value, UserFieldTypes userFieldTypes)
        {
            try
            {
                DateTime date;
                switch (userFieldTypes)
                {
                case UserFieldTypes.Number:
                    if (!Helper.CheckDataConditions(value).IsIntNumber)
                    {
                        throw new Exception();
                    }
                    break;

                case UserFieldTypes.DateTime:
                    date = DateManager.GetChristianDateForDB(value);
                    if (date != DateTime.MinValue)
                    {
                        value = date.ToString();
                    }
                    break;
                }

                switch (customFieldId)
                {
                case 1:
                    phoneNumber.F1 = value;
                    break;

                case 2:
                    phoneNumber.F2 = value;
                    break;

                case 3:
                    phoneNumber.F3 = value;
                    break;

                case 4:
                    phoneNumber.F4 = value;
                    break;

                case 5:
                    phoneNumber.F5 = value;
                    break;

                case 6:
                    phoneNumber.F6 = value;
                    break;

                case 7:
                    phoneNumber.F7 = value;
                    break;

                case 8:
                    phoneNumber.F8 = value;
                    break;

                case 9:
                    phoneNumber.F9 = value;
                    break;

                case 10:
                    phoneNumber.F10 = value;
                    break;

                case 11:
                    phoneNumber.F11 = value;
                    break;

                case 12:
                    phoneNumber.F12 = value;
                    break;

                case 13:
                    phoneNumber.F13 = value;
                    break;

                case 14:
                    phoneNumber.F14 = value;
                    break;

                case 15:
                    phoneNumber.F15 = value;
                    break;

                case 16:
                    phoneNumber.F16 = value;
                    break;

                case 17:
                    phoneNumber.F17 = value;
                    break;

                case 18:
                    phoneNumber.F18 = value;
                    break;

                case 19:
                    phoneNumber.F19 = value;
                    break;

                case 20:
                    phoneNumber.F20 = value;
                    break;
                }
            }
            catch
            {
                throw new Exception(Language.GetString("CustomFieldValueIsInValid"));
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Common.PhoneNumber        phoneNumber;
            List <Common.PhoneNumber> lstNumbers = new List <Common.PhoneNumber>();
            string fieldId;
            string saveReport = string.Empty;

            try
            {
                string file = hdnFilePath.Value;

                if (!System.IO.File.Exists(Server.MapPath(string.Format("/Uploads/{0}", file))))
                {
                    throw new Exception(Language.GetString("FileDoesNotExist"));
                }

                string    extension = file.Substring(file.LastIndexOf('.')).TrimStart('.');
                bool      firstRowHasColumnNames = chbHeaderRow.Checked;
                DataTable dtb = new DataTable();

                switch (extension.ToLower())
                {
                case "csv":
                    dtb = ImportFile.ImportCSV(Server.MapPath(string.Format("/Uploads/{0}", file)), firstRowHasColumnNames);
                    break;

                case "xls":
                case "xlsx":
                    dtb = ImportFile.ImportExcel(Server.MapPath(string.Format("/Uploads/{0}", file)), firstRowHasColumnNames);
                    break;
                }

                foreach (DataRow row in dtb.Rows)
                {
                    phoneNumber = new Common.PhoneNumber();
                    phoneNumber.PhoneNumberGuid = Guid.NewGuid();
                    phoneNumber.PhoneBookGuid   = PhoneBookGuid;
                    phoneNumber.CreateDate      = DateTime.Now;
                    phoneNumber.FirstName       = !string.IsNullOrEmpty(txtFirstName.Text) ? row[Helper.GetInt(txtFirstName.Text.Trim()) - 1].ToString() : string.Empty;
                    phoneNumber.LastName        = !string.IsNullOrEmpty(txtLastName.Text) ? row[Helper.GetInt(txtLastName.Text.Trim()) - 1].ToString() : string.Empty;

                    if (!string.IsNullOrEmpty(txtBirthDate.Text))
                    {
                        phoneNumber.BirthDate = DateManager.GetChristianDateForDB(row[Helper.GetInt(txtBirthDate.Text.Trim()) - 1].ToString());
                    }

                    if (!string.IsNullOrEmpty(txtSex.Text))
                    {
                        phoneNumber.Sex = GetSex(row[Helper.GetInt(txtSex.Text.Trim()) - 1].ToString());
                    }

                    string mobile = !string.IsNullOrEmpty(txtCellPhone.Text) ? Helper.GetLocalMobileNumber(row[Helper.GetInt(txtCellPhone.Text.Trim()) - 1].ToString()) : string.Empty;
                    string email  = !string.IsNullOrEmpty(txtEmail.Text) ? row[Helper.GetInt(txtEmail.Text.Trim()) - 1].ToString() : string.Empty;

                    if (!Helper.CheckDataConditions(email).IsEmail)
                    {
                        email = string.Empty;
                    }

                    //if (!Helper.CheckingCellPhone(ref mobile) && !Helper.CheckDataConditions(email).IsEmail)
                    //	continue;

                    phoneNumber.Email     = email;
                    phoneNumber.CellPhone = mobile;
                    phoneNumber.Job       = !string.IsNullOrEmpty(txtJob.Text) ? row[Helper.GetInt(txtJob.Text.Trim()) - 1].ToString() : string.Empty;
                    phoneNumber.Telephone = !string.IsNullOrEmpty(txtTelephone.Text) ? row[Helper.GetInt(txtTelephone.Text.Trim()) - 1].ToString() : string.Empty;
                    phoneNumber.FaxNumber = !string.IsNullOrEmpty(txtFaxNumber.Text) ? row[Helper.GetInt(txtFaxNumber.Text.Trim()) - 1].ToString() : string.Empty;
                    phoneNumber.Address   = !string.IsNullOrEmpty(txtAddress.Text) ? row[Helper.GetInt(txtAddress.Text.Trim()) - 1].ToString() : string.Empty;

                    fieldId = string.Empty;
                    for (int customFieldCounter = 1; customFieldCounter <= 20; customFieldCounter++)
                    {
                        fieldId = "Field" + customFieldCounter.ToString();
                        TextBox customField = pnlUserField.FindControl(fieldId) as TextBox;
                        if (customField != null && !string.IsNullOrEmpty(customField.Text))
                        {
                            SetCustomFieldValue(phoneNumber,
                                                customFieldCounter,
                                                row[Helper.GetInt(customField.Text.Trim()) - 1].ToString(),
                                                (UserFieldTypes)Helper.GetInt(customField.Attributes["FieldType"]));
                        }
                    }

                    lstNumbers.Add(phoneNumber);
                }

                if (!Facade.PhoneNumber.InsertBulkNumbers(lstNumbers, UserGuid))
                {
                    throw new Exception(Language.GetString("ErrorRecord"));
                }

                ClientSideScript = "saveResult('OK','" + Language.GetString("InsertRecord") + "');";

                hdnFilePath.Value = string.Empty;
            }
            catch (Exception ex)
            {
                ClientSideScript = "saveResult('Error','" + ex.Message + "');";
            }
        }
        public HttpResponseMessage GetDelivery(HttpRequestMessage request)
        {
            string strIncomingMessage = string.Empty;
            string element            = string.Empty;

            StreamReader MyStreamReader = new StreamReader(request.Content.ReadAsStreamAsync().Result);

            strIncomingMessage = MyStreamReader.ReadToEnd();
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.XmlResolver   = null;
            settings.DtdProcessing = DtdProcessing.Parse;
            XmlReader objXMLReader = XmlReader.Create(new StringReader(strIncomingMessage), settings);

            while (objXMLReader.Read())
            {
                switch (objXMLReader.NodeType)
                {
                case XmlNodeType.Element:
                    element = objXMLReader.Name;
                    break;
                }
                if (!string.IsNullOrEmpty(element))
                {
                    break;
                }
            }

            switch (element.ToLower())
            {
            case "smsdeliver":
                #region ReceiveSms
                ReceiveMessage receiveMessage = new ReceiveMessage();
                while (objXMLReader.Read())
                {
                    switch (objXMLReader.NodeType)
                    {
                    case XmlNodeType.Element:
                        element = objXMLReader.Name;
                        if (element == "destAddrNbr")
                        {
                            receiveMessage.Receiver = objXMLReader.Value;
                        }
                        if (element == "origAddr")
                        {
                            receiveMessage.Sender = objXMLReader.Value;
                        }
                        if (element == "message")
                        {
                            receiveMessage.SmsText = objXMLReader.Value;
                        }

                        break;

                    case XmlNodeType.Text:
                        if (element == "destAddrNbr")
                        {
                            receiveMessage.Receiver = objXMLReader.Value;
                            break;
                        }
                        if (element == "origAddr")
                        {
                            receiveMessage.Sender = objXMLReader.Value;
                            break;
                        }
                        if (element == "message")
                        {
                            receiveMessage.SmsText = objXMLReader.Value;
                            break;
                        }
                        break;

                    case XmlNodeType.CDATA:
                        if (element == "origAddr")
                        {
                            receiveMessage.Sender = objXMLReader.Value;
                        }
                        if (element == "message")
                        {
                            receiveMessage.SmsText = objXMLReader.Value;
                        }
                        break;
                    }
                }
                if (strIncomingMessage.IndexOf("binary=") != -1)
                {
                    int    index   = strIncomingMessage.IndexOf("binary=") + 8;
                    string strLang = strIncomingMessage.Substring(index, 1);
                    if (strLang == "t")
                    {
                        receiveMessage.SmsText = DecodeUCS2(receiveMessage.SmsText);
                        receiveMessage.SmsText = Helper.PersianNumberToEnglish(receiveMessage.SmsText);
                    }
                }
                receiveMessage.ReceiveDateTime = DateTime.Now;
                receiveMessage.SmsText         = Helper.PersianNumberToEnglish(receiveMessage.SmsText);

                ManageQueue.SendMessage(Queues.ReceiveMessagesQueue, receiveMessage, receiveMessage.Sender);
                break;

                #endregion
            case "smsstatusnotification":
                #region DeliveryStatus
                Common.DeliveryMessage deliveryMessage = new Common.DeliveryMessage();
                deliveryMessage.Agent = (int)SmsSenderAgentReference.RahyabRG;
                while (objXMLReader.Read())
                {
                    switch (objXMLReader.NodeType)
                    {
                    case XmlNodeType.Element:
                        element = objXMLReader.Name;
                        if (element == "batch")
                        {
                            deliveryMessage.BatchId = objXMLReader.GetAttribute("batchID").Split('+')[1];
                        }
                        if (element == "sms")
                        {
                            deliveryMessage.ReturnId = objXMLReader.GetAttribute("smsId");
                        }
                        if (element == "destAddr")
                        {
                            deliveryMessage.Mobile = objXMLReader.Value;
                        }
                        if (element == "status")
                        {
                            deliveryMessage.Status = GetDeliveryStatus(objXMLReader.Value);
                        }
                        if (element == "time")
                        {
                            deliveryMessage.Date = !string.IsNullOrEmpty(objXMLReader.Value) ? DateManager.GetChristianDateForDB(objXMLReader.Value) : DateTime.Now;
                        }
                        break;

                    case XmlNodeType.CDATA:
                        if (element == "destAddr")
                        {
                            deliveryMessage.Mobile = objXMLReader.Value;
                        }
                        break;

                    case XmlNodeType.Text:
                        if (element == "status")
                        {
                            deliveryMessage.Status = GetDeliveryStatus(objXMLReader.Value);
                        }
                        if (element == "time")
                        {
                            deliveryMessage.Date = !string.IsNullOrEmpty(objXMLReader.Value) ? DateTime.Parse(objXMLReader.Value.Replace('-', '/')) : DateTime.Now;
                        }
                        break;
                    }
                }

                ManageQueue.SendMessage(Queues.SaveDelivery, deliveryMessage, deliveryMessage.ReturnId);
                break;

                #endregion
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }