Exemple #1
0
 //强制更新一个群的数据
 private void forceUpdateGroupInfo(int gid)
 {
     HttpReqHelper.requestSync(AppConst.WebUrl + "groupBaseInfo?protocol=" + HttpGroupProtocol.GROUP_BASE_INFO + "&gid=" + gid, delegate(string info)
     {
         try
         {
             GroupInfoModel model = Coding <GroupInfoModel> .decode(info);
             if (groupDic.ContainsKey(gid))
             {
                 groupDic[gid] = model;
             }
             else
             {
                 groupDic.TryAdd(gid, model);
             }
             //发送事件
             if (updateGroupInfoEvent != null)
             {
                 updateGroupInfoEvent(gid, model);
             }
             //移除无效列表
             invalidGroup.Remove(gid);
         }
         catch (Exception err)
         {
             Debug.Print("!!!DataMgr.modifyGroupInfo失败" + err.ToString());
         }
     });
 }
Exemple #2
0
 public void getPersonalByID(string personalId, RequestPersonalInfoEvent callBack)
 {
     if (personalId == string.Empty || personalId == null)
     {
         if (callBack != null)
         {
             callBack(new PersonalInfoModel());
         }
         return;
     }
     if (personalDic.ContainsKey(personalId))
     {
         if (callBack != null)
         {
             callBack(personalDic[personalId]);
         }
     }
     else  //请求这个人的信息,请求完后要更新至字典中。
     {
         HttpReqHelper.requestSync(AppConst.WebUrl + "baseInfo?protocol=" + HttpPersonalProtocol.BASE_INFO + "&username="******"DataMgr.getPersonalByID解析失败" + err.ToString());
                 if (callBack != null)
                 {
                     callBack(default(PersonalInfoModel));
                 }
             }
         });
     }
 }
Exemple #3
0
        public void getGroupByID(int groupId, RequestGroupInfoEvent callBack)
        {
            if (groupDic.ContainsKey(groupId))
            {
                //判断有效性,这样可以保证拉取信息的地方,总可以获得最新的数据

                if (invalidGroup.Contains(groupId))//已过时,去更新,返回最新数据。
                {
                    HttpReqHelper.requestSync(AppConst.WebUrl + "groupBaseInfo?protocol=" + HttpGroupProtocol.GROUP_BASE_INFO + "&gid=" + groupId, delegate(string info)
                    {
                        try
                        {
                            GroupInfoModel newmodel = Coding <GroupInfoModel> .decode(info);
                            if (groupDic.ContainsKey(groupId))
                            {
                                groupDic[groupId] = newmodel;
                            }
                            //发送数据已更新的事件
                            if (updateGroupInfoEvent != null)
                            {
                                updateGroupInfoEvent(groupId, newmodel);
                            }
                            //移除无效列表
                            invalidGroup.Remove(groupId);
                            //返回最新数据
                            if (callBack != null)
                            {
                                callBack(groupDic[groupId]);
                            }
                        }
                        catch (Exception err)
                        {
                            Debug.Print("!!!DataMgr.modifyGroupInfo失败" + err.ToString());
                        }
                    });
                }
                else  //有效数据直接返回
                {
                    if (callBack != null)
                    {
                        callBack(groupDic[groupId]);
                    }
                }
            }
            else//还没有这条数据
            {
                HttpReqHelper.requestSync(AppConst.WebUrl + "groupBaseInfo?protocol=" + HttpGroupProtocol.GROUP_BASE_INFO + "&gid=" + groupId, delegate(string info) {
                    try
                    {
                        GroupInfoModel model = Coding <GroupInfoModel> .decode(info);
                        //  Debug.Print("收到信息"+ groupId+"  " + model.Name+ model.Master+"|||"+model.Createdtime+model.Verifymode);
                        groupDic.TryAdd(groupId, model);
                        //返回结果
                        if (callBack != null)
                        {
                            callBack(model);
                        }
                    }
                    catch (Exception err)
                    {
                        Debug.Print("!!!DataMgr.getGroupByID解析失败" + err.ToString());
                        if (callBack != null)
                        {
                            callBack(default(GroupInfoModel));
                        }
                    }
                });
            }
        }