public override void Format(StringBuilder ddl, DBSchema schema, DDLType ddlType) { string tsname = $"ts{schema.Name}"; if (ddlType == DDLType.Create) { ddl.Append($"begin\n"); ddl.Append($" execute immediate 'create tablespace {tsname} datafile ''{tsname}.dat'' size 10M autoextend on';\n"); ddl.Append($" execute immediate 'create temporary tablespace {tsname}_temp tempfile ''{tsname}_temp.dat'' size 5M autoextend on';\n"); ddl.Append($" execute immediate 'create user {schema.Name} identified by {schema.Name} default tablespace {tsname} temporary tablespace {tsname}_temp';\n"); ddl.Append($" execute immediate 'grant create session to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant create table to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant create view to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant create sequence to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant create any procedure to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant unlimited tablespace to {schema.Name}';\n"); if (!schema.Sequences.Contains("db_lob_seq")) { var lobSequence = new DBSequence("db_lob_seq"); schema.Sequences.Add(lobSequence); Format(ddl, lobSequence, DDLType.Create); } ddl.AppendLine($"create table db_lob(oid number(18) not null primary key, lob_data blob);"); ddl.Append($"end;"); } else if (ddlType == DDLType.Drop) { ddl.Append($"begin\n"); ddl.Append($" execute immediate 'drop user {schema.Name} CASCADE';\n"); ddl.Append($" execute immediate 'drop tablespace {tsname} including contents and datafiles';\n"); ddl.Append($" execute immediate 'drop tablespace {tsname}_temp including contents and datafiles';\n"); ddl.Append($"end;"); } }
public override void Format(StringBuilder ddl, DBSchema schema, DDLType ddlType) { string tsname = $"ts{schema.Name}"; if (ddlType == DDLType.Create) { ddl.Append($"begin\n"); ddl.Append($" execute immediate 'create tablespace {tsname} datafile ''{tsname}.dat'' size 10M autoextend on';\n"); ddl.Append($" execute immediate 'create temporary tablespace {tsname}_temp tempfile ''{tsname}_temp.dat'' size 5M autoextend on';\n"); ddl.Append($" execute immediate 'create user {schema.Name} identified by {schema.Name} default tablespace {tsname} temporary tablespace {tsname}_temp';\n"); ddl.Append($" execute immediate 'grant create session to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant create table to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant create view to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant create sequence to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant create any procedure to {schema.Name}';\n"); ddl.Append($" execute immediate 'grant unlimited tablespace to {schema.Name}';\n"); ddl.Append($"end;"); } else if (ddlType == DDLType.Drop) { ddl.Append($"begin\n"); ddl.Append($" execute immediate 'drop user {schema.Name} CASCADE';\n"); ddl.Append($" execute immediate 'drop tablespace {tsname} including contents and datafiles';\n"); ddl.Append($" execute immediate 'drop tablespace {tsname}_temp including contents and datafiles';\n"); ddl.Append($"end;"); } }
/// <summary> /// Creates a JSON object of syms tables in the correct shape given an instance of a symsManifestContent object. /// </summary> internal static string GetTablesPayload(List <TableEntity> symsTables, DDLType dDLType) { string retValue; IList <DDLPayload> DDLs = new List <DDLPayload>(); foreach (var entity in symsTables) { DDLPayload dDlPayloadEntity = new DDLPayload(); dDlPayloadEntity.ActionType = dDLType; switch (dDLType) { case DDLType.CREATE: dDlPayloadEntity.NewEntity = entity; break; case DDLType.DROP: dDlPayloadEntity.OldEntity = entity; break; default: return(null); } DDLs.Add(dDlPayloadEntity); } DDLBatch dDLBatch = new DDLBatch(DDLs); retValue = JsonConvert.SerializeObject(dDLBatch, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(retValue); }
public override void Format(StringBuilder ddl, DBSchema schema, DDLType ddlType) { if (ddlType == DDLType.Create) { var dataFile = Path.Combine(schema.Connection.Path, $"{schema.DataBase}.mdf"); ddl.AppendLine($"create database {schema.DataBase}"); ddl.AppendLine("on"); ddl.AppendLine($"(name = {schema.DataBase}_dat,"); ddl.AppendLine($"filename = '{dataFile}',"); ddl.AppendLine("size = 10, maxsize = unlimited, filegrowth = 5MB);"); ddl.AppendLine($"alter database {schema.DataBase} set recovery simple;"); if (!schema.Sequences.Contains("db_lob_seq")) { var lobSequence = new DBSequence("db_lob_seq"); schema.Sequences.Add(lobSequence); Format(ddl, lobSequence, DDLType.Create); } ddl.AppendLine($"create table [db_lob]([oid] bigint not null primary key, [lob_data] varbinary(max));"); } else if (ddlType == DDLType.Drop) { //ddl.AppendLine($"alter database {schema.DataBase} remove file {schema.DataBase}_dat;"); ddl.AppendLine($"drop database {schema.DataBase};"); } }
public override string FormatSql(DDLType ddlType) { var ddl = new StringBuilder(); Schema.System.Format(ddl, this, ddlType); return(ddl.ToString()); }
public override string FormatSql(DDLType ddlType) { var builder = new StringBuilder(); Table?.System.Format(builder, this, ddlType); return(builder.ToString()); }
public override void Format(StringBuilder ddl, DBSchema schema, DDLType ddlType) { base.Format(ddl, schema, ddlType); if (ddlType == DDLType.Create) { ddl.AppendLine($"use {schema.DataBase};"); ddl.AppendLine($"create table db_sequence(name varchar(512) not null primary key, seq long);"); } }
/// <summary> /// Initializes a new instance of the SyMSAPIDDLResponse class. /// </summary> /// <param name="dDLType">Possible values include: 'CREATE', 'ALTER', /// 'DROP'</param> /// <param name="entityName">Entity name.</param> /// <param name="entityType">Possible values include: 'DATABASE', /// 'TABLE', 'SCHEMA', 'VIEW', 'FUNCTION', 'PARTITIONINFO', /// 'RELATIONSHIP'</param> /// <param name="originObjectId">Object id maintained by Origin /// Catalog.</param> /// <param name="objectId">Object id maintained by SyMS.</param> /// <param name="objectVersion">Object version maintained by /// SyMS.</param> public SyMSAPIDDLResponse(DDLType dDLType, string entityName, SASEntityType entityType, string originObjectId, string objectId, long objectVersion) { DDLType = dDLType; EntityName = entityName; EntityType = entityType; OriginObjectId = originObjectId; ObjectId = objectId; ObjectVersion = objectVersion; }
public override void Format(StringBuilder ddl, DBSchema schema, DDLType ddlType) { if (ddlType == DDLType.Create) { ddl.AppendLine($"create table db_sequence(name varchar(512) not null primary key, seq long);"); } else { ddl.AppendLine($"drop table db_sequence;"); } }
public void FormatTablespace(StringBuilder ddl, DBSchema schema, DDLType ddlType) { if (ddlType == DDLType.Create) { ddl.AppendLine($"create tablespace ts_{schema.DataBase} owner {schema.Connection.User} location '{schema.Connection.Path}';"); } else if (ddlType == DDLType.Drop) { ddl.AppendLine($"drop tablespace ts_{schema.DataBase};"); } }
public override void Format(StringBuilder ddl, DBSchema schema, DDLType ddlType) { if (ddlType == DDLType.Create) { ddl.AppendLine($@"create database {schema.DataBase} with owner {schema.Connection.User} encoding = 'UTF8' tablespace = ts_{schema.DataBase};"); } else if (ddlType == DDLType.Drop) { ddl.AppendLine($"drop database {schema.DataBase};"); } }
public static void OnDBSchemaChanged(DBSchemaItem item, DDLType type) { if (type == DDLType.Default || !item.Containers.Any() || item.Schema == null || !item.Schema.Containers.Any() || item.Schema.IsSynchronizing) { return; } if (item is IDBTableContent tabled) { if (tabled.Table is IDBVirtualTable || !tabled.Table.Containers.Any()) { return; } if (item is DBColumn column && column.ColumnType != DBColumnTypes.Default) { return; } } DBSchemaChange change = null; var list = Changes.Select(DBSchemaChangeItemInvoker, CompareType.Equal, item).ToList(); if (list.Count > 0) { change = list[0]; if (change.Change != type) { if (change.Change == DDLType.Create && type == DDLType.Alter) { return; } change = null; } } if (change == null) { change = new DBSchemaChange() { Item = item, Change = type }; Changes.Add(change); } DBSchemaChanged?.Invoke(item, new DBSchemaChangedArgs { Item = item, Type = type }); }
public override void Format(StringBuilder ddl, DBSequence sequence, DDLType ddlType) { switch (ddlType) { case DDLType.Create: //if not exists pg 9.5 or above ddl.AppendLine($"create sequence {sequence.Name} start with {sequence.Current} increment by {sequence.Increment}"); break; case DDLType.Alter: ddl.AppendLine($"alter sequence {sequence.Name} restart with {sequence.Current + 1} increment by {sequence.Increment}"); break; case DDLType.Drop: ddl.AppendLine($"drop sequence {sequence.Name}"); break; } }
public override void Format(StringBuilder ddl, DBSequence sequence, DDLType ddlType) { switch (ddlType) { case DDLType.Create: ddl.AppendLine($"create sequence {sequence.Name} as {FormatType(sequence.DBDataType, sequence.Size, sequence.Scale)} start with {sequence.Current} increment by {sequence.Increment};"); break; case DDLType.Alter: ddl.AppendLine($"alter sequence {sequence.Name} restart with {sequence.Current} increment by {sequence.Increment};"); break; case DDLType.Drop: ddl.AppendLine($"drop sequence {sequence.Name};"); break; } }
public override void Format(StringBuilder ddl, DBSequence sequence, DDLType ddlType) { switch (ddlType) { case DDLType.Create: ddl.AppendLine($"insert into db_sequence(name, seq) values('{sequence.Name}', {sequence.Current - 1});"); break; case DDLType.Alter: ddl.AppendLine($"update db_sequence set seq = {sequence.Current} where name = '{sequence.Name}';"); break; case DDLType.Drop: ddl.AppendLine($"delete from db_sequence where name = '{sequence.Name}';"); break; } }
public override void Format(StringBuilder ddl, DBSchema schema, DDLType ddlType) { if (ddlType == DDLType.Create) { var dataFile = Path.Combine(schema.Connection.Path, $"{schema.DataBase}.mdf"); ddl.AppendLine($"create database {schema.DataBase}"); ddl.AppendLine("on"); ddl.AppendLine($"(name = {schema.DataBase}_dat,"); ddl.AppendLine($"filename = '{dataFile}',"); ddl.AppendLine("size = 10, maxsize = unlimited, filegrowth = 5MB);"); ddl.AppendLine($"alter database {schema.DataBase} set recovery simple;"); } else if (ddlType == DDLType.Drop) { //ddl.AppendLine($"alter database {schema.DataBase} remove file {schema.DataBase}_dat;"); ddl.AppendLine($"drop database {schema.DataBase};"); } }
protected void Page_Load(object sender, EventArgs e) { user = (UserModel)Session["User"]; if (Session["User"] == null || Session["User"].ToString() == "" || user.UserType != 1) { Response.Redirect("../Login.aspx"); } else { if (!IsPostBack) { DDLType.DataSource = bll.GetCodeTable(); DDLType.DataBind(); CodeGridView.DataSource = bll.GetTypeByID(Convert.ToInt32(DDLType.SelectedValue)); CodeGridView.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { user = (UserModel)Session["User"]; if (Session["User"] == null || Session["User"].ToString() == "" || user.UserType != 1) { Response.Redirect("../Login.aspx"); } else { if (!IsPostBack) { DDLType.DataSource = parkbll.GetBasePark(); DDLType.DataBind(); DDLPa.DataSource = pabll.GetAllPavilion(); DDLPa.DataBind(); DDLCell.DataSource = typebll.GetType("Cell"); DDLCell.DataBind(); string str = DDLPa.SelectedValue; int i = Convert.ToInt32(DDLCell.SelectedValue); if (i < 10) { str += "0" + i.ToString(); } else { str += i.ToString(); } List <RoomModel> list = roombll.GetAllRoomUsed(str); if (list.Count != 0) { DDLRoomID.DataSource = list; DDLRoomID.DataBind(); Panel1.Visible = true; Panel2.Visible = false; } else { Panel1.Visible = false; Panel2.Visible = true; } } } }
protected void Page_Load(object sender, EventArgs e) { user = (UserModel)Session["User"]; if (Session["User"] == null || Session["User"].ToString() == "" || user.UserType != 1) { Response.Redirect("../Login.aspx"); } else { if (!IsPostBack) { DDLType.DataSource = parkbll.GetBasePark(); DDLType.DataBind(); int id = int.Parse(Request.QueryString["ID"]); HomeParkModel homePark = bll.GetHomeParkByID(id); lbCell.Text = homePark.RoomID; DDLType.SelectedValue = homePark.ParkID.ToString(); txtCarID.Text = homePark.CarID; txtType.Text = homePark.Type; txtColor.Text = homePark.Color; txtBuyDate.Value = homePark.BuyDate.ToString("yyyy-MM-dd"); } } }
public override void Format(StringBuilder ddl, DBSequence sequence, DDLType ddlType) { throw new NotImplementedException(); }
public override string FormatSql(DDLType ddlType) { var builder = new StringBuilder(); Schema?.System?.Format(builder, this, ddlType); return builder.ToString(); }
public override string FormatSql(DDLType ddlType) { return(null); }
/// <summary> /// Initializes a new instance of the DDLPayload class. /// </summary> /// <param name="actionType">Possible values include: 'CREATE', /// 'ALTER', 'DROP'</param> public DDLPayload(DDLType actionType, MDEntity oldEntity = default(MDEntity), MDEntity newEntity = default(MDEntity)) { ActionType = actionType; OldEntity = oldEntity; NewEntity = newEntity; }