internal string GetRecord(string Id) { FlaimError.Error rc = FlaimError.Error.FERR_OK; char [] Buffer; int length = 4096; do { Buffer = new char[length]; rc = FWGetObject(pStore, Id, ref length, Buffer); } while (rc == FlaimError.Error.FERR_MEM); if (FlaimError.IsError(rc) && rc != FlaimError.Error.FERR_NOT_FOUND) { throw FlaimError.GetException(rc); } if (length > 0) { return(new string(Buffer, 0, length)); } else { return(null); } }
/// <summary> /// Called to Create a new Collection Store at the specified location. /// </summary> public void CreateStore() { FlaimError.Error rc = Flaim.CreateStore(); if (FlaimError.IsError(rc)) { throw (new CreateException("Flaim DB", FlaimError.GetException(rc))); } }
/// <summary> /// Called to Delete the opened CollectionStore. /// </summary> public void DeleteStore() { FlaimError.Error rc = Flaim.DeleteStore(); if (FlaimError.IsError(rc)) { // We had an error the store was not deleted. throw(new DeleteException("Flaim DB", FlaimError.GetException(rc))); } }
/// <summary> /// Used to Create, Modify or Delete records from the store. /// </summary> /// <param name="container">The container that the commit applies to.</param> /// <param name="createDoc">The records to create or modify.</param> /// <param name="deleteDoc">The records to delete.</param> public void CommitRecords(string container, XmlDocument createDoc, XmlDocument deleteDoc) { FlaimError.Error rc = Flaim.CommitRecords(container, createDoc, deleteDoc); if (FlaimError.IsError(rc)) { // We had an error the commit was not successful. throw(new CommitException(createDoc, deleteDoc, FlaimError.GetException(rc))); } }
/// <summary> /// Called to Delete a record container. /// This call is deep (all records contained are deleted). /// </summary> /// <param name="name">The name of the container.</param> public void DeleteContainer(string name) { FlaimError.Error rc = Flaim.DeleteContainer(name); if (FlaimError.IsError(rc)) { // We had an error the container was not deleted. throw(new DeleteException(name, FlaimError.GetException(rc))); } }
/// <summary> /// Called to Open an existing Collection store at the specified location. /// </summary> public void OpenStore() { FlaimError.Error rc = Flaim.OpenStore(); if (FlaimError.IsError(rc)) { if (rc == FlaimError.Error.FERR_IO_PATH_NOT_FOUND) { // The files do not exist. throw new ApplicationException(); } else { // We had an error the store was not opened. throw(new OpenException("Flaim DB", FlaimError.GetException(rc))); } } }
/// <summary> /// Used to Create, Modify or Delete records from the store. /// </summary> /// <param name="container">The container that the commit applies to.</param> /// <param name="createDoc">The records to create or modify.</param> /// <param name="deleteDoc">The records to delete.</param> internal FlaimError.Error CommitRecords(string container, XmlDocument createDoc, XmlDocument deleteDoc) { FlaimError.Error rc = FlaimError.Error.FERR_OK; Flaim4 flaim = this.Flaim; try { Flaim.BeginTrans(); try { if (createDoc != null) { XmlNodeList recordList = createDoc.DocumentElement.SelectNodes(XmlTags.ObjectTag); foreach (XmlElement recordEl in recordList) { bool reuseId; int flmId = 0; if (IdQueue.Count != 0) { flmId = (int)IdQueue.Peek(); reuseId = true; } FlaimRecord record = new FlaimRecord(recordEl); rc = flaim.CreateObject(record, flmId, out reuseId); if (FlaimError.IsSuccess(rc)) { if (reuseId) { flmId = (int)IdQueue.Dequeue(); } } else { throw FlaimError.GetException(rc); } } } if (deleteDoc != null) { XmlNodeList recordList = deleteDoc.DocumentElement.SelectNodes(XmlTags.ObjectTag); foreach (XmlElement recordEl in recordList) { int flmId; FlaimRecord record = new FlaimRecord(recordEl); rc = flaim.DeleteObject(record.Id, out flmId); if (FlaimError.IsSuccess(rc)) { IdQueue.Enqueue(flmId); } else if (rc != FlaimError.Error.FERR_NOT_FOUND) { throw FlaimError.GetException(rc); } else { rc = FlaimError.Error.FERR_OK; } } } Flaim.EndTrans(); } catch { Flaim.AbortTrans(); } } catch { if (FlaimError.IsSuccess(rc)) { rc = FlaimError.Error.FERR_FAILURE; } } return(rc); }