public static DBRecord Update(this DBRecord record, Task t) { record.SetObject(new NSString(t.Title), "Title"); record.SetObject(new NSString(t.Description), "Description"); record.SetObject(new NSString(t.IsDone.ToString()), "IsDone"); return(record); }
public static DBRecord Update(this DBRecord record, TodoItem t) { record.Set("Title", t.Name); record.Set("Description", t.Notes); record.Set("IsDone", t.Done); return(record); }
public static Line Update(this Line line, DBRecord record) { line.Id = record.RecordId; line.Color = Convert.ToInt32(record.Fields [new NSString("Color")].ToString()); line.Points = Newtonsoft.Json.JsonConvert.DeserializeObject <List <PointF> > (record.Fields [new NSString("Points")].ToString()); return(line); }
public BTreeCell FindCell(DBRecord key, BTreeNode root) { BTreeNode child; BTreeCell cell; UInt16 offset; if (root.PageType == PageTypes.LeafTablePage) { (cell, _, _) = root.FindBTreeCell(key, false); return(cell); } // If it's internal node (cell, offset, _) = root.FindBTreeCell(key); MemoryPage nextpage; if (offset == 0) //rightpage { nextpage = _pager.ReadPage((int)root.RightPage); child = new BTreeNode(nextpage); } else { InternalTableCell internalTableCell = (InternalTableCell)cell; nextpage = _pager.ReadPage((int)internalTableCell.ChildPage); child = new BTreeNode(nextpage); } return(FindCell(key, child)); }
static void TestInternalIndexCell() { // init record DBRecord record = GetTestBRecord(); // init key List <AtomValue> keyValues = new List <AtomValue>(); AtomValue key = new AtomValue() { Type = AttributeTypes.Char, CharLimit = 8, StringValue = "114514" }; keyValues.Add(key); DBRecord keyRecord = new DBRecord(keyValues); // make raw bytes List <byte> rawNode = new List <byte>(); rawNode.AddRange(new byte[30]); // build cell InternalIndexCell internalIndexCell = new InternalIndexCell(record, 114514, keyRecord); byte[] raw = internalIndexCell.Pack(); rawNode.AddRange(raw); // clone InternalIndexCell clone = new InternalIndexCell(rawNode.ToArray(), 30); // assert AssertCell(internalIndexCell, clone); Assert.Equal(internalIndexCell.ChildPage, clone.ChildPage); AssertDBRecords(internalIndexCell.PrimaryKey, clone.PrimaryKey); }
public static DBRecord Update(this DBRecord record, TodoItem t) { record.SetObject(new NSString(t.Name), "Title"); record.SetObject(new NSString(t.Notes), "Description"); record.SetObject(new NSString(t.Done.ToString()), "IsDone"); return(record); }
// cast the document to a record and return it public static DBRecord ReadDocument(string id) { Document doc = GetDocument(id); DBRecord docrecord = (DBRecord)doc; return(docrecord); }
public Dictionary <string, object> SaveStatus(pim_spotd Record) { Dictionary <string, object> RetData = new Dictionary <string, object>(); Boolean retvalue = false; try { Con_Oracle = new DBConnection(); DBRecord Rec = new DBRecord(); Rec.CreateRow("pim_spotd", "EDIT", "spotd_pkid", Record.spotd_pkid); Rec.InsertString("spotd_status", Record.spotd_status); sql = Rec.UpdateRow(); Con_Oracle.BeginTransaction(); Con_Oracle.ExecuteNonQuery(sql); Con_Oracle.CommitTransaction(); Con_Oracle.CloseConnection(); retvalue = true; } catch (Exception Ex) { if (Con_Oracle != null) { Con_Oracle.RollbackTransaction(); Con_Oracle.CloseConnection(); } retvalue = false; throw Ex; } Con_Oracle.CloseConnection(); RetData.Add("retvalue", retvalue); return(RetData); }
private async void DataInsertRecordBtn_Click(object sender, RoutedEventArgs e) { if (!isBusy) { isBusy = true; if (selectedRecord == -1) { DBRecord newRecord = new DBRecord(columns); DBInterface.db.AddRecordObject(newRecord); topRecordIndex = Math.Max(0, DBInterface.db.records.Count - visibleRecords); } else { DBInterface.db.InsertRecordObject(selectedRecord, new DBRecord(columns)); } UpdateUnsavedChanges(true); DeselectAll(); await UpdateDBGrid(); UpdateStatusText("Ready"); isBusy = false; } }
//TODO: tidy up this method!!! void ProccessResults (DBRecord[] results) { taskDictionary.Clear (); //records = results.ToDictionary (x => x.Id.ToString (), x => x); lock (locker) { Console.WriteLine("ProcessResults" + results.Length.ToString()); //foreach (var result in results) { for (var i = 0; i < results.Length; i++) { var result = results [i]; var id = result.Id.ToString (); Console.WriteLine ("id " + id + " " + i); TodoItem t; taskDictionary.TryGetValue (id, out t); if (t == null) { t = result.ToTask (); taskDictionary.Add (id, t); } else { t.Update (result); } } Items = taskDictionary.Select (x => x.Value).OrderBy (x => x.Name).ToList(); Console.WriteLine("Updated " + Items.Count); // store.BeginInvokeOnMainThread (() => { if (ItemsUpdated != null) { Console.WriteLine("TasksUpdated handler called " + Items.Count); ItemsUpdated (this, EventArgs.Empty); } // }); Console.WriteLine ("DONE"); } }
static void TestLeafTableCell() { // init record DBRecord record = GetTestBRecord(); // init key List <AtomValue> keyValues = new List <AtomValue>(); AtomValue key = new AtomValue() { Type = AttributeTypes.Char, CharLimit = 8, StringValue = "114514" }; keyValues.Add(key); DBRecord keyRecord = new DBRecord(keyValues); // make raw bytes List <byte> rawNode = new List <byte>(); rawNode.AddRange(new byte[30]); // build cell LeafTableCell leafTableCell = new LeafTableCell(keyRecord, record); byte[] raw = leafTableCell.Pack(); rawNode.AddRange(raw); // clone LeafTableCell leafTableCellClone = new LeafTableCell(rawNode.ToArray(), 30); // assert AssertDBRecords(leafTableCell.DBRecord, leafTableCellClone.DBRecord); AssertCell(leafTableCell, leafTableCellClone); }
public int CreateIndex(int tableRootPage, string indexedColumnName, List <AttributeDeclaration> attributeDeclarations) { BTreeNode indexRoot = _bTree.OccupyNewTableNode(); BTreeNode tableRoot = BTreeNodeHelper.GetBTreeNode(_pager, tableRootPage); int indexedColumnIndex = attributeDeclarations.FindIndex(x => x.AttributeName == indexedColumnName); foreach (BTreeCell tableCell in _bTree.LinearSearch(tableRoot)) { AtomValue indexedValue = ((LeafTableCell)tableCell).DBRecord.GetValues()[indexedColumnIndex]; AtomValue primaryKey = ((LeafTableCell)tableCell).Key.GetValues()[0]; // List<AtomValue> indexPrimaryKeyPair = new List<AtomValue>() { indexedValue, primaryKey }; List <AtomValue> wrappedPrimaryKey = new List <AtomValue>() { primaryKey }; DBRecord wrappedKey = new DBRecord(new List <AtomValue>() { indexedValue }); // DBRecord wrappedValues = new DBRecord(indexPrimaryKeyPair); DBRecord wrappedValues = new DBRecord(wrappedPrimaryKey); indexRoot = _bTree.InsertCell(indexRoot, wrappedKey, wrappedValues); } return(indexRoot.RawPage.PageNumber); }
static DBRecord GetTestBRecord(int key = 222) { // init record List <AtomValue> values = new List <AtomValue>(); AtomValue value1 = new AtomValue() { Type = AttributeTypes.Int, IntegerValue = key }; AtomValue value2 = new AtomValue() { Type = AttributeTypes.Null }; AtomValue value3 = new AtomValue() { Type = AttributeTypes.Char, CharLimit = 5, StringValue = "222" }; values.Add(value1); values.Add(value2); values.Add(value3); DBRecord record = new DBRecord(values); DBRecord cloneRecord = new DBRecord(record.Pack(), 0); AssertDBRecords(record, cloneRecord); return(record); }
/// <summary> /// Insert a row/record/cell. /// </summary> /// <param name="root">the root of the B+ tree.</param> /// <param name="key">primary key in table tree and indexed column in index tree.</param> /// <param name="dBRecord">new row of values to insert.</param> /// <returns>new root node of the B+ tree</returns> public BTreeNode InsertCell(BTreeNode root, DBRecord key, DBRecord dBRecord) { // create a new tree if (root == null) { BTreeNode newRootFromNull = GetNewNode(PageTypes.LeafTablePage); LeafTableCell newCell = new LeafTableCell(key, dBRecord); newRootFromNull.InsertBTreeCell(newCell); return(newRootFromNull); } // no need to split if (root.NumCells < MaxCell) { InsertNonFull(root, key, dBRecord); return(root); } // need to split, and return with a new root BTreeNode newRoot = GetNewNode(PageTypes.InternalTablePage); root.ParentPage = (uint)newRoot.RawPage.PageNumber; SplitNode(root, newRoot, key); InsertNonFull(newRoot, key, dBRecord); return(newRoot); }
public static Task Update(this Task t, DBRecord record) { t.id = record.RecordId; t.Title = record.Fields [new NSString("Title")].ToString(); t.Description = record.Fields [new NSString("Description")].ToString(); t.IsDone = Convert.ToBoolean(record.Fields [new NSString("IsDone")].ToString()); return(t); }
public static TodoItem Update(this TodoItem t, DBRecord record) { t.ID = record.RecordId; t.Name = record.Fields [new NSString("Title")].ToString(); t.Notes = record.Fields [new NSString("Description")].ToString(); t.Done = Convert.ToBoolean(record.Fields [new NSString("IsDone")].ToString()); return(t); }
public static TodoItem Update(this TodoItem t, DBRecord record) { t.ID = record.Id; t.Name = record.GetString("Title"); t.Notes = record.GetString("Description"); t.Done = record.GetBoolean("IsDone"); return(t); }
public Dictionary <string, object> Save(Modulem Record) { Dictionary <string, object> RetData = new Dictionary <string, object>(); string ErrorMessage = ""; try { Con_Oracle = new DBConnection(); if (Record.module_name.Trim().Length <= 0) { Lib.AddError(ref ErrorMessage, "Name Cannot Be Empty"); } if (ErrorMessage != "") { throw new Exception(ErrorMessage); } if ((ErrorMessage = AllValid(Record)) != "") { throw new Exception(ErrorMessage); } DBRecord Rec = new DBRecord(); Rec.CreateRow("modulem", Record.rec_mode, "module_pkid", Record.module_pkid); Rec.InsertString("module_name", Record.module_name, "Z"); Rec.InsertNumeric("module_order", Record.module_order.ToString()); if (Record.rec_mode == "ADD") { Rec.InsertString("rec_company_code", Record._globalvariables.comp_code); } sql = Rec.UpdateRow(); Con_Oracle.BeginTransaction(); Con_Oracle.ExecuteNonQuery(sql); Con_Oracle.CommitTransaction(); Con_Oracle.CloseConnection(); } catch (Exception Ex) { if (Con_Oracle != null) { Con_Oracle.RollbackTransaction(); Con_Oracle.CloseConnection(); } throw Ex; } Con_Oracle.CloseConnection(); return(RetData); }
public async Task DeleteLink_GivenId_FromDynamoDb() { var obj = new DBRecord() { Id = "000", Source = "source_project", Target = "target_project" }; await aws.DeleteRecordAsync(obj.Id);// when item does not exist, do not throw exception }
public static MvxDBRecord ToMvxDBRecord(this DBRecord record) { if (record == null) { return(null); } var map = MvxDBMapping.Get(record.Table.Id); return(new MvxDBRecord(record)); }
public BTreeNode Delete(DBRecord key, BTreeNode Root) { BTreeNode NodeTobeDeleted = FindNode(key, Root); if (NodeTobeDeleted == null) { throw new KeyNotExistsException("Cannot find the key!"); } return(Delete_entry(NodeTobeDeleted, key, Root)); }
public static DbRecord ToDbRecord(this DBRecord record) { if (record == null) { return(null); } var map = DbMapping.Get(record.Table.TableId); return(new DbRecord(record)); }
public static Monkey Update(this Monkey monkey, DBRecord record) { monkey.Name = record.Fields [new NSString("Name")].ToString(); monkey.Rotation = float.Parse(record.Fields [new NSString("Rotation")].ToString()); monkey.Scale = float.Parse(record.Fields [new NSString("Scale")].ToString()); monkey.X = float.Parse(record.Fields [new NSString("X")].ToString()); monkey.Y = float.Parse(record.Fields [new NSString("Y")].ToString()); monkey.Z = int.Parse(record.Fields [new NSString("Z")].ToString()); return(monkey); }
// return new root page number public int InsertRecord(List <AtomValue> values, AtomValue key, int rootPage) { BTreeNode node = BTreeNodeHelper.GetBTreeNode(_pager, rootPage); DBRecord wrappedKey = new DBRecord(new List <AtomValue>() { key }); DBRecord wrappedValues = new DBRecord(values); BTreeNode newRoot = _bTree.InsertCell(node, wrappedKey, wrappedValues); return(newRoot.RawPage.PageNumber); }
static void TestExpressionDelete() { string dbPath = "./testdbfile.minidb"; File.Delete(dbPath); Pager pager = new Pager(dbPath); FreeList freeList = new FreeList(pager); BTreeController controller = new BTreeController(pager, freeList); BTreeNode root = null; Expression expression = GetAndsExpression(); for (int i = 1; i < 30; i++) { DBRecord record = GetTestRecord_expression(i, "str", (float)3.3); DBRecord key = GetTestKey_expression(i); if (i == 17 || i == 19) { record = GetTestRecord_expression(i, "str", (float)10.5); } else if (i == 20 || i == 23) { record = GetTestRecord_expression(i, "www", (float)1.3); } root = controller.InsertCell(root, key, record); } List <AttributeDeclaration> attributeNames = new List <AttributeDeclaration>(); AttributeDeclaration attribute_1 = new AttributeDeclaration(); attribute_1.AttributeName = "a"; attribute_1.IsUnique = true; attributeNames.Add(attribute_1); AttributeDeclaration attribute_2 = new AttributeDeclaration(); attribute_2.AttributeName = "b"; attribute_2.IsUnique = false; attributeNames.Add(attribute_2); AttributeDeclaration attribute_3 = new AttributeDeclaration(); attribute_3.AttributeName = "c"; attribute_3.IsUnique = false; attributeNames.Add(attribute_3); root = controller.DeleteCells(root, expression, "a", attributeNames); BTreeNodeHelper.VisualizeIntegerTree(pager, root); pager.Close(); }
public static DropboxRace Update(this DropboxRace race, DBRecord record) { race.Code = record.Fields ["Code"].ToString(); if (record.Fields.ContainsKey(new NSString("IntermediateLocations"))) { var locations = race.Locations.ToList(); IList <ILocation> toAdd = new List <ILocation>(); foreach (var location in record .Fields["IntermediateLocations"] .ToString() .Split(',') .Union(new List <string> { "start", "finish" })) { if (!locations.Select(l => l.Name).Contains(location)) { toAdd.Add(new LocationFactory().SetName(location).Create()); } } if (toAdd.Count > 0) { race.Locations = locations.Union(toAdd); } } if (record.Fields.ContainsKey(new NSString("DatastoreID"))) { race.DataStoreID = record.Fields ["DatastoreID"].ToString(); } if (record.Fields.ContainsKey(new NSString("FullName"))) { race.Name = record.Fields ["FullName"].ToString(); } if (record.Fields.ContainsKey(new NSString("RaceDate"))) { var rd = record.Fields["RaceDate"]; var nsd = (NSDate)rd; var dt = DateTime.SpecifyKind(nsd, DateTimeKind.Unspecified); race.Date = dt; } if (record.Fields.ContainsKey(new NSString("BoatsUpdated"))) { race.BoatsUpdated = DateTime.SpecifyKind(((NSDate)record.Fields["BoatsUpdated"]), DateTimeKind.Unspecified); } if (record.Fields.ContainsKey(new NSString("DetailsUpdated"))) { race.DetailsUpdated = DateTime.SpecifyKind(((NSDate)record.Fields["DetailsUpdated"]), DateTimeKind.Unspecified); } return(race); }
private static DBRecord GetTestKey_expression(int value_1) { List <AtomValue> values = new List <AtomValue>(); AtomValue value1 = new AtomValue() { Type = AttributeTypes.Int, IntegerValue = value_1 }; values.Add(value1); DBRecord record = new DBRecord(values); return(record); }
// return null if not found public List <AtomValue> SelectRecord(AtomValue key, int rootPage) { List <AtomValue> wrapper = new List <AtomValue> { key }; DBRecord keyDBRecord = new DBRecord(wrapper); BTreeNode node = BTreeNodeHelper.GetBTreeNode(_pager, rootPage); BTreeCell cell = _bTree.FindCell(keyDBRecord, node); List <AtomValue> result = null; result = ((LeafTableCell)cell)?.DBRecord.GetValues(); return(result); }
public Dictionary <string, object> Save(paramvalues_vm Record) { Dictionary <string, object> RetData = new Dictionary <string, object>(); try { Con_Oracle = new DBConnection(); DBRecord Rec = new DBRecord(); Con_Oracle.BeginTransaction(); sql = "delete from paramvalues where parent_id ='" + Record.param_pkid + "'"; Con_Oracle.ExecuteNonQuery(sql); foreach (paramvalues _Record in Record.RecordDet) { if (_Record.param_value.ToString().Length > 0) { _Record.param_pkid = System.Guid.NewGuid().ToString().ToUpper(); Rec.CreateRow("paramvalues", "ADD", "param_pkid", _Record.param_pkid); Rec.InsertString("parent_id", Record.param_pkid); Rec.InsertString("param_key", _Record.param_key); Rec.InsertString("param_value", _Record.param_value, "P"); Rec.InsertString("param_filetype", _Record.param_filetype); Rec.InsertString("param_impexp", _Record.param_impexp); Rec.InsertString("param_edifile", _Record.param_edifile); Rec.InsertString("param_format", _Record.param_format); Rec.InsertString("rec_company_code", Record._globalvariables.comp_code); sql = Rec.UpdateRow(); Con_Oracle.ExecuteNonQuery(sql); } } Con_Oracle.CommitTransaction(); Con_Oracle.CloseConnection(); } catch (Exception Ex) { if (Con_Oracle != null) { Con_Oracle.RollbackTransaction(); Con_Oracle.CloseConnection(); } throw Ex; } Con_Oracle.CloseConnection(); return(RetData); }
// update a modified document public async Task <Document> UpdateDocument(DocumentCollection coll, DBRecord record) { var updateDone = false; Document doc = null; while (!updateDone) { try { Console.WriteLine("updating document for: " + record.id + " on: " + DateTime.Now.ToString()); Trace.TraceInformation("worker role: updating document for: " + record.id + " on: " + DateTime.Now.ToString()); doc = await client.UpsertDocumentAsync(coll.SelfLink, record); updateDone = true; } catch (DocumentClientException documentClientException) { var statusCode = (int)documentClientException.StatusCode; if (statusCode == 429 || statusCode == 503) { Thread.Sleep(documentClientException.RetryAfter); } else { Console.WriteLine("ERROR: updating document: " + document.id); Trace.TraceInformation("worker role ERROR: updating document: " + document.id); updateDone = true; } } catch (AggregateException aggregateException) { if (aggregateException.InnerException.GetType() == typeof(DocumentClientException)) { var docExcep = aggregateException.InnerException as DocumentClientException; var statusCode = (int)docExcep.StatusCode; if (statusCode == 429 || statusCode == 503) { Thread.Sleep(docExcep.RetryAfter); } else { Console.WriteLine("ERROR: updating document: " + document.id); Trace.TraceInformation("worker role ERROR: updating document: " + document.id); updateDone = true; } } } } return(doc); }
//REGISTRA CONTACTO void RegistraContacto(String Nombre, String Telefono) { //INICIALIZAMOS NUESTRO DATASTORE InicializarDropboxDatastore(Account.LinkedAccount); //RECUPERAMOS LA TABLA DE NUESTRO DATASTORE PARA REGISTRAR EN ELLA EL NUEVO CONTACTO DBTable table = DropboxDatastore.GetTable("Contactos"); int New_id = 1; //RECUPERAMOS TODO LOS CONTACTOS DE LA TABLA var results = table.Query(); //RECUPERAMOS EL ULTIMO ID DEL CONTACTO REGISTRADO Y LO AUMENTAMOS PARA REGISTRA OTRO NUEVO Y NO SE //DUPLIQUEN if (results.Count() > 0) { DBRecord UltimoRegistro = results.AsList() [results.Count() - 1]; New_id = int.Parse(UltimoRegistro.GetString("Id")) + 1; } //CREAMOS UN OBJECTO DE TIPO CONTACTO Contacto cto = new Contacto(New_id.ToString(), Nombre, Telefono); //REGISTRAMOS EL OBJECTO CONTACTO PASANDO LA PROPIEDAD DE "Campos" QUE ES DE TIPO DBFields table.Insert(cto.Campos()); //VERIFICAMOS QUE NUESTRA DATASTORE ESTE ABIERTA PARA PODER REALIZAR EL ALTA DEL CONACTO if (!EstatusDataStore()) { //REINICIAMOS LA CONEXION CON DROPBOX ReiniciarConexion(); } else { // SI NO HAY NINGUN PROBLEMA DE CONEXION PROCEDEMOS A REALIZAR LA SINCRONIZACION CON NUESTRO DATASTORE // Y DAR DE ALTA NUESTRO CONTACTO DropboxDatastore.Sync(); Toast.MakeText(this, "Contacto Registrado", ToastLength.Long).Show(); txtNombre.Text = ""; txtTelefono.Text = ""; //CERRAMOS LA CONEXION A NUESTRO DATASTORE DropboxDatastore.Close(); } }
public static TodoItem Update (this TodoItem t, DBRecord record) { t.ID = record.Id; t.Name = record.GetString ("Title"); t.Notes = record.GetString("Description"); t.Done = record.GetBoolean ("IsDone"); return t; }
//REGISTRA CONTACTO void BuscaContacto (string id) { InicializarDropboxDatastore (Account.LinkedAccount); //RECUPERAMOS LA TABLA DE NUESTRO DATASTORE PARA REGISTRAR EN ELLA EL NUEVO CONTACTO DBTable table = DropboxDatastore.GetTable ("Contactos"); //RECUPERA CONTACTO CREANDO UN FILTRO var fieldsFiltro = new DBFields(); fieldsFiltro.Set("Id", id); //APLICAMOS EL FILTRO AL QUERY var results = table.Query (fieldsFiltro); //VERIFICAMOS EL RESULTADO Y SI TIENE RECUPERAMOS EL CONTACTO if (results.Count () > 0) { temp_contacto = results.AsList () [0]; txtNombre.Text = temp_contacto.GetString ("Nombre"); txtTelefono.Text = temp_contacto.GetString ("Telefono"); } else { Toast.MakeText (this, "No se encontro el contacto", ToastLength.Long).Show(); } //SINCRONIZAMOS LOS DATOS DropboxDatastore.Sync (); //CERRAMOS LA CONEXION A NUESTRO DATASTORE DropboxDatastore.Close (); }