예제 #1
0
        /// <summary>
        /// 构造操作管理中的页面展示 数据源
        /// </summary>
        /// <returns></returns>
        public NySoftland.Core.Result GenerateResourceReadOnlyForOperation()
        {
            Result result = new Result();
            List <ModuleGroup_Readonly_Model> moduleGroupList_ViewModel = new List <ModuleGroup_Readonly_Model>();

            try
            {
                var moduleGroupList = moduleGroupBll.GetAllModuleGroup();
                moduleGroupList.ForEach(g =>
                {
                    //初始化Module Group 视图模型 基础属性
                    var moduleGroupObj = new ModuleGroup_Readonly_Model();
                    moduleGroupObj.Instance(g);

                    #region 构造与当前module Group 关联的Modules
                    //Module 实体列表
                    var moduleList = moduleBll.GetModuleListByModuleGroupID(g.ID);

                    //Module 模型列表
                    var moduleList_ViewModel = new List <Module_Readonly_Model>();


                    //Copy(moduleList, moduleList_ViewModel);

                    //使用 Module 实体列表 初始化 Module 模型列表
                    moduleList.ForEach(m =>
                    {
                        //初始化module 基本属性
                        var module_ViewModel = new Module_Readonly_Model();
                        module_ViewModel.Instance(m);

                        #region 构造与当前module关联的Operations
                        //Operation 模型列表
                        var operationList_ViewModel = new List <Operation_Readonly_Model>();

                        //Operation 实体列表
                        var operationList = operationBll.GetOperationByModuleID(m.ID);

                        //使用 Operation 实体列表 初始化 Operation 模型列表
                        operationList.ForEach(o =>
                        {
                            var operation_ViewModel = new Operation_Readonly_Model();
                            operation_ViewModel.Instance(o);
                            operationList_ViewModel.Add(operation_ViewModel);
                        });

                        #endregion

                        //初始化Module 视图模型关联的OperationLst属性
                        module_ViewModel.OperationLst = operationList_ViewModel;

                        moduleList_ViewModel.Add(module_ViewModel);
                    });

                    #endregion

                    //初始化Module Group 视图模型关联的 ModulelLst属性
                    moduleGroupObj.ModulelLst = moduleList_ViewModel;
                    moduleGroupList_ViewModel.Add(moduleGroupObj);
                });


                result.Message    = "";
                result.IsSucess   = true;
                result.ResultCode = 0;
                //result.Datas = new JavaScriptSerializer().Serialize(moduleGroupList_ViewModel);
                result.Datas = JsonConvert.SerializeObject(moduleGroupList_ViewModel);
            }
            catch (Exception ex)
            {
                result.Message    = ex.Message;
                result.IsSucess   = false;
                result.ResultCode = 1;
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// 构造操作管理中的操作编辑 数据源
        /// </summary>
        /// <returns></returns>
        public Result GenerateResourceEditForOperation(string moduleID)
        {
            Result result          = new Result();
            var    specifiedModule = moduleBll.GetModuleByID(moduleID);

            try
            {
                //初始化module 基本属性
                var module_ViewModel = new Module_Readonly_Model();
                module_ViewModel.Instance(specifiedModule);

                #region 构造与当前module关联的Operations. return operationList_ViewModel
                //Operation 模型列表
                var operationList_ViewModel = new List <Operation_Readonly_Model>();

                //Operation 实体列表
                var operationList = operationBll.GetOperationByModuleID(moduleID);

                //使用 Operation 实体列表 初始化 Operation 模型列表
                operationList.ForEach(o =>
                {
                    var operation_ViewModel = new Operation_Readonly_Model();
                    operation_ViewModel.Instance(o);
                    operationList_ViewModel.Add(operation_ViewModel);
                });

                #endregion

                #region 构造基础CRUD Operations. return operationBasedList_ViewModel(因数据库表结构暂时不变更,暂时取消基本操作列)
                ////Operation 模型列表
                //var operationBasedList_ViewModel = new List<Operation_Readonly_Model>();

                ////Operation 实体列表
                //var operationBasedList = operationBll.GetAllOperation(o => o.IsBasedOp && o.IsEnable && !o.IsDelete);

                ////使用 Operation 实体列表 初始化 Operation 模型列表
                //operationBasedList.ForEach(o =>
                //{
                //    //基础 Operation中排除已选Operation中存在的
                //    if (operationList.FirstOrDefault(op => op.ID == o.ID) == null)
                //    {
                //        var operationBased_ViewModel = new Operation_Readonly_Model();
                //        operationBased_ViewModel.Instance(o);
                //        operationBasedList_ViewModel.Add(operationBased_ViewModel);
                //    }
                //});

                #endregion

                //初始化Module 视图模型关联的OperationLst属性
                module_ViewModel.OperationLst = operationList_ViewModel;

                //初始化Module 视图模型关联的OperationLst属性
                //module_ViewModel.BaseOperationLst = operationBasedList_ViewModel;

                result.Message    = "";
                result.IsSucess   = true;
                result.ResultCode = 0;
                result.Datas      = JsonConvert.SerializeObject(module_ViewModel);
            }
            catch (Exception ex)
            {
                result.Message    = ex.Message;
                result.IsSucess   = false;
                result.ResultCode = 1;
            }

            return(result);
        }