示例#1
0
        public static void ResetUser()
        {
            DNHUsers     objUser = null;
            RBVHEmployee objEmp  = RBVHEmployeeManager.GetByDomainId(GetNTId());

            if (objEmp.EmployeeCode != 0)
            {
                objUser = new DNHUsers()
                {
                    EmployeeCode   = objEmp.EmployeeCode,
                    EmployeeName   = objEmp.FirstName_EN + " " + objEmp.LastName_EN,
                    EmployeeNumber = objEmp.EmployeeNo,
                    JoinedDate     = objEmp.JoinedDate,
                    //DeprtmanetId = objEmp.EmpContract.DeptID,
                    EntityID = SystemConfig.DefaultEntity,
                    //  NTId = objEmp.DomainId,
                    DomainID  = objEmp.DomainId,
                    UserName  = objEmp.DomainId,
                    CompanyID = 1, ///think about to add Entity into this one
                };
                objUser.UserSiteMaps = CommonHelper.ReadWriteSiteMap(objUser);
                // Contract objContract = ContractManager.GetById(objEmp.EmployeeCode);
                //add UserSession
                Biz.Core.Helpers.SessionHelper.SetRBVH(objUser);
                //Auth = true;
            }
        }
示例#2
0
        public virtual DNHUserInRoles Save(DNHUserInRoles model)
        {
            model.CreatedDate  = SystemConfig.CurrentDate;
            model.ModifiedDate = SystemConfig.CurrentDate;
            string ErrorMessage = ValidateData(model);

            if (string.IsNullOrEmpty(ErrorMessage))
            {
                DNHUserInRoles OldRole = JsonConvert.DeserializeObject <DNHUserInRoles>(Get(model.UserID, model.CompanyID, model.RoleName));
                if (OldRole == null)
                {
                    DNHUsers objUser = DNHUsersManager.GetById(model.UserID, model.CompanyID);
                    if (objUser != null)
                    {
                        model.UserName = objUser.UserName;
                    }
                    model = Add(model);
                }
                else
                {
                    model = Update(model);
                }
            }
            else
            {
                model.ErrorMesssage = ErrorMessage;
            }
            return(model);
        }
示例#3
0
 public DNHSiteMapCollection GetNodeByLevel(DNHUsers objUser, int Max)
 {
     myTree   = new DNHSiteMapCollection();
     MaxValue = Max;
     foreach (DNHSiteMap node in objUser.UserSiteMaps)
     {
         if (node.ParentID == null || node.ParentID == Guid.Empty)
         {
             DigNode(node, objUser.UserName, objUser.CompanyID, 0);
         }
     }
     return(myTree);
 }
示例#4
0
        /// <summary>
        /// check Employee has Domain account or not
        /// Set Session for Employee
        /// </summary>
        /// <param name="NTId"></param>
        /// <returns></returns>
        public static bool setRBVHUser(string NTId)
        {
            bool     Auth    = false;
            DNHUsers objUser = RBVHUser();

            if (objUser != null)
            {
                Auth = true;
            }
            else
            {
                Auth = true;
            }
            return(Auth);
        }
示例#5
0
        public static bool CheckSiteMapPermission(DNHUsers CurrentUser, string controllerName, string actionName)
        {
            DNHSiteMapCollection result = CurrentUser.UserSiteMaps;
            bool             isAllow    = false;
            DNHSitemapAction objAction  = null;
            DNHSiteMap       objItem;

            //foreach (DNHSiteMap objItem in result)
            if (controllerName.ToLower() != "home")
            {
                for (int i = 0; i < result.Count; i++)

                {
                    objItem = result[i];
                    if (objItem.Url.Trim().ToLower() == controllerName.ToLower())
                    {
                        isAllow = true;
                        // check user Action
                        //objAction = CommonHelper.CheckActionPermission(objItem, actionName);
                        //if (objAction != null)
                        //{
                        //    isAllow = objAction.Allow;
                        //    if (objItem.Access != objAction.ID)
                        //    {
                        //        objItem.Access = objAction.ID;
                        //        result[i] = objItem;
                        //        CurrentUser.UserSiteMaps = result;
                        //    }

                        //}
                        //isAllow = true;
                        break;
                    }
                }
                ;
            }
            else
            {
                isAllow = true;
            }
            if (!isAllow && CurrentUser.IsAdmin)
            {
                isAllow = true;
            }
            return(isAllow);
        }
