Esempio n. 1
0
        public WCFReturnResult Create(WCFAuthInfoVM entity_WCFAuthInfoVM, FunctionTypeVM entity_FunTypeVM)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                WCFReturnResult returnResult = new WCFReturnResult();

                //Contruct Login User Respository
                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();
                FunctionTypeRespository     Respo_FT  = new FunctionTypeRespository(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 = Respo_FT.Create(entity_FunTypeVM, languageKey, ref strList_Error);
                }

                returnResult.IsSuccess = ret;

                returnResult.StrList_Error = strList_Error;

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
        public FTSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, FunctionTypeVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter)
        {
            FTSerListResult ret = null;

            ret = _client.GetListWithPaging(entity_WCFAuthInfoVM, entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, str_CustomFilter);
            return(ret);
        }
        public WCFReturnResult Update(WCFAuthInfoVM entity_WCFAuthInfoVM, FunctionTypeVM functionTypeVM)
        {
            WCFReturnResult ret = null;

            ret = _client.Update(entity_WCFAuthInfoVM, functionTypeVM);
            return(ret);
        }
        public void DeleteFunType()
        {
            ftManageController.FunTypeKey = "Delete";
            commonFixture.MockControllerInfo(ftManageController, "http://localhost:50653/AccessControl/FTManage/Delete");

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

            List <FunctionTypeVM> entityList_FunTypeVM = ftManageController.funTypeMgtHelper.Value.GetAllFunType(entity_WCFAuthInfoVM);

            Assert.NotEmpty(entityList_FunTypeVM);

            FunctionTypeVM entity_FunTypeVM = entityList_FunTypeVM.Where(current => current.FunctionType == "FTTest3").FirstOrDefault();

            Assert.NotNull(entity_FunTypeVM);

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

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

            Assert.NotNull(jsonResult.Data);

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

            Assert.True(((CommonJsonResult)jsonResult.Data).Success);
        }
Esempio n. 5
0
        // GET: AccessControl/FTMange
        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, "FTManage");

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

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

            //Define wcf output object;
            FTSerListResult entity_FTSerListResult = null;

            FunctionTypeVM selectionCriteria = new FunctionTypeVM();

            //Retrieve selection criteria that cached by system
            GetSelectionCriteriaFromViewData(ref selectionCriteria);

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

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

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

            //Set paging bar info (Total Record Count and Page Index)
            StorePageInfo(recordCount, page);
            //Cache selection criteria
            StoreSelectionCriteria <FunctionVM>(null);

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

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

            if (entity_FTSerListResult.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));
        }
Esempio n. 6
0
        public List <string> CustomFilter(FunctionTypeVM vm)
        {
            List <string> strList_Query = new List <string>();

            if (!string.IsNullOrWhiteSpace(vm.FunctionType))
            {
                strList_Query.Add(String.Format("{0}.StartsWith(\"{1}\")", "FT_Name", vm.FunctionType));
            }
            return(strList_Query);
        }
Esempio n. 7
0
        public ActionResult Create(FunctionTypeVM functionTypeVM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "FTManage_Create");

            ModelState.Clear();
            TryValidateModel(functionTypeVM);

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

            string strError = "";

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

            //Call WCF Service
            WebCommonHelper webCommonHelper = new WebCommonHelper();

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

            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(functionTypeVM));
            }
        }
        public void CreateFunType()
        {
            ftManageController.FunTypeKey = "Create";
            commonFixture.MockControllerInfo(ftManageController, "http://localhost:50653/AccessControl/FTManage/Create");

            FunctionTypeVM functionTypeVM = new FunctionTypeVM()
            {
                FunctionType = "FTTest"
            };

            ActionResult result = ftManageController.Create(functionTypeVM);

            Assert.IsType <RedirectToRouteResult>(result);
        }
Esempio n. 9
0
        public ActionResult Edit(FunctionTypeVM functionTypeVM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "FTManage_Edit");

            ModelState.Clear();
            TryValidateModel(functionTypeVM);

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

            string strError = "";

            WCFReturnResult entity_Return   = new WCFReturnResult();
            WebCommonHelper webCommonHelper = new WebCommonHelper();

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

            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)
            {
                webCommonHelper.RefreshSeverSideSession(this, this.HttpContext, postOffice.LoginUserMgtSerPath);

                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(functionTypeVM));
            }
        }
        public void Search()
        {
            ftManageController.FunTypeKey = "Search";
            commonFixture.MockControllerInfo(ftManageController, "http://localhost:50653/AccessControl/LoginUserManage/Index");

            FunctionTypeVM entity_FunTypeVM = new FunctionTypeVM();

            entity_FunTypeVM.FunctionType = "C";

            ViewResult viewResult = (ViewResult)ftManageController.Index(entity_FunTypeVM);

            Assert.NotNull(viewResult);

            Assert.NotEmpty((List <FunctionTypeVM>)viewResult.Model);
        }
