ToSiaqodbDocument() 공개 정적인 메소드

public static ToSiaqodbDocument ( CouchDBDocument cobj ) : SiaqodbDocument
cobj CouchDBDocument
리턴 SiaqodbCloudService.Models.SiaqodbDocument
예제 #1
0
        public async Task <SiaqodbDocument> Get(string bucketName, string key, string version)
        {
            using (var client = new MyCouchClient(DbServerUrl, bucketName))
            {
                var startTime = DateTime.Now;
                var response  = await client.Documents.GetAsync(key, version);

                if (response.IsSuccess)
                {
                    var size = response.Content == null ? 0 : response.Content.Length;

                    if (size == 0)
                    {
                        return(null);
                    }
                    var doc = client.Serializer.Deserialize <CouchDBDocument>(response.Content);
                    return(Mapper.ToSiaqodbDocument(doc));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    if (response.Reason == "no_db_file")
                    {
                        throw new BucketNotFoundException(bucketName);
                    }
                    else
                    {
                        throw new DocumentNotFoundException(key, version);
                    }
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    throw new InvalidVersionFormatException();
                }
                else
                {
                    throw new GenericCouchDBException(response.Reason, response.StatusCode);
                }
            }
        }
예제 #2
0
        private void AddChangedDoc(BatchSet changeSet, ChangesResponse <string> .Row row, SyncLogItem logItem, Filter query, MyCouch.Serialization.ISerializer serializer)
        {
            if (changeSet.ChangedDocuments == null)
            {
                changeSet.ChangedDocuments = new List <SiaqodbDocument>();
            }
            CouchDBDocument co = serializer.Deserialize <CouchDBDocument>(row.IncludedDoc);

            if (co._id.StartsWith("_design/"))
            {
                return;
            }
            //check uploaded anchor- means cliet just uploaded this record and we should not return back
            if (logItem != null && logItem.KeyVersion != null && logItem.KeyVersion.ContainsKey(co._id) && logItem.KeyVersion[co._id] == co._rev)
            {
                return;
            }
            if (OutOfFilter(query, co))
            {
                return;
            }
            changeSet.ChangedDocuments.Add(Mapper.ToSiaqodbDocument(co));
        }