コード例 #1
0
        public async Task <ResponseUpdate> UpdateRoutingDeal(RequestUpdate data)
        {
            var model  = new Deal();
            var result = new ResponseUpdate();

            try
            {
                using (var conn = Get())
                {
                    conn.Open();
                    var cmd    = new MySqlCommand($"update tbl_deal set state={data.State}, url='{data.Url}', template='{data.Template}' where invoicekey = '{data.InvoiceKey}'", conn);
                    var reader = cmd.ExecuteNonQuery();

                    result.Code = 200;
                    result.Data = new UpdateDeal()
                    {
                        InvoiceKey = data.InvoiceKey,
                        State      = true,
                    };
                    result.Message = "OK";
                }
            }
            catch (Exception ex)
            {
                result.Code    = 500;
                result.Message = ex.Message;
                result.Data    = null;
            }

            return(await Task.Run(() => result));
        }
コード例 #2
0
        //@Headers({ "Content-Type: application/json"})
        //@POST("api/v1/data/update")
        //Call<ResponseUpdate> update(@Body RequestUpdate requestUpdate);
        public async Task <ResponseUpdate> UpdateAsync(RequestUpdate requestUpdate)
        {
            var uri = new Uri(baseUri + @"api/v1/data/update");
            // Сформировать JSON данные
            string jsonContent = JsonConvert.SerializeObject(requestUpdate);
            HttpResponseMessage httpResponse = await cmd.PostAsync(uri, jsonContent);

            ResponseUpdate.Results results        = new ResponseUpdate.Results();
            ResponseUpdate         responseRemove = new ResponseUpdate(results);

            if (httpResponse.IsSuccessStatusCode)
            {
                responseRemove = JsonConvert.DeserializeObject <ResponseUpdate>(httpResponse.Content.ToString());
            }
            else
            {
                responseRemove.Error   = true;
                responseRemove.ErrCode = "";
                responseRemove.ErrMsg  = "Ошибка HttpClient.";
            }
            return(responseRemove);
        }
