示例#1
0
        //根据表编码,获取列名字段信息(用于子页展示字段信息)
        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();
        }
示例#2
0
        public dynamic CompareTable([FromBody] JsonElement input)
        {
            var mdl = System.Text.Json.JsonSerializer.Deserialize <DtModel>(input.GetRawText());

            DTables.CompareTable(mdl);
            return(mdl);
        }
示例#3
0
        //保存表信息
        public void SaveTables()
        {
            NameValueCollection Params = HttpContext.Request.Form;//参数
            Tables tables = new Tables();

            tables.Author       = User.Identity.Name;
            tables.DatabaseCode = new Guid(Params["databaseCode"]);
            tables.GroupCode    = new Guid(Params["groupCode"]);
            tables.Name         = Params["name"];
            tables.Alias        = Params["alias"];
            string result = string.Empty;

            if (Params["code"] != null)
            {
                tables.Code = new Guid(Params["code"]);
                result      = DTables.Update(tables) != null ? "{HasError:false,msg:'表编辑成功!'}" : "{HasError:true,msg:'表编辑失败,请稍候再试!'}";
            }
            else
            {
                tables.Code = Guid.NewGuid();
                result      = DTables.Add(tables) != null ? "{HasError:false,msg:'表创建成功!'}" : "{HasError:true,msg:'表创建失败,请稍候再试!'}";
            }
            Response.Write(result);
            Response.End();
        }
