Ejemplo n.º 1
0
        public vCard GetVCard(string id)
        {
            Dictionary <string, string> results = this.Query(this.serverUrl + id, "GET");

            if (results.ContainsKey("status"))
            {
                string status = results["status"];

                if (status.Equals("200") || status.Equals("207") || status.Equals("204") || status.Equals("201") || status.ToLower().Equals("ok"))
                {
                    if (results.ContainsKey("response"))
                    {
                        StringReader reader = new StringReader(results["response"]);
                        vCard        card   = new vCard();
                        card.Parse(reader);

                        return(card);
                    }
                    else
                    {
                        throw new HTTPException("Arrgg. No response returned from the server!");
                    }
                }
                else
                {
                    throw new HTTPException("Whoops something went wrong! The server returned a status code of: " + status);
                }
            }
            else
            {
                throw new HTTPException("No status code returned from HTTP Request");
            }
        }
Ejemplo n.º 2
0
        public void ExtractImageToPath(string outputPath)
        {
            vCard vCphoto = new vCard();

            vCphoto.Parse(FilePath);
            int    ctr         = 0;
            String strFileName = outputPath.TrimEnd('\\') + "\\" + System.IO.Path.GetFileNameWithoutExtension(FilePath);

            if (File.Exists(strFileName + ".jpeg") == true)
            {
                while (File.Exists(String.Format(strFileName + "_{0}.jpeg", ctr.ToString())) == true)
                {
                    ctr = ctr + 1;
                }
                strFileName = String.Format(strFileName + "_{0}", ctr.ToString());
            }
            vCphoto.Photo.Save(strFileName + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
        }