Пример #1
0
        protected void impersonateClient(Client client)
        {
            List <SecRoleModuleManager.secRoleModuleGet> resRolePermission = new List <SecRoleModuleManager.secRoleModuleGet>();

            string userData = null;

            CRM.Data.Entities.SecUser user = null;

            user = client.SecUser;

            Session["UserId"]   = client.SecUser.UserId;
            Session["UserName"] = client.SecUser.UserName;
            Session["RoleId"]   = client.SecUser.SecRole.RoleId.ToString();

            // 201307-29
            Session["ClientId"]       = client.SecUser.ClientID;
            Session["ClientShowTask"] = (client.isShowTasks ?? true);

            userData = string.Format("{0}|{1}|{2} {3}|{4}", user.SecRole.RoleName, user.SecRole.RoleId, user.FirstName, user.LastName, user.Email);

            var ticket = new FormsAuthenticationTicket
                         (
                1,
                client.SecUser.UserId.ToString(),
                DateTime.Now,
                DateTime.Now.AddMinutes(120),
                true,
                userData,                       //(client.SecUser.SecRole.RoleName + "|" + client.SecUser.SecRole.RoleId.ToString()),
                FormsAuthentication.FormsCookiePath
                         );

            string encryptedTicket = FormsAuthentication.Encrypt(ticket);

            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket));
            Session["rolePermission"] = resRolePermission = SecRoleModuleManager.getRolePermission(client.SecUser.SecRole.RoleId).ToList();



            var url = FormsAuthentication.DefaultUrl;

            Response.Redirect(url);
        }
Пример #2
0
        public void DoAuthenticate(CRM.Data.Entities.SecUser user)
        {
            string     url         = null;
            string     userData    = null;
            List <int> roleActions = null;

            Session["UserId"]   = user.UserId;
            Session["UserName"] = user.UserName;
            Session["RoleId"]   = user.SecRole.RoleId.ToString();

            // 201307-29
            Session["ClientId"] = user.ClientID;
            if (user.Client.Count > 0)
            {
                Session["ClientShowTask"] = user.Client == null ? true : (user.Client.FirstOrDefault().isShowTasks ?? true);
            }
            else
            {
                Session["ClientShowTask"] = true;
            }

            userData = string.Format("{0}|{1}|{2} {3}|{4}", user.SecRole.RoleName, user.SecRole.RoleId, user.FirstName, user.LastName, user.Email);

            var ticket = new FormsAuthenticationTicket
                         (
                1,
                user.UserId.ToString(),
                DateTime.Now,
                DateTime.Now.AddMinutes(120),
                true,
                userData,       //(user.SecRole.RoleName + "|" + user.SecRole.RoleId.ToString()),
                FormsAuthentication.FormsCookiePath
                         );

            string encryptedTicket = FormsAuthentication.Encrypt(ticket);

            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket));
            Session["rolePermission"] = resRolePermission = SecRoleModuleManager.getRolePermission(user.SecRole.RoleId).ToList();

            // get role actions
            if (user.RoleId != (int)UserRole.Administrator)
            {
                using (ActionManager repository = new ActionManager())
                {
                    roleActions            = repository.GetActions((int)user.ClientID, (int)user.RoleId);
                    Session["roleActions"] = roleActions;
                }
            }

            //if (user.SecRole.RoleId == (int)UserRole.Adjuster)
            //	url = "~/Protected/Intake/form.aspx";
            //else
            if (Request.QueryString["url"] != null)
            {
                url = Request.QueryString["url"].ToString();
            }
            else
            {
                url = FormsAuthentication.DefaultUrl;
                Session["Count"] = null;


                formatException();
                setRulexception();

                setGlobalSession();



                Thread thread = new Thread(delegate()
                {
                    workerObject.DoWork();
                });
                //ThreadPool.QueueUserWorkItem(new WaitCallback(workerObject.DoWork), leadView, testse);

                // workerThread = new Thread(workerObject.DoWork);

                thread.Start();
            }

            Response.Redirect(url);
        }
