예제 #1
0
        public static string  submit_Via_REST(this API_Firebase firebase, API_Firebase.SubmitData submitData)
        {
            var result = "";

            if (submitData.notNull())
            {
                try
                {
                    switch (submitData.Type)
                    {
                    case API_Firebase.Submit_Type.GET:
                        result = firebase.GET();
                        break;

                    case API_Firebase.Submit_Type.ADD:
                        result = firebase.POST(submitData.Data);
                        break;

                    case API_Firebase.Submit_Type.SET:
                        result = firebase.PUT(submitData.Data);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    ex.log("[API_Firebase] [submit_Via_REST] for: {0}".format(submitData));
                }
                if (result.notValid())                          // this could happen in the cases where the SSL failed to connect
                {
                    firebase.offlineQueue().add(submitData);
                }
            }
            return(result);
        }
예제 #2
0
        public static API_Firebase submitThread_HandleQueue(this API_Firebase firebase)
        {
            var next = firebase.next();

            while (next.notNull())
            {
                // "[SubmitThread] got next: {0}".info(next);

                if (firebase.offline() || firebase.site_Configured().isFalse())
                {
                    firebase.offlineQueue().add(next);
                }
                else
                {
                    ThreadPool.QueueUserWorkItem((o) => firebase.submit_Via_REST(next));
                }

                next = firebase.next();
            }
            return(firebase);
        }