Esempio n. 11
0
        public FTSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, FunctionTypeVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter)
        {
            try
            {
                //Restore Server Session by token
                RetrieveServerSideSession(entity_WCFAuthInfoVM);

                //Flag Success or Fail
                bool ret = false;

                //Define error list
                List <string> strList_Error = new List <string>();

                //Instantiate  FTSerListResult
                FTSerListResult returnResult = new FTSerListResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                FunctionTypeRespository entityRepos_FT = new FunctionTypeRespository(dbContext, entity_BaseSession.ID);

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

                //Initialize FTSerListResult instance
                returnResult.StrList_Error             = strList_Error;
                returnResult.Int_TotalRecordCount      = 0;
                returnResult.EntityList_FunctionTypeVM = new List <FunctionTypeVM>();

                //Success
                if (ret)
                {
                    int recordCount = 0;

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

                    //Assign data to FTSerListResult instance
                    returnResult.EntityList_FunctionTypeVM = vmList;
                    returnResult.Int_TotalRecordCount      = recordCount;
                }

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
Esempio n. 12
0
        public ActionResult Edit(string guid)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "FTManage_Edit");

            string strError = "";

            //Define wcf output object;
            FTSerEditResult entity_Return = new FTSerEditResult();

            //Call WCF Service
            WebCommonHelper webCommonHelper = new WebCommonHelper();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entity_Return = funTypeMgtHelper.Value.GetEntityByID(entity_WCFAuthInfoVM, guid);
            });

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

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

                FunctionTypeVM selectionCriteria = new FunctionTypeVM();

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

                TempData[SelectionCriteriaKey] = selectionCriteria;

                TempData[ActionMessageKey] = errorMsgInfo;
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(entity_Return.Entity_FunctionTypeVM));
            }
        }
        public FTSerEditResult GetEntityByID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_FTID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

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

                FTSerEditResult returnResult = new FTSerEditResult();

                //Contruct Login User Respository
                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                FunctionTypeRespository Respo_FT = new FunctionTypeRespository(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("FTManage", "Edit", "", null);
                bool allowDel  = entity_BaseSession.CheckAccessRight("FTManage", "Delete", "", null);

                if (ret)
                {
                    FunctionTypeVM db_FunctionTypeVM = Respo_FT.GetEntityByID(Guid.Parse(str_FTID), languageKey, out strList_Error);

                    db_FunctionTypeVM.AllowDel  = allowDel;
                    db_FunctionTypeVM.AllowEdit = allowEdit;

                    returnResult.Entity_FunctionTypeVM = db_FunctionTypeVM;
                }

                returnResult.StrList_Error = strList_Error;

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }
        public void EditFunType()
        {
            ftManageController.FunTypeKey = "Edit";
            commonFixture.MockControllerInfo(ftManageController, "http://localhost:50653/AccessControl/FTManage/Edit");

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

            List <FunctionTypeVM> entityList_FunTypeVM = ftManageController.funTypeMgtHelper.Value.GetAllFunType(entity_WCFAuthInfoVM);

            Assert.NotEmpty(entityList_FunTypeVM);

            FunctionTypeVM entity_FunTypeVM = entityList_FunTypeVM.Where(current => current.FunctionType.IndexOf("FTTest") == 0).FirstOrDefault();

            Assert.NotNull(entity_FunTypeVM);

            entity_FunTypeVM.FunctionType = "FTTest3";

            ActionResult actionResult = ftManageController.Edit(entity_FunTypeVM);

            Assert.IsType <RedirectToRouteResult>(actionResult);
        }
Esempio n. 15
0
        public FTSerEditResult GetEntityByID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_FTID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

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

                FTSerEditResult returnResult = new FTSerEditResult();

                //Contruct Login User Respository
                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                FunctionTypeRespository Respo_FT = new FunctionTypeRespository(dbContext, entity_BaseSession.ID);

                bool ret = false;

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

                if (ret)
                {
                    FunctionTypeVM db_FunctionTypeVM = Respo_FT.GetEntityByID(Guid.Parse(str_FTID), languageKey, out strList_Error);

                    returnResult.Entity_FunctionTypeVM = db_FunctionTypeVM;
                }

                returnResult.StrList_Error = strList_Error;

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
        public FTSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, FunctionTypeVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter)
        {
            try
            {
                //Restore Server Session by token
                RetrieveServerSideSession(entity_WCFAuthInfoVM);

                //Flag Success or Fail
                bool ret = false;

                //Define error list
                List <string> strList_Error = new List <string>();

                //Instantiate  FTSerListResult
                FTSerListResult returnResult = new FTSerListResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                FunctionTypeRespository entityRepos_FT = new FunctionTypeRespository(dbContext, entity_BaseSession.ID);

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

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

                //Initialize FTSerListResult instance
                returnResult.StrList_Error             = strList_Error;
                returnResult.Int_TotalRecordCount      = 0;
                returnResult.EntityList_FunctionTypeVM = new List <FunctionTypeVM>();

                //Success
                if (ret)
                {
                    int recordCount = 0;

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

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

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

                        return(entityList_FunTypeVM);
                    });

                    //Assign data to FTSerListResult instance
                    returnResult.EntityList_FunctionTypeVM = vmList;
                    returnResult.Int_TotalRecordCount      = recordCount;
                }

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