Beispiel #1
0
        public void PostData(string message, bool withStatus, string url, string json, Action <string> success, Action <string> fail = null)
        {
            this.Output(MessageType.Server, message + (withStatus ? ".........." : "\n"));
            this.TaskbarProgressState(TaskbarItemProgressState.Indeterminate);

            var requester = new ServiceRequester();

            requester.Post(url, json,
                           returnJson =>
            {
                if (withStatus)
                {
                    this.Output(MessageType.Server, "done\n");
                }

                success(returnJson);

                this.TaskbarProgressState(TaskbarItemProgressState.None);
            },
                           error =>
            {
                this.TaskbarProgressState(TaskbarItemProgressState.Error);

                if (withStatus)
                {
                    this.Output(MessageType.Error, "fail\n");
                }

                if (fail != null)
                {
                    fail(error);
                }
                else
                {
                    this.Output(MessageType.Error, error + "\n");
                }
            });
        }
Beispiel #2
0
        internal void RetrieveData(string message, bool withStatus, string url, KeyValuePair <string, string>[] parameters, Action <string> success, Action <string> fail = null)
        {
            this.Output(MessageType.Server, message + (withStatus ? ".........." : "\n"));
            this.TaskbarProgressState(TaskbarItemProgressState.Indeterminate);

            var requester = new ServiceRequester();

            requester.Get(url, parameters,
                          json =>
            {
                if (withStatus)
                {
                    this.Output(MessageType.Server, "done\n");
                }

                success(json);

                this.TaskbarProgressState(TaskbarItemProgressState.None);
            },
                          error =>
            {
                this.TaskbarProgressState(TaskbarItemProgressState.Error);

                if (withStatus)
                {
                    this.Output(MessageType.Error, "fail\n");
                }

                this.Output(MessageType.Error, error + "\n");

                if (fail != null)
                {
                    fail(error);
                }
            });
        }