Ejemplo n.º 1
0
        public RoleSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserRoleVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter)
        {
            RoleSerListResult ret = null;

            ret = _client.GetListWithPaging(entity_WCFAuthInfoVM, entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, str_CustomFilter);
            return(ret);
        }
        // GET: AccessControl/LURoleManage
        public ActionResult Index(int page = 1, string sort = "", string sortDir = "")
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LoginUserManage_Create");

            LUserRoleVM selectionCriteria = new LUserRoleVM();

            GetSelectionCriteriaFromViewData(ref selectionCriteria);

            //Define output variable(recordCount && entityList_Result)
            int recordCount = 0;

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

            //Define wcf output object;
            RoleSerListResult entity_RoleSerListResult = null;

            //Instantiate WebCommonHelper in order to call wcf service
            WebCommonHelper webCommonHelper = new WebCommonHelper();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entity_RoleSerListResult = roleMgtHelper.Value.GetListWithPaging(entity_WCFAuthInfoVM, selectionCriteria, page, PageSize, sort, sortDir, CustomFilter(selectionCriteria));
            });

            if (entity_RoleSerListResult != null)
            {
                recordCount       = entity_RoleSerListResult.Int_TotalRecordCount;
                entityList_Result = entity_RoleSerListResult.EntityList_LUserRoleVM;
            }

            StorePageInfo(recordCount, page);

            StoreSelectionCriteria <LUserRoleVM>(null);

            string strError = "";

            if (entity_RoleSerListResult.StrList_Error.Count() > 0)
            {
                strError = string.Join("<br/>", entity_RoleSerListResult.StrList_Error.ToArray());
            }

            if (entity_RoleSerListResult.StrList_Error.Count > 0)
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;
                ViewBag.ActionMessage = errorMsgInfo;
            }

            return(View(entityList_Result));
        }
Ejemplo n.º 3
0
        public RoleSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserRoleVM 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>();

                RoleSerListResult returnResult = new RoleSerListResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                UserRoleRespository entityRepos_Role = new UserRoleRespository(dbContext, entity_BaseSession.ID);

                #region [ Check Privilege ]
                ret_CheckPrivilege = 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_LUserRoleVM = new List <LUserRoleVM>();

                if (ret_CheckPrivilege)
                {
                    int recordCount = 0;

                    List <LUserRoleVM> vmList = entityRepos_Role.GetEntityListByPage(entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, out recordCount, str_CustomFilter);

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

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
        public RoleSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserRoleVM 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>();

                RoleSerListResult returnResult = new RoleSerListResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                UserRoleRespository entityRepos_Role = new UserRoleRespository(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);

                returnResult.StrList_Error          = strList_Error;
                returnResult.Int_TotalRecordCount   = 0;
                returnResult.EntityList_LUserRoleVM = new List <LUserRoleVM>();

                if (ret_CheckPrivilege)
                {
                    int recordCount = 0;

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

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

                    List <LUserRoleVM> vmList = entityRepos_Role.GetEntityListByPage(entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, out recordCount, str_CustomFilter, null, null, (entityList_VM) =>
                    {
                        foreach (var item in entityList_VM)
                        {
                            item.AllowDel  = allowDel;
                            item.AllowEdit = allowEdit;
                        }
                        return(entityList_VM);
                    });

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