/// <summary> /// 获取表信息 /// </summary> /// <param name="tableName"></param> /// <returns></returns> public code_table GetTable(string tableName) { code_table model = Sqldb.Select <code_table>().Where(s => s.table_name == tableName).First(); if (model != null) { model.columns = Sqldb.Select <code_column>() .Where(s => s.table_name == tableName) .OrderBy(s => s.sort_num).ToList(); } return(model); }
public IActionResult GenCode(string tableName) { code_table table = codeGenApp.GetTable(tableName.Trim()); GenerateCodeDto codeDto = new GenerateCodeDto(); if (table != null) { GenerateCodeTemplate generateCode = new GenerateCodeTemplate(table); //实体类 var ret = generateCode.GenEntity(); if (ret.Status) { codeDto.Entity = ret.Html; } //服务 var ret2 = generateCode.GenAppService(); if (ret2.Status) { codeDto.Service = ret2.Html; } //控制器 var ret3 = generateCode.GenController(); if (ret3.Status) { codeDto.Controller = ret3.Html; } //列表页 var ret4 = generateCode.GenList(); if (ret4.Status) { codeDto.List = ret4.Html; } //服务 var ret5 = generateCode.GenForm(); if (ret5.Status) { codeDto.Form = ret5.Html; } } ViewData.Model = codeDto; return(View()); }
public override void Start() { AtomicNET.GetSubsystem <Player> ().LoadScene("Scenes/Scene.scene"); var ui = GetSubsystem <UI> (); ui.AddFont("Textures/BrokenGlass.ttf", "BrokenGlass"); // add a gooder font ui.LoadSkin("Textures/desktop.tb.txt"); // load in the app skin ResourceCache cache = GetSubsystem <ResourceCache> (); Graphics graphics = GetSubsystem <Graphics> (); graphics.SetWindowTitle("PeriodicApp"); Image icon = cache.GetResource <Image> ("Textures/AtomicLogo32.png"); graphics.SetWindowIcon(icon); myuivew = new UIView(); mylayout = new UILayout(); // make the host widget for all visible ui mylayout.SetId("UIPeriodicTable"); // tag it, like a big game scientist mylayout.SetRect(myuivew.GetRect()); //size it to fill the screen area mylayout.SetLayoutConfig("YAGAC"); //all-in-one setting mylayout.SetSkinBg("background_solid"); // make it look gooder mylayout.Load("Scenes/main_layout.ui.txt"); // load the main layout myuivew.AddChild(mylayout); // And make it show up. UITabContainer maintb = (UITabContainer)mylayout.GetWidget("maintabs"); UITabContainer acttb = (UITabContainer)mylayout.GetWidget("primarytabs"); UITabContainer semitb = (UITabContainer)mylayout.GetWidget("moretabs"); UITabContainer viewtb = (UITabContainer)mylayout.GetWidget("supporttabs"); UITabContainer supporttb = (UITabContainer)mylayout.GetWidget("atomictabs"); supporttb.SetCurrentPage(0); viewtb.SetCurrentPage(0); semitb.SetCurrentPage(0); acttb.SetCurrentPage(0); maintb.SetCurrentPage(0); // do this or else the tab contents look like crap! mylog = (UITextField)mylayout.GetWidget("LogText"); UIWidget ea = mylayout.GetWidget("exitapp"); var cota = new code_table(); cota.Setup(mylayout); var cobg = new code_uibargraph(); cobg.Setup(mylayout.GetWidget("pageuibargraph")); var cobu = new code_uibutton(); cobu.Setup(mylayout.GetWidget("pageuibutton")); var cocb = new code_uicheckbox(); cocb.Setup(mylayout.GetWidget("pageuicheckbox")); var cocl = new code_uiclicklabel(); cocl.Setup(mylayout.GetWidget("pageuiclicklabel")); var coch = new code_uicolorwheel(); coch.Setup(mylayout.GetWidget("pageuicolorwheel")); var cocw = new code_uicolorwidget(); cocw.Setup(mylayout.GetWidget("pageuicolorwidget")); var coco = new code_uicontainer(); coco.Setup(mylayout.GetWidget("pageuicontainer")); var coef = new code_uieditfield(); coef.Setup(mylayout.GetWidget("pageuieditfield")); var cofw = new code_uifinderwindow(); cofw.Setup(mylayout.GetWidget("pageuifinderwindow")); var cofd = new code_uifontdescription(); cofd.Setup(mylayout.GetWidget("pageuifontdescription")); var coiw = new code_uiimagewidget(); coiw.Setup(mylayout.GetWidget("pageuiimagewidget")); var cois = new code_uiinlineselect(); cois.Setup(mylayout.GetWidget("pageuiinlineselect")); var colo = new code_uilayout(); colo.Setup(mylayout.GetWidget("pageuilayout")); var colp = new code_uilayoutparams(); colp.Setup(mylayout.GetWidget("pageuilayoutparams")); var comi = new code_uimenuitem(); comi.Setup(mylayout.GetWidget("pageuimenuitem")); var comw = new code_uimenuwindow(); comw.Setup(mylayout.GetWidget("pageuimenuwindow")); var come = new code_uimessagewindow(); come.Setup(mylayout.GetWidget("pageuimessagewindow")); var copw = new code_uipromptwindow(); copw.Setup(mylayout.GetWidget("pageuipromptwindow")); var copd = new code_uipulldownmenu(); copd.Setup(mylayout.GetWidget("pageuipulldownmenu")); var corb = new code_uiradiobutton(); corb.Setup(mylayout.GetWidget("pageuiradiobutton")); var cosv = new code_uisceneview(); cosv.Setup(mylayout.GetWidget("pageuisceneview")); var cosb = new code_uiscrollbar(); cosb.Setup(mylayout.GetWidget("pageuiscrollbar")); var cosc = new code_uiscrollcontainer(); cosc.Setup(mylayout.GetWidget("pageuiscrollcontainer")); var cose = new code_uisection(); cose.Setup(mylayout.GetWidget("pageuisection")); var cosd = new code_uiselectdropdown(); cosd.Setup(mylayout.GetWidget("pageuiselectdropdown")); var cosi = new code_uiselectitem(); cosi.Setup(mylayout.GetWidget("pageuiselectitem")); var cosl = new code_uiselectlist(); cosl.Setup(mylayout.GetWidget("pageuiselectlist")); var cosp = new code_uiseparator(); cosp.Setup(mylayout.GetWidget("pageuiseparator")); var cosk = new code_uiskinimage(); cosk.Setup(mylayout.GetWidget("pageuiskinimage")); var cosa = new code_uislider(); cosa.Setup(mylayout.GetWidget("pageuislider")); var cotc = new code_uitabcontainer(); cotc.Setup(mylayout.GetWidget("pageuitabcontainer")); var cotf = new code_uitextfield(); cotf.Setup(mylayout.GetWidget("pageuitextfield")); var cotw = new code_uitexturewidget(); cotw.Setup(mylayout.GetWidget("pageuitexturewidget")); var cowd = new code_uiwidget(); cowd.Setup(mylayout.GetWidget("pageuiwidget")); var cowi = new code_uiwindow(); cowi.Setup(mylayout.GetWidget("pageuiwindow")); SubscribeToEvent <WidgetEvent> (ea, ev => { if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { GetSubsystem <Engine> ().Exit(); } }); SubscribeToEvent <KeyDownEvent> (e => { if (e.Key == Constants.KEY_ESCAPE) { GetSubsystem <Engine> ().Exit(); } }); }
/// <summary> /// 保存数据 /// </summary> /// <param name="dto"></param> public void SyncAll() { string conn = Sqldb.Ado.ConnectionString; string dbName = CommHelper.GetDataBaseName(conn); if (dbName.IsEmpty()) { return; } var tables = Sqldb.DbFirst.GetTablesByDatabase(dbName); if (tables.Count == 0) { return; } List <code_table> newTables = new List <code_table>(); List <code_table> updateTables = new List <code_table>(); List <code_column> newColumns = new List <code_column>(); foreach (var table in tables) { var exist = Sqldb.Select <code_table>().Where(s => s.table_name == table.Name).First(); if (exist != null) { exist.db_name = table.Schema; exist.table_type = (int)table.Type; exist.update_time = DateTime.Now; exist.remark = table.Comment; updateTables.Add(exist); Sqldb.Delete <code_column>().Where(s => s.table_name == table.Name).ExecuteAffrows(); } else { exist = new code_table(); exist.table_name = table.Name; exist.entity_name = table.Name; exist.db_name = table.Schema; exist.table_type = (int)table.Type; exist.sync_time = DateTime.Now; exist.remark = table.Comment; exist.update_time = exist.sync_time; newTables.Add(exist); } //列信息 var columns = table.Columns; if (columns.Count > 0) { foreach (var col in columns) { code_column colModel = new code_column(); colModel.table_name = table.Name; colModel.sort_num = col.Position; colModel.column_name = col.Name; colModel.comment = col.Coment; colModel.can_null = col.IsNullable == true ? 1 : 0; colModel.type_text = col.DbTypeText; colModel.type_text_full = col.DbTypeTextFull; colModel.dbtype = col.DbType; colModel.cstype = col.CsType.Name; colModel.is_identity = col.IsIdentity == true ? 1 : 0; colModel.is_primary = col.IsPrimary == true ? 1 : 0; colModel.sync_time = DateTime.Now; colModel.update_time = colModel.sync_time; colModel.max_length = col.MaxLength; newColumns.Add(colModel); } } } if (newTables.Count > 0) { Sqldb.Insert(newTables).ExecuteAffrows(); } if (updateTables.Count > 0) { Sqldb.Update <code_table>().SetSource(updateTables).ExecuteAffrows(); } if (newColumns.Count > 0) { Sqldb.Insert(newColumns).ExecuteAffrows(); } }
/// <summary> /// 同步单表结构 /// </summary> /// <param name="tableName"></param> public void SyncTable(string tableName) { var table = Sqldb.DbFirst.GetTableByName(tableName); if (table == null) { return; } var exist = Sqldb.Select <code_table>().Where(s => s.table_name == table.Name).First(); if (exist != null) { exist.db_name = table.Schema; exist.table_type = (int)table.Type; exist.update_time = DateTime.Now; exist.remark = table.Comment; Sqldb.Update <code_table>().SetSource(exist).ExecuteAffrows(); Sqldb.Delete <code_column>().Where(s => s.table_name == table.Name).ExecuteAffrows(); } else { exist = new code_table(); exist.table_name = table.Name; exist.entity_name = table.Name; exist.db_name = table.Schema; exist.table_type = (int)table.Type; exist.sync_time = DateTime.Now; exist.remark = table.Comment; exist.update_time = exist.sync_time; Sqldb.Insert(exist).ExecuteAffrows(); } //列信息 var newColumns = new List <code_column>(); var columns = table.Columns; if (columns.Count > 0) { foreach (var col in columns) { code_column colModel = new code_column(); colModel.table_name = table.Name; colModel.sort_num = col.Position; colModel.column_name = col.Name; colModel.comment = col.Coment; colModel.can_null = col.IsNullable == true ? 1 : 0; colModel.type_text = col.DbTypeText; colModel.type_text_full = col.DbTypeTextFull; colModel.dbtype = col.DbType; colModel.cstype = col.CsType.Name; colModel.is_identity = col.IsIdentity == true ? 1 : 0; colModel.is_primary = col.IsPrimary == true ? 1 : 0; colModel.sync_time = DateTime.Now; colModel.update_time = colModel.sync_time; colModel.max_length = col.MaxLength; newColumns.Add(colModel); } } if (newColumns.Count > 0) { Sqldb.Insert(newColumns).ExecuteAffrows(); } }
public GenerateCodeTemplate(code_table codeTable) { this.table = codeTable; this.columns = codeTable.columns; }