Exemplo n.º 1
0
        public void DeleteOrg()
        {
            orgMgtController.FunTypeKey = "Delete";
            commonFixture.MockControllerInfo(orgMgtController, "http://localhost:50653/AccessControl/LUOrganizationManage/Delete");

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

            List <LUserOrganizationVM> entityList_OrgVM = orgMgtController.orgMgtHelper.Value.GetAll(entity_WCFAuthInfoVM);

            Assert.NotEmpty(entityList_OrgVM);

            LUserOrganizationVM entity_OrgVM = entityList_OrgVM.Where(current => current.OrganizationPath == "1100").FirstOrDefault();

            Assert.NotNull(entity_OrgVM);

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

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

            Assert.NotNull(jsonResult.Data);

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

            Assert.True(((CommonJsonResult)jsonResult.Data).Success);
        }
        public WCFReturnResult Update(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserOrganizationVM entity_OrgVM)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                WCFReturnResult returnResult = new WCFReturnResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                LUserOrganizationRespository entityRepos_Org = new LUserOrganizationRespository(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_Org.Update(entity_OrgVM, 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);
            }
        }
Exemplo n.º 3
0
        public WCFReturnResult Update(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserOrganizationVM orgVM)
        {
            WCFReturnResult ret = null;

            ret = _client.Update(entity_WCFAuthInfoVM, orgVM);
            return(ret);
        }
Exemplo n.º 4
0
        public List <string> CustomFilter(LUserOrganizationVM vm)
        {
            List <string> strList_Query = new List <string>();

            if (!string.IsNullOrWhiteSpace(vm.OrganizationKey))
            {
                strList_Query.Add(String.Format("{0}.StartsWith(\"{1}\")", "LUO_Key", vm.OrganizationKey));
            }
            return(strList_Query);
        }
Exemplo n.º 5
0
        // GET: AccessControl/LUOrganizationManage
        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, "LUOrganizationManage");

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

            LUserOrganizationVM selectionCriteria = new LUserOrganizationVM();

            GetSelectionCriteriaFromViewData(ref selectionCriteria);

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

            //Define wcf output object;
            OrgSerListResult entity_OrgSerListResult = null;

            WebCommonHelper webCommonHelper = new WebCommonHelper();

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

            //Assign data to local variable
            if (entity_OrgSerListResult != null)
            {
                recordCount       = entity_OrgSerListResult.Int_TotalRecordCount;
                entityList_Result = entity_OrgSerListResult.EntityList_LUserOrganizationVM;
            }

            StorePageInfo(recordCount, page);

            StoreSelectionCriteria <FunctionVM>(null);

            //Pass Error To UI
            string strError = "";

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

            if (!string.IsNullOrWhiteSpace(strError))
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;
                ViewBag.ActionMessage = errorMsgInfo;
            }

            return(View(entityList_Result));
        }
Exemplo n.º 6
0
        public ActionResult Create(LUserOrganizationVM orgVM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LUOrganizationManage_Create");

            WebCommonHelper webCommonHelper = new WebCommonHelper();

            List <LUserOrgDetailsVM> entityList_OrgDetailsVM = initOrgDetailsList();

            ViewBag.OrgDList = webCommonHelper.GetSelectList(entityList_OrgDetailsVM, "OrgDetailsKey", "ID", true);

            ModelState.Clear();
            TryValidateModel(orgVM);

            if (!ErrorMsgHelper.CustomValiation(str_MsgBoxTitle, ModelState, ViewBag))
            {
                return(View(orgVM));
            }

            string strError = "";

            //Define wcf output object;
            WCFReturnResult ret = new WCFReturnResult();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                ret = orgMgtHelper.Value.Create(entity_WCFAuthInfoVM, orgVM);
            });

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

            if (ret != null && ret.IsSuccess)
            {
                MsgInfo successMsgInfo = new MsgInfo();
                successMsgInfo.MsgTitle    = str_MsgBoxTitle;
                successMsgInfo.MsgDesc     = MultilingualHelper.GetStringFromResource(languageKey, "I000");
                successMsgInfo.MsgType     = MessageType.Success;
                TempData[ActionMessageKey] = successMsgInfo;
                return(RedirectToAction("Index"));
            }
            else
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;
                ViewBag.ActionMessage = errorMsgInfo;
                return(View(orgVM));
            }
        }
        public OrgSerEditResult GetEntityByID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_OrgID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

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

                OrgSerEditResult returnResult = new OrgSerEditResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                LUserOrganizationRespository Respo_Org = new LUserOrganizationRespository(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_OrgDID = default(Guid);
                    if (Guid.TryParse(str_OrgID, out guid_OrgDID))
                    {
                        LUserOrganizationVM db_OrgVM = Respo_Org.GetEntityByID(guid_OrgDID, languageKey, ref strList_Error);

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

                        returnResult.Entity_LUserOrganizationVM = 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);
            }
        }
