Пример #1
0
        //update SecurityUserRight object
        public bool Update(SecurityUserAccess pSecurityUserAccess)
        {
            try
            {
                if (pSecurityUserAccess.ID > 0)
                {
                    SecurityUserAccess vSecurityUserAccess = rep.Find(pSecurityUserAccess.ID);
                    if (vSecurityUserAccess != null)
                    {
                        //vSecurityUserRight.ID = pSecurityUserRight.ID;
                        vSecurityUserAccess.UserCode        = pSecurityUserAccess.UserCode;
                        vSecurityUserAccess.ApplicationCode = pSecurityUserAccess.ApplicationCode;
                        vSecurityUserAccess.FormCode        = pSecurityUserAccess.FormCode;
                        vSecurityUserAccess.FormActionCode  = pSecurityUserAccess.FormActionCode;
                        vSecurityUserAccess.ActionValue     = pSecurityUserAccess.ActionValue;

                        rep.Edit(vSecurityUserAccess);
                        rep.SaveChanges();
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        //delete SecurityUserRight object by id
        public bool DeleteByID(long pSecurityUserActionID)
        {
            try
            {
                if (pSecurityUserActionID > 0)
                {
                    SecurityUserAccess vSecurityUserAction = rep.Find(pSecurityUserActionID);
                    if (vSecurityUserAction != null)
                    {
                        ////Update DelFlag To "Y" For Soft Delete

                        //vSecurityUserRight.ID = pSecurityUserRight.ID;
                        //vSecurityUserRight.UserCode = pSecurityUserRight.UserCode;
                        //vSecurityUserRight.ApplicationCode = pSecurityUserRight.ApplicationCode;
                        //vSecurityUserRight.FormCode = pSecurityUserRight.FormCode;
                        //vSecurityUserRight.FormRightCode = pSecurityUserRight.FormRightCode;
                        //vSecurityUserRight.RightValue = pSecurityUserRight.RightValue;
                        //vSecurityUserRight.UserID = pSecurityUserRight.UserID;
                        //vSecurityUserRight.ApplicationID = pSecurityUserRight.ApplicationID;
                        //vSecurityUserRight.FormID = pSecurityUserRight.FormID;
                        //vSecurityUserRight.FormRightID = pSecurityUserRight.FormRightID;

                        rep.Edit(vSecurityUserAction);
                        rep.SaveChanges();
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public bool Authenticate(string userName, string password)
        {
            bool value        = false;
            var  Authenticate = SContext.SecurityUsers.Where(s => s.LoginName == userName.Trim() && s.Password == password.Trim() && s.ActiveFlag == "Y").ToList();

            if (Authenticate.Count != 0)
            {
                string SBSAppCode = ConfigurationManager.AppSettings["SecurityAppCode"].ToString();
                foreach (var item in Authenticate)
                {
                    string uUserCode        = item.UserCode.Trim();
                    string uUserCompanyCode = item.CompCode.Trim();
                    var    SBSCompanyCode   = (from a in DefinitionContext.Dealers where a.DealerCode == uUserCompanyCode select a.DealerCode).FirstOrDefault();
                    if (uUserCompanyCode == SBSCompanyCode)
                    {
                        var sCompanyApplications = (from a in SContext.CompanyApplications where a.CompanyCode == uUserCompanyCode && a.ActiveFlag == "Y" select a.ApplicationCode.Trim()).ToList();
                        if (sCompanyApplications.Contains(SBSAppCode))
                        {
                            string sSecUserApps = (from a in SContext.SecurityUserApplications where a.UserCode == uUserCode && a.ApplicationCode == SBSAppCode && a.AllowFlag == "Y" select a.ApplicationCode).FirstOrDefault();
                            if (!string.IsNullOrWhiteSpace(sSecUserApps))
                            {
                                System.Web.HttpContext.Current.Session["UserName"]    = item.LoginName;
                                System.Web.HttpContext.Current.Session["UserCode"]    = item.UserCode;
                                System.Web.HttpContext.Current.Session["CompanyCode"] = item.CompCode;
                                System.Web.HttpContext.Current.Session["CompanyDesc"] = DefinitionContext.Dealers.Where(x => x.DealerCode == item.CompCode).Select(x => x.DealerDesc).FirstOrDefault();
                                var UserRights = SContext.SecurityUserAccesses.Where(s => s.UserCode == item.UserCode && s.ApplicationCode == SBSAppCode).ToList();
                                System.Web.HttpContext.Current.Session["UserRights"] = UserRights;
                                List <SecurityUserAccess> ItemObj = new List <SecurityUserAccess>();
                                foreach (var items in UserRights)
                                {
                                    SecurityUserAccess master = new SecurityUserAccess();
                                    master.ID              = items.ID;
                                    master.UserCode        = items.UserCode;
                                    master.ApplicationCode = items.ApplicationCode;
                                    master.FormCode        = items.FormCode;
                                    master.FormActionCode  = items.FormActionCode;
                                    master.ActionValue     = items.ActionValue;
                                    ItemObj.Add(master);
                                }
                                System.Web.HttpContext.Current.Session["UserRights"] = ItemObj;
                                value = true;
                            }
                        }
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Session["LoginError"] = "User Name or Password Is Incorrect...!";
                    }
                }
            }
            return(value);
        }
Пример #4
0
        //000000000
        public List <SecurityUserAccess> GetByUserAppForm(SecurityUser pSecurityUser, SecurityForm pSecurityForm)
        {
            List <SecurityUserAccess>        vList  = new List <SecurityUserAccess>();
            IRepository <SecurityUserAccess> repSUA = new Repository <SecurityUserAccess>(ctx);

            try
            {
                var query = from a in ctx.SecurityFormActions
                            join b in ctx.SecurityUserAccesses.Where(o => o.UserCode == pSecurityUser.UserCode) on
                            new { a.ApplicationCode, a.FormCode, a.FormActionCode } equals new { b.ApplicationCode, b.FormCode, b.FormActionCode } into Details
                from ua in Details.DefaultIfEmpty()
                where a.ApplicationCode == pSecurityForm.ApplicationCode && a.FormCode == pSecurityForm.FormCode
                    select new { a, ua };

                //string strQuery = "exec sp_SecurityUserActionALL @UserID='" + pSecurityUser.ID + "', @UserCode='" + pSecurityUser.UserCode + "', @FormID='" + pSecurityForm.ID + "'";

                foreach (var eachItem in query)
                {
                    if (eachItem.ua == null)
                    {
                        SecurityUserAccess oNew = new SecurityUserAccess();
                        oNew.UserCode        = pSecurityUser.UserCode;
                        oNew.ApplicationCode = eachItem.a.ApplicationCode;
                        oNew.FormCode        = eachItem.a.FormCode;
                        oNew.FormName        = pSecurityForm.FormName;

                        oNew.FormActionCode = eachItem.a.FormActionCode;
                        oNew.FormActionName = eachItem.a.FormActionName;
                        oNew.ActionValue    = "N";

                        vList.Add(oNew);
                    }
                    else
                    {
                        eachItem.ua.FormActionName = eachItem.a.FormActionName;
                        vList.Add(eachItem.ua);
                    }
                }

                return(vList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        //insert SecurityUserRight object
        public bool Insert(SecurityUserAccess pSecurityUserAccess)
        {
            try
            {
                //pSecurityUserAccess.ID = GetMaxID();
                pSecurityUserAccess.UserCode        = pSecurityUserAccess.UserCode;
                pSecurityUserAccess.ApplicationCode = pSecurityUserAccess.ApplicationCode;
                pSecurityUserAccess.FormCode        = pSecurityUserAccess.FormCode;
                pSecurityUserAccess.FormActionCode  = pSecurityUserAccess.FormActionCode;
                pSecurityUserAccess.ActionValue     = pSecurityUserAccess.ActionValue;

                rep.Add(pSecurityUserAccess);
                rep.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }