Пример #1
0
        public ActionResult CreateOrEdit(Guid id)
        {
            bool isNew = false;
            var  bo    = _Service.GetSingle(id);

            if (bo == null)
            {
                bo    = new Person();
                bo.ID = id;
                isNew = true;
            }
            var boVM = new PersonVM(bo);

            boVM.ParentItemColection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(true);

            boVM.CredentialsTypeCollection = BusinessCollectionFactory <CredentialsType> .GetPlainFacadeItemCollection();

            boVM.JobLevelCollection = BusinessCollectionFactory <JobLevel> .GetPlainFacadeItemCollection();

            boVM.JobTitleCollection = BusinessCollectionFactory <JobTitle> .GetPlainFacadeItemCollection();

            var editor = PageComponentRepository <PersonVM> .CreateOrEditDialog(boVM, isNew);

            return(Json(editor));
        }
Пример #2
0
        public ActionResult Index(string typeID)
        {
            var pageIndex = 1;
            var pageSize  = 18;

            if (String.IsNullOrEmpty(typeID))
            {
                typeID = _DepartmentService.GetSingleBy(x => x.ParentDapartment.ID == x.ID).ID.ToString();
            }
            var dID = Guid.Parse(typeID);

            var boCollection = _Service.Paginate(pageIndex, pageSize, x => x.SortCode, x => x.Department.ID == dID);
            var paginate     = new MucPaginate(boCollection.PageIndex, boCollection.PageSize, boCollection.TotalCount);

            var boVMCollection = new List <PersonVM>();
            int count          = 0;

            foreach (var item in boCollection)
            {
                var boVM = new PersonVM(item);
                boVM.OrderNumber = (++count).ToString();
                boVMCollection.Add(boVM);
            }
            var leftNavigatorItemCollection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(false);

            // 创建页面模型
            var pageModel = PageModelRepository <PersonVM> .GetPageMode(boVMCollection, leftNavigatorItemCollection, paginate);

            return(View("../../Views/Admin/Common/Index", pageModel));
        }
Пример #3
0
        public ActionResult RefreshTreeView()
        {
            var leftNavigatorItemCollection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(false);

            var pageModel = PageModelRepository <DepartmentVM> .GetTreeViewNavigator(leftNavigatorItemCollection, "系统业务部门");

            return(Json(pageModel.InnerHtmlContent));
        }
Пример #4
0
 public MyAppQueryContext
 (
     BusinessContext businessContext,
     BusinessObjectFactory <TObject, TEntry, Int32> objectFactory,
     BusinessCollectionFactory <TCollection, TReadOnlyCollection, TObject, TEntry, Int32> collectionFactory
 )
     : base(businessContext, objectFactory, collectionFactory)
 {
 }
Пример #5
0
        public ActionResult Save(DepartmentVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo    = new Department();
                    bo.ID = boVM.ID;
                }
                var parentBo = bo; // 对于具有层次结构关系的实体类,如果没有选择上级层次对象,缺省处理为自身,即为根节点对象。
                if (!String.IsNullOrEmpty(boVM.ParentItemID))
                {
                    parentBo = _Service.GetSingle(Guid.Parse(boVM.ParentItemID));
                }

                boVM.MapToBo(bo, parentBo);

                _Service.AddOrEditAndSave(bo);

                var typeID            = bo.ParentDapartment.ID.ToString();
                var extessionFunction = "RefreshTreeView"; // 约定数据持久化之后,除了执行返回列表的方法外,还需要执行的刷新导航树的另外的方法

                return(Json(PageComponentRepository <DepartmentVM> .SaveOK(true, "1", typeID, extessionFunction)));
            }
            else
            {
                var vItems = new List <ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name         = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                boVM.ParentItemColection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(true);

                var editor = PageComponentRepository <DepartmentVM> .UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;

                return(Json(editor));
            }
        }
Пример #6
0
 public BusinessQueryContext
 (
     BusinessContext businessContext,
     BusinessObjectFactory <TObject, TEntry, TKey> objectFactory,
     BusinessCollectionFactory <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> collectionFactory,
     IDictionary <object, IBusinessQueryFilter <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> > customFilters = null,
     IBusinessQueryFilter <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> finalizingFilter = null
 )
 {
     BusinessContext   = businessContext;
     ObjectFactory     = objectFactory;
     CollectionFactory = collectionFactory;
     CustomFilters     = customFilters.ToImmutableDictionary();
     FinalizingFilter  = finalizingFilter;
 }
Пример #7
0
        public ActionResult Index(string typeID)
        {
            // 提取缺省的部门,用于约束列表中的下级部门
            var defaultDepartment = _Service.GetSingleBy(x => x.ParentDapartment.ID == x.ID);

            if (!String.IsNullOrEmpty(typeID))
            {
                var id = Guid.Parse(typeID);
                defaultDepartment = _Service.GetSingle(id);
            }
            var boCollection = _Service.FindBy(x => x.ParentDapartment.ID == defaultDepartment.ID).OrderBy(s => s.SortCode);

            // 创建部门视图模型集合
            var boVMCollection = new List <DepartmentVM>();
            var count          = 0;

            foreach (var bo in boCollection)
            {
                var boVM = new DepartmentVM(bo);
                boVM.OrderNumber = (++count).ToString();
                var addColItems = new List <CommonAlinkItem>()
                {
                    new CommonAlinkItem()
                    {
                        DisplayName     = "<span class=\"icon-user-3\"></span> 部门数据配置",
                        OnClickFunction = "javascript:departmentConfig(\"" + bo.ID + "\")"
                    },
                };
                boVM.AdditionOperateUrlItems = addColItems;

                boVMCollection.Add(boVM);
            }

            // 提取用于处理左列导航树的列表
            var leftNavigatorItemCollection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(false);

            // 创建页面模型
            var pageModel = PageModelRepository <DepartmentVM> .GetPageMode(boVMCollection, leftNavigatorItemCollection, null);

            return(View("../../Views/Admin/Common/Index", pageModel));
        }
Пример #8
0
        public ActionResult SinglePerson(string keyword, string deptID, string selectedPersonID, string selectedPersonIDItem, string selectedPersonDisplayDiv)
        {
            var boCollection   = _PersonService.GetAll();
            var boVMCollection = new List <PlainFacadeItem>();

            foreach (var item in boCollection)
            {
                var boVM = new PlainFacadeItem()
                {
                    ID = item.ID.ToString(), Name = item.Name, SortCode = item.SortCode
                };
                if (item.Department != null)
                {
                    boVM.Description = item.Department.Name;
                }

                boVMCollection.Add(boVM);
            }

            var tempName = "";

            if (!String.IsNullOrEmpty(selectedPersonID))
            {
                tempName = _PersonService.GetSingle(Guid.Parse(selectedPersonID)).Name;
            }

            ViewBag.SelectedPersonIDItem     = selectedPersonIDItem;
            ViewBag.SelectedPersonDisplayDiv = selectedPersonDisplayDiv;

            ViewBag.SelectedPersonID   = selectedPersonID;
            ViewBag.SelectedPersonName = tempName;

            ViewBag.PersonKeyword = keyword;

            ViewBag.Departments = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(true);

            ViewBag.SelectedDepartmentID = deptID;

            return(PartialView("../../Views/Common/Person/_SinglePersonSelector", boVMCollection));
        }
Пример #9
0
        public ActionResult Save(PersonVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo    = new Person();
                    bo.ID = boVM.ID;
                }

                boVM.MapToBo(bo);

                var creID          = Guid.Parse(boVM.CredentialsTypeID);
                var credentialType = _Service.GetSingleRelevance <CredentialsType>(creID);

                var jlID     = Guid.Parse(boVM.JobLevelID);
                var jobLevel = _Service.GetSingleRelevance <JobLevel>(jlID);

                var jtID     = Guid.Parse(boVM.JobTitleID);
                var jobTitle = _Service.GetSingleRelevance <JobTitle>(jtID);

                var dID  = Guid.Parse(boVM.ParentItemID);
                var dept = _Service.GetSingleRelevance <Department>(dID);

                bo.Name = bo.FirstName + bo.LastName;
                if (String.IsNullOrEmpty(bo.SortCode))
                {
                    bo.SortCode = BusinessEntityComponentsFactory.SortCodeByDefaultDateTime <Person>();
                }

                bo.CredentialsType = credentialType;
                bo.JobLevel        = jobLevel;
                bo.JobTitle        = jobTitle;
                bo.Department      = dept;
                bo.UpdateTime      = DateTime.Now;
                bo.IsActivePerson  = true;

                _Service.AddOrEditAndSave(bo);

                //var personInDepartment = _Service.GetSingleRelevanceBy<PersonsInDepartment>(p => p.Person.ID == bo.ID && p.Department.ID == dID);
                //if (personInDepartment == null)
                //{
                //    personInDepartment = new PersonsInDepartment() { Department = dept, Person = bo };
                //    _Service.AddAndSaveRelevance<PersonsInDepartment>(personInDepartment);
                //}

                var typeID = boVM.ParentItemID;
                return(Json(PageComponentRepository <PersonVM> .SaveOK(true, "1", typeID)));
            }
            else
            {
                var vItems = new List <ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name         = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                boVM.ParentItemColection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(true);

                boVM.CredentialsTypeCollection = BusinessCollectionFactory <CredentialsType> .GetPlainFacadeItemCollection();

                boVM.JobLevelCollection = BusinessCollectionFactory <JobLevel> .GetPlainFacadeItemCollection();

                boVM.JobTitleCollection = BusinessCollectionFactory <JobTitle> .GetPlainFacadeItemCollection();

                var editor = PageComponentRepository <PersonVM> .UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;

                return(Json(editor));
            }
        }