当前位置: 首页>>代码示例>>C#>>正文


C# Database.GetDocNumericID方法代码示例

本文整理汇总了C#中Couchbase.Lite.Database.GetDocNumericID方法的典型用法代码示例。如果您正苦于以下问题:C# Database.GetDocNumericID方法的具体用法?C# Database.GetDocNumericID怎么用?C# Database.GetDocNumericID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Couchbase.Lite.Database的用法示例。


在下文中一共展示了Database.GetDocNumericID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PurgeRevisionsTask

 internal static Boolean PurgeRevisionsTask(Database enclosingDatabase, IDictionary<String, IList<String>> docsToRevs, IDictionary<String, Object> result)
 {
     foreach (string docID in docsToRevs.Keys)
     {
         long docNumericID = enclosingDatabase.GetDocNumericID(docID);
         if (docNumericID == -1)
         {
             continue;
         }
         var revsPurged = new AList<string>();
         var revIDs = docsToRevs [docID];
         if (revIDs == null)
         {
             return false;
         }
         else
         {
             if (revIDs.Count == 0)
             {
                 revsPurged = new AList<string>();
             }
             else
             {
                 if (revIDs.Contains("*"))
                 {
                     try
                     {
                         var args = new[] { Convert.ToString(docNumericID) };
                         enclosingDatabase.StorageEngine.ExecSQL("DELETE FROM revs WHERE doc_id=?", args);
                     }
                     catch (SQLException e)
                     {
                         Log.E(Tag, "Error deleting revisions", e);
                         return false;
                     }
                     revsPurged = new AList<string>();
                     revsPurged.AddItem("*");
                 }
                 else
                 {
                     Cursor cursor = null;
                     try
                     {
                         var args = new [] { Convert.ToString(docNumericID) };
                         var queryString = "SELECT revid, sequence, parent FROM revs WHERE doc_id=? ORDER BY sequence DESC";
                         cursor = enclosingDatabase.StorageEngine.RawQuery(queryString, args);
                         if (!cursor.MoveToNext())
                         {
                             Log.W(Tag, "No results for query: " + queryString);
                             return false;
                         }
                         var seqsToPurge = new HashSet<long>();
                         var seqsToKeep = new HashSet<long>();
                         var revsToPurge = new HashSet<string>();
                         while (!cursor.IsAfterLast())
                         {
                             string revID = cursor.GetString(0);
                             long sequence = cursor.GetLong(1);
                             long parent = cursor.GetLong(2);
                             if (seqsToPurge.Contains(sequence) || revIDs.Contains(revID) && !seqsToKeep.Contains
                                     (sequence))
                             {
                                 seqsToPurge.AddItem(sequence);
                                 revsToPurge.AddItem(revID);
                                 if (parent > 0)
                                 {
                                     seqsToPurge.AddItem(parent);
                                 }
                             }
                             else
                             {
                                 seqsToPurge.Remove(sequence);
                                 revsToPurge.Remove(revID);
                                 seqsToKeep.AddItem(parent);
                             }
                             cursor.MoveToNext();
                         }
                         seqsToPurge.RemoveAll(seqsToKeep);
                         Log.I(Tag, String.Format("Purging doc '{0}' revs ({1}); asked for ({2})", docID, revsToPurge, revIDs));
                         if (seqsToPurge.Count > 0)
                         {
                             string seqsToPurgeList = String.Join(",", seqsToPurge);
                             string sql = string.Format("DELETE FROM revs WHERE sequence in ({0})", seqsToPurgeList);
                             try
                             {
                                 enclosingDatabase.StorageEngine.ExecSQL(sql);
                             }
                             catch (SQLException e)
                             {
                                 Log.E(Tag, "Error deleting revisions via: " + sql, e);
                                 return false;
                             }
                         }
                         Collections.AddAll(revsPurged, revsToPurge);
                     }
                     catch (SQLException e)
                     {
                         Log.E(Tag, "Error getting revisions", e);
                         return false;
                     }
//.........这里部分代码省略.........
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:101,代码来源:Database.cs


注:本文中的Couchbase.Lite.Database.GetDocNumericID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。