コード例 #1
0
        public List <LUserRoleVM> GetRoleSettingsByOrgDID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_OrgDetailsID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                WCFReturnResult returnResult = new WCFReturnResult();

                LUOrgDetailsAccessPolicy lUOrgDetailsAccessPolicy = new LUOrgDetailsAccessPolicy();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                bool ret = false;

                List <LUserRoleVM> entityList_R = new List <LUserRoleVM>();

                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_OrgDetailsID, out guid_OrgDID))
                    {
                        entityList_R = lUOrgDetailsAccessPolicy.Get_RoleSettings_OrgDID(guid_OrgDID);
                    }
                }
                return(entityList_R);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }
コード例 #2
0
        public ODSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserOrgDetailsVM 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_CheckPrivilege = false;

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

                ODSerListResult returnResult = new ODSerListResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                OrgDRespository entityRepos_OrgD = new OrgDRespository(dbContext, entity_BaseSession.ID);

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

                bool allowEdit = entity_BaseSession.CheckAccessRight(entity_WCFAuthInfoVM.RequestFunKey, "Edit", "", null);
                bool allowDel  = entity_BaseSession.CheckAccessRight(entity_WCFAuthInfoVM.RequestFunKey, "Delete", "", null);

                bool allowEdit_Role = entity_BaseSession.CheckAccessRight("LURoleManage", "Edit", "", null);
                bool allowDel_Role  = entity_BaseSession.CheckAccessRight("LURoleManage", "Delete", "", null);

                returnResult.StrList_Error                = strList_Error;
                returnResult.Int_TotalRecordCount         = 0;
                returnResult.EntityList_LUserOrgDetailsVM = new List <LUserOrgDetailsVM>();

                if (ret_CheckPrivilege)
                {
                    int recordCount = 0;

                    if (entity_SearchCriteria == null)
                    {
                        entity_SearchCriteria = new LUserOrgDetailsVM();
                    }

                    if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.OrgDetailsKey) && str_CustomFilter.Count == 0)
                    {
                        str_CustomFilter.Add(String.Format("{0}.StartsWith(\"{1}\")", "OD_Key", entity_SearchCriteria.OrgDetailsKey));
                    }

                    LUOrgDetailsAccessPolicy lUOrgDetailsAccessPolicy = new LUOrgDetailsAccessPolicy();

                    Func <List <LUserOrgDetails>, List <LUserOrgDetails> > func_OtherFilter = (entityList_OrgDetails) =>
                    {
                        List <LUserOrgDetails> ret = entityList_OrgDetails;
                        if (entity_SearchCriteria.OrgDetailsType.HasValue)
                        {
                            if (entity_SearchCriteria.OrgDetailsType.Value == 1)
                            {
                                ret = ret.Where(current => current.OD_Type.HasValue && current.OD_Type.Value == 1).ToList();
                            }
                            else if (entity_SearchCriteria.OrgDetailsType.Value == 2)
                            {
                                ret = ret.Where(current => current.OD_Type.HasValue && current.OD_Type.Value == 2).ToList();
                                if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.SC_RoleName))
                                {
                                    List <LUserOrgDetailsVM> entityList_LoginUservm = lUOrgDetailsAccessPolicy.Get_OrgDetailsSettings_RoleName(dbContext, entity_SearchCriteria.SC_RoleName.ToString());

                                    var IDList_LoginUserVM = entityList_LoginUservm.Select(current => current.ID).ToList();

                                    ret = ret.Where(current => IDList_LoginUserVM.Contains(current.ID)).ToList();
                                }
                            }
                        }

                        if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.OrgDetailsKey))
                        {
                            string str_OrganizationKey = entity_SearchCriteria.OrgDetailsKey.ToString();
                            ret = ret.Except(ret.Where(current => current.OD_Key.IndexOf(str_OrganizationKey) != 0)).ToList();
                        }
                        return(ret);
                    };

                    List <LUserOrgDetailsVM> vmList = entityRepos_OrgD.GetEntityListByPage(entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, out recordCount, str_CustomFilter, func_OtherFilter, null, (entityList_VM) =>
                    {
                        foreach (var item in entityList_VM)
                        {
                            if (item.OrgDetailsType == 2)
                            {
                                List <LUserRoleVM> entityList_RoleVM = lUOrgDetailsAccessPolicy.Get_RoleSettings_OrgDID(item.ID);

                                foreach (var item_Role in entityList_RoleVM)
                                {
                                    item_Role.AllowDel  = allowDel_Role;
                                    item_Role.AllowEdit = allowEdit_Role;
                                }

                                item.EntityList_Role    = entityList_RoleVM;
                                item.OrgDetailsTypeName = MultilingualHelper.GetStringFromResource(languageKey, "AsRoleSetting");
                            }
                            else if (item.OrgDetailsType == 1)
                            {
                                item.OrgDetailsTypeName = MultilingualHelper.GetStringFromResource(languageKey, "SpecificFunctions");
                            }

                            item.AllowDel  = allowDel;
                            item.AllowEdit = allowEdit;
                        }
                        return(entityList_VM);
                    });

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

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }