Exemplo n.º 1
0
        /// <summary>
        /// 获取业务服务与业务方法映射模型
        /// </summary>
        /// <param name="mapIndex">输入参数</param>
        /// <returns>业务服务与业务方法映射模型</returns>
        private ServiceMethodMapViewModel GetServiceMethodMapViewModel(string mapIndex)
        {
            ServiceMethodMapViewModel model = new ServiceMethodMapViewModel();

            if (string.IsNullOrEmpty(mapIndex))
            {
                mapIndex = "-1";
            }
            string strIndex = mapIndex;

            if (string.IsNullOrEmpty(strIndex) || strIndex == "-1")
            {
                this.SelectedMapIndex = FindSelectedMapIndex("", "");
            }
            else
            {
                this.SelectedMapIndex = int.Parse(strIndex);
            }
            if (this.SelectedMapIndex > -1 && this.Method.MethodMaps.Length > 0)
            {
                this.SelectedMap = this.Method.MethodMaps[this.SelectedMapIndex];
            }
            else
            {
                this.SelectedMap = null;
            }

            //根据当前业务服务是否绑定映射,控制界面按钮显示
            if (this.SelectedMap == null)//新增
            {
                model.IsSelectMap  = false;
                model.ExeCondition = string.Empty;
                model.ServiceCode  = "";
            }
            else//编辑
            {
                model.ServiceCode  = this.SelectedMap.ServiceCode;
                model.MethodName   = this.SelectedMap.MethodName;
                model.ExeCondition = this.SelectedMap.ExeCondition;
                model.IsSelectMap  = true;
                model.MapIndex     = mapIndex;
            }
            model.MethodType = this.MethodType;
            model.SchemaCode = this.SchemaCode;
            model.Method     = this.SelectedMethod;
            return(model);
        }
Exemplo n.º 2
0
 public JsonResult SaveServiceMethodMap(ServiceMethodMapViewModel model)
 {
     return(ExecuteFunctionRun(() =>
     {
         ActionResult result = new ActionResult();
         result = ParseParam(model.SchemaCode, model.Method, model.MethodType);
         if (!result.Success)
         {
             return Json(result, JsonRequestBehavior.AllowGet);
         }
         if (string.IsNullOrWhiteSpace(model.ServiceCode))
         {
             result.Success = false;
             result.Message = "EditBizObjectSchemaMethodMap.SelectBiz";
             return Json(result, JsonRequestBehavior.AllowGet);
         }
         if (string.IsNullOrWhiteSpace(model.MethodName))
         {
             result.Success = false;
             result.Message = "EditBizObjectSchemaMethodMap.SelectMethodName";
             return Json(result, JsonRequestBehavior.AllowGet);
         }
         GetServiceMethodMapViewModel(model.MapIndex);//初始化this.SelectedMap
         if (this.SelectedMap == null)
         {
             this.Schema.GetMethod(this.SelectedMethod).AddMethodMap(BuldMap(model.ServiceCode, model.MethodName));
         }
         this.SelectedMap = this.Schema.GetMethod(this.SelectedMethod).MethodMaps.FirstOrDefault(p => p.ServiceCode == model.ServiceCode && p.MethodName == model.MethodName);
         this.SelectedMap.ExeCondition = model.ExeCondition;
         // 保存
         if (!this.Engine.BizObjectManager.UpdateDraftSchema(this.Schema))
         {
             result.Success = false;
             result.Message = "msgGlobalString.SaveFailed";
             return Json(result, JsonRequestBehavior.AllowGet);
         }
         result.Success = true;
         result.Message = "msgGlobalString.SaveSuccess";
         this.SelectedMapIndex = this.Schema.GetMethod(this.SelectedMethod).MethodMaps.Length - 1;
         model = GetServiceMethodMapViewModel(this.SelectedMapIndex.ToString());
         result.Extend = model;
         return Json(result, JsonRequestBehavior.AllowGet);
     }));
 }