/// <summary> /// Get all failed objects with their associated errors /// </summary> public KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError>[] GetFailedObjectsWithErrors() { CheckContextInitialized(); int number; // failed objects can be retrieved only if the context is stopped if(_status != ContextStatus.Stopped) { throw new Exception("Object can be inserted only when the context is stopped"); } if(GetFailedObjectNumber(out number) == false) { return null; } // get the errors List<KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError>> objects = new List<KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError>>(); for(int i = 0; i < number; i++) { NativeMethods.WSmallObject item = new NativeMethods.WSmallObject(); NativeMethods.WError error = new NativeMethods.WError(); if(GetFailedObject(i, out item, true, out error) == false) { // return what we could get so far return objects.ToArray(); } else { KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError> pair = new KeyValuePair<NativeMethods.WSmallObject, NativeMethods.WError>(item, error); objects.Add(pair); } } // all errors could be retrieved return objects.ToArray(); }
/// <summary> /// Get an failed object, and optionally, its associated error /// </summary> public bool GetFailedObject(int index, out NativeMethods.WSmallObject item, bool getAssociatedError, out NativeMethods.WError error) { CheckContextInitialized(); // object can be inserted only when the context is stopped if(_status != ContextStatus.Stopped) { throw new Exception("Object can be inserted only when the context is stopped"); } int result = NativeMethods.GetFailedObject(_contextId, index, out item); if(result == NativeMethods.ERRORCODE_SUCCESS && getAssociatedError) { // get the associated error result = NativeMethods.GetError(_contextId, item.log, out error); } else { error = new NativeMethods.WError(); } return ValidResult(result); }
/// <summary> /// Get all failed objects /// </summary> public NativeMethods.WSmallObject[] GetFailedObjects() { CheckContextInitialized(); int number; // object can be inserted only when the context is stopped if(_status != ContextStatus.Stopped) { throw new Exception("Object can be inserted only when the context is stopped"); } if(GetFailedObjectNumber(out number) == false) { return null; } // get the errors NativeMethods.WError dummyError = new NativeMethods.WError(); List<NativeMethods.WSmallObject> objects = new List<NativeMethods.WSmallObject>(); for(int i = 0; i < number; i++) { NativeMethods.WSmallObject item = new NativeMethods.WSmallObject(); if(GetFailedObject(i, out item, false, out dummyError) == false) { // return what we could get so far return objects.ToArray(); } else { objects.Add(item); } } // all errors could be retrieved return objects.ToArray(); }
/// <summary> /// Get all errors /// </summary> public NativeMethods.WError[] GetErrors() { CheckContextInitialized(); int number; // object can be inserted only when the context is stopped if(_status != ContextStatus.Stopped) { throw new Exception("Object can be inserted only when the context is stopped"); } if(GetErrorNumber(out number) == false) { return null; } // get the errors List<NativeMethods.WError> errors = new List<NativeMethods.WError>(); for(int i = 0; i < number; i++) { NativeMethods.WError error = new NativeMethods.WError(); if(GetError(i, out error) == false) { // return what we could get so far return errors.ToArray(); } else { errors.Add(error); } } // all errors could be retrieved return errors.ToArray(); }