예제 #1
0
        private void checkQueue()
        {
            StomtCreation stomtCreation = StomtOfflineQueue <StomtCreation> .pop();

            if (stomtCreation != null)
            {
                Debug.Log("Send queued Stomt: " + stomtCreation);
                this.SendStomt(stomtCreation);
                return;
            }

            StomtSubscription stomtSubscription = StomtOfflineQueue <StomtSubscription> .pop();

            if (stomtSubscription != null)
            {
                Debug.Log("Send queued Subscription: " + stomtSubscription);
                this.SendSubscription(stomtSubscription);
                return;
            }

            StomtTrack stomtTrack = StomtOfflineQueue <StomtTrack> .pop();

            if (stomtTrack != null)
            {
                Debug.Log("Send queued Track: " + stomtTrack);
                this.SendTrack(stomtTrack);
                return;
            }
        }
예제 #2
0
        // Stomt Handling
        public StomtCreation initStomtCreation()
        {
            StomtCreation stomtCreation = new StomtCreation();

            stomtCreation.DisableDefaultLabels = !SendDefaultLabels;

            stomtCreation.target_id           = StomtConfig.TargetID;
            stomtCreation.lang                = this.lang.getLanguage();
            stomtCreation.anonym              = false;
            stomtCreation.labels              = Labels;
            stomtCreation.CustomKeyValuePairs = this.CustomKeyValuePairs;

            return(stomtCreation);
        }
        private void handleStomtSending()
        {
            // send StomtCreation
            StomtCreation stomtCreation = _api.initStomtCreation();

            stomtCreation.text     = this._message.text;
            stomtCreation.positive = _like.sortingOrder > _wish.sortingOrder;

            // attach screenshot
            if (this._screenshotToggle.isOn)
            {
                stomtCreation.attachScreenshot(this._screenshot);
            }

            // attach logs
            if (this.UploadLogFile)
            {
                stomtCreation.attachLogs(this._log);
            }

            this._api.SendStomt(stomtCreation, (response) => {
            }, (response) => {
                if (response == null)
                {
                    return;
                }

                if (response.StatusCode.ToString().Equals("409"))
                {
                    Debug.Log("Duplicate");
                    // TODO return to form
                    //					ShowErrorMessage("You already posted this stomt.");
                    //					_LayerInput.SetActive(true);
                    //					_LayerSuccessfulSent.SetActive(false);
                    //					_LayerSubscription.SetActive(false);
                }
            });

            ResetInputForm();

            // Tigger Callback
            if (OnStomtSend != null)
            {
                OnStomtSend();
            }
        }
예제 #4
0
        public void SendStomt(StomtCreation stomtCreation, Action <LitJsonStomt.JsonData> callbackSuccess = null, Action <HttpWebResponse> callbackError = null)
        {
            // Upload file if pressent (and call function again)
            if (stomtCreation.screenshot != null)
            {
                SendImage(stomtCreation.screenshot, (response) => {
                    var img_name             = (string)response["images"]["stomt"]["name"];
                    stomtCreation.img_name   = img_name;
                    stomtCreation.screenshot = null;
                    SendStomt(stomtCreation, callbackSuccess, callbackError);
                }, (response) => {
                    // upload even when scrennshot upload failed
                    stomtCreation.screenshot = null;
                    SendStomt(stomtCreation, callbackSuccess, callbackError);
                }, () => {
                    // save and send later
                    StomtOfflineQueue <StomtCreation> .add(stomtCreation);
                });
                return;
            }

            // Upload image if pressent (and call function again)
            if (stomtCreation.logs != null)
            {
                SendFile(stomtCreation.logs, (response) => {
                    var file_uid           = (string)response["files"]["stomt"]["file_uid"];
                    stomtCreation.file_uid = file_uid;
                    stomtCreation.logs     = null;
                    SendStomt(stomtCreation, callbackSuccess, callbackError);
                }, (response) => {
                    // upload even when logs upload failed
                    stomtCreation.logs = null;
                    SendStomt(stomtCreation, callbackSuccess, callbackError);
                }, () => {
                    // save and send later
                    StomtOfflineQueue <StomtCreation> .add(stomtCreation);
                });
                return;
            }

            // Submit stomt
            var url = string.Format("{0}/stomts", restServerURL);

            // Send Stomt
            GetPOSTResponse(url, stomtCreation.ToString(), (response) => {
                string stomt_id = (string)response["id"];

                var track            = this.initStomtTrack();
                track.event_category = "stomt";
                track.event_action   = "submit";
                track.stomt_id       = stomt_id;
                this.SendTrack(track);

                if (callbackSuccess != null)
                {
                    callbackSuccess(response);
                }
            }, callbackError, () => {
                // save and send later
                StomtOfflineQueue <StomtCreation> .add(stomtCreation);
            });
        }