예제 #1
0
        internal void OnProgress(C8oProgress progress)
        {
            if (!c8oProgress.Equals(default(KeyValuePair <C8oOnProgress, bool>)))
            {
                if (c8oProgress.Value)
                {
                    var locker = new object();
                    lock (locker)
                    {
                        c8o.RunUI(() =>
                        {
                            lock (locker)
                            {
                                try
                                {
                                    c8oProgress.Key.Invoke(progress);
                                }
                                catch (Exception e)
                                {
                                    OnFailure(e, new Dictionary <string, object>()
                                    {
                                        { C8o.ENGINE_PARAMETER_PROGRESS, progress }
                                    });
                                }
                                finally
                                {
                                    Monitor.Pulse(locker);
                                }
                            }
                        });

                        Monitor.Wait(locker);
                    }
                }
                else
                {
                    c8oProgress.Key.Invoke(progress);
                }
            }
            else if (nextPromise != null)
            {
                nextPromise.OnProgress(progress);
            }
        }
예제 #2
0
        /// <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);
        }