Exemplo n.º 8
0
        public void Search()
        {
            orgMgtController.FunTypeKey = "Search";
            commonFixture.MockControllerInfo(orgMgtController, "http://localhost:50653/AccessControl/LUOrganizationManage/Index");

            LUserOrganizationVM entity_OrgVM = new LUserOrganizationVM();

            entity_OrgVM.OrganizationPath = "0001";

            ViewResult viewResult = (ViewResult)orgMgtController.Index(entity_OrgVM);

            Assert.NotNull(viewResult);

            Assert.NotEmpty((List <LUserOrganizationVM>)viewResult.Model);
        }
Exemplo n.º 9
0
        public void CreateOrg()
        {
            orgMgtController.FunTypeKey = "Create";
            commonFixture.MockControllerInfo(orgMgtController, "http://localhost:50653/AccessControl/LUOrganizationManage/Create");

            LUserOrganizationVM orgVM = new LUserOrganizationVM()
            {
                OrganizationPath   = "1100",
                OrganizationKey    = "1100",
                OrganizationName   = "1100",
                OrganizationStatus = 1
            };

            ActionResult result = orgMgtController.Create(orgVM);

            Assert.IsType <RedirectToRouteResult>(result);
        }
Exemplo n.º 10
0
        public void EditOrg()
        {
            orgMgtController.FunTypeKey = "Edit";
            commonFixture.MockControllerInfo(orgMgtController, "http://localhost:50653/AccessControl/LUOrganizationManage/Edit");

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

            List <LUserOrganizationVM> entityList_OrgVM = orgMgtController.orgMgtHelper.Value.GetAll(entity_WCFAuthInfoVM);

            Assert.NotEmpty(entityList_OrgVM);

            LUserOrganizationVM entity_OrgVM = entityList_OrgVM.Where(current => current.OrganizationPath == "1100").FirstOrDefault();

            Assert.NotNull(entity_OrgVM);

            entity_OrgVM.OrganizationKey = "Test1100";

            ActionResult actionResult = orgMgtController.Edit(entity_OrgVM);

            Assert.IsType <RedirectToRouteResult>(actionResult);
        }
