private AddItem ( IOfflineEntity iOfflineEntity ) : void | ||
iOfflineEntity | IOfflineEntity | |
리턴 | void |
private object ProcessDownloadRequest(HttpWebRequest webRequest, CacheRequest request) { using (Stream memoryStream = new MemoryStream()) { // Create a SyncWriter to write the contents this._syncWriter = new ODataAtomWriter(base.BaseUri); this._syncWriter.StartFeed(true, request.KnowledgeBlob ?? new byte[0]); this._syncWriter.WriteFeed(XmlWriter.Create(memoryStream)); memoryStream.Flush(); webRequest.ContentLength = memoryStream.Position; Stream requestStream = webRequest.GetRequestStream(); CopyStreamContent(memoryStream, requestStream); requestStream.Flush(); requestStream.Close(); // Fire the Before request handler this.FirePreRequestHandler(webRequest); } // Get the response HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); if (webResponse.StatusCode == HttpStatusCode.OK) { ChangeSet changeSet = new ChangeSet(); using (Stream responseStream = webResponse.GetResponseStream()) { // Create the SyncReader this._syncReader = new ODataAtomReader(responseStream, this._knownTypes); // Read the response while (this._syncReader.Next()) { switch (this._syncReader.ItemType) { case ReaderItemType.Entry: changeSet.AddItem(this._syncReader.GetItem()); break; case ReaderItemType.SyncBlob: changeSet.ServerBlob = this._syncReader.GetServerBlob(); break; case ReaderItemType.HasMoreChanges: changeSet.IsLastBatch = !this._syncReader.GetHasMoreChangesValue(); break; } } this.FirePostResponseHandler(webResponse); } webResponse.Close(); return changeSet; } else { throw new CacheControllerException( string.Format("Remote service returned error status. Status: {0}, Description: {1}", webResponse.StatusCode, webResponse.StatusDescription)); } }
private object ProcessDownloadRequest(HttpWebRequest webRequest, CacheRequest request) { using (Stream memoryStream = new MemoryStream()) { // Create a SyncWriter to write the contents this._syncWriter = new ODataAtomWriter(base.BaseUri); this._syncWriter.StartFeed(true, request.KnowledgeBlob ?? new byte[0]); this._syncWriter.WriteFeed(XmlWriter.Create(memoryStream)); memoryStream.Flush(); webRequest.ContentLength = memoryStream.Position; Stream requestStream = webRequest.GetRequestStream(); CopyStreamContent(memoryStream, requestStream); requestStream.Flush(); requestStream.Close(); // Fire the Before request handler this.FirePreRequestHandler(webRequest); } // Get the response HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); if (webResponse.StatusCode == HttpStatusCode.OK) { ChangeSet changeSet = new ChangeSet(); using (Stream responseStream = webResponse.GetResponseStream()) { // Create the SyncReader this._syncReader = new ODataAtomReader(responseStream, this._knownTypes); // Read the response while (this._syncReader.Next()) { switch (this._syncReader.ItemType) { case ReaderItemType.Entry: changeSet.AddItem(this._syncReader.GetItem()); break; case ReaderItemType.SyncBlob: changeSet.ServerBlob = this._syncReader.GetServerBlob(); break; case ReaderItemType.HasMoreChanges: changeSet.IsLastBatch = !this._syncReader.GetHasMoreChangesValue(); break; } } this.FirePostResponseHandler(webResponse); } webResponse.Close(); return(changeSet); } else { throw new CacheControllerException( string.Format("Remote service returned error status. Status: {0}, Description: {1}", webResponse.StatusCode, webResponse.StatusDescription)); } }