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); }
/// <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); }
internal FlaimError.Error SetProperty(FlaimRecord record, string name, string type, string value, string flags) { return(FWSetProperty(record.pRecord, name, type, value, flags)); }
internal FlaimError.Error CloseObject(FlaimRecord record, bool abort) { FlaimError.Error rc = FWCloseObject(record.pRecord, abort); record.pRecord = IntPtr.Zero; return(rc); }