public WCFReturnResult Update(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserRoleVM entity_RoleVM)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                WCFReturnResult returnResult = new WCFReturnResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

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

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

                bool ret = false;

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

                if (ret)
                {
                    ret = entityRepos_Role.Update(entity_RoleVM, languageKey, ref strList_Error);
                }

                returnResult.IsSuccess = ret;

                returnResult.StrList_Error = strList_Error;

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }
Пример #2
0
        public void DeleteRole()
        {
            roleManageController.FunTypeKey = "Delete";
            commonFixture.MockControllerInfo(roleManageController, "http://localhost:50653/AccessControl/LURoleManage/Delete");

            WCFAuthInfoVM entity_WCFAuthInfoVM = new WCFAuthInfoVM("", "", commonFixture.StrToken, roleManageController.FunKey, roleManageController.FunTypeKey, this.commonFixture.LanguageKey.ToString(), "");

            List <LUserRoleVM> entityList_OrgVM = roleManageController.roleMgtHelper.Value.GetAll(entity_WCFAuthInfoVM);

            Assert.NotEmpty(entityList_OrgVM);

            LUserRoleVM entity_RoleVM = entityList_OrgVM.Where(current => current.RoleName.IndexOf("Test") == 0).FirstOrDefault();

            Assert.NotNull(entity_RoleVM);

            FormCollection formCollection = new FormCollection(new NameValueCollection
            {
                { "ID", entity_RoleVM.ID.ToString() }
            });

            JsonResult jsonResult = (JsonResult)roleManageController.Delete(formCollection);

            Assert.NotNull(jsonResult.Data);

            Assert.IsType <CommonJsonResult>(jsonResult.Data);

            Assert.True(((CommonJsonResult)jsonResult.Data).Success);
        }
        public ActionResult Edit(string ID)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LURoleManage_Edit");

            initFunsList();

            string strError = "";

            RoleSerEditResult wcf_Return = new RoleSerEditResult();

            WebCommonHelper webCommonHelper = new WebCommonHelper();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                wcf_Return = roleMgtHelper.Value.GetEntityByID(entity_WCFAuthInfoVM, ID);
            });

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

                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;

                LUserRoleVM selectionCriteria = new LUserRoleVM();

                if (TempData.ContainsKey(SelectionCriteriaKey))
                {
                    selectionCriteria = (LUserRoleVM)TempData[SelectionCriteriaKey];
                }

                TempData[SelectionCriteriaKey] = selectionCriteria;

                TempData[ActionMessageKey] = errorMsgInfo;

                return(RedirectToAction("Index"));
            }
            else
            {
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
                {
                    List <FunDetailInfo> entityList_FunDetailInfo = orgDetailMgtHelper.Value.GetPrivilegeByUserID(entity_WCFAuthInfoVM, ID, RoleType.Role);

                    wcf_Return.Entity_LUserRoleVM.EntityList_FDInfo = entityList_FunDetailInfo;
                    wcf_Return.Entity_LUserRoleVM.funDListJson      = javaScriptSerializer.Serialize(entityList_FunDetailInfo);
                });
            }

            return(View(wcf_Return.Entity_LUserRoleVM));
        }
        // 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));
        }
        public RoleSerEditResult GetEntityByID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_RoleID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

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

                RoleSerEditResult returnResult = new RoleSerEditResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

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

                bool ret = false;

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

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

                if (ret)
                {
                    Guid guid_RoleID = default(Guid);
                    if (Guid.TryParse(str_RoleID, out guid_RoleID))
                    {
                        LUserRoleVM db_OrgVM = Respo_Role.GetEntityByID(guid_RoleID, languageKey, ref strList_Error);

                        db_OrgVM.AllowEdit = allowEdit;
                        db_OrgVM.AllowDel  = allowDel;

                        returnResult.Entity_LUserRoleVM = db_OrgVM;
                    }
                    else
                    {
                        ret = false;
                        string str_Message = MultilingualHelper.GetStringFromResource(languageKey, "E012");
                        strList_Error.Add(string.Format(str_Message, "ID"));
                    }
                }

                returnResult.StrList_Error = strList_Error;

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }
Пример #6
0
        public void Search()
        {
            roleManageController.FunTypeKey = "Search";
            commonFixture.MockControllerInfo(roleManageController, "http://localhost:50653/AccessControl/LURoleManage/Index");

            LUserRoleVM entity_RoleVM = new LUserRoleVM();

            entity_RoleVM.RoleName = "Admin";

            ViewResult viewResult = (ViewResult)roleManageController.Index(entity_RoleVM);

            Assert.NotNull(viewResult);

            Assert.NotEmpty((List <LUserRoleVM>)viewResult.Model);
        }
        // GET: AccessControl/SystemInfoManage
        public ActionResult Index()
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "SystemInfoManage");

            string strError = "";

            SystemInfoVM entity_SystemInfoVM = null;

            WebCommonHelper webCommonHelper = new WebCommonHelper();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entity_SystemInfoVM = systemMgtHelper.Value.GetSystemInfo(entity_WCFAuthInfoVM);
            });

            if (entity_SystemInfoVM == null)
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;

                LUserRoleVM selectionCriteria = new LUserRoleVM();

                if (TempData.ContainsKey(SelectionCriteriaKey))
                {
                    selectionCriteria = (LUserRoleVM)TempData[SelectionCriteriaKey];
                }

                TempData[SelectionCriteriaKey] = selectionCriteria;

                TempData[ActionMessageKey] = errorMsgInfo;

                return(View("Index"));
            }
            else
            {
                if (TempData[ActionMessageKey] != null)
                {
                    ViewBag.ActionMessage = TempData[ActionMessageKey];
                }

                return(View(entity_SystemInfoVM));
            }
        }
