protected void Page_Load(object sender, EventArgs e) { try { Parameter = ProjectParameter.GetSettingsByProjectName(CurrentSession.UserCode, ProjectName); Generator = new CodeGenerator(Parameter); ColumnInfos = Generator.GetColumnsInfo(TableName, PrimaryKeyOverwrite); ReferFolder = Path.Combine(Server.MapPath(".."), "Manage\\Refer"); OutputFolder = Path.Combine(Server.MapPath(".."), string.Concat("Manage\\", CurrentSession.UserCode, "\\", TableName)); if (!System.IO.Directory.Exists(OutputFolder)) System.IO.Directory.CreateDirectory(OutputFolder); switch (type) { case 1: Search(); Callback(); Result(); Edit(); GetTogether.Mapping.MappingInfoCache.Caches.Clear(); if (!string.IsNullOrEmpty(Request["download"])) Compress(OutputFolder, string.Concat(OutputFolder, "-Management.zip")); break; default: break; } JsonSuccess(); } catch (Exception ex) { JsonError(ex.Message); } }
private void GenDataObjectByTable(string table) { string doString = string.Empty; string primaryKeys = string.Empty; string autoIncrement = string.Empty; try { if (!string.IsNullOrEmpty(ProjectName) && !string.IsNullOrEmpty(table)) { ProjectParameter st = ProjectParameter.GetSettingsByProjectName(CurrentSession.UserCode, ProjectName); CodeGenerator cg = new GetTogether.Studio.Database.CodeGenerator(st); doString = cg.GenerateCodeByTable(GetTogether.Studio.Database.CodeGenerator.CodeType.DAL, table, PrimaryKeyOverwrite, true); ColumnMapping.ColumnInfos columnInfos = cg.GetColumnsInfo(table, ""); primaryKeys = GetTogether.Utility.StringHelper.ArrayToString(columnInfos.PrimaryKeys.ToArray(), ","); autoIncrement = GetTogether.Utility.StringHelper.ArrayToString(columnInfos.AutoIncrements.ToArray(), ","); if (string.IsNullOrEmpty(primaryKeys)) primaryKeys = "-"; if (string.IsNullOrEmpty(autoIncrement)) autoIncrement = "-"; } } catch (Exception ex) { doString = ex.ToString(); } Response.Write(string.Format(@"<div class='box-option' style='padding-left:2px;'>{0}</div> <div class='header-2 box' style='padding:2px;'> <div> Auto Increment: <span style='font-style:italic;'>{3}</span> </div> <div class='line-sub'></div> <div> Primary Key(s): <span style='font-style:italic;'>{2}</span> </div> <div class='line-sub'></div> <div> Primary Key Overwrite:<input type=""text"" style='width:50%;' id=""primary-key-overwrite"" value=""{1}"" class=""txt"" /> </div> <div class='line-sub' style='margin:3px 0px;'></div> <div style='text-align:right;'> <input class='btn6' type='button' onclick=""GenDoTableCode('{0}');"" value=""Re-Generate"" /> <input class='btn6' type='button' style='margin-left:5px;' onclick=""GenerateManagePage('{0}');"" value=""Management"" /> <input class='btn6' type='button' style='margin-left:5px;' onclick=""GenerateManagePage('{0}',true);"" value=""Download Management Pages"" /> </div> </div>", table, PrimaryKeyOverwrite, primaryKeys, autoIncrement)); Response.Write(string.Concat(@"<div class='box-option' style='margin-top:5px;'>Data Object (Double click on the textarea to enlarge) </div><div class='box'><textarea rows='10' style='width:99.8%;'>", doString, "</textarea></div>")); }