示例#1
0
        /// <summary>
        /// Retrieves the Inbox folder
        /// </summary>
        /// <param name="pageNumber">Page number to retrieve</param>
        /// <param name="urlOverride">URL override, if retrieving from a different location</param>
        public GetFolderResult Inbox(uint?pageNumber = null, string urlOverride = null, bool unread = false)
        {
            string             url        = (urlOverride ?? GenerateUrl()) + (unread ? "unread/" : "");
            VariableCollection parameters = GenerateParameters(pageNumber);

            try {
                var result   = WebClient.Get(url, parameters);
                var messages = result.GetMessagesResponsesFromXml();


                GetFolderResult returnValue = new GetFolderResult();
                string          json        = result.GetJsonFromXml();

                try {
                    returnValue = json.ToObject <GetFolderResult>();
                } catch (Exception ex) {
                    object[] methodParameters = { pageNumber, urlOverride };

                    if (!ReloginAnd <GetFolderResult>(out returnValue, pageNumber, urlOverride))
                    {
                        throw new FolderException(url, ex);
                    }
                }

                return(returnValue);
            } catch (Exception ex) {
                throw new FolderException(url, ex);
            }
        }
示例#2
0
        /// <summary>
        /// Initiates a call to the destination phone number from the local phone
        /// </summary>
        public bool Call(string localPhone, string destinationPhoneNumber)
        {
            try
            {
                VariableCollection parameters = GenerateParameters();

                parameters["outgoingNumber"].Value   = destinationPhoneNumber;
                parameters["forwardingNumber"].Value = localPhone;
                parameters["subscriberNumber"].Value = "undefined";
                parameters["phoneType"].Value        = 2;
                parameters["remember"].Value         = 0;
                parameters["_rnr_se"].Value          = Session;

                var result = WebClient.Post(GenerateUrl(), parameters);

                GetFolderResult returnValue = new GetFolderResult();
                var             dictionary  = result.Content.ToObject <Dictionary <string, object> >();

                return(Convert.ToBoolean(dictionary["ok"]));
            }
            catch (Exception ex)
            {
                throw new CallException(ex);
            }
        }
        public static async Task <GetFolderResult> GetFolderSilentAsync()
        {
            if (!StorageApplicationPermissions.FutureAccessList.ContainsItem(EBOOKREADERFOLDERFILETOKEN))
            {
                return(GetFolderResult.CreateFromError(GetFolderResult.Reason.NotSet));
            }
            try
            {
                var folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(EBOOKREADERFOLDERFILETOKEN);

                return(GetFolderResult.CreateFromFolder(folder));
            }
            catch (Exception)
            {
            }
            return(GetFolderResult.CreateFromError(GetFolderResult.Reason.NoSuchFolder));
        }
示例#4
0
        /// <summary>
        /// Retrieves the Inbox folder
        /// </summary>
        /// <param name="pageNumber">Page number to retrieve</param>
        /// <param name="urlOverride">URL override, if retrieving from a different location</param>
        /// <param name="rnr_se">URL override, if retrieving from a different location</param>
        ///
        public HtmlNodeCollection InboxMessages(string rnr_se, uint?pageNumber = null, string urlOverride = null)
        {
            string base_url = (urlOverride ?? GenerateUrl());
            string get_url  = base_url;

            VariableCollection parameters = GenerateParameters(pageNumber);

            try {
                var result = WebClient.Get(get_url, parameters);
                //TODO if no messages
                GetFolderResult messageJson = new GetFolderResult();
                string          json        = result.GetJsonFromXml();

                messageJson = json.ToObject <GetFolderResult>();
                if (messageJson.totalSize == 0)  //no messages
                {
                    return(null);
                }
                else
                {
                    var messages = result.GetMessagesResponsesFromXml();
                    VariableCollection delete = new VariableCollection();

                    XmlDocument xmlResponse = new XmlDocument();
                    xmlResponse.LoadXml(result);
                    string responseXml = xmlResponse.SelectSingleNode("/response/html").InnerText;
                    var    doc         = new HtmlDocument();
                    doc.LoadHtml(responseXml);
                    var messageId = doc.DocumentNode.SelectSingleNode("//div").Attributes["id"].Value;
                    delete["messages"].Value = messageId;
                    delete["archive"].Value  = 1;
                    delete["_rnr_se"].Value  = rnr_se;

                    string archive_url = Regex.Replace(base_url, "/recent", "") + "archiveMessages/";
                    var    response    = WebClient.Post(archive_url, delete);
                    return(messages);
                }
            } catch (Exception ex) {
                throw new FolderException(get_url, ex);
            }
        }
示例#5
0
        /// <summary>
        /// Performs a search for the specified term
        /// </summary>
        /// <param name="pageNumber">Page number to retrieve</param>
        public GetFolderResult Search(string term, uint?pageNumber = null)
        {
            try
            {
                VariableCollection parameters = GenerateParameters(pageNumber);

                parameters["q"].Value = term;

                var result = WebClient.Get(GenerateUrl(), parameters);

                GetFolderResult returnValue = new GetFolderResult();
                string          json        = result.GetJsonFromXml();

                returnValue = json.ToObject <GetFolderResult>();

                return(returnValue);
            }
            catch (Exception ex)
            {
                throw new SearchException(ex);
            }
        }
示例#6
0
        /// <summary>
        /// Sends a SMS message to the destination phone number with the specified message
        /// </summary>
        public bool SMS(string destinationPhoneNumber, string message)
        {
            try
            {
                VariableCollection parameters = GenerateParameters();

                parameters["phoneNumber"].Value  = destinationPhoneNumber;
                parameters["text"].Value         = message;
                parameters["sendErrorSms"].Value = 0;
                parameters["_rnr_se"].Value      = Session;

                var result = WebClient.Post(GenerateUrl(), parameters);

                GetFolderResult returnValue = new GetFolderResult();
                var             dictionary  = result.Content.ToObject <Dictionary <string, object> >();

                return(Convert.ToBoolean(dictionary["ok"]));
            }
            catch (Exception ex)
            {
                throw new SmsException(ex);
            }
        }