コード例 #3
0
    public void ResponseInfoReceieved(DataInfo dataInfo)
    {
        ResponseInfo responseInfo = (ResponseInfo)dataInfo;

        Debug.Log("Ответ: " + responseInfo.responseType);
        switch (responseInfo.responseType)
        {
        case ResponseInfo.ResponseType.VisitedOK:
            SyncContext.RunOnUnityThread(() => Links.ToastController.Show("Посещение засчитано!"));
            break;

        case ResponseInfo.ResponseType.ResponseString:
            ResponseString responseString = (ResponseString)responseInfo;
            SyncContext.RunOnUnityThread(() => Links.MainMenuController.QRlayout.ShowLayout(responseString.String));
            break;

        case ResponseInfo.ResponseType.AutorizationOk:
            SyncContext.RunOnUnityThread(Links.LoginLayoutController.OpenMainMenu);
            break;

        case ResponseInfo.ResponseType.ResponseUserInfo:
            ResponseUser tmp = (ResponseUser)responseInfo;

            if (tmp.responseUserType == ResponseUser.ResponseUserType.PurchaseOk)
            {
                Links.DeviceInformation.PlayerData = tmp.data;
                //TODO
                //Отрисовать купленный предмет
                return;
            }

            if (tmp.responseUserType == ResponseUser.ResponseUserType.DescriptionUpdate)
            {
                //Обновить описание!!!
                //TODO
                //Links.DeviceInformation.PlayerData.Description = ""
                Links.DeviceInformation.PlayerData = tmp.data;
                return;
            }

            Links.DeviceInformation.PlayerData = tmp.data;

            Links.LoginLayoutController.OpenMainMenu();
            break;

        case ResponseInfo.ResponseType.AutorizationFalied_WrongLogin:
            SyncContext.RunOnUnityThread(() =>
                                         Links.LoginLayoutController.OpenLoginLayoutWithError("Wrong login!"));
            break;

        case ResponseInfo.ResponseType.AutorizationFailed_WrongPassword:
            SyncContext.RunOnUnityThread(() =>
                                         Links.LoginLayoutController.OpenLoginLayoutWithError("Wrong password!"));
            break;

        case ResponseInfo.ResponseType.RegistartionFailed_ExistLogin:
            SyncContext.RunOnUnityThread(() =>
                                         Links.LoginLayoutController.OpenRegisterWithError("Login already exists!"));
            break;

        case ResponseInfo.ResponseType.ResponseEvents:
            //события на которые записан пользователь
            //TODO

            //actual: все события
            ResponseUserEvent responseUserEvent = (ResponseUserEvent)responseInfo;
            //responseUserEvent.data[0].visited  (не визит а записан)
            Links.DeviceInformation.PlayerEvents = responseUserEvent.data;
            SyncContext.RunOnUnityThread(() => Links.EventsLayout.UpdateList(responseUserEvent.data));
            break;

        case ResponseInfo.ResponseType.ResponseUsers:
            ResponseUsers response = (ResponseUsers)responseInfo;
            switch (response.usersType)
            {
            case ResponseUsers.UsersType.Name:
                SyncContext.RunOnUnityThread(() =>
                                             Links.FindUserLayout.UpdateList(response.players));
                break;

            case ResponseUsers.UsersType.Rating:
                SyncContext.RunOnUnityThread(() => Links.TopPlayersLayout.UpdateTop(response.players));
                break;
            }

            break;

        case ResponseInfo.ResponseType.ResponseUserEvents:
            //не Все предстоящие события (хз вообще что это)
            ResponseEvent responseEvent = (ResponseEvent)responseInfo;
            Links.DeviceInformation.FutureEvents = responseEvent.data;
            //SyncContext.RunOnUnityThread(() => Links.EventsLayout.UpdateList(responseEvent.data));
            break;

        case ResponseInfo.ResponseType.ResponseMainInfo:
            //Серверное время
            ResponseMainInfo mainInfo = (ResponseMainInfo)responseInfo;
            SyncContext.RunOnUnityThread(() => Links.CurrentPlayerGameManagerScript.ResponseMainInfo(mainInfo));
            break;

        case ResponseInfo.ResponseType.ResponseCastle:
            ResponseCastle responsedCastle = (ResponseCastle)responseInfo;
            SyncContext.RunOnUnityThread(() => Links.LastOpenedCastle.CastleResponse(responsedCastle));
            break;

        case ResponseInfo.ResponseType.ResponseReviews:
            ResponseReviews responsedReviews = (ResponseReviews)responseInfo;
            if (responsedReviews.responseReviewsType == ResponseReviews.ResponseReviewsType.CastleReviews)
            {
                SyncContext.RunOnUnityThread(() => Links.LastOpenedCastle.CastleHistoryResponse(responsedReviews));
            }

            if (responsedReviews.responseReviewsType == ResponseReviews.ResponseReviewsType.EventReviews)
            {
                Links.MainMenuController.CommentsLayout.GetComponent <CommentsLayout>()
                .ShowComments(responsedReviews.reviews);
            }

            break;

        case ResponseInfo.ResponseType.ResponseUpdate:
            ResponseUpdate responsedUpdate = (ResponseUpdate)responseInfo;

            switch (responsedUpdate.responseUpdateType)
            {
            case ResponseUpdate.ResponseUpdateType.UpdateEventReviews:
                //TODO
                //TODO
                ResponseReviews reviews = (ResponseReviews)responsedUpdate.updatingData;

                //обновить список комментов!
                //reviews.reviews
                break;

            case ResponseUpdate.ResponseUpdateType.UpdateCastleReviews:
                SyncContext.RunOnUnityThread(() =>
                                             Links.LastOpenedCastle.CastleUpdateResponse(responsedUpdate));
                break;
            }

            break;
        }
    }