Exemplo n.º 1
0
        public static void GetImagesFromId(String PropertyId, Model.Type type = Model.Type.TYPE_LARGET_PHOTO, String ImageId = "*")
        {
            string requestArguments = String.Format("?Resource={0}&Type={1}&ID={2}:{3}", "Property", TypeHandler.Convert(type), PropertyId, ImageId);
            string searchService    = RetsUrl + "/GetObject.svc/GetObject" + requestArguments;


            httpWebRequest = (HttpWebRequest)WebRequest.Create(searchService);
            httpWebRequest.CookieContainer = cookieJar;          //GRAB THE COOKIE
            httpWebRequest.Credentials     = requestCredentials; //PASS CREDENTIALS


            using (HttpWebResponse httpResponse = httpWebRequest.GetResponse() as HttpWebResponse)
            {
                Stream stream   = httpResponse.GetResponseStream();
                string filename = String.Concat(CreateDirIfNotExists(PropertyId), @"\", PropertyId, "_", ImageId.Equals("*") ? "0" : ImageId, ".png");

                using (Stream file = File.Create(filename))
                {
                    CopyStream(stream, file);
                }
            }
        }