本文整理汇总了C#中SQLite.SQLiteConnection.BeginTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# SQLite.SQLiteConnection.BeginTransaction方法的具体用法?C# SQLite.SQLiteConnection.BeginTransaction怎么用?C# SQLite.SQLiteConnection.BeginTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLite.SQLiteConnection.BeginTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshPushDirectory
public static void RefreshPushDirectory()
{
Console.WriteLine("starting contacts sync");
AddressBook book = new AddressBook();
PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
book.RequestPermission().ContinueWith(t => {
if (!t.Result) {
Console.WriteLine("Permission denied by user or manifest");
return;
}
long now = Utils.CurrentTimeMillis();
Dictionary<String, String> map = new Dictionary<String, String>();
int i = 0, j = 0, k = 0;
foreach (Contact contact in book) {
if (String.IsNullOrEmpty(contact.DisplayName))
continue;
foreach (Phone phone in contact.Phones) {
j++;
if (phone.Number.Contains("*") || phone.Number.Contains("#"))
continue;
try {
String number = phoneUtil.Format(phoneUtil.Parse(phone.Number, AppDelegate.GetCountryCode()), PhoneNumberFormat.E164);
if (!map.ContainsKey(number))
map.Add(number, contact.DisplayName);
} catch (Exception e) {
Console.WriteLine("Exception parsing/formatting '" + phone.Number + "': " + e.Message);
}
}
foreach (Email email in contact.Emails) {
k++;
if (!map.ContainsKey(email.Address))
map.Add(email.Address, contact.DisplayName);
}
i++;
}
Console.WriteLine(i + " contacts in address book with " + j + " phone numbers and " + k + " email addresses");
Dictionary<String, String> tokens = hashNumbers(map.Keys.ToList());
List<String> response = MessageManager.RetrieveDirectory(tokens.Keys.ToList());
Console.WriteLine("found " + response.Count + " securecom users");
using (var conn = new SQLite.SQLiteConnection(AppDelegate._dbPath)) {
conn.BeginTransaction();
conn.Execute("DELETE FROM PushContact");
foreach (String key in response) {
String number = tokens[key];
if (number == null) // is this needed?
continue;
conn.Insert(new PushContact { Number = number, Name = map[number] });
}
conn.Commit();
}
Console.WriteLine("contacts sync finished, took " + ((Utils.CurrentTimeMillis() - now) / 1000.0) + " seconds");
}, TaskScheduler.Current);
}