示例#4
0
        //获取需要导入的表
        public void GetImportTables()
        {
            NameValueCollection Params = HttpContext.Request.Form;//参数
            string page    = Params["page"];
            string rows    = Params["rows"];
            int    intPage = int.Parse((page == null || page == "0") ? "1" : page);
            //每页显示条数
            int pageSize = int.Parse((rows == null || rows == "0") ? "10" : rows);
            //每页的开始记录  第一页为1  第二页为number +1
            int    start      = (intPage - 1) * pageSize;
            string ServerName = Params["ServerName"];
            string ServerUser = Params["ServerUser"];
            string ServerPwd  = Params["ServerPwd"];

            ServerPwd = NHibernateHelper.DecryptAES(ServerPwd, "zhangzhangdebing"); //解密
            string    DatabaseCode = Params["DatabaseCode"];                        //数据库编码
            string    DatabaseName = Params["DatabaseName"];                        //数据库名称
            string    SearchValue  = Params["SearchValue"];                         //查询条件
            DataTable dt           = new DataTable();
            DataTable dt2          = new DataTable();
            Hashtable hasTable     = new Hashtable();

            try
            {
                //根据数据库编码,获取表名称
                string tablesName = string.Empty;
                if (DatabaseCode != null)
                {
                    tablesName = DTables.GetTablesName(new Guid(DatabaseCode));
                }
                string SqlConnection = string.Format("server={0};database={1};uid={2};pwd={3};", ServerName, DatabaseName, ServerUser, ServerPwd);
                string Sql           = "select name,crdate as createdate from sysobjects where xtype='U' and name!='sysdiagrams'";//排除sysdiagrams表
                if (!string.IsNullOrEmpty(tablesName))
                {
                    Sql += string.Format(" and name not in({0})", tablesName);
                }
                if (!string.IsNullOrEmpty(SearchValue))
                {
                    Sql += string.Format(" and name like '%{0}%'", SearchValue);
                }
                dt = SQLHelper.GetDataTable(SqlConnection, Sql);
                //拼装分页SQL
                Sql = string.Format(@"select top {1} * from ({0}) as t
                where t.name not in (select top {2} t2.name from ({0}) as t2)", Sql, pageSize, start);
                dt2 = SQLHelper.GetDataTable(SqlConnection, Sql);
                hasTable.Add("total", dt.Rows.Count);//总数据行数
                hasTable.Add("rows", dt2);
            }
            catch (Exception ex)
            {
                NHibernateHelper.WriteErrorLog("获取需要导入的表异常", ex);
                return;
            }
            Response.Write(JsonHelper.ToJson(hasTable));
            Response.End();
        }
示例#5
0
        //导入指定表到数据库
        public void ImportTables()
        {
            NameValueCollection Params = HttpContext.Request.Form;//参数

            //批量添加表信息
            string[] tables     = Params["tables"].Split(',');                      //表名称数据集
            string   ServerName = Params["ServerName"];                             //服务器名称
            string   ServerUser = Params["ServerUser"];                             //用户名
            string   ServerPwd  = Params["ServerPwd"];                              //密码

            ServerPwd = NHibernateHelper.DecryptAES(ServerPwd, "zhangzhangdebing"); //解密
            string DatabaseName = Params["DatabaseName"];                           //指定数据库名称
            string databaseCode = Params["databaseCode"];                           //数据库信息编码
            string groupCode    = Params["groupCode"];                              //功能分组编码
            bool   resultT      = false;

            try
            {
                for (int i = 0; i < tables.Length; i++)
                {
                    resultT = false;
                    string tableName = tables[i];
                    //表名是否,重复则不执行保存操作
                    if (!DTables.RepeatTablesName(tableName, databaseCode, groupCode, User.Identity.Name))
                    {
                        Tables table = new Tables();
                        table.Author       = User.Identity.Name;
                        table.DatabaseCode = new Guid(databaseCode);
                        table.GroupCode    = new Guid(groupCode);
                        table.Name         = tableName;
                        table.Alias        = tableName;
                        table.Code         = Guid.NewGuid();

                        //根据表名,获取表字段信息
                        string    SqlConnection = string.Format("server={0};database={1};uid={2};pwd={3};", ServerName, DatabaseName, ServerUser, ServerPwd);
                        DataTable dt            = DColumn.GetTableColumn(tableName, SqlConnection);
                        if (dt.Rows.Count > 0)
                        {
                            DTables.Add(table);//添加表
                            resultT = BatchAddColumn(resultT, table, dt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                NHibernateHelper.WriteErrorLog("导入指定表发生异常", ex);
                return;
            }
            Response.Write(resultT ? "{HasError:false,msg:'指定表导入成功!'}" : "{HasError:true,msg:'指定表导入失败,请稍候再试!'}");
            Response.End();
        }
示例#6
0
        //删除表信息
        public void DeleteTables()
        {
            NameValueCollection Params = HttpContext.Request.Form;//参数

            string[] codes  = Params["codes"].Split(',');
            string   result = string.Empty;

            for (int i = 0; i < codes.Length; i++)
            {
                result = DTables.Delete(new Guid(codes[i])) != null ? "{HasError:false,msg:'表删除成功!'}" : "{HasError:true,msg:'表删除失败,请稍候再试!'}";
            }
            Response.Write(result);
            Response.End();
        }
示例#7
0
        //获取表信息
        public void GetPageTables()
        {
            NameValueCollection Params = HttpContext.Request.Form;//参数
            string page    = Params["page"];
            string rows    = Params["rows"];
            int    intPage = int.Parse((page == null || page == "0") ? "1" : page);
            //每页显示条数
            int pageSize = int.Parse((rows == null || rows == "0") ? "10" : rows);
            //每页的开始记录  第一页为1  第二页为number +1
            int    start        = (intPage - 1) * pageSize;
            string databaseCode = Params["databaseCode"];
            string groupCode    = Params["groupCode"];
            string query        = Params["query"];

            Response.Write(DTables.GetPageTables(start, pageSize, query, databaseCode, groupCode));
            Response.End();
        }
示例#8
0
        //根据项目编码,获取数据库以及表信息(用于主页展示目录)
        public void PreviewTable()
        {
            NameValueCollection Params       = HttpContext.Request.Form;//参数
            IList <Database>    databaselist = DDatabase.GetDatabase(new Guid(Params["projectCode"].ToString()));
            StringBuilder       Json         = new StringBuilder();

            Json.Append("{ projectName: '" + Params["projectName"] + "',");
            Json.Append("copyright:'DBVortaro',");
            Json.Append("time: '" + DateTime.Now.ToString("yyyy年MM月dd日") + "',list: [");
            int databaseNumber = 0;//数据库计数器

            for (int i = 0; i < databaselist.Count; i++)
            {
                DataTable tableslist = DTables.GetTables2(databaselist[i].Code);
                if (tableslist.Rows.Count > 0)//判断数据库下面是否存在表信息
                {
                    if (databaseNumber > 0)
                    {
                        Json.Append(",");
                    }
                    Json.Append("{ databaseName: '" + databaselist[i].Name
                                + "',serverName: '" + databaselist[i].ServerName
                                + "',list: [");
                    for (int j = 0; j < tableslist.Rows.Count; j++)
                    {
                        if (j > 0)
                        {
                            Json.Append(",");
                        }
                        Json.Append("{ Name: '" + tableslist.Rows[j]["Name"].ToString() + "',");
                        Json.Append("Url: 'Items/items.html?code=" + tableslist.Rows[j]["Code"].ToString() + "',");
                        Json.Append("Alias: '" + tableslist.Rows[j]["Alias"].ToString() + "',");
                        Json.Append("Author: '" + tableslist.Rows[j]["Author"].ToString() + "',");
                        Json.Append("GroupName: '" + DGroup.GetGroupName(new Guid(tableslist.Rows[j]["GroupCode"].ToString())) + "'");
                        Json.Append("}");
                    }
                    Json.Append("]}");
                    databaseNumber++;
                }
            }
            Json.Append("]}");
            Response.Write(Json.ToString());
            Response.End();
        }
示例#9
0
        /// <summary>
        /// 生成HTML首页
        /// </summary>
        /// <param name="projectCode">项目编码</param>
        /// <param name="fileName">文件名称</param>
        /// <param name="directory">输出路径</param>
        /// <param name="indexPath">首页模板路径</param>
        /// <param name="itemsPath">子页模板路径</param>
        private static void BuildIndex(string projectCode, string fileName, string directory, string indexPath, string itemsPath)
        {
            string           tableStr     = string.Empty; //表格
            IList <Database> databaselist = DDatabase.GetDatabase(new Guid(projectCode));
            int  rowspan = 0;                             //分组跨行计数
            bool merger  = false;                         //是否合并

            for (int k = 0; k < databaselist.Count; k++)
            {
                DataTable tableslist = DTables.GetTables2(databaselist[k].Code);
                if (tableslist.Rows.Count > 0)//是否存在表字段
                {
                    tableStr += @"
                    <table style=""width: 100%;"">
		            <tr><td colspan=""5"" style=""font-weight:bold;line-height:20px;"">服务器:"         + databaselist[k].ServerName + "<br/>数据库:" + databaselist[k].Name + @"</td></tr>
		            <tr class=""text-center""><th style=""width:60px"">序号</th><th>分组</th><th>表名</th><th>别名</th><th>作者</th></tr>"        ;
                    for (int q = 0; q < tableslist.Rows.Count; q++)
                    {
                        string url = string.Format("Items/{0}_{1}.html", databaselist[k].Name, tableslist.Rows[q]["Name"].ToString());
                        tableStr += string.Format(@"<tr><td style=""padding-left:10px;"">{0}</td>", q + 1);
                        string GroupName = string.Empty,
                               TempName  = DGroup.GetGroupName(new Guid(tableslist.Rows[q]["GroupCode"].ToString()));
                        //名称竖排
                        for (int Q = 0; Q < TempName.Length; Q++)
                        {
                            GroupName += TempName[Q].ToString() + "<br/>";
                        }
                        //分组跨行处理
                        if (rowspan == 0)
                        {
                            for (int j = q; j < tableslist.Rows.Count; j++)
                            {
                                if (tableslist.Rows[j]["GroupCode"].ToString() == tableslist.Rows[q]["GroupCode"].ToString())
                                {
                                    rowspan++;
                                }
                            }
                            merger = true;
                        }
                        if (rowspan > 0 && merger == true)
                        {
                            tableStr += string.Format(@"<td class=""text-center"" style=""width:60px;"" rowspan=""{0}"">{1}</td>", rowspan, GroupName);
                            merger    = false; //停用合并
                            rowspan--;         //合并行计数
                        }
                        else if (rowspan > 0)
                        {
                            rowspan--;//合并行计数
                        }
                        else
                        {
                            tableStr += string.Format(@"<td class=""text-center"" style=""width:60px;"">{0}</td>", GroupName);
                        }
                        tableStr += string.Format(@"<td><a href=""{0}"">{1}</a></td><td><a href=""{0}"">{2}</a></td>
	                        <td class=""text-center"">{3}</td></tr>"    ,
                                                  url, tableslist.Rows[q]["Name"].ToString(),
                                                  tableslist.Rows[q]["Alias"].ToString(),
                                                  tableslist.Rows[q]["Author"].ToString());
                        BuildItems(new Guid(tableslist.Rows[q]["Code"].ToString()),
                                   tableslist.Rows[q]["Name"].ToString(),
                                   tableslist.Rows[q]["Alias"].ToString(),
                                   directory + "/" + url, itemsPath);
                    }
                    tableStr += "</table><br/>";
                }
            }
            string[] indexTemp = new string[] { "@title", "@table", "@footer" };
            string[] indexHtml = new string[] { fileName, tableStr, "DBVortaro" };
            DTemplates.WriteHtml(indexTemp, indexHtml, indexPath, directory + "/index.html");
        }