コード例 #1
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            if (commandParam.LocalUid < 1)
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList);
                return(false);
            }

            //get unread and mostrecent message/notification count
            NotificationGetResponse notification = new NotificationGetResponse();

            notification.Message            = new Notification();
            notification.Message.Unread     = Discuz.Forum.PrivateMessages.GetPrivateMessageCount(commandParam.LocalUid, 0, 1);
            notification.Message.MostRecent = Discuz.Forum.PrivateMessages.GetLatestPMID(commandParam.LocalUid);


            notification.Notification            = new Notification();
            notification.Notification.Unread     = Discuz.Forum.Notices.GetNoticeCount(commandParam.LocalUid, 1);
            notification.Notification.MostRecent = Discuz.Forum.Notices.GetLatestNoticeID(commandParam.LocalUid);

            result = commandParam.Format == FormatType.JSON ?
                     JavaScriptConvert.SerializeObject(notification) : SerializationHelper.Serialize(notification);

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// 获取用户通知
        /// </summary>
        /// <returns></returns>
        public string Get()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return("");
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return("");
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return("");
            }

            if (Uid < 1)
            {
                ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                return("");
            }

            //get unread and mostrecent message/notification count
            NotificationGetResponse notification = new NotificationGetResponse();

            notification.Message            = new Notification();
            notification.Message.Unread     = Discuz.Forum.PrivateMessages.GetPrivateMessageCount(Uid, 0, 1);
            notification.Message.MostRecent = Discuz.Forum.PrivateMessages.GetLatestPMID(Uid);


            notification.Notification            = new Notification();
            notification.Notification.Unread     = Discuz.Forum.Notices.GetNoticeCount(Uid, 1);
            notification.Notification.MostRecent = Discuz.Forum.Notices.GetLatestNoticeID(Uid);

            if (Format == FormatType.JSON)
            {
                return(JavaScriptConvert.SerializeObject(notification));
            }

            return(SerializationHelper.Serialize(notification));
        }
コード例 #3
0
ファイル: Notifications.cs プロジェクト: khaliyo/DiscuzNT
        /// <summary>
        /// 获取用户通知
        /// </summary>
        /// <returns></returns>
        public string Get()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return "";
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return "";
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return "";
            }

            if (Uid < 1)
            {
                ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                return "";
            }

            //get unread and mostrecent message/notification count
            NotificationGetResponse notification = new NotificationGetResponse();
            notification.Message = new Notification();
            notification.Message.Unread = Discuz.Forum.PrivateMessages.GetPrivateMessageCount(Uid, 0, 1);
            notification.Message.MostRecent = Discuz.Forum.PrivateMessages.GetLatestPMID(Uid);


            notification.Notification = new Notification();
            notification.Notification.Unread = Discuz.Forum.Notices.GetNoticeCount(Uid, 1);
            notification.Notification.MostRecent = Discuz.Forum.Notices.GetLatestNoticeID(Uid);

            if (Format == FormatType.JSON)
                return JavaScriptConvert.SerializeObject(notification);

            return SerializationHelper.Serialize(notification);
        }
コード例 #4
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            if (commandParam.LocalUid < 1)
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList);
                return false;
            }

            //get unread and mostrecent message/notification count
            NotificationGetResponse notification = new NotificationGetResponse();
            notification.Message = new Notification();
            notification.Message.Unread = Discuz.Forum.PrivateMessages.GetPrivateMessageCount(commandParam.LocalUid, 0, 1);
            notification.Message.MostRecent = Discuz.Forum.PrivateMessages.GetLatestPMID(commandParam.LocalUid);


            notification.Notification = new Notification();
            notification.Notification.Unread = Discuz.Forum.Notices.GetNoticeCount(commandParam.LocalUid, 1);
            notification.Notification.MostRecent = Discuz.Forum.Notices.GetLatestNoticeID(commandParam.LocalUid);

            result = commandParam.Format == FormatType.JSON ?
                JavaScriptConvert.SerializeObject(notification) : SerializationHelper.Serialize(notification);

            return true;
        }