//根据表编码,获取列名字段信息(用于子页展示字段信息) public void PreviewColumn() { NameValueCollection Params = HttpContext.Request.Form;//参数 Guid tableCode = new Guid(Params["tableCode"]); IList <Column> columnlist = DColumn.GetColumn(tableCode); //根据表编码获取表信息 Tables tables = DTables.GetProjectById(tableCode); StringBuilder Json = new StringBuilder(); Json.Append("{ Name: '" + tables.Name + "',"); //表名 Json.Append("Alias:'" + tables.Alias + "',"); //别名 Json.Append("copyright:'DBVortaro',"); Json.Append("list: ["); for (int i = 0; i < columnlist.Count; i++) { if (i > 0) { Json.Append(","); } Json.Append("{ Name: '" + columnlist[i].Name + "',"); Json.Append("Type: '" + columnlist[i].Type + "',"); Json.Append("Bewrite: '" + columnlist[i].Bewrite + "',"); Json.Append("Author: '" + columnlist[i].Author + "',"); Json.Append("CreateTime: '" + columnlist[i].CreateTime.ToString("yyyy年MM月dd日 HH:mm:ss") + "'"); Json.Append("}"); } Json.Append("]}"); Response.Write(Json.ToString().Replace("\'", "\"")); Response.End(); }
/// <summary> /// 生成HTML子页 /// </summary> /// <param name="tableCode">表编码</param> /// <param name="tableName">表名称</param> /// <param name="tableAlias">表别名</param> /// <param name="directory">输出路径</param> /// <param name="itemsPath">模板路径</param> private static void BuildItems(Guid tableCode, string tableName, string tableAlias, string directory, string itemsPath) { IList <Column> columnlist = DColumn.GetColumn(tableCode); string tableStr = @"<table style=""width: 100%;""> <tr class=""text-center""><th style=""width:60px"">序号</th><th>字段</th><th>类型</th><th>说明</th><th>作者</th><th>时间</th></tr>"; for (int k = 0; k < columnlist.Count; k++) { tableStr += string.Format(@"<tr><td style=""padding-left:10px;"">{0}</td> <td>{1}</td><td>{2}</td><td>{3}</td><td class=""text-center"">{4}</td><td class=""text-center"">{5}</td></tr>", k + 1, columnlist[k].Name, columnlist[k].Type, columnlist[k].Bewrite, columnlist[k].Author, columnlist[k].CreateTime.ToString("yyyy年MM月dd日 HH:mm:ss")); } tableStr += "</table>"; string[] itemsTemp = new string[] { "@title", "@name", "@alias", "@table", "@footer" }; string[] itemsHtml = new string[] { tableAlias, tableName, tableAlias, tableStr, "DBVortaro" }; DTemplates.WriteHtml(itemsTemp, itemsHtml, itemsPath, directory); }
//同步列字段及说明信息 public void SynchronousColumnBewrite() { NameValueCollection Params = HttpContext.Request.Form; //参数 string ServerName = Params["ServerName"]; //服务器名称 string ServerUser = Params["ServerUser"]; //用户名 string ServerPwd = Params["ServerPwd"]; //密码 ServerPwd = NHibernateHelper.DecryptAES(ServerPwd, "zhangzhangdebing"); //解密 string DatabaseName = Params["DatabaseName"]; //指定数据库名称 string[] TablesCode = Params["tablesCodes"].Split(','); //表编码集合 string[] TablesName = Params["tablesNames"].Split(','); //表名称集合 try { string SqlConnection = string.Format("server={0};database={1};uid={2};pwd={3};", ServerName, DatabaseName, ServerUser, ServerPwd); string exMsg = string.Empty; //异常记录 for (int i = 0; i < TablesCode.Length; i++) //循环表编码集合 { //根据表编码,获取列字段信息(主表) DataTable columnDt = DColumn.GetTableColumn(TablesName[i], SqlConnection); if (columnDt.Rows.Count == 0) { exMsg += "主表[" + TablesName[i] + "],列字段信息为空。<br/>"; continue; } //根据表编码,获取列字段信息(副表) IList <Column> columnlist = DColumn.GetColumn(new Guid(TablesCode[i])); if (columnlist.Count == 0) { exMsg += "副表[" + TablesName[i] + "],列字段信息为空。<br/>"; continue; } //获取(副表同步主表)说明的SQL语句 SynchronousChief(Params, new Guid(TablesCode[i]), TablesName[i], SqlConnection, columnDt, columnlist); //根据(主表同步副表)字段 SynchronousSide(Params, new Guid(TablesCode[i]), columnDt, columnlist); } Response.Write("{HasError:false,msg:'同步成功!<br/>" + exMsg + "'}"); } catch (Exception ex) { Response.Write("{HasError:true,msg:'同步失败!<br/>异常:" + ex.Message.Replace("\r\n", "<br/>") + "'}"); } Response.End(); }