Esempio n. 1
0
        public override CreateUserData Execute()
        {
            try
            {
                if (IsCreateNew)
                {
                    Data.ScorePoints = 0;
                }
                string imagePath = " ";
                if (Data.ProfileImage != null && !Data.ProfileImage.ToLower().StartsWith("http"))
                {
                    imagePath         = Data.ProfileImage;
                    Data.ProfileImage = null;
                }

                string serializedData = JsonConvert.SerializeObject(Data);

                string userId = UserId;

                if (IsCreateNew)
                {
                    //	var result = WebClient.PostStringAsync(QueryBuilder.Instance.GetUsersQuery (), serializedData).Result;
                    var result = KinveyWebClient.PostSignUpStringAsync(QueryBuilder.Instance.GetUsersKinveyQuery(), serializedData).Result;

                    UniqueItem uniqueItemId = JsonConvert.DeserializeObject <UniqueItem>(result);
                    userId = uniqueItemId.Id;
                }
                else
                {
                    if (!Data.IsEmpty())
                    {
                        AppProvider.Log.WriteLine(LogChannel.All, QueryBuilder.Instance.GetPostUserProfileChangesKinveyQuery(UserId) + " : " + serializedData);
                        var update = KinveyWebClient.PutStringAsync(QueryBuilder.Instance.GetPostUserProfileChangesKinveyQuery(UserId), serializedData).Result;
                    }
                }

                if (!string.IsNullOrEmpty(imagePath.Trim()))
                {
                    var postImageToPost = new PostImageKinveyBackgroundTask(imagePath, userId, KinveyImageType.User);

                    postImageToPost.Execute();
                    //Data.ProfileImage = postImageToPost.Execute();

                    //var response = WebClient.PutBytesAsync(QueryBuilder.Instance.GetUploadUserImageQuery (userId), imageContent).Result;
                }

                return(Data);
            }
            catch (Exception ex)
            {
                AppProvider.Log.WriteLine(LogChannel.Exception, ex);
                Exception = ex;
            }

            return(null);
        }
        public override RequestConnectionData Execute()
        {
            try
            {
                string result = null;
                if (RequestData != null)
                {
                    //     string serializedData = JsonConvert.SerializeObject(ConnReq);

                    /*
                     * var settings = new JsonSerializerSettings
                     * {
                     *  Error = (sender, args) =>
                     *  {
                     *      if (System.Diagnostics.Debugger.IsAttached)
                     *      {
                     *          System.Diagnostics.Debugger.Break();
                     *      }
                     *  }
                     * };*/

                    string serializedData = JsonConvert.SerializeObject(RequestData);

                    result = KinveyWebClient.PostStringAsync(QueryBuilder.Instance.GetPostRequestConnectionKinveyQuery(), serializedData).Result;
                }
                else
                {
                    string serializedData = JsonConvert.SerializeObject(AcceptData);

                    if (string.IsNullOrEmpty(RequestId))
                    {
                        result = KinveyWebClient.PostStringAsync(QueryBuilder.Instance.GetPostRequestConnectionKinveyQuery(), serializedData).Result;
                    }
                    else
                    {
                        string query = QueryBuilder.Instance.GetPostRequestConnectionKinveyQuery(RequestId);
                        AppProvider.Log.WriteLine(LogChannel.All, query + " " + serializedData);
                        result = KinveyWebClient.PutStringAsync(query, serializedData).Result;
                    }
                }
                ConnectRequest        ResultConnReq = JsonConvert.DeserializeObject <ConnectRequest>(result);
                RequestConnectionData resultRCD     = JsonConvert.DeserializeObject <RequestConnectionData>(result);
                AppProvider.Log.WriteLine(LogChannel.All, result);
                return(resultRCD);
            }
            catch (Exception ex)
            {
                AppProvider.Log.WriteLine(LogChannel.Exception, ex);
                Exception = ex;
            }

            return(null);
        }
Esempio n. 3
0
        public override T Execute()
        {
            try
            {
                string serializedData = JsonConvert.SerializeObject(Data);
                string result         = null;

                AppProvider.Log.WriteLine(LogChannel.All, Query + ":" + serializedData);

                try
                {
                    if (IsPostQuery)
                    {
                        result = KinveyWebClient.PostStringAsync(Query, serializedData).Result;
                    }
                    //result = WebClient.PostStringAsync(Query, serializedData).Result;
                    else
                    {
                        result = KinveyWebClient.PutStringAsync(Query, serializedData).Result;
                    }
                }
                catch (Exception ex)
                {
                    AppProvider.Log.WriteLine(LogChannel.All, ex);
                }

                AppProvider.Log.WriteLine(LogChannel.All, result);
                Result = JsonConvert.DeserializeObject <T>(result);

                OnResult(Result);
                return(Result);
            }
            catch (Exception ex)
            {
                AppProvider.Log.WriteLine(LogChannel.Exception, ex);
                Exception = ex;
            }

            return(null);
        }