本文整理汇总了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;
}
//.........这里部分代码省略.........