internal FlaimError.Error CreateObject(FlaimRecord record, int flmId, out bool usedId) { FlaimError.Error rc; int isNew; usedId = false; rc = FWCreateObject(pStore, record.Name, record.Id, record.Type, out isNew, flmId, out record.pRecord); if (FlaimError.IsSuccess(rc)) { if (isNew == 1 && flmId != 0) { usedId = true; } // Now Create all of the properties. foreach (Property property in record) { rc = FWSetProperty(record.pRecord, property.Name, property.Type, property.Value, property.Flags); if (FlaimError.IsError(rc)) { break; } } FWCloseObject(record.pRecord, FlaimError.IsSuccess(rc) ? false : true); } return(rc); }
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> /// Method used to search for Records using the specified query. /// </summary> /// <param name="query">Query used for this search</param> /// <returns></returns> internal IResultSet Search(Query query) { FlaimResultSet resultSet; FlaimError.Error rc = Flaim.Search(query, out resultSet, this); if (FlaimError.IsError(rc)) { throw new SearchException(query.ToString()); } return(resultSet); }
/// <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))); } } }