Example #1
0
 void LoadDataForm_onGetUsersSuccessfully(Users users)
 {
     foreach (User user in users.User)
     {
         DataCenter.Instance().Users[user.userId] = user;
     }
     ExecuteTask();
 }
Example #2
0
        public void getUsers(Form attachedForm)
        {
            new Thread(delegate()
            {
                byte[] respData;
                string json = "";
                WebHeaderCollection headers;
                string url = getUrl(Action.getusers);
                HttpStatusCode statusCode = HTTPRequest.MakeRequest(url, "GET",
                    Constants.JSON_MIME, null,
                    null, out respData, out headers);
                if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.NoContent)
                {
                    if (onGetUsersSuccessfully != null)
                    {
                        Users users = new Users();
                        if (respData != null)
                        {
                            json = Encoding.UTF8.GetString(respData);
                            users = Utility.JsonDeserialize<Users>(json);
                            Utility.FillUsers(users);
                        }
                        attachedForm.BeginInvoke(onGetUsersSuccessfully, users);
                    }
                }
                else
                {
                    if (onGetUsersSuccessfully != null)
                        attachedForm.BeginInvoke(onGetUsersSuccessfully, statusCode);
                }

            }).Start();
        }