コード例 #1
0
 private async Task SendData(TYPEGET typeGet, TYPE type, MessageInfo param, IDictionary<string,string> arg)
 {
     try
     {
         JToken body = JToken.FromObject(param);
         if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
         {
             if (!isResponsed)
             {
                 isResponsed = true;
                 JToken result = await App.MobileService.InvokeApiAsync("MessageInboxes", body, HttpMethod.Get, arg);
                 JArray response = JArray.Parse(result.ToString());
                 if (typeGet == TYPEGET.START)
                 {
                     MessageList = response.ToObject<ObservableCollection<MessageInbox>>();
                 }
                 else
                 {
                     ObservableCollection<MessageInbox> more = response.ToObject<ObservableCollection<MessageInbox>>();
                     if (type == TYPE.OLD)
                     {
                         for (int i = 0; i < more.Count; i++)
                         {
                             MessageList.Insert(i, more[i]);
                         }
                     }
                     else
                     {                                
                         foreach (var item in more)
                         {
                             MessageList.Add(item);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         await new MessageDialog(ex.Message.ToString(), "Message!").ShowAsync();
     }
     finally
     {
         isResponsed = false;
     }
 }
コード例 #2
0
        public async void LoadInboxHitory(TYPEGET typeGet, TYPE type = TYPE.OLD)
        {          
            int userID = MediateClass.UserVM.UserInfo.UserId;
            int userChat = UserChated.UserID;
            int msgId = -1;
            if(typeGet == TYPEGET.MORE)
            {
                if(type == TYPE.OLD)
                {
                    msgId = MessageList.Min(x => x.MessageId);
                }
                else
                {
                    msgId = MessageList.Max(x => x.MessageId);
                }
            }

            MessageInfo msg = new MessageInfo(msgId, userID, userChat, type);

            IDictionary<string, string> param = new Dictionary<string, string>
            {
                {"type" , "1"}
            };
                        
            await SendData(typeGet, type, msg, param);
        }