コード例 #1
0
ファイル: CustomerAuthorize.cs プロジェクト: nmtri1987/Duc-fw
        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);
            }
        }
コード例 #2
0
ファイル: CustomerAuthorize.cs プロジェクト: nmtri1987/Duc-fw
        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);
            }
        }