/// <summary> /// 获取参数前缀符号 /// </summary> /// <param name="Service"></param> /// <returns></returns> private Settings.BizDbConnectionConfig GetDbConnectionConfig(OThinker.H3.BizBus.BizService.BizService Service) { Settings.BizDbConnectionConfig DbConnectionConfig = null; if (Service.Settings != null) { foreach (OThinker.H3.BizBus.BizService.BizServiceSetting s in Service.Settings) { if (s.SettingName == OThinker.H3.BizBus.Declaration.DbTableAdapter_DbCode) { string dbCode = s.SettingValue; DbConnectionConfig = Engine.SettingManager.GetBizDbConnectionConfig(dbCode); if (DbConnectionConfig != null) { _ParameterPrefix = OThinker.Data.Database.Database.GetParameterFlag(DbConnectionConfig.DbType); } } } } return(DbConnectionConfig); }
/// <summary> /// 获取方法列 /// </summary> /// <param name="serviceCode"></param> /// <param name="methodName"></param> /// <param name="sql"></param> /// <param name="parameters"></param> /// <returns></returns> public JsonResult GetMethodColumns(string serviceCode, string methodName, string sql, string parameters) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(true, ""); OThinker.H3.BizBus.BizService.BizService Service = GetService(serviceCode); Settings.BizDbConnectionConfig DbConnectionConfig = GetDbConnectionConfig(Service); if (DbConnectionConfig != null) { try { string[] ParameterNames = (string[])JsonConvert.DeserializeObject <string[]>(parameters);//前端组合的XML中的Parameters List <OThinker.Data.Database.Parameter> lstParameters = new List <OThinker.Data.Database.Parameter>(); if (ParameterNames != null) { foreach (string p in ParameterNames) { lstParameters.Add(new OThinker.Data.Database.Parameter(p, System.Data.DbType.String, null)); } } OThinker.Data.Database.ICommand Command = new OThinker.Data.Database.CommandFactory(DbConnectionConfig.DbType, DbConnectionConfig.DbConnectionString).CreateCommand(); System.Data.DataTable dt = Command.ExecuteDataTable(sql, lstParameters.ToArray()); if (dt != null) { Dictionary <string, string> ColumnDictionary = new Dictionary <string, string>(); string StringType = typeof(string).FullName + string.Empty; foreach (System.Data.DataColumn c in dt.Columns) { if (!ColumnDictionary.ContainsKey(c.ColumnName)) { Data.DataLogicType LogicType = Data.DataLogicType.ShortString; switch (c.DataType.ToString().ToLower()) { case "system.boolean": LogicType = Data.DataLogicType.Bool; break; case "system.char": case "system.byte": case "system.sbyte": LogicType = Data.DataLogicType.ShortString; break; case "system.int": case "system.int16": case "system.int32": case "system.int64": case "system.uint16": case "system.uint32": case "system.uint64": LogicType = Data.DataLogicType.Int; break; case "system.decimal": case "system.double": case "system.single": LogicType = Data.DataLogicType.Decimal; break; case "system.object": break; case "system.string": LogicType = Data.DataLogicType.String; break; default: break; } ColumnDictionary.Add(c.ColumnName, LogicType.ToString()); } } result.Extend = ColumnDictionary; } } catch (Exception ex) { result.Success = false; result.Extend = ex.Message; } return Json(result, JsonRequestBehavior.AllowGet); } return null; })); }
/// <summary> /// 获取方法信息 /// </summary> /// <param name="serviceCode"></param> /// <param name="methodName"></param> /// <returns></returns> public JsonResult GetMethod(string serviceCode, string methodName) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(true, ""); // 编辑模式 OThinker.H3.BizBus.BizService.BizService Service = GetService(serviceCode); Settings.BizDbConnectionConfig DbConnectionConfig = null; OThinker.H3.BizBus.BizService.BizServiceMethod Method = null; if (Service == null) { result.Success = false; result.Message = "BizServiceMethod.ServiceNotExists"; //ShowErrorMessage(PortalResource.GetString("EditBizServiceMethod_Msg1")); //CloseCurrentDialog(); 客户端执行 return Json(result, JsonRequestBehavior.AllowGet); } //如果是DbSqlAdapter else if (OThinker.H3.BizBus.Declaration.DbSqlAdapter_Code == Service.BizAdapterCode) { //获取参数前缀符号 DbConnectionConfig = GetDbConnectionConfig(Service); } // 方法名称 if (!string.IsNullOrEmpty(methodName)) { Method = Service.GetMethod(methodName); if (Method == null) { //ShowErrorMessage(PortalResource.GetString("EditBizServiceMethod_Msg2")); //CloseCurrentDialog(); result.Message = "BizServiceMethod.MethodNotExist"; result.Success = false; } else { BizServiceMethodViewModel model = new BizServiceMethodViewModel() { ObjectID = Method.ObjectID, MethodName = Method.MethodName, BizAdapterCode = Service.BizAdapterCode, DisplayName = Method.DisplayName, Description = Method.Description, ReturnType = Method.ReturnType.ToString(), MethodSetting = Method.MethodSetting, ServiceCode = serviceCode, ParameterPrefix = _ParameterPrefix }; result.Extend = model; } return Json(result, JsonRequestBehavior.AllowGet); } else { BizServiceMethodViewModel model = new BizServiceMethodViewModel() { ParameterPrefix = _ParameterPrefix, BizAdapterCode = Service.BizAdapterCode, ServiceCode = serviceCode }; result.Extend = model; } result.Success = true; result.Message = ""; return Json(result, JsonRequestBehavior.AllowGet); })); }