public List <string> GetOrgPathListByLUID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_UserID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                List <string> strList_OrgPath_CheckUser = new List <string>();

                List <string> strList_Error = new List <string>();

                bool ret = false;

                ret = CheckTokenOnly(entity_BaseSession, ref strList_Error);

                if (ret)
                {
                    DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
                    {
                        strList_OrgPath_CheckUser = CoolUtilities.CoolLinqUtility.InnerJoin(
                            dbContext.LUserAccessByOrgs.AsNoTracking().Where(current => current.UA_User_ID.ToString() == str_UserID).ToList(),
                            dbContext.LUserOrganizations.AsNoTracking().ToList(),
                            (left, right) => left.UA_Org_ID == right.ID,
                            (left, right) => right).Select(current => current.LUO_Path).ToList();
                    });
                }

                return(strList_OrgPath_CheckUser);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
Beispiel #2
0
        public void ValuesValidation()
        {
            DBContextHelper database = new DBContextHelper();
            DataTable       table    = database.GetAllCust();

            Assert.IsNotNull(table);
        }
Beispiel #3
0
        public List <Guid> GetLUIDList(WCFAuthInfoVM entity_WCFAuthInfoVM, List <string> strList_OrgPath)
        {
            List <Guid> lUserList = new List <Guid>();

            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                bool ret = false;

                List <string> strList_Error = new List <string>();

                ret = CheckTokenOnly(entity_BaseSession, ref strList_Error);

                if (ret)
                {
                    if (strList_OrgPath.Count() == 0)
                    {
                        DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
                        {
                            lUserList = dbContext.LUsers.Select(current => current.ID).ToList();
                        });
                    }
                    else
                    {
                        DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
                        {
                            //Filter Under Organization
                            List <LUserOrganization> entityList_LUserOrganization = dbContext.LUserOrganizations.AsNoTracking().Where(current => strList_OrgPath.Where(current1 => current.LUO_Path.IndexOf(current1) == 0 && current.LUO_Path != current1).Count() > 0).ToList();

                            List <Guid> guidList_OrgID = entityList_LUserOrganization.Select(current => current.ID).ToList();

                            var entityList_LUserAccessByOrgs = dbContext.LUserAccessByOrgs.AsNoTracking().ToList().Where(current => guidList_OrgID.Contains(current.UA_Org_ID));

                            List <Guid> guidList = CoolUtilities.CoolLinqUtility.InnerJoin(entityList_LUserAccessByOrgs, dbContext.LUsers.AsNoTracking().ToList(), (left, right) =>
                                                                                           left.UA_User_ID == right.ID, (left, right) => right.ID
                                                                                           ).ToList();

                            //Add Current User
                            guidList.Add(entity_BaseSession.ID);

                            if (guidList.Count > 0)
                            {
                                lUserList = guidList;
                            }
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
            return(lUserList);
        }
        public async Task GetSkillById()
        {
            using var ctx = await DBContextHelper.ResetWithData(testSkills);

            ICodingSkillRepository repo = new CodingSkillRepository(ctx);

            CodingSkillEntity skill = await repo.GetById(testSkills.First().Id);

            Assert.Equal(skill.Id, testSkills.First().Id);
            Assert.Equal(skill.Name, testSkills.First().Name);
            Assert.Equal(skill.Level, testSkills.First().Level);
        }
        public IList <string> GetOrgPathListBy(Guid guid_UserID)
        {
            IList <string> strList_OrgPath_CheckUser = new List <string>();

            DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
            {
                strList_OrgPath_CheckUser = CoolUtilities.CoolLinqUtility.InnerJoin(
                    dbContext.LUserAccessByOrgs.AsNoTracking().Where(current => current.UA_User_ID == guid_UserID).ToList(),
                    dbContext.LUserOrganizations.AsNoTracking().ToList(),
                    (left, right) => left.UA_Org_ID == right.ID,
                    (left, right) => right).Select(current => current.LUO_Path).ToList();
            });
            return(strList_OrgPath_CheckUser);
        }
        public async Task AddUser()
        {
            var newUser = GetUsers(1).First();

            newUser.Id = 0;

            using var ctx = await DBContextHelper.ResetWithData(testUsers);

            IUserRepository repo = new UserRepository(ctx);

            var user = await repo.Add(newUser);

            Assert.True(user.Id != 0);
            Assert.Equal(user.UserName, newUser.UserName);
            Assert.Equal(user.Password, newUser.Password);
        }
        public async Task GetSkillByLevel()
        {
            var testSkill = testSkills.First();

            using var ctx = await DBContextHelper.ResetWithData(testSkills);

            ICodingSkillRepository repo = new CodingSkillRepository(ctx); var filter = new CodingSkillFilter()

            {
                Levels = new List <CodingSkillLevel> {
                    testSkill.Level
                }
            };
            IEnumerable <CodingSkillEntity> skills = await repo.GetByFilter(filter);

            Assert.All(skills, skill => filter.Levels.Contains(skill.Level));
            Assert.Contains(skills, s => s.Id == testSkill.Id);
        }
        public IDictionary <Guid, List <string> > GetOrgPathListByUserIDList(List <Guid> guidList_UserID)
        {
            IDictionary <Guid, List <string> > ret = new Dictionary <Guid, List <string> >();

            foreach (var guid_UserID in guidList_UserID)
            {
                List <string> strList_OrgPath_CheckUser = new List <string>();
                DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
                {
                    strList_OrgPath_CheckUser = CoolUtilities.CoolLinqUtility.InnerJoin(
                        dbContext.LUserAccessByOrgs.AsNoTracking().Where(current => current.UA_User_ID == guid_UserID).ToList(),
                        dbContext.LUserOrganizations.AsNoTracking().ToList(),
                        (left, right) => left.UA_Org_ID == right.ID,
                        (left, right) => right).Select(current => current.LUO_Path).ToList();
                });
                ret[guid_UserID] = strList_OrgPath_CheckUser;
            }
            return(ret);
        }
        AHSerListResult IAuthHisMgtSer.GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, AuthorizedHistoryVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter)
        {
            try
            {
                //Restore Server Session
                RetrieveServerSideSession(entity_WCFAuthInfoVM);

                bool ret = false;

                List <string> strList_Error = new List <string>();

                AHSerListResult returnResult = new AHSerListResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                AuthorizedHistoryRespository entityRepos_AH = new AuthorizedHistoryRespository(dbContext, entity_BaseSession.ID);

                #region [ Check Privilege ]
                ret = CheckAccPrivilege(entity_BaseSession.ID, entity_WCFAuthInfoVM.RequestFunKey, entity_WCFAuthInfoVM.RequestFunTypeKey, ref strList_Error);
                #endregion

                returnResult.StrList_Error                  = strList_Error;
                returnResult.Int_TotalRecordCount           = 0;
                returnResult.EntityList_AuthorizedHistoryVM = new List <AuthorizedHistoryVM>();

                if (ret)
                {
                    int recordCount = 0;

                    List <AuthorizedHistoryVM> vmList = entityRepos_AH.GetEntityListByPage(entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, out recordCount, str_CustomFilter, (entityList) =>
                    {
                        List <AuthorizedHistory> entityList_AuthorizedHistory = new List <AuthorizedHistory>();

                        if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.LoginName))
                        {
                            DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext_Temp =>
                            {
                                List <LUser> entityList_LUser = dbContext_Temp.LUsers.Where(current => current.LU_Name.IndexOf(entity_SearchCriteria.LoginName) == 0).ToList();
                                if (entityList_LUser != null && entityList_LUser.Count > 0)
                                {
                                    List <Guid> guidList_UserID = entityList_LUser.Select(current => current.ID).ToList();

                                    entityList_AuthorizedHistory = entityList.Where(current => guidList_UserID.Contains(current.AH_UserID) && (!string.IsNullOrWhiteSpace(entity_SearchCriteria.OperationType) ? current.AH_EventType == entity_SearchCriteria.OperationType : true)).ToList();
                                }
                            });
                        }
                        else
                        {
                            DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext_Temp =>
                            {
                                entityList_AuthorizedHistory = entityList.Where(current => !string.IsNullOrWhiteSpace(entity_SearchCriteria.OperationType) ? current.AH_EventType == entity_SearchCriteria.OperationType : true).ToList();
                            });
                        }
                        return(entityList_AuthorizedHistory);
                    }, null, (entityList) =>
                    {
                        List <Guid> userIDList = entityList.Select(current => current.LoginUserID).ToList();

                        List <LUser> entityList_LUser_GetLoginName = new List <LUser>();

                        DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext_Temp =>
                        {
                            entityList_LUser_GetLoginName = dbContext_Temp.LUsers.Where(current => userIDList.Contains(current.ID)).ToList();
                        });

                        foreach (var item in entityList)
                        {
                            var item_LUser = entityList_LUser_GetLoginName.Where(current => current.ID == item.LoginUserID).FirstOrDefault();
                            if (item_LUser != null)
                            {
                                item.LoginName = item_LUser.LU_Name;
                            }

                            if (item.OperationType == OperationType.L.ToString())
                            {
                                item.OperationTypeName = MultilingualHelper.GetStringFromResource(languageKey, "Login");
                            }
                            else if (item.OperationType == OperationType.O.ToString())
                            {
                                item.OperationTypeName = MultilingualHelper.GetStringFromResource(languageKey, "Logout");
                            }
                        }
                        return(entityList);
                    });

                    returnResult.EntityList_AuthorizedHistoryVM = vmList;
                    returnResult.Int_TotalRecordCount           = recordCount;
                }

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
Beispiel #10
0
        public LUSerEditResult GetEntityByIDWDetails(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_LUID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                List <string> strList_Error = new List <string>();

                bool ret_CheckPrivilege = false;

                LUSerEditResult ret = new LUSerEditResult();
                ret.StrList_Error = strList_Error;

                Guid ID = Guid.Parse(str_LUID);

                ret_CheckPrivilege = CheckAccPrivilege(entity_BaseSession.ID, entity_WCFAuthInfoVM.RequestFunKey, entity_WCFAuthInfoVM.RequestFunTypeKey, ref strList_Error);

                if (ret_CheckPrivilege)
                {
                    string      str_Error      = "";
                    LoginUserVM db_LoginUserVM = null;

                    DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
                    {
                        LoginUserRespository Respo_LU = new LoginUserRespository(dbContext, entity_BaseSession.ID);
                        db_LoginUserVM = Respo_LU.GetEntityByID(ID, languageKey, ref strList_Error);
                    });

                    if (!string.IsNullOrWhiteSpace(str_Error))
                    {
                        ret.StrList_Error.Add(str_Error);
                    }
                    else
                    {
                        db_LoginUserVM.isChangePwd = false;

                        //By Role Settings
                        if (db_LoginUserVM.UserType.HasValue && db_LoginUserVM.UserType.Value == 2)
                        {
                            LUserAccessPolicy lUserAccessPolicy = new LUserAccessPolicy();

                            DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
                            {
                                List <LUserRoleVM> entityList = lUserAccessPolicy.Get_RoleSettings_LUserID(dbContext, ID);

                                if (entityList.Count > 0)
                                {
                                    db_LoginUserVM.roleListIDList = entityList.Select(currrent => currrent.ID.ToString()).Aggregate((first, next) =>
                                    {
                                        return(first + "|" + next);
                                    });
                                }
                            });
                        }
                        //By Organization Settings
                        else if (db_LoginUserVM.UserType.HasValue && db_LoginUserVM.UserType.Value == 3)
                        {
                            DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
                            {
                                LUserAccessByOrgRespository entity_LUserAccessByOrgRespo = new LUserAccessByOrgRespository(dbContext, entity_BaseSession.ID);

                                List <LUserAccessByOrgVM> entityList = entity_LUserAccessByOrgRespo.Get_LoginUserOrgSettings_LUserID(dbContext, ID);

                                if (entityList.Count > 0)
                                {
                                    db_LoginUserVM.orgListIDList = entityList.Select(currrent => currrent.UA_Org_ID.ToString()).Aggregate((first, next) =>
                                    {
                                        return(first + "|" + next);
                                    });

                                    db_LoginUserVM.orgDetailsIDList = entityList.Select(currrent => currrent.UA_OrgD_ID.ToString()).Aggregate((first, next) =>
                                    {
                                        return(first + "|" + next);
                                    });
                                }
                            });
                        }
                        //By Specific Function Settings
                        else
                        {
                            DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext =>
                            {
                                AccPrivilegePolicy userRoleFunDetailsPolicy = new AccPrivilegePolicy();

                                List <FunDetailInfo> entityList_FunDetailInfo = userRoleFunDetailsPolicy.Get_LoginUserPrivilege_UserID(dbContext, ID);

                                db_LoginUserVM.EntityList_FDInfo = entityList_FunDetailInfo;
                            });
                        }
                    }
                    ret.Entity_LoginUserVM = db_LoginUserVM;
                }
                return(ret);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }