Ejemplo n.º 1
0
        private void UpdateLibraryState()
        {
            this.DisposeLocalFile();
            InboxImageDataProviderObject result = this.Result as InboxImageDataProviderObject;
            string inboxPhotoUrl = MessagingService.Instance.GetInboxPhotoUrl(this._title, this._collectionName);

            result.InLibrary = inboxPhotoUrl != null;
            result.ImagePath = inboxPhotoUrl;
        }
Ejemplo n.º 2
0
        private void OnRequestComplete(Microsoft.Zune.Service.HttpWebResponse response, object requestArgs)
        {
            RequestArgs requestArgs1            = (RequestArgs)requestArgs;
            string      requestUri              = requestArgs1.m_requestUri;
            InboxImageDataProviderObject result = requestArgs1.m_result;
            int        tcStart    = requestArgs1.m_tcStart;
            Stream     stream     = null;
            FileStream fileStream = null;

            try
            {
                stream = response.StatusCode == HttpStatusCode.OK ? response.GetResponseStream() : throw new HttpWebException(response);
                int tickCount1 = Environment.TickCount;
                this.SetWorkerStatus(DataProviderQueryStatus.ProcessingData);
                int    contentLength = (int)response.ContentLength;
                byte[] buffer        = new byte[40960];
                string tempFileName  = Path.GetTempFileName();
                fileStream = new FileStream(tempFileName, FileMode.Truncate, FileAccess.Write, FileShare.None, 40960, FileOptions.SequentialScan);
                int count;
                for (; contentLength > 0 && (count = stream.Read(buffer, 0, 40960)) > 0; contentLength -= count)
                {
                    fileStream.Write(buffer, 0, count);
                }
                fileStream.Close();
                result.ImagePath = tempFileName;
                Application.DeferredInvoke(new DeferredInvokeHandler(this.DeferredSetResult), new DeferredSetResultArgs(result));
                this.SetWorkerStatus(DataProviderQueryStatus.Complete);
                int tickCount2 = Environment.TickCount;
            }
            catch (Exception ex)
            {
                this.SetWorkerStatus(DataProviderQueryStatus.Error);
            }
            finally
            {
                fileStream?.Close();
                stream?.Close();
            }
        }
Ejemplo n.º 3
0
 public DeferredSetResultArgs(InboxImageDataProviderObject result) => this.m_result = result;
Ejemplo n.º 4
0
 public RequestArgs(string requestUri, InboxImageDataProviderObject result, int tcStart)
 {
     this.m_requestUri = requestUri;
     this.m_result     = result;
     this.m_tcStart    = tcStart;
 }