internal void OnFailure(Exception exception, IDictionary <string, object> parameters) { lastFailure = exception; lastParameters = parameters; if (!c8oFail.Equals(default(KeyValuePair <C8oOnFail, bool>))) { if (c8oFail.Value) { var locker = new object(); lock (locker) { c8o.RunUI(() => { lock (locker) { try { c8oFail.Key.Invoke(exception, parameters); } catch (Exception e) { lastFailure = e; } finally { Monitor.Pulse(locker); } } }); Monitor.Wait(locker); } } else { c8oFail.Key.Invoke(lastFailure, parameters); } } if (nextPromise != null) { nextPromise.OnFailure(lastFailure, parameters); } }
/// <summary> /// Call a Convertigo Server backend service and return data as an XML Document. /// CallXML will asynchrously call a "requestable" (Sequence, transaction or FullSync database) and return a /// C8oPromise object. /// </summary> /// <param name="requestable"> /// A "requestable" object of this form : /// <list type ="bullet"> /// <item>project.sequence to call a Sequence in the convertigo server. If project is not specified explicitly here, /// (.sequence) the default project specified in the enpoint will be used.</item> /// <item> /// project.connector.transaction to call a transaction in the convertigo server. if project is not specified explicitly here, /// (.connector.transaction) the default project specified in the enpoint will be used. If /// connector is not specified (..transaction) the default connector will be used.</item> /// <item>fs://database.fullsync_verb to call the local NoSQL database for quering, updating and syncing according to the full_sync /// verb used. See FullSync documentation for a list of verbs and parameters.</item> /// </list> /// </param> /// <param name="parameters"> /// A IDictionary of Key/Value pairs mapped on Sequence/transaction/fullsync variables. /// </param> /// <returns> /// A C8oPromise object on which you can chain other requests to get the data with the Then(), ThenUI() methods or /// use the Async() to wait for the server response without blocking the request thread. You can also use the .Fail() and /// FailUI() methods to handle errors. /// </returns> public C8oPromise <XDocument> CallXml(string requestable, IDictionary <string, object> parameters) { var promise = new C8oPromise <XDocument>(this); Call(requestable, parameters, new C8oResponseXmlListener((response, requestParameters) => { if (response == null && requestParameters.ContainsKey(ENGINE_PARAMETER_PROGRESS)) { promise.OnProgress(requestParameters[ENGINE_PARAMETER_PROGRESS] as C8oProgress); } else { promise.OnResponse(response, requestParameters); } }), new C8oExceptionListener((exception, requestParameters) => { promise.OnFailure(exception, requestParameters); })); return(promise); }