Exemplo n.º 1
0
        public List <FunDetailInfo> GetPrivilegeByUserID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_ID, RoleType enum_RoleType)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                WCFReturnResult returnResult = new WCFReturnResult();

                AccPrivilegePolicy userRoleFunDetailsPolicy = new AccPrivilegePolicy();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                bool ret = false;

                List <FunDetailInfo> entityList_FunDetailInfo = new List <FunDetailInfo>();

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

                ret = CheckTokenOnly(entity_BaseSession, ref strList_Error);

                if (ret)
                {
                    Guid guid_OrgDID = default(Guid);
                    if (Guid.TryParse(str_ID, out guid_OrgDID))
                    {
                        entityList_FunDetailInfo = userRoleFunDetailsPolicy.Get_LoginUserPrivilege_UserID(dbContext, guid_OrgDID, enum_RoleType);

                        foreach (var item in entityList_FunDetailInfo)
                        {
                            item.FName = MultilingualHelper.GetStringFromResource(languageKey, item.FKey);
                        }
                    }
                }
                return(entityList_FunDetailInfo);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }
Exemplo n.º 2
0
        public List <FunDetailInfo> GetPrivilegeByUserID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_ID, RoleType enum_RoleType)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);



                WCFReturnResult returnResult = new WCFReturnResult();

                AccPrivilegePolicy userRoleFunDetailsPolicy = new AccPrivilegePolicy();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                bool ret = false;

                List <FunDetailInfo> entityList_FunDetailInfo = new List <FunDetailInfo>();

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

                ret = CheckTokenOnly(entity_BaseSession, ref strList_Error);

                if (ret)
                {
                    Guid guid_OrgDID = default(Guid);
                    if (Guid.TryParse(str_ID, out guid_OrgDID))
                    {
                        entityList_FunDetailInfo = userRoleFunDetailsPolicy.Get_LoginUserPrivilege_UserID(dbContext, guid_OrgDID, RoleType.Role);
                    }
                }
                return(entityList_FunDetailInfo);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
Exemplo n.º 3
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);
            }
        }