public ActionResult GetTables() { ContentResult actionResult; //获得传入数据 var inModel = new Mo.CoderMaker.CodeMakerGetTablesIn(); try { UpdateModel(inModel); inModel.ConnectionString = HttpUtility.UrlDecode(inModel.ConnectionString); var databaseTables = CommonMethod.GetDatabaseTables(inModel.ConnectionString, (JlDatabaseType)Enum.Parse(typeof(JlDatabaseType), inModel.DbType)); return(new JlJsonResult() { Content = JlJson.ToJson(databaseTables) }); } catch (Exception exception) { //构造异常结果 actionResult = new JlJsonResult() { Content = JlJson.ToJson(new { Message = exception.Message }) }; } return(actionResult); }
public ActionResult GetDatas(string connection, string sql, string dbType) { sql = HttpUtility.UrlDecode(sql); connection = HttpUtility.UrlDecode(connection); if (sql.Contains("delete ") || sql.Contains("update ") || sql.Contains("drop ")) { return(new JlJsonResult() { Content = JlJson.ToJson(new { Message = "涉及敏感关键字" }) }); } var ds = new DataSet(); try { JlDatabase.Fill(connection, sql, ds, null, (JlDatabaseType)Enum.Parse(typeof(JlDatabaseType), dbType)); } catch (Exception ex) { return(new JlJsonResult() { Content = JlJson.ToJson(new { Message = ex.Message }) }); } var result = CommonMethod.ConvertDataTableToList(ds.Tables[0], true); return(new JlJsonResult() { Content = JlJson.ToJson(result) }); }
public ActionResult GeneratCode() { var inModel = new CodeMakerGeneratCodeIn(); UpdateModel(inModel); try { inModel.Lang = HttpUtility.UrlDecode(inModel.Lang); inModel.ClassName = HttpUtility.UrlDecode(inModel.ClassName); inModel.ConnectionString = HttpUtility.UrlDecode(inModel.ConnectionString); inModel.Package = HttpUtility.UrlDecode(inModel.Package); inModel.Table = HttpUtility.UrlDecode(inModel.Table); inModel.DbType = HttpUtility.UrlDecode(inModel.DbType); JlDatabaseType databaseType; switch (inModel.DbType.ToLower()) { case "mysql": databaseType = JlDatabaseType.MySql; break; case "postgresql": databaseType = JlDatabaseType.PostgreSql; break; case "sqlserver": databaseType = JlDatabaseType.SqlServer; break; default: databaseType = JlDatabaseType.MySql; break; } var databaseColumns = CommonMethod.GetDatabaseColumns(inModel.ConnectionString, inModel.Table, (JlDatabaseType)Enum.Parse(typeof(JlDatabaseType), inModel.DbType)); var outModel = new CodeMakerGeneratCodeOut { CodeMakerGeneratCodeIn = inModel, FieldDescriptions = databaseColumns, databaseType = databaseType }; #region 通过反射调用方法 var type = Type.GetType(JlConfig.GetValue <string>("ReflectClass") + "_" + inModel.Lang); //声明创建当前类实例 var model = Activator.CreateInstance(type); var method = type.GetMethod(inModel.Type); var result = method.Invoke(model, new object[] { outModel }).ToString(); #endregion return(new JlJsonResult() { Content = JlJson.ToJson(result) }); } catch (Exception ex) { return(new JlJsonResult() { Content = JlJson.ToJson(new { Message = ex.Message }) }); } }
public ActionResult GetCodeTypeSlt(string lang) { var type = Type.GetType(JlConfig.GetValue <string>("ReflectClass") + "_" + lang); return(new JlJsonResult() { Content = JlJson.ToJson(type.GetMethods().Where(m => m.Name.StartsWith("Ref")).Select(m => m.Name).ToList()) }); }
public ActionResult GetAudio(string tex, int per) { var speech = new Speech(); var fileName = speech.Tts(HttpUtility.UrlDecode(tex), per); return(new JlJsonResult() { Content = JlJson.ToJson(JlConfig.GetValue <string>("SaveFilePath") + fileName) }); }
public ActionResult GetDbFile(string connection, string dbType) { connection = HttpUtility.UrlDecode(connection); var result = new List <ToolGetDbFileOut>(); var databaseTables = CommonMethod.GetDatabaseTables(connection, (JlDatabaseType)Enum.Parse(typeof(JlDatabaseType), dbType)); databaseTables.ForEach(dbTableName => { result.Add(new ToolGetDbFileOut(dbTableName, CommonMethod.GetDatabaseColumns(connection, dbTableName, (JlDatabaseType)Enum.Parse(typeof(JlDatabaseType), dbType)))); }); return(new JlJsonResult() { Content = JlJson.ToJson(result) }); }
public ActionResult DecodeString(string str, string encoding) { try { var result = HttpUtility.UrlDecode(str, Encoding.GetEncoding(encoding)); return(new JlJsonResult() { Content = JlJson.ToJson(result) }); } catch (Exception ex) { return(new JlJsonResult() { Content = JlJson.ToJson(new { Message = ex.Message }) }); } }
public ActionResult SearchByName() { var inModel = new IndexSearchByNameIn(); UpdateModel(inModel); var keyword = inModel.PageName.ToLower(); var pages = CommonMethod.GetAllPageMethod(); if (keyword == "all") { return(new JlJsonResult() { Content = JlJson.ToJson("/Main/SearchPagesByKeyword?isall=1") }); } if (pages.Count(p => p.Key.Contains(keyword)) == 1) { return(new JlJsonResult() { Content = JlJson.ToJson(CommonMethod.GetUrlByControllerMethod(pages.Single(p => p.Key.Contains(keyword)).Value)) }); } else if (pages.Any(m => m.Key.Contains(keyword))) { return(new JlJsonResult() { Content = JlJson.ToJson("/Main/SearchPagesByKeyword?keyword=" + HttpUtility.HtmlEncode(keyword)) }); } return(new JlJsonResult() { Content = JlJson.ToJson(new { Message = "empty" }) }); }