/// <summary> /// 从代码库中删除 /// </summary> private void DelCodeLibrary() { string table = ((dynamic)ActionParama.Arg).tb; if (!IsNotEmptyString(table)) { Outmsg("参数无效"); return; } var tablecode = BufHelp.ProtoBufDeserialize <List <KeyValue> >(KeyCenter.CodeFile) ?? new List <KeyValue>(); var query = tablecode.FirstOrDefault(x => x.key == table); //是否存 if (query == null) { Outmsg("非法删除"); return; } tablecode.Remove(query); var result = BufHelp.ProtoBufSerialize <List <KeyValue> >(tablecode, KeyCenter.CodeFile); Outmsg(result, outmsg: "删除失败"); }
/// <summary> /// 导入到代码库 /// </summary> private void GenCodeLibrary() { string table = ((dynamic)ActionParama.Arg).tb; string field = ((dynamic)ActionParama.Arg).fd; if (!IsNotEmptyString(table) || !IsNotEmptyString(field)) { Outmsg("参数无效"); return; } var tablecode = BufHelp.ProtoBufDeserialize <List <KeyValue> >(KeyCenter.CodeFile) ?? new List <KeyValue>(); var query = tablecode.FirstOrDefault(x => x.key == table); //是否存 if (query != null) { tablecode.Remove(query); //存在就删除 } tablecode.Add(new KeyValue { key = table, value = field }); var result = BufHelp.ProtoBufSerialize <List <KeyValue> >(tablecode, KeyCenter.CodeFile); Outmsg(result, outmsg: "导入到代码库失败"); }
/// <summary> /// 表的业务说明备注 /// </summary> private void TableMark() { string table = ((dynamic)ActionParama.Arg).tb; string mark = ((dynamic)ActionParama.Arg).mk; if (!IsNotEmptyString(table) || !IsNotEmptyString(mark)) { Outmsg("参数无效"); return; } var tbBizInfo = BufHelp.ProtoBufDeserialize <List <TableInfoTiny> >(KeyCenter.TableBusinessFile) ?? new List <TableInfoTiny>(); var currentbiz = tbBizInfo.FirstOrDefault(x => x.tablename == table); //当前表的业务说明信息 if (currentbiz == null) { tbBizInfo.RemoveAll(x => x.tablename == table); tbBizInfo.Add(new TableInfoTiny { tablename = table, tablemark = mark }); } else { currentbiz.tablemark = mark; //修改业务描述内容 } var result = BufHelp.ProtoBufSerialize <List <TableInfoTiny> >(tbBizInfo, KeyCenter.TableBusinessFile); Outmsg(result, outmsg: string.Format("修改表{0}的业务说明出错", table)); }
/// <summary> /// 获取代码库内容 /// </summary> private void GetCodeLibrary() { var tablecode = BufHelp.ProtoBufDeserialize <List <KeyValue> >(KeyCenter.CodeFile) ?? new List <KeyValue>(); Outmsg(true, outdata: tablecode); }
/// <summary> /// 获取表的业务描述 /// </summary> private void GetTableMark() { string tbname = ((dynamic)ActionParama.Arg).tbname; if (!IsNotEmptyString(tbname)) { Outmsg("参数无效"); return; } //业务场景的表信息标记 var tbBizInfo = BufHelp.ProtoBufDeserialize <List <TableInfoTiny> >(KeyCenter.TableBusinessFile) ?? new List <TableInfoTiny>(); var currentbiz = tbBizInfo.FirstOrDefault(x => x.tablename == tbname); //当前表的业务说明信息 if (currentbiz != null) { Outmsg(true, outdata: currentbiz.tablemark); } else { Outmsg(true, outdata: ""); } }
/// <summary> /// 对象模型代码 /// </summary> private string getmodelcode(string table, string[] fields) { var cachedata = GetTableDetail(table); if (cachedata == null) { return(""); } //表字段的业务场景描述内容 var tbbizinfo = BufHelp.ProtoBufDeserialize <List <TableInfoTiny> >(KeyCenter.TableBusinessFile) ?? new List <TableInfoTiny>(); var currentbiz = tbbizinfo.FirstOrDefault(x => x.tablename == table); //当前表的业务说明信息 var biztag = currentbiz != null && currentbiz.fieldinfo.Count > 0; //字段是否有业务场景描述 var tag = 0; //标记 var strb = new System.Text.StringBuilder(); cachedata.ForEach(x => { if (!fields.Contains(x.name)) { return; } tag++; if (biztag) { var _temp = currentbiz.fieldinfo.FirstOrDefault(f => f.name == x.name); strb.AppendFormat(summarytemplate, x.description, (_temp != null ? _temp.biz : "")); } else { strb.AppendFormat(summarytemplate, x.description, ""); } if (SupportProtobuf) //支持buf序列化 { strb.Append(System.Environment.NewLine); strb.Append(string.Format(" [ProtoMember({0})]", tag)); } strb.Append(System.Environment.NewLine); strb.AppendFormat(propertytemplate, FormatType(x.type, x.isnull == 1), x.name); }); return(string.Format( classtemplate, table, strb.ToString(), modeltype, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), SupportProtobuf ? System.Environment.NewLine + "[ProtoContract]" : "", SupportProtobuf ? System.Environment.NewLine + "using ProtoBuf;" : "")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var kv = BufHelp.ProtoBufDeserialize <KeyValue>(KeyCenter.DBConfigFile); if (kv != null && kv.key == KeyCenter.DBKey) { connectionstring = kv.value; } else { connectionstring = ConfigurationManager.ConnectionStrings[KeyCenter.DBKey].ToString(); } } }
/// <summary> /// 表单代码 /// </summary> private string formdesign(string table, string[] fields) { string template = @" <div class=""v52fmbx_dlbox""> <dl> <dt>{0}:</dt> <dd> <input name=""{1}"" validate type=""text"" value="""" class=""text nonull ccverify"" /> <span class=""tips"">{2}</span> </dd> </dl> </div>"; var cachedata = GetTableDetail(table); //表字段的业务场景描述内容 var tbbizinfo = BufHelp.ProtoBufDeserialize <List <TableInfoTiny> >(KeyCenter.TableBusinessFile) ?? new List <TableInfoTiny>(); var currentbiz = tbbizinfo.FirstOrDefault(x => x.tablename == table); //当前表的业务说明信息 var biztag = currentbiz != null && currentbiz.fieldinfo.Count > 0; //字段是否有业务场景描述 var strb = new System.Text.StringBuilder(); cachedata.ForEach(x => { if (!fields.Contains(x.name)) { return; } string tips = string.Empty; if (biztag) { var _temp = currentbiz.fieldinfo.FirstOrDefault(f => f.name == x.name); tips = _temp != null ? _temp.biz : ""; } strb.AppendFormat(template, x.description, x.name.ToLower(), tips); strb.Append(System.Environment.NewLine); }); return(strb.ToString()); }
/// <summary> /// 获取表信息 /// </summary> private void GetTableInfo() { string tbname = ((dynamic)ActionParama.Arg).tbname; if (!IsNotEmptyString(tbname)) { Outmsg("参数无效"); return; } var query = GetTableDetail(tbname); if (GetArgParam() != "biz") { Outmsg(query != null, outdata: query); return; } //业务场景的表信息标记 var tbBizInfo = BufHelp.ProtoBufDeserialize <List <TableInfoTiny> >(KeyCenter.TableBusinessFile) ?? new List <TableInfoTiny>(); var currentbiz = tbBizInfo.FirstOrDefault(x => x.tablename == tbname); //当前表的业务说明信息 if (currentbiz != null && currentbiz.fieldinfo != null) { query.ForEach(x => { var _temp = currentbiz.fieldinfo.FirstOrDefault(f => f.name == x.name); x.biz = _temp != null ? _temp.biz : ""; //设置字段的业务场景描述 }); Outmsg(true, outdata: query); } else { Outmsg(true, outdata: query); } }
/// <summary> /// 修改字段的业务场景说明 /// </summary> private void Sence() { #region check var argdata = GetActionParamData <MofifyArg>(true); if (argdata == null) { Outmsg("参数解析错误"); return; } if (!IsNotEmptyString(argdata.table) || !IsNotEmptyString(argdata.name) || !IsNotEmptyString(argdata.biz)) { Outmsg("参数无效"); return; } var query = GetTableDetail(argdata.table); //表信息 if (query == null || query.Count == 0) { Outmsg("数据表无效"); return; } var field = query.FirstOrDefault(x => x.name == argdata.name); //字段信息 if (field == null) { Outmsg("无效字段"); return; } #endregion #region 字段的业务场景描述 var tbBizInfo = BufHelp.ProtoBufDeserialize <List <TableInfoTiny> >(KeyCenter.TableBusinessFile) ?? new List <TableInfoTiny>(); //业务属性描述 var currentbiz = tbBizInfo.FirstOrDefault(x => x.tablename == argdata.table); //当前表的业务说明信息 if (currentbiz == null || currentbiz.fieldinfo.Count == 0) //表不存在 { var fieldbiz = new TableInfoTiny { tablename = argdata.table, fieldinfo = query.Select(x => new FieldInfo { name = x.name, type = x.type, des = x.des, biz = x.name == argdata.name ? argdata.biz.Trim() : "" }).ToList() }; tbBizInfo.RemoveAll(x => x.tablename == argdata.table); tbBizInfo.Add(fieldbiz); } else //表存在 { var tempf = currentbiz.fieldinfo.FirstOrDefault(x => x.name == argdata.name); tempf.biz = argdata.biz; //修改业务描述内容 } var result = BufHelp.ProtoBufSerialize <List <TableInfoTiny> >(tbBizInfo, KeyCenter.TableBusinessFile); Outmsg(result, outmsg: string.Format("修改字段{0}的业务属性出错", argdata.name)); #endregion }