Esempio n. 1
0
        protected void loadUserData()
        {
            String      userId = Request.QueryString.GetValues("userId")[0];
            userDetails uDObj  = BackEndObjects.userDetails.getUserDetailsbyIdDB(userId, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());

            if (uDObj != null && uDObj.getUserId() != null && !uDObj.getUserId().Equals(""))
            {
                Label_Name.Text    = uDObj.getName();
                Label_Email.Text   = uDObj.getEmailId();
                Label_Contact.Text = uDObj.getContactNo();
            }
        }
        protected userDetails populatePersonalData()
        {
            userDetails uDObj = BackEndObjects.userDetails.
                                getUserDetailsbyIdDB(User.Identity.Name, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());

            if (uDObj.getName() != null)
            {
                TextBox_Name.Text = uDObj.getName();
            }
            if (uDObj.getEmailId() != null)
            {
                TextBox_Email.Text = uDObj.getEmailId();
            }
            if (uDObj.getContactNo() != null)
            {
                TextBox_Contact.Text = uDObj.getContactNo();
            }

            /*if (uDObj.getDeptId() != null)
             *  TextBox_Dept.Text = uDObj.getDeptId();*/

            return(uDObj);
        }
        protected void Create_Chain_User_Click(object sender, EventArgs e)
        {
            userDetails udTest = BackEndObjects.userDetails.getUserDetailsbyIdDB(TextBox1.Text);

            if (udTest.getUserId() == null || udTest.getUserId().Equals("")) //New user id
            {
                userDetails uD = new userDetails();
                uD.setMainEntityId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());

                Random ranGen         = new Random();
                int    saltInt        = ranGen.Next(1, 16);
                byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes((TextBox2.Text.Equals("") ? TextBox2.Attributes["password"] : TextBox2.Text)
                                                                           + saltInt);
                HashAlgorithm hashConverter    = new SHA256Managed();
                byte[]        hashedByteStream = hashConverter.ComputeHash(plainTextBytes);
                String        encryptedAndConvertedPassword = Convert.ToBase64String(hashedByteStream);

                //uD.setSubEntityId(DropDownList1.SelectedValue);
                uD.setUserId(TextBox1.Text);
                uD.setPassword(encryptedAndConvertedPassword);
                uD.setSalt(saltInt.ToString());
                uD.setName(TextBox_User_Name_NewAccount.Text);

                Dictionary <String, userDetails> userList = MainBusinessEntity.getUserDetailsforMainEntitybyIdDB(uD.getMainEntityId());
                if (userList.ContainsKey(uD.getUserId()))
                {
                    Label2.Visible   = true;
                    Label2.ForeColor = System.Drawing.Color.Red;
                    Label2.Text      = "This user account is already created for your organization";
                }
                else
                {
                    ArrayList uDChains = new ArrayList();
                    uDChains.Add(uD);
                    ActionLibrary.RegistrationActions regstr = new RegistrationActions();
                    try
                    {
                        regstr.completeRegr(uDChains);
                        Label2.Visible   = true;
                        Label2.ForeColor = System.Drawing.Color.Green;
                        Label2.Text      = "Account created successfully. User can login and enter contact details and other details from user preference page.";

                        DataTable dt    = (DataTable)Session[SessionFactory.ADMIN_PREF_USER_MGMT_BASIC_USER_DET_GRID];
                        int       count = dt.Rows.Count;
                        dt.Rows.Add();
                        dt.Rows[count]["UserName"] = uD.getName();
                        dt.Rows[count]["UserId"]   = uD.getUserId();

                        GridView_User_List.DataSource = dt;
                        GridView_User_List.DataBind();
                        Session[SessionFactory.ADMIN_PREF_USER_MGMT_BASIC_USER_DET_GRID] = dt;
                    }
                    catch (Exception ex)
                    {
                        Label2.Visible   = true;
                        Label2.ForeColor = System.Drawing.Color.Red;
                        Label2.Text      = "Account creation failed";
                    }
                }
            }
            else
            {
                Label2.Visible   = true;
                Label2.ForeColor = System.Drawing.Color.Red;
                Label2.Text      = "User Id is not available..please choose another one";
            }
        }