public override object InternalExecute(Program program) { LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; string[] files = Directory.GetFiles((string)Nodes[0].Execute(program), Nodes.Count == 2 ? (string)Nodes[1].Execute(program) : "*"); for (int index = 0; index < files.Length; index++) { row[0] = files[index]; result.Insert(row); } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }
public int Delete(Obj_CaNhan obj_CaNhan) { SQLiteCommand cm = new SQLiteCommand(DbAccess.DatabaseConnection); cm.CommandType = CommandType.Text; cm.CommandText = "DELETE FROM " + LocalTable.TableName + " WHERE id = " + obj_CaNhan.ID; DbAccess.OpenConnection(); int i = cm.ExecuteNonQuery(); DbAccess.CloseConnection(); if (i == 1) { foreach (DataRow item in LocalTable.Rows) { if ((long)item[0] == obj_CaNhan.ID) { LocalTable.Rows.Remove(item); LocalTable.AcceptChanges(); break; } } } return(i); }
public MultipleEntitySetOnSameClrType_Products1Controller() : base("ID") { if (!initialized) { LocalTable.AddOrUpdate( 1, new Product { ID = 1, Name = "Product 1" }, (key, oldEntity) => oldEntity); LocalTable.AddOrUpdate( 2, new Product { ID = 2, Name = "Product 2" }, (key, oldEntity) => oldEntity); initialized = true; } }
public DataTable GetDtb(string WhereCondition = "") { LocalTable.Rows.Clear(); SQLiteCommand command = new SQLiteCommand(); command.CommandType = CommandType.Text; if (WhereCondition.Length == 0) { command.CommandText = "SELECT * FROM " + LocalTable.TableName; } else { command.CommandText = "SELECT * FROM " + LocalTable.TableName + " WHERE " + WhereCondition; } command.Connection = DbAccess.DatabaseConnection; DbAccess.OpenConnection(); SQLiteDataReader r = command.ExecuteReader(); while (r.Read()) { DataRow newRow = LocalTable.NewRow(); for (int i = 0; i < 9; i++) { newRow[i] = r[i]; } LocalTable.Rows.Add(newRow); } DbAccess.CloseConnection(); return(LocalTable); }
public ConditionalLinkGeneration_ProductsController() : base("ID") { if (!initialized) { LocalTable.AddOrUpdate(1, new Product { ID = 1, Name = "Product 1", Family = new ProductFamily { ID = 1, Name = "Product Family 1", Supplier = new Supplier { ID = 1, Name = "Supplier 1" } } }, (key, oldEntity) => oldEntity); initialized = true; } }
public int Update(Obj_CaNhan obj_CaNhan) { SQLiteCommand command = new SQLiteCommand(DbAccess.DatabaseConnection) { CommandType = CommandType.Text, CommandText = "UPDATE " + LocalTable.TableName + " SET " + "idDonVi = @idDonVi, " + "hoTen = @hoTen, " + "gioiTinh = @gioiTinh, " + "ngaySinh = @ngaySinh, " + "chucDanh = @chucDanh, " + "chucVu = @chucVu, " + "email = @email, " + "phone = @phone " + "WHERE id = @id " }; command.Parameters.Add(new SQLiteParameter("@idDonVi", obj_CaNhan.ID_DonVi)); command.Parameters.Add(new SQLiteParameter("@hoTen", obj_CaNhan.HoTen)); command.Parameters.Add(new SQLiteParameter("@gioiTinh", obj_CaNhan.GioiTinh)); command.Parameters.Add(new SQLiteParameter("@ngaySinh", obj_CaNhan.NgaySinh)); command.Parameters.Add(new SQLiteParameter("@chucDanh", obj_CaNhan.ChucDanh)); command.Parameters.Add(new SQLiteParameter("@chucVu", obj_CaNhan.ChucVu)); command.Parameters.Add(new SQLiteParameter("@email", obj_CaNhan.Email)); command.Parameters.Add(new SQLiteParameter("@phone", obj_CaNhan.Phone)); command.Parameters.Add(new SQLiteParameter("@id", obj_CaNhan.ID)); DbAccess.OpenConnection(); int i = command.ExecuteNonQuery(); DbAccess.CloseConnection(); //update to localtable if (i == 1) { foreach (DataRow item in LocalTable.Rows) { if ((long)item[0] == obj_CaNhan.ID) { item[1] = obj_CaNhan.ID_DonVi; item[2] = obj_CaNhan.HoTen; item[3] = obj_CaNhan.GioiTinh; item[4] = obj_CaNhan.NgaySinh; item[5] = obj_CaNhan.ChucDanh; item[6] = obj_CaNhan.ChucVu; item[7] = obj_CaNhan.Email; item[8] = obj_CaNhan.Phone; LocalTable.AcceptChanges(); break; } } } return(i); }
public EntityWithSimplePropertiesController() : base("Id") { EntityWithSimpleProperties[] entities = MetadataTestHelpers.CreateInstances <EntityWithSimpleProperties[]>(); foreach (var entity in entities) { LocalTable.AddOrUpdate(entity.Id, entity, (key, oldEntity) => oldEntity); } }
public override object InternalExecute(Program program) { LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; if (program.ServerProcess.ServerSession.Debugger != null) { foreach (DebugProcessInfo process in program.ServerProcess.ServerSession.CheckedDebugger.GetProcesses()) { row[0] = process.ProcessID; row[1] = process.IsPaused; if (process.Location != null) { row[2] = process.Location.Locator; row[3] = process.Location.Line; row[4] = process.Location.LinePos; row[5] = process.DidBreak; row[6] = process.Error; } else { row[2] = null; row[3] = null; row[4] = null; row[5] = null; row[6] = null; } result.Insert(row); } } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }
public OneToOneChildController() : base("Id") { var entities = MetadataTestHelpers.CreateInstances <OneToOneParent[]>(); foreach (var entity in entities.Select(x => x.Child)) { LocalTable.AddOrUpdate(entity.Id, entity, (key, oldEntity) => oldEntity); } }
public StubEntityController() : base("Id") { var entities = MetadataTestHelpers.CreateInstances <StubEntity[]>(); foreach (var entity in entities) { LocalTable.AddOrUpdate(entity.Id, entity, (key, oldEntity) => oldEntity); } }
public int Insert(Obj_CaNhan obj_CaNhan) { SQLiteCommand cm = new SQLiteCommand(DbAccess.DatabaseConnection); cm.CommandType = CommandType.Text; cm.CommandText = "INSERT INTO " + LocalTable.TableName + " VALUES (" + "@id, " + "@idDonVi, " + "@hoTen, " + "@gioiTinh, " + "@ngaySinh, " + "@chucDanh, " + "@chucVu, " + "@email, " + "@phone)"; cm.Parameters.Add(new SQLiteParameter("@id", obj_CaNhan.ID)); cm.Parameters.Add(new SQLiteParameter("@idDonVi", obj_CaNhan.ID_DonVi)); cm.Parameters.Add(new SQLiteParameter("@hoTen", obj_CaNhan.HoTen)); cm.Parameters.Add(new SQLiteParameter("@gioiTinh", obj_CaNhan.GioiTinh)); cm.Parameters.Add(new SQLiteParameter("@ngaySinh", obj_CaNhan.NgaySinh)); cm.Parameters.Add(new SQLiteParameter("@chucDanh", obj_CaNhan.ChucDanh)); cm.Parameters.Add(new SQLiteParameter("@chucVu", obj_CaNhan.ChucVu)); cm.Parameters.Add(new SQLiteParameter("@email", obj_CaNhan.Email)); cm.Parameters.Add(new SQLiteParameter("@phone", obj_CaNhan.Phone)); int i = -1; if (DbAccess.OpenConnection()) { i = cm.ExecuteNonQuery(); DbAccess.CloseConnection(); } if (i == 1) { DataRow item = LocalTable.NewRow(); item[0] = obj_CaNhan.ID; item[1] = obj_CaNhan.ID_DonVi; item[2] = obj_CaNhan.HoTen; item[3] = obj_CaNhan.GioiTinh; item[4] = obj_CaNhan.NgaySinh; item[5] = obj_CaNhan.ChucDanh; item[6] = obj_CaNhan.ChucVu; item[7] = obj_CaNhan.Email; item[8] = obj_CaNhan.Phone; LocalTable.Rows.Add(item); LocalTable.AcceptChanges(); } return(i); }
public int Update(Obj_DonVi obj_DonVi) { SQLiteCommand cm = new SQLiteCommand(DbAccess.DatabaseConnection); cm.CommandType = CommandType.Text; cm.CommandText = "UPDATE " + LocalTable.TableName + " SET " + "loai = @loai, " + "tenDonVi = @tenDonVi, " + "diaDiem = @diaDiem, " + "email = @email, " + "phone = @phone, " + "trangThai = @trangThai" + " WHERE id = @id"; cm.Parameters.Add(new SQLiteParameter("@loai", obj_DonVi.Loai)); cm.Parameters.Add(new SQLiteParameter("@tenDonVi", obj_DonVi.TenDonVi)); cm.Parameters.Add(new SQLiteParameter("@diaDiem", obj_DonVi.DiaDiem)); cm.Parameters.Add(new SQLiteParameter("@email", obj_DonVi.Email)); cm.Parameters.Add(new SQLiteParameter("@phone", obj_DonVi.Phone)); cm.Parameters.Add(new SQLiteParameter("@trangThai", obj_DonVi.TrangThai)); cm.Parameters.Add(new SQLiteParameter("@id", obj_DonVi.ID)); DbAccess.OpenConnection(); int i = cm.ExecuteNonQuery(); DbAccess.CloseConnection(); if (i == 1) { foreach (DataRow item in LocalTable.Rows) { if ((long)item[0] == obj_DonVi.ID) { item[1] = obj_DonVi.Loai; item[2] = obj_DonVi.TenDonVi; item[3] = obj_DonVi.DiaDiem; item[4] = obj_DonVi.Email; item[5] = obj_DonVi.Phone; item[6] = obj_DonVi.TrangThai; LocalTable.AcceptChanges(); break; } } } return(i); }
public override object InternalExecute(Program program) { int processID = (int)Nodes[0].Execute(program); LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; var debugger = program.ServerProcess.ServerSession.CheckedDebugger; if (debugger != null) { foreach (CallStackEntry entry in debugger.GetCallStack(processID)) { row[0] = entry.Index; row[1] = entry.Description; row[2] = entry.Locator.Locator; row[3] = entry.Locator.Line; row[4] = entry.Locator.LinePos; row[5] = entry.Location; row[6] = entry.Statement; result.Insert(row); } } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }
public BaseEntityController() : base("Id") { BaseEntity[] baseEntities = new BaseEntity[] { new BaseEntity(1), new BaseEntity(2), new BaseEntity(3), new BaseEntity(4), new BaseEntity(5), new BaseEntity(6), new BaseEntity(7) }; DerivedEntity[] derivedEntities = new DerivedEntity[] { new DerivedEntity(8), new DerivedEntity(9), new DerivedEntity(10), new DerivedEntity(11), new DerivedEntity(12), new DerivedEntity(13), new DerivedEntity(14) }; foreach (var entity in baseEntities.Union(derivedEntities, new BaseEntity.IdEqualityComparer())) { LocalTable.AddOrUpdate(entity.Id, entity, (key, oldEntity) => oldEntity); } }
public DefaultBatchCustomerController() : base("Id") { if (!_initialized) { IList <DefaultBatchCustomer> customers = Enumerable.Range(0, 10).Select(i => new DefaultBatchCustomer { Id = i, Name = string.Format("Name {0}", i) }).ToList(); foreach (DefaultBatchCustomer customer in customers) { LocalTable.AddOrUpdate(customer.Id, customer, (key, oldEntity) => oldEntity); } _initialized = true; } }
public int Insert(Obj_DonVi obj_DonVi) { SQLiteCommand cm = new SQLiteCommand(DbAccess.DatabaseConnection); cm.CommandType = CommandType.Text; cm.CommandText = "INSERT INTO " + LocalTable.TableName + " VALUES (" + "@id, " + "@loai, " + "@tenDonVi, " + "@diaDiem, " + "@email, " + "@phone, " + "@trangThai)"; cm.Parameters.Add(new SQLiteParameter("@id", obj_DonVi.ID)); cm.Parameters.Add(new SQLiteParameter("@loai", obj_DonVi.Loai)); cm.Parameters.Add(new SQLiteParameter("@tenDonVi", obj_DonVi.TenDonVi)); cm.Parameters.Add(new SQLiteParameter("@diaDiem", obj_DonVi.DiaDiem)); cm.Parameters.Add(new SQLiteParameter("@email", obj_DonVi.Email)); cm.Parameters.Add(new SQLiteParameter("@phone", obj_DonVi.Phone)); cm.Parameters.Add(new SQLiteParameter("@trangThai", obj_DonVi.TrangThai)); DbAccess.OpenConnection(); int i = cm.ExecuteNonQuery(); DbAccess.CloseConnection(); if (i == 1) { DataRow item = LocalTable.NewRow(); item[0] = obj_DonVi.ID; item[1] = obj_DonVi.Loai; item[2] = obj_DonVi.TenDonVi; item[3] = obj_DonVi.DiaDiem; item[4] = obj_DonVi.Email; item[5] = obj_DonVi.Phone; item[6] = obj_DonVi.TrangThai; LocalTable.Rows.Add(item); LocalTable.AcceptChanges(); } return(i); }
public override object InternalExecute(Program program) { int processID = (int)Nodes[0].Execute(program); int windowIndex = (int)Nodes[1].Execute(program); LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; foreach (StackEntry entry in program.ServerProcess.ServerSession.CheckedDebugger.GetStack(processID, windowIndex)) { row[0] = entry.Index; row[1] = entry.Name; row[2] = entry.Type; row[3] = entry.Value; result.Insert(row); } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }
public override object InternalExecute(Program program) { LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; var debugger = program.ServerProcess.ServerSession.CheckedDebugger; if (debugger != null) { foreach (Breakpoint entry in debugger.Breakpoints) { row[0] = entry.Locator; row[1] = entry.Line; row[2] = entry.LinePos; result.Insert(row); } } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }
public override object InternalExecute(Program program) { LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; if (program.ServerProcess.ServerSession.Debugger != null) { foreach (DebugSessionInfo session in program.ServerProcess.ServerSession.CheckedDebugger.GetSessions()) { row[0] = session.SessionID; result.Insert(row); } } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }
public override object InternalExecute(Program program) { LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; foreach (Debugger debugger in program.ServerProcess.ServerSession.Server.GetDebuggers()) { row[0] = debugger.Session.SessionID; row[1] = debugger.BreakOnStart; row[2] = debugger.BreakOnException; row[3] = debugger.IsPaused; result.Insert(row); } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }
public override object InternalExecute(Program program) { string environment = (string)Nodes[0].Execute(program); using (ITable libraries = (ITable)Nodes[1].Execute(program)) { LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result using (Row row = new Row(program.ValueManager, result.DataType.RowType)) { row.ValuesOwned = false; using (Row libraryRow = new Row(program.ValueManager, libraries.DataType.RowType)) { while (libraries.Next()) { libraries.Select(libraryRow); PopulateRequiredFiles(program, environment, program.Catalog.Libraries[(string)libraryRow["Library_Name"]], result, row); } } } result.First(); return(result); } catch { result.Dispose(); throw; } } }
public override object InternalExecute(Program program) { LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; List <string> logs = program.ServerProcess.ServerSession.Server.ListLogs(); for (int index = 0; index < logs.Count; index++) { row[0] = index; row[1] = logs[index]; result.Insert(row); } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }
public override object InternalExecute(Program program) { string user = ""; string password = ""; if (Nodes.Count > 1) { user = (string)Nodes[1].Execute(program); password = (string)Nodes[2].Execute(program); } string listing = GetDirectoryListing((string)Nodes[0].Execute(program), user, password); LocalTable result = new LocalTable(this, program); try { result.Open(); // Populate the result Row row = new Row(program.ValueManager, result.DataType.RowType); try { row.ValuesOwned = false; int offset = 0; while (offset < listing.Length) { int nextOffset = listing.IndexOf('\n', offset + 1); if (nextOffset < 0) { nextOffset = listing.Length; } row[0] = listing.Substring(offset, nextOffset - offset).Trim(new char[] { '\r', '\n', ' ' }); offset = nextOffset; if (((string)row[0]).Trim() != "") { try { result.Insert(row); } catch (IndexException) { // Ignore duplicate keys } } } } finally { row.Dispose(); } result.First(); return(result); } catch { result.Dispose(); throw; } }