示例#6
0
        public static void ChangeUser(string DomainID)
        {
            string UserName = DomainID;
            //if the system don't have this domain --> Create the new User for him
            DNHUsers objUser = DNHUsersManager.GetByID(UserName, 1);

            if (objUser != null)
            {
                RBVHEmployee objEmp = RBVHEmployeeManager.GetByDomainId(UserName);
                if (objEmp.EmployeeCode != 0)
                {
                    objUser.EmployeeCode = objEmp.EmployeeCode;
                    objUser.EntityID     = objEmp.EntityID;
                    objUser.CompanyID    = 1;
                }
                objUser.UserSiteMaps = CommonHelper.ReadWriteSiteMap(objUser);
                Biz.Core.Helpers.SessionHelper.SetRBVH(objUser);
            }
        }
示例#7
0
        public static DNHUsers RBVHUser()
        {
            DNHUsers objUser = null;

            if (HttpContext.Current.Session[SystemConfig.loginKey] == null)
            {
                string UserName = GetNTId();
                //if the system don't have this domain --> Create the new User for him
                objUser = DNHUsersManager.GetByID(UserName, 1); ///Default company=1 for Bosch Company
                if (objUser == null)
                {
                    RBVHEmployee objEmp = RBVHEmployeeManager.GetByDomainId(UserName);
                    if (objEmp.EmployeeCode != 0)
                    {
                        objUser = new DNHUsers()
                        {
                            EmployeeCode   = objEmp.EmployeeCode,
                            EmployeeName   = objEmp.FirstName_EN + " " + objEmp.LastName_EN,
                            EmployeeNumber = objEmp.EmployeeNo,
                            JoinedDate     = objEmp.JoinedDate,
                            //DeprtmanetId = objEmp.EmpContract.DeptID,
                            EntityID = objEmp.EntityID,
                            //  NTId = objEmp.DomainId,
                            DomainID       = objEmp.DomainId,
                            UserName       = objEmp.DomainId,
                            CompanyID      = 1,
                            Email          = objEmp.Email,
                            PhoneNumber    = objEmp.HandPhone,
                            Application    = "APAC",
                            CreatedDate    = SystemConfig.CurrentDate,
                            EmailConfirmed = true,
                            CreatedUser    = "******"
                                             ///think about to add Entity into this one
                        };
                        DNHUsersManager.Add(objUser);
                        //get UserSiteMapp Permission
                        //   DNHSiteMapCollection objSMaps = CommonHelper.ReadWriteSiteMap(objUser);// new DNHSiteMapCollection(); //DNHSiteMapManager.GetAllByUser(objUser.DomainID, objUser.CompanyID, null);

                        ////save file
                        //string FileName = IOHelper.GetDirectory(CommonHelper.myConfig.UserDataFolder + objUser.CompanyID + "\\SiteMap\\" + objUser.UserName) + "\\sitemap.bin";
                        //if (IOHelper.HasFile(FileName))
                        //{
                        //    //get form the file
                        //    objSMaps = IOHelper.ReadFromBinaryFile<DNHSiteMapCollection>(FileName);
                        //}
                        //else
                        //{
                        //    objSMaps = DNHSiteMapManager.GetAllByUser(objUser.DomainID, objUser.CompanyID, null);
                        //    //var nopConfig =
                        //    if (objSMaps.Count > 0)
                        //    {

                        //        IOHelper.WriteToBinaryFile<IList<DNHSiteMap>>(FileName, objSMaps);
                        //    }
                        //}
                    }
                }
                else
                {
                    RBVHEmployee objEmp = RBVHEmployeeManager.GetByDomainId(UserName);
                    if (objEmp.EmployeeCode != 0)
                    {
                        objUser.EmployeeCode = objEmp.EmployeeCode;
                        objUser.EntityID     = objEmp.EntityID;
                        objUser.CompanyID    = 1;
                    }
                    objUser.UserSiteMaps = CommonHelper.ReadWriteSiteMap(objUser);
                    // objUser.EmployeeCode = 2297; //just use for test
                    // Contract objContract = ContractManager.GetById(objEmp.EmployeeCode);
                    //add UserSession
                    Biz.Core.Helpers.SessionHelper.SetRBVH(objUser);
                }
                return(objUser);
            }
            else
            {
                return(HttpContext.Current.Session[SystemConfig.loginKey] as DNHUsers);
            }
        }
示例#8
0
 public static void SetRBVH(DNHUsers objUser)
 {
     HttpContext.Current.Session[SystemConfig.loginKey] = objUser;
 }