コード例 #1
0
ファイル: NIMTeamAPI.cs プロジェクト: xw0001/NIM-CSharp-SDK
        private static NIMTeamEventData ParseTeamEventData(int resCode, int nid, string tid, string result)
        {
            NIMTeamEventData    eventData        = null;
            NIMNotificationType notificationType = (NIMNotificationType)Enum.Parse(typeof(NIMNotificationType), nid.ToString());

            if (!string.IsNullOrEmpty(result))
            {
                try
                {
                    eventData = NIMTeamEventData.Deserialize(result);
                    if (eventData != null)
                    {
                        if (notificationType.Equals(NIMNotificationType.kNIMNotificationIdLocalGetTeamMsgUnreadCount) ||
                            notificationType.Equals(NIMNotificationType.kNIMNotificationIdLocalGetTeamMsgUnreadList))
                        {
                            NIMTeamEventDataObjects eventDataObjects = NIMTeamEventDataObjects.Deserialize(result);
                            if (eventDataObjects != null)
                            {
                                eventData.TeamEvents = eventDataObjects.TeamEventInfos;
                            }
                        }
                        else
                        {
                            NIMTeamEventDataObject eventDataObject = NIMTeamEventDataObject.Deserialize(result);
                            if (eventDataObject != null && eventDataObject.TeamEvent != null)
                            {
                                eventData.TeamEvent = eventDataObject.TeamEvent;
                            }
                            else
                            {
                                eventData.TeamEvent = new NIMTeamEvent();
                            }

                            eventData.TeamEvent.TeamId           = tid;
                            eventData.TeamEvent.ResponseCode     = (ResponseCode)Enum.Parse(typeof(ResponseCode), resCode.ToString());
                            eventData.TeamEvent.NotificationType = notificationType;
                        }
                    }
                }
                catch
                {
                    eventData      = new NIMTeamEventData();
                    eventData.JSON = result;
                }
            }
            if (eventData == null)
            {
                eventData      = new NIMTeamEventData();
                eventData.JSON = result;
            }
            eventData.NotificationId = notificationType;

            return(eventData);
        }
コード例 #2
0
        private static NIMTeamEventData ParseTeamEventData(int resCode, int nid, string tid, string result)
        {
            NIMTeamEventData eventData = null;

            if (!string.IsNullOrEmpty(result))
            {
                eventData = NIMTeamEventData.Deserialize(result);
                if (eventData.TeamEvent == null)
                {
                    eventData.TeamEvent = new NIMTeamEvent();
                }
                eventData.TeamEvent.TeamId           = tid;
                eventData.TeamEvent.ResponseCode     = (ResponseCode)Enum.Parse(typeof(ResponseCode), resCode.ToString());
                eventData.TeamEvent.NotificationType = (NIMNotificationType)Enum.Parse(typeof(NIMNotificationType), nid.ToString());
            }
            return(eventData);
        }