Пример #1
0
        /// <summary>
        /// Returns the message count for a specific folder type (inbox, sent, deleted)
        /// </summary>
        /// <param name="pFolder">
        /// Mailbox folder to fetch count for
        /// </param>
        /// <param name="pCount">
        /// Message count for the folder type
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class with details of the fetch and results from the server
        /// </returns>
        public WebCallResult GetFolderCount(FolderTypes pFolder, out int pCount)
        {
            pCount = 0;
            string strUrl = string.Format("{0}mailbox/folders/{1}?userobjectid={2}", HomeServer.BaseUrl, pFolder.ToString(), UserObjectId);

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false)
            {
                return res;
            }

            Folder oFolder= HomeServer.GetObjectFromJson<Folder>(res.ResponseText, "Folder");

            if (oFolder==null)
            {
                res.ErrorText = "Failure parsing JSON response into MailboxInfo class:" + res.ResponseText;
                res.Success = false;
                return res;
            }

            pCount = oFolder.MessageCount;
            return res;
        }