Example #1
0
        public JsonResult GetOTP(string UID)
        {
            BALCommon obj     = new BALCommon(ConStr);
            bool      res     = false;
            string    message = "";

            try
            {
                string OTP = Utility.GetRendomString(6, "N");
                res = obj.SetOTP(UID, OTP);
                #region SendMail
                if (res)
                {
                    BALCommon   CSvc         = new BALCommon(ConStr);
                    UserMasters userMasters  = CSvc.getUserProfile(UID);
                    MailDetails _MailDetails = new MailDetails();
                    _MailDetails.ToMailIDs = userMasters.EMAILID;
                    _MailDetails.HTMLBody  = true;
                    _MailDetails.Subject   = "Reset OTP";
                    _MailDetails.Body      = BALMail.TemplateResetOTP(userMasters, AESEncrytDecry.EncryptStringAES(OTP));
                    if (BALMail.SendMail(_MailDetails))
                    {
                        message = "OTP has been sent to your registered mail id.";
                    }
                    else
                    {
                        message = "Please contact technical team";
                    }
                }
                else
                {
                    message = "Please contact technical team";
                }
                #endregion SendMail
            }
            catch (Exception ex)
            {
                res = false;
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult Create(SignupModel model, FormCollection collection)
        {
            BALCommon          CSvc   = new BALCommon(ConStr);
            OragnisationMaster master = new OragnisationMaster();

            //model.CountryList = CSvc.GetCountryList(0);
            //model.CityList = CSvc.GetCityList(0, 0);
            //model.StateList = CSvc.GetStateList(0, 0);
            if (ModelState.IsValid)
            {
                try
                {
                    master = CSvc.GetOragnisationAlready(model.LEmailId);
                    if (master.OMID == 0)
                    {
                        HttpPostedFileBase empimg     = Request.Files["emppathimage"];
                        string             folderpath = Constants.EMPATTACHMENT;

                        if (empimg.ContentLength > 0)
                        {
                            string guidstring = Guid.NewGuid().ToString();
                            string _FileName  = Path.GetFileName(empimg.FileName);
                            string filepath   = Path.Combine(Server.MapPath(folderpath) + guidstring + "_" + _FileName);
                            string dbpath     = Path.Combine(folderpath + guidstring + "_" + _FileName);
                            empimg.SaveAs(filepath);
                            master.OrgImage = dbpath;
                        }
                        else
                        {
                            string _FileName = "schooldummylogo.png";
                            string dbpath    = Path.Combine(folderpath + _FileName);
                            master.OrgImage = dbpath;
                        }
                        master.Oname        = model.Oname;
                        master.BOAddress    = model.BOAddress;
                        master.BOAddress2   = model.BOAddress2;
                        master.BOCity       = model.CITY_ID;
                        master.BOPincode    = model.BOPincode;
                        master.LCountry     = model.COUNTRY_ID;
                        master.LState       = model.STATE_ID;
                        master.LDistict     = model.LDistict;
                        master.LArea        = model.LArea;
                        master.LEmailId     = model.LEmailId;
                        master.LMobile      = model.LMobile;
                        master.LPhone       = model.LPhone;
                        master.LWebsite     = model.LWebsite;
                        master.OAfficilate  = model.OAfficilate;
                        master.OlicNo       = model.OlicNo;
                        master.OTaxNo       = model.OTaxNo;
                        master.OPanNo       = model.OPanNo;
                        master.OContactNo   = model.OContactNo;
                        master.IsActive     = false;
                        master.Createddate  = DateTime.Now;
                        master.Modifieddate = DateTime.Now;
                        master.CreatedBy    = "EndUser";
                        master.ModifiedBy   = "EndUser";
                        master.Otype        = "INS"; // to check
                        int _retua = CSvc.OragnasitionBasicopation(master);
                        if (_retua > 0)
                        {
                            string Password = Utility.GenerateRandomPassword();

                            WebSecurity.CreateUserAndAccount(master.LEmailId, Password, new { Name = master.OContactNo, Mobile = master.LMobile, EmailId = master.LEmailId, Address = master.BOAddress, RoleId = 1, CITY_ID = master.BOCity, STATE_ID = master.LState, COUNTRY_ID = master.LCountry, ISACTIVE = 0, SchoolID = _retua });
                            CSvc.Firstuserconfigure(_retua);//first user configure
                            //TempData[Constants.MessageInfo.SUCCESS] = Constants.Orgnisation_ADD_SUCCESS;
                            #region SendMail
                            MailDetails _MailDetails = new MailDetails();
                            _MailDetails.ToMailIDs = master.LEmailId;
                            _MailDetails.HTMLBody  = true;
                            _MailDetails.Subject   = "Organisation Registration";
                            _MailDetails.Body      = BALMail.TemplateOrganisation(master, AESEncrytDecry.EncryptStringAES(Password));
                            if (BALMail.SendMail(_MailDetails))
                            {
                                TempData[Constants.MessageInfo.SUCCESS] = Constants.Orgnisation_ADD_SUCCESS + ", Please check your mail inbox for more information.";
                            }
                            else
                            {
                                TempData[Constants.MessageInfo.SUCCESS] = Constants.Orgnisation_ADD_SUCCESS;
                            }
                            #endregion SendMail
                            return(RedirectToAction("login"));
                        }
                    }
                    else
                    {
                        TempData[Constants.MessageInfo.SUCCESS] = "Orgnisation is already Exist !";
                        return(RedirectToAction("Create"));
                    }
                }
                catch (Exception ex)
                {
                    WebSecurity.Logout();
                    ExecptionLogger.FileHandling("Account(Create_Post)", "Error_014", ex, "Account");
                }
            }

            return(View(model));
        }
Example #3
0
    protected void btnCreateUser_Click(object sender, EventArgs e)
    {
        try
        {
            if (btnCreateUser.Text == "Modify The User")
            {
                strUser1 = AESEncrytDecry.EncryptStringAES(usernametext2.Text);
            }
            else
            {
                strUser1 = usernametext2.Text;
            }
            string strUser = AESEncrytDecry.DecryptStringAES(strUser1);
            usernametext2.Text = "";

            string strpassword = AESEncrytDecry.DecryptStringAES(password.Text);
            password.Text = "";

            string strReptpassword = AESEncrytDecry.DecryptStringAES(repeatPassword.Text);
            repeatPassword.Text = "";

            string strSans = AESEncrytDecry.DecryptStringAES(answer.Text);
            answer.Text = "";

            string strMobile = AESEncrytDecry.DecryptStringAES(mobile_phone.Text);
            mobile_phone.Text = "";

            if (!strpassword.Any(char.IsUpper) || !strpassword.Any(char.IsLower) || strpassword.Length < 8 || !hasSpecialChar(strpassword) || !strpassword.Any(char.IsDigit) || strpassword.Length > 14)
            {
                password.Attributes["value"]       = "";
                repeatPassword.Attributes["value"] = "";
                var page = HttpContext.Current.CurrentHandler as Page;
                ScriptManager.RegisterStartupScript(page, page.GetType(), "alert", "UserAlert('Password Must Contain atleast One Upper Case, One Lower Case, One Special Character, One Numeric Value and minimum length is 8');", true);
                return;
            }

            WebClient   client      = new WebClient();
            UserDetails userDetails = new UserDetails();
            userDetails.res = false;
            if (btnCreateUser.Text == "Create New User")
            {
                client.Headers[HttpRequestHeader.ContentType] = "text/json";
                ServicePointManager.SecurityProtocol          = SecurityProtocolType.Tls12;
                string     JsonString1    = JsonConvert.SerializeObject(strUser);
                EncRequest objEncRequest1 = new EncRequest();
                objEncRequest1.RequestData = AesGcm256.Encrypt(JsonString1);
                string dataEncrypted1 = JsonConvert.SerializeObject(objEncRequest1);

                string result = client.UploadString(URL + "/GetUserDetails", "POST", dataEncrypted1);

                EncResponse objResponse1 = JsonConvert.DeserializeObject <EncResponse>(result);
                objResponse1.ResponseData = AesGcm256.Decrypt(objResponse1.ResponseData);

                //objRes = JsonConvert.DeserializeObject<Reply>(objResponse.ResponseData);
                //DataContractJsonSerializer objDCS1 = new DataContractJsonSerializer(typeof(Reply));
                //MemoryStream objMS1 = new MemoryStream(Encoding.UTF8.GetBytes(objResponse1.ResponseData));
                //userDetails = (UserDetails)objDCS1.ReadObject(objMS1);

                Newtonsoft.Json.JsonSerializer json1 = new Newtonsoft.Json.JsonSerializer();
                json1.NullValueHandling = NullValueHandling.Ignore;
                StringReader sr1 = new StringReader(objResponse1.ResponseData);
                Newtonsoft.Json.JsonTextReader reader1 = new JsonTextReader(sr1);
                userDetails = json1.Deserialize <UserDetails>(reader1);

                if (userDetails.res)
                {
                    Response.Write("<script>alert('Username already Exist')</script>");
                    usernametext2.Text             = "";
                    password.Text                  = "";
                    repeatPassword.Text            = "";
                    useremail.Text                 = "";
                    mobile_phone.Text              = "";
                    recoveryQuestion.SelectedIndex = 0;
                    answer.Text                = "";
                    UserType.SelectedIndex     = 0;
                    locationList.SelectedIndex = 0;
                    return;
                }
                else
                {
                    userDetails.res = true;
                }
            }

            userDetails.Username = strUser;
            userDetails.Usertype = UserType.SelectedValue == "Admin User" ? "admin" : UserType.SelectedValue;
            userDetails.location = UserType.SelectedItem.Text == "Admin User" ? "Admin User" : locationList.SelectedItem.Text;
            userDetails.Answer   = strSans;
            userDetails.email    = useremail.Text;
            if (Session["Pass"] != null && Session["Pass"].ToString() == strpassword)
            {
                userDetails.password = strpassword;
            }
            else
            {
                userDetails.password = "******" + strpassword;
            }

            userDetails.phone            = strMobile;
            userDetails.securityQuestion = recoveryQuestion.SelectedItem.Text;
            client.Headers[HttpRequestHeader.ContentType] = "text/json";
            ServicePointManager.SecurityProtocol          = SecurityProtocolType.Tls12;
            string     JsonString    = JsonConvert.SerializeObject(userDetails);
            EncRequest objEncRequest = new EncRequest();
            objEncRequest.RequestData = AesGcm256.Encrypt(JsonString);
            string dataEncrypted = JsonConvert.SerializeObject(objEncRequest);

            string resultUser = client.UploadString(URL + "/CreateUser", "POST", dataEncrypted);

            EncResponse objResponse = JsonConvert.DeserializeObject <EncResponse>(resultUser);
            objResponse.ResponseData = AesGcm256.Decrypt(objResponse.ResponseData);

            //objRes = JsonConvert.DeserializeObject<Reply>(objResponse.ResponseData);
            //DataContractJsonSerializer objDCS = new DataContractJsonSerializer(typeof(Reply));
            //MemoryStream objMS = new MemoryStream(Encoding.UTF8.GetBytes(objResponse.ResponseData));
            //resultUser = (string)objDCS.ReadObject(objMS);

            Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer();
            json.NullValueHandling = NullValueHandling.Ignore;
            StringReader sr = new StringReader(objResponse.ResponseData);
            Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);
            userDetails = json.Deserialize <UserDetails>(reader);

            if (resultUser == "true")
            {
                var page = HttpContext.Current.CurrentHandler as Page;
                ScriptManager.RegisterStartupScript(page, page.GetType(), "alert", "UserSuccess();", true);
                Session["Pass"]        = null;
                UserType.SelectedIndex = 0;
                locationList.Items.Clear();
                locationList.Items.Add("Select");
                usernametext2.Text             = "";
                password.Text                  = "";
                repeatPassword.Text            = "";
                useremail.Text                 = "";
                mobile_phone.Text              = "";
                answer.Text                    = "";
                recoveryQuestion.SelectedIndex = 0; reset.Enabled = true; usernametext2.Enabled = true; password.Attributes["value"] = ""; repeatPassword.Attributes["value"] = "";
                btnCreateUser.Text             = "Create New User";
                reset.Enabled                  = true;
                locationList.Enabled           = false;
            }
            else
            {
                PageUtility.MessageBox(this, "UserFail.");
            }
        }
        catch (Exception ex)
        {
            PageUtility.MessageBox(this, "Excp -: " + ex.Message);
        }
        finally { bindUserList(); }
    }