// POST api/<controller> public string Post([FromBody] string value) { BasicClass bc = new BasicClass(); string str = ""; if (!string.IsNullOrEmpty(value)) { //转换大小写 str = bc.ConvertInitials(value); //去除空格 str = bc.GoToSpace(value); } return(str); }
/// <summary> /// 创建数据表 /// </summary> /// <returns></returns> public string GetTable() { string newLine = "\r\n"; string tableName = ""; if (!string.IsNullOrEmpty(inputName.Value)) { tableName = bc.GoToRemoveChar(inputName.Value); } List <string> listData = new List <string>(); //字段名称 string s = bc.GoToRemoveChar(txtarea.InnerHtml.Replace(newLine, ";")); //表名 if (flowCk.Checked == true || ConventionalCk.Checked == true)//英语 { tableName = GetData(tableName)[0]; tableName = inputStart.Value + "_" + bc.GoToRemoveChar(bc.GoToSpace(bc.ConvertInitials(tableName))); //英文 listData = GetData(s); } else if (flowCkPY.Checked == true || ConventionalCkPY.Checked == true) { tableName = GetPYData(tableName)[0]; tableName = inputStart.Value + "_" + bc.GoToRemoveChar(bc.GoToSpace(tableName)); //拼音 listData = GetPYData(s); } //默认长度为nvarchar(200),时间为 datetime,主键为 int string charType = " [nvarchar](200)"; string dataType = " [datetime]"; string pramaryKeyType = " [int] IDENTITY(1,1) PRIMARY KEY NOT NULL"; List <string> filedList = new List <string>(); string data = ""; foreach (var item in listData) { if (!string.IsNullOrEmpty(item)) { data = bc.GoToRemoveChar(item); if (flowCk.Checked == true || ConventionalCk.Checked == true)//英语 { //转成首字母大写 data = bc.ConvertInitials(bc.GoToRemoveChar(item)); } //去除空格和异常字符 data = bc.GoToSpace(data); filedList.Add(data); } else { filedList.Add("空值"); } } //组合数据表结构 string sql = $"CREATE TABLE {tableName}{newLine}"; sql += "(" + newLine; //主键 sql += " [Id]" + pramaryKeyType + "," + newLine; //判断是否为流程表 if (flowCk.Checked == true || flowCkPY.Checked == true) { sql += " [FormTitle] [nvarchar](100)," + newLine; sql += " [FlowGuid] [nvarchar](50)," + newLine; } //遍历组合 for (int i = 0; i < filedList.Count; i++) { if (filedList[i].Contains("Time") || filedList[i].Contains("Date")) { sql += " [" + filedList[i] + "]" + dataType + ","; } else { sql += " [" + filedList[i] + "]" + charType + ","; } sql += newLine; } sql += ")"; return(sql); }