Пример #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text    = string.Empty;
            lblSave.Text     = string.Empty;
            lblSave.Visible  = false;
            lblError.Visible = false;
            try {
                using (TransactionScope scope = new TransactionScope()) {
                    SecRoleModuleManager.UpdateSecRoleModuleStatus(Convert.ToInt32(ddlRole.SelectedValue));

                    foreach (GridViewRow row in grdModule.Rows)
                    {
                        int         check          = 0;
                        int         checkParent    = 0;
                        GridView    gv             = (GridView)row.FindControl("gvSubModule");
                        HiddenField hfRoleModuleId = (HiddenField)row.FindControl("hfRoleModuleId");
                        HiddenField hfModuleId     = (HiddenField)row.FindControl("hfModuleId");

                        if (hfRoleModuleId.Value == string.Empty)
                        {
                            hfRoleModuleId.Value = "0";
                        }

                        CheckBox chkAllAdd  = (CheckBox)row.FindControl("chkAllAdd");
                        CheckBox chkAllEdit = (CheckBox)row.FindControl("chkAllEdit");
                        CheckBox chkAllDel  = (CheckBox)row.FindControl("chkAllDel");
                        CheckBox chkAllView = (CheckBox)row.FindControl("chkAllView");

                        SecRoleModule roleModuleMainGrid = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                        if (chkAllView.Checked || chkAllAdd.Checked || chkAllEdit.Checked || chkAllEdit.Checked)
                        {
                            var secRoleModule = new CRM.Data.Entities.SecRoleModule {
                                ModuleID         = Convert.ToInt32(hfModuleId.Value),
                                RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                AddPermssion     = chkAllAdd.Checked == true ? true : false,
                                EditPermission   = chkAllEdit.Checked == true ? true : false,
                                DeletePermission = chkAllDel.Checked == true ? true : false,
                                ViewPermission   = chkAllView.Checked == true ? true : false,
                                Status           = 1,
                                CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                CreatedOn        = DateTime.Now,
                                UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                UpdatedOn        = DateTime.Now,
                                CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                            };
                            SecRoleModuleManager.SaveRoleModule(secRoleModule);
                            checkParent = 1;
                        }


                        foreach (GridViewRow subGridRow in gv.Rows)
                        {
                            CheckBox      chkAdd          = (CheckBox)subGridRow.FindControl("chkAdd");
                            CheckBox      chkEdit         = (CheckBox)subGridRow.FindControl("chkEdit");
                            CheckBox      chkDelete       = (CheckBox)subGridRow.FindControl("chkDel");
                            CheckBox      chkView         = (CheckBox)subGridRow.FindControl("chkView");
                            HiddenField   hfModuleIdChild = (HiddenField)subGridRow.FindControl("hfModuleIdChild");
                            SecRoleModule roleModule      = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                            if (chkAdd.Checked || chkEdit.Checked || chkDelete.Checked || chkView.Checked)
                            {
                                var secRoleModuleChild = new CRM.Data.Entities.SecRoleModule {
                                    ModuleID         = Convert.ToInt32(hfModuleIdChild.Value),
                                    RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                    AddPermssion     = chkAdd.Checked == true ? true : false,
                                    EditPermission   = chkEdit.Checked == true ? true : false,
                                    DeletePermission = chkDelete.Checked == true ? true : false,
                                    ViewPermission   = chkView.Checked == true ? true : false,
                                    Status           = 1,
                                    CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                    CreatedOn        = DateTime.Now,
                                    UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                    UpdatedOn        = DateTime.Now,
                                    CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                                };
                                SecRoleModuleManager.SaveRoleModule(secRoleModuleChild);
                                check       = 1;
                                checkParent = 0;
                            }

                            GridView gvchild = (GridView)subGridRow.FindControl("gvSubModule1");
                            if (gvchild.Rows.Count > 0)
                            {
                                foreach (GridViewRow child in gvchild.Rows)
                                {
                                    CheckBox      chkAdd1          = (CheckBox)child.FindControl("chkAdd");
                                    CheckBox      chkEdit1         = (CheckBox)child.FindControl("chkEdit");
                                    CheckBox      chkDelete1       = (CheckBox)child.FindControl("chkDel");
                                    CheckBox      chkView1         = (CheckBox)child.FindControl("chkView");
                                    HiddenField   hfModuleIdChild1 = (HiddenField)child.FindControl("hfModuleIdChild1");
                                    SecRoleModule roleModule1      = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                                    if (chkAdd1.Checked || chkEdit1.Checked || chkDelete1.Checked || chkView1.Checked)
                                    {
                                        var secRoleModuleChild = new CRM.Data.Entities.SecRoleModule {
                                            ModuleID         = Convert.ToInt32(hfModuleIdChild1.Value),
                                            RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                            AddPermssion     = chkAdd.Checked == true ? true : false,
                                            EditPermission   = chkEdit.Checked == true ? true : false,
                                            DeletePermission = chkDelete.Checked == true ? true : false,
                                            ViewPermission   = chkView.Checked == true ? true : false,
                                            Status           = 1,
                                            CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                            CreatedOn        = DateTime.Now,
                                            UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                            UpdatedOn        = DateTime.Now,
                                            CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                                        };
                                        SecRoleModuleManager.SaveRoleModule(secRoleModuleChild);
                                        check       = 1;
                                        checkParent = 0;
                                    }
                                }
                            }
                        }
                    }

                    CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(Convert.ToInt32(HttpContext.Current.User.Identity.Name));
                    if (user.SecRole.RoleId == Convert.ToInt32(ddlRole.SelectedValue))
                    {
                        Session["rolePermission"] = refreshRolePermission = SecRoleModuleManager.getRolePermission(user.SecRole.RoleId).ToList();
                    }
                    bindGrid(Convert.ToInt32(ddlRole.SelectedValue));
                    lblSave.Text    = "Record Saved Sucessfully.";
                    lblSave.Visible = true;
                    scope.Complete();
                }
            }
            catch (Exception ex) {
                lblError.Text    = "Record Not Saved Sucessfully.";
                lblError.Visible = true;
            }
        }