Exemplo n.º 11
0
        public OrgSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserOrganizationVM 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>();

                OrgSerListResult returnResult = new OrgSerListResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                LUserOrganizationRespository entityRepos_Org = new LUserOrganizationRespository(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_LUserOrganizationVM = new List <LUserOrganizationVM>();

                if (ret_CheckPrivilege)
                {
                    int recordCount = 0;

                    Func <List <LUserOrganization>, List <LUserOrganization> > func_OtherFilter = (entityList_LUVM) =>
                    {
                        List <LUserOrganization> ret = entityList_LUVM;
                        if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.OrganizationPath))
                        {
                            string str_OrganizationPath = entity_SearchCriteria.OrganizationPath.ToString();
                            ret = ret.Except(ret.Where(current => current.LUO_Path.IndexOf(str_OrganizationPath) != 0)).ToList();
                        }

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

                    List <LUserOrganizationVM> vmList = entityRepos_Org.GetEntityListByPage(entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, out recordCount, str_CustomFilter, func_OtherFilter, (entityList_VM) =>
                    {
                        List <LUserOrganizationVM> ret = new List <LUserOrganizationVM>();
                        if (!string.IsNullOrWhiteSpace(str_SortColumn))
                        {
                            if (str_SortColumn.ToLower() == "OrganizationPath")
                            {
                                if (str_SortDir.ToLower() == "asc")
                                {
                                    entityRepos_Org.SortFunctionByPath(ret, entityList_VM, "ASC");
                                }
                                else
                                {
                                    entityRepos_Org.SortFunctionByPath(ret, entityList_VM, "Desc");
                                }
                            }
                            else
                            {
                                ret = entityList_VM;
                            }
                        }
                        else
                        {
                            entityRepos_Org.SortFunctionByPath(ret, entityList_VM, "ASC");
                        }
                        return(ret);
                    }, (entityList_VM) =>
                    {
                        foreach (var item in entityList_VM)
                        {
                            if (!string.IsNullOrWhiteSpace(MultilingualHelper.GetStringFromResource(languageKey, item.OrganizationKey)))
                            {
                                item.OrganizationName = MultilingualHelper.GetStringFromResource(languageKey, item.OrganizationKey);
                            }
                        }
                        return(entityList_VM);
                    });

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

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
Exemplo n.º 12
0
        public List <LUserAccessByOrgVM> GetEntityListByIDList_LUserAccessByOrgVM(WCFAuthInfoVM entity_WCFAuthInfoVM, List <string> strList_OrgID, List <string> strList_OrgDetailsID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

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

                bool ret_CheckPrivilege = false;

                List <LUserAccessByOrgVM> ret = new List <LUserAccessByOrgVM>();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                LoginUserRespository entityRepos_LoginUser = new LoginUserRespository(dbContext, entity_BaseSession.ID);

                SessionWUserInfo entity_SessionWUserInfo = entityRepos_LoginUser.GetLoginUserAccRight(entity_BaseSession.ID);

                string str_E025 = MultilingualHelper.GetStringFromResource(languageKey, "E025");
                if (entity_SessionWUserInfo == null)
                {
                    if (!ret_CheckPrivilege)
                    {
                        strList_Error.Add(str_E025);
                    }
                }

                if (strList_Error.Count == 0)
                {
                    LUserOrganizationRespository orgRespo = new LUserOrganizationRespository(dbContext, entity_BaseSession.ID);

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

                    for (int i = 0; i < strList_OrgID.Count; ++i)
                    {
                        LUserOrganizationVM entity_LUserOrgVM = orgRespo.GetLUOrgVM_ID(strList_OrgID[i]);

                        LUserOrgDetailsVM entity_LUserOrgDetailsVM = orgDetailsRespo.GetLUOrgDVM_ID(strList_OrgDetailsID[i]);

                        if (entity_LUserOrgVM != null && entity_LUserOrgDetailsVM != null)
                        {
                            LUserAccessByOrgVM entity_LUserAccessByOrgVM = new LUserAccessByOrgVM();

                            entity_LUserAccessByOrgVM.UA_Org_ID  = Guid.Parse(strList_OrgID[i]);
                            entity_LUserAccessByOrgVM.UA_OrgD_ID = Guid.Parse(strList_OrgDetailsID[i]);

                            entity_LUserAccessByOrgVM.Entity_OrgVM = entity_LUserOrgVM;

                            entity_LUserAccessByOrgVM.OrganizationKey  = entity_LUserOrgVM.OrganizationKey;
                            entity_LUserAccessByOrgVM.OrganizationName = MultilingualHelper.GetStringFromResource(languageKey, entity_LUserAccessByOrgVM.OrganizationKey);

                            if (entity_LUserOrgDetailsVM != null)
                            {
                                entity_LUserAccessByOrgVM.Entity_OrgDVM = entity_LUserOrgDetailsVM;

                                entity_LUserAccessByOrgVM.OrgDetailsKey  = entity_LUserOrgDetailsVM.OrgDetailsKey;
                                entity_LUserAccessByOrgVM.OrgDetailsType = entity_LUserOrgDetailsVM.OrgDetailsType;

                                if (entity_LUserOrgDetailsVM.OrgDetailsType.HasValue)
                                {
                                    if (entity_LUserOrgDetailsVM.OrgDetailsType.Value == 1)
                                    {
                                        entity_LUserAccessByOrgVM.OrgDetailsTypeName = MultilingualHelper.GetStringFromResource(languageKey, "SpecificFunctions");
                                    }
                                    else if (entity_LUserOrgDetailsVM.OrgDetailsType.Value == 2)
                                    {
                                        entity_LUserAccessByOrgVM.OrgDetailsTypeName = MultilingualHelper.GetStringFromResource(languageKey, "AsRoleSetting");
                                    }
                                }
                            }
                            ret.Add(entity_LUserAccessByOrgVM);
                        }
                    }
                }
                return(ret);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
Exemplo n.º 13
0
        public ActionResult Edit(LUserOrganizationVM organizationVM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LUOrganizationManage_Edit");

            WebCommonHelper webCommonHelper = new WebCommonHelper();

            List <LUserRoleVM> entityList_RoleVM = new List <LUserRoleVM>();
            List <FunctionVM>  entityList_FunVM  = new List <FunctionVM>();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entityList_FunVM = funMgtHelper.Value.GetAll(entity_WCFAuthInfoVM);

                entityList_RoleVM = roleMgtHelper.Value.GetAll(entity_WCFAuthInfoVM);
            });

            ViewBag.RoleList = webCommonHelper.GetSelectList(entityList_RoleVM, "RoleName", "ID", true);

            entityList_FunVM.ForEach(current => current.FunctionKey = current.FunctionPath + " - " + MultilingualHelper.GetStringFromResource(current.FunctionKey));

            ViewBag.FunIDs = webCommonHelper.GetSelectList(entityList_FunVM, "FunctionKey", "ID", true);

            ModelState.Clear();
            TryValidateModel(organizationVM);

            if (!ErrorMsgHelper.CustomValiation(str_MsgBoxTitle, ModelState, ViewBag))
            {
                return(View(organizationVM));
            }

            string strError = "";

            WCFReturnResult entity_Return = new WCFReturnResult();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entity_Return = orgMgtHelper.Value.Update(entity_WCFAuthInfoVM, organizationVM);
            });

            if (entity_Return != null && entity_Return.IsSuccess)
            {
                webCommonHelper.RefreshSeverSideSession(this, this.HttpContext, postOffice.LoginUserMgtSerPath);
            }

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

            if (entity_Return != null && entity_Return.IsSuccess)
            {
                MsgInfo successMsgInfo = new MsgInfo();
                successMsgInfo.MsgTitle    = str_MsgBoxTitle;
                successMsgInfo.MsgDesc     = MultilingualHelper.GetStringFromResource(languageKey, "I000");
                successMsgInfo.MsgType     = MessageType.Success;
                TempData[ActionMessageKey] = successMsgInfo;
                return(RedirectToAction("Index"));
            }
            else
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;
                ViewBag.ActionMessage = errorMsgInfo;
                return(View(organizationVM));
            }
        }
Exemplo n.º 14
0
        public OrgSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserOrganizationVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter)
        {
            OrgSerListResult ret = null;

            ret = _client.GetListWithPaging(entity_WCFAuthInfoVM, entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, str_CustomFilter);
            return(ret);
        }