Пример #8
0
        public void EditRole()
        {
            roleManageController.FunTypeKey = "Edit";
            commonFixture.MockControllerInfo(roleManageController, "http://localhost:50653/AccessControl/LURoleManage/Edit");

            //00010001
            FunctionVM entity_FunctionVM = entityList_FunVM.Where(current => current.FunctionPath == "00010001").FirstOrDefault();

            string str_FunID = entity_FunctionVM.ID.ToString();

            FunDetailInfo entity_FunDetailInfo = new FunDetailInfo();

            WebCommonHelper webCommonHelper      = new WebCommonHelper();
            WCFAuthInfoVM   entity_WCFAuthInfoVM = new WCFAuthInfoVM("", "", commonFixture.StrToken, roleManageController.FunKey, roleManageController.FunTypeKey, this.commonFixture.LanguageKey.ToString(), "");

            entity_FunDetailInfo = roleManageController.funMgtHelper.Value.GetFunDetailInfo_FID(entity_WCFAuthInfoVM, str_FunID);
            entity_FunDetailInfo.FDSelected.ForEach(current => current = true);

            if (entity_FunDetailInfo.FDSelected.Count > 0)
            {
                entity_FunDetailInfo.FDSelected[entity_FunDetailInfo.FDSelected.Count - 1] = false;
            }

            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

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

            entityList_FunDetailInfo.Add(entity_FunDetailInfo);

            List <LUserRoleVM> entityList_RoleVM = roleManageController.roleMgtHelper.Value.GetAll(entity_WCFAuthInfoVM);

            Assert.NotEmpty(entityList_RoleVM);

            LUserRoleVM entity_RoleVM = entityList_RoleVM.Where(current => current.RoleName.IndexOf("Test") == 0).FirstOrDefault();

            Assert.NotNull(entity_RoleVM);

            entity_RoleVM.funDListJson = javaScriptSerializer.Serialize(entityList_FunDetailInfo);

            ActionResult actionResult = roleManageController.Edit(entity_RoleVM);

            Assert.IsType <RedirectToRouteResult>(actionResult);
        }
Пример #9
0
        public void CreateRole()
        {
            roleManageController.FunTypeKey = "Create";
            commonFixture.MockControllerInfo(roleManageController, "http://localhost:50653/AccessControl/LURoleManage/Create");

            Random random = new Random();

            #region [ Create User Role with Specific Functions ]
            //00010001
            FunctionVM entity_FunctionVM = entityList_FunVM.Where(current => current.FunctionPath == "00010001").FirstOrDefault();

            string str_FunID = entity_FunctionVM.ID.ToString();

            FunDetailInfo entity_FunDetailInfo = new FunDetailInfo();

            WebCommonHelper webCommonHelper = new WebCommonHelper();
            webCommonHelper.CallWCFHelper(roleManageController, (entity_WCFAuthInfoVM) =>
            {
                entity_FunDetailInfo = roleManageController.funMgtHelper.Value.GetFunDetailInfo_FID(entity_WCFAuthInfoVM, str_FunID);
                entity_FunDetailInfo.FDSelected.ForEach(current => current = true);
            });

            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            List <FunDetailInfo> entityList_FunDetailInfo = new List <FunDetailInfo>();
            entityList_FunDetailInfo.Add(entity_FunDetailInfo);

            int    r            = random.Next(1, 1000);
            string str_RoleName = "Test" + r;

            //User Role
            LUserRoleVM orgVM = new LUserRoleVM()
            {
                RoleName     = str_RoleName,
                funDListJson = javaScriptSerializer.Serialize(entityList_FunDetailInfo)
            };

            ActionResult actionResult = roleManageController.Create(orgVM);

            Assert.IsType <RedirectToRouteResult>(actionResult);
            #endregion
        }
Пример #10
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);
            }
        }