public async void getImageFromServer(Uri imageFileUri)
        {
            //BitmapImage bm = new BitmapImage();
            //WebClient m_webClient = new WebClient();
            //m_webClient.OpenReadCompleted += (o, e) =>
            //{
            //    if (e.Error != null || e.Cancelled) return;
            //    CacheImageFileConverter.WriteToIsolatedStorage(IsolatedStorageFile.GetUserStoreForApplication(), e.Result, CacheImageFileConverter.GetFileNameInIsolatedStorage(imageFileUri));
            //    bm.SetSource(e.Result);
            //    e.Result.Close();
            //};
            bool   fs            = false;
            string unixTime      = "tiempo";
            string unixTimestamp = (int)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + "";
            Uri    path          = new Uri(imageFileUri.ToString() + "?" + unixTime + "=" + unixTimestamp);


            HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(path);

            webRequest.Method = "HEAD";
            HttpWebResponse webResponse    = ((HttpWebResponse)await webRequest.GetResponseAsync());
            var             fechaUltimaMod = webResponse.Headers["Last-Modified"];
            CacheImagen     cache          = new CacheImagen(imageFileUri.ToString(), fechaUltimaMod.ToString());
            CacheImagen     accesBDCache   = bdCache.getCacheImage(cache.url);

            if (accesBDCache != null)
            {
                if (cache.date == accesBDCache.date)
                {
                    //bm = (BitmapImage)CacheImageFileConverter.ExtractFromLocalStorage(imageFileUri);
                    fs = false;
                }
                else
                {
                    //bdCache.insert(cache);
                    //m_webClient.OpenReadAsync(imageFileUri);
                    fs = true;
                }
            }
            else
            {
                //bdCache.insert(cache);
                //m_webClient.OpenReadAsync(imageFileUri);
                fs = true;
            }
            webResponse.Close();
            if (fotoCargada != null)
            {
                fotoCargada(this, new FotoCargardaEventArgs(fs, cache));
            }
        }
 public FotoCargardaEventArgs(bool s, CacheImagen c)
 {
     //bitmap = a;
     fromServer = s;
     cache      = c;
 }
Example #3
0
 public void insert(CacheImagen a)
 {
     dbConn.InsertOrReplace(a);
 }