本文整理汇总了C#中SqlDatabase.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDatabase.Remove方法的具体用法?C# SqlDatabase.Remove怎么用?C# SqlDatabase.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlDatabase
的用法示例。
在下文中一共展示了SqlDatabase.Remove方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NotQueuedSanityCheckup
private static void NotQueuedSanityCheckup()
{
lock (_dbLock)
{
using (var db = new SqlDatabase<NotQueuedEntry>(NotQueuedLocation))
{
const int secondsInWeek = 604800;
var nowTime = Time.GetNowUnixTimestamp();
var truncateTime = nowTime - secondsInWeek;
var removing = false;
var bubblesToTruncate = new List<NotQueuedEntry>();
foreach (var possibleBubble in db.Store.Where(x => x.Time < truncateTime))
{
if (!removing)
{
Utils.DebugPrint("Pruning not queued bubbles database. Some bubbles are too old!");
}
removing = true;
bubblesToTruncate.Add(possibleBubble);
}
foreach (var possibleBubble in bubblesToTruncate)
{
db.Remove(possibleBubble);
}
}
}
}
示例2: Load
public static void Load()
{
lock (_lock)
{
using (var db = new SqlDatabase<BubbleGroupSettings>(GetPath()))
{
var toRemoves = new List<BubbleGroupSettings>();
foreach (var settings in db.Store.ToList())
{
var bubbleGroup = BubbleGroupManager.Find(settings.Guid);
if (bubbleGroup == null)
{
toRemoves.Add(settings);
}
else
{
bubbleGroup.Settings = settings;
}
}
if (toRemoves.Any())
{
foreach (var toRemove in toRemoves)
{
db.Remove(toRemove);
}
}
}
}
}
示例3: PurgeBubble
public static Task PurgeBubble(string bubbleId)
{
return Task.Factory.StartNew(() =>
{
lock (_dbLock)
{
using (var db = new SqlDatabase<Entry>(Location))
{
foreach (var entry in db.Store.Where(x => x.Guid == bubbleId))
{
db.Remove(entry);
}
var sending = InsertBubble.Sending.FirstOrDefault(x => x.ID == bubbleId);
if (sending != null)
{
InsertBubble.Sending.Remove(sending);
}
}
}
});
}
示例4: Send
public static Task<List<Receipt>> Send(string[] serviceNames, bool scheduled = false)
{
return Task<List<Receipt>>.Factory.StartNew(() =>
{
//PROCESS: 1) find all bubbles under serviceNames in db
// 2) relate db entries to bubbles loaded into memory by Disa
// 3) parallel send bubbles based respective to service
// 4) delete all successful bubbles out of db
lock (_sendLock)
{
var possibleBubblesFromDatabase = new List<Entry>();
lock (_dbLock)
{
using (var db = new SqlDatabase<Entry>(Location))
{
foreach (var possibleBubble in db.Store.Where(x => serviceNames.Contains(x.ServiceName)).Reverse())
{
if (!InsertBubble.IsSending(possibleBubble.Guid))
{
possibleBubblesFromDatabase.Add(possibleBubble);
}
}
}
}
var possibleBubblesInDisa = new List<Tuple<Entry, VisualBubble>>();
foreach (var bubbleGroup in BubbleGroupManager.BubbleGroupsNonUnified)
{
if (bubbleGroup.PartiallyLoaded)
{
continue;
}
foreach (var bubble in bubbleGroup)
{
if (bubble.Status != Bubble.BubbleStatus.Waiting)
continue;
var possibleBubbleFromDatabase = possibleBubblesFromDatabase.FirstOrDefault(x => x.Guid == bubble.ID);
if (possibleBubbleFromDatabase != null)
{
possibleBubblesInDisa.Add(new Tuple<Entry, VisualBubble>(possibleBubbleFromDatabase, bubble));
}
}
}
var sent = new List<Tuple<Entry, bool>>();
var possibleBubblesInDisaByService = possibleBubblesInDisa.GroupBy(x => x.Item1.ServiceName);
Parallel.ForEach(possibleBubblesInDisaByService, possibleBubblesInService =>
{
var failed = false;
foreach (var possibleBubble in possibleBubblesInService)
{
if (failed)
{
sent.Add(new Tuple<Entry, bool>(possibleBubble.Item1, false));
continue;
}
Utils.DebugPrint(">>>>>>>>>>> Sending queued bubble on "
+ possibleBubble.Item2.Service.Information.ServiceName + "!");
var sendBubbleTask = BubbleManager.Send(possibleBubble.Item2, true);
sendBubbleTask.Wait();
if (sendBubbleTask.Result)
{
Utils.DebugPrint(">>>>>>>>> Successfully sent queued bubble on " +
possibleBubble.Item2.Service.Information.ServiceName + "!");
sent.Add(new Tuple<Entry, bool>(possibleBubble.Item1, true));
lock (_dbLock)
{
using (var db = new SqlDatabase<Entry>(Location))
{
db.Remove(possibleBubble.Item1);
}
}
Utils.Delay(100).Wait();
}
else
{
Utils.DebugPrint(">>>>>>>>> Failed to send queued bubble on " +
possibleBubble.Item2.Service.Information.ServiceName + "!");
sent.Add(new Tuple<Entry, bool>(possibleBubble.Item1, false));
failed = true; // fail the entire chain for this service from here on out so messages aren't sent out of order
}
}
});
SanityCheckup();
var receipts = sent.Select(x => new Receipt(x.Item1.Guid, x.Item2)).ToList();
if (!scheduled)
{
if (receipts.FirstOrDefault(x => !x.Success) != null)
{
ScheduleReSend(serviceNames);
//.........这里部分代码省略.........
示例5: Remove
private static void Remove(Entry entry)
{
lock (_dbLock)
{
using (var db = new SqlDatabase<Entry>(Location))
{
db.Remove(entry);
}
}
}
示例6: PurgeNotQueuedBubble
public static Task PurgeNotQueuedBubble(string bubbleId)
{
return Task.Factory.StartNew(() =>
{
lock (_dbLock)
{
using (var db = new SqlDatabase<NotQueuedEntry>(NotQueuedLocation))
{
foreach (var entry in db.Store.Where(x => x.Guid == bubbleId))
{
db.Remove(entry);
}
}
}
});
}
示例7: Remove
private static void Remove(Entry[] entries)
{
lock (_dbLock)
{
using (var db = new SqlDatabase<Entry>(Location))
{
foreach (var entry in entries)
{
db.Remove(entry);
}
}
}
}
示例8: RemoveNotQueued
private static void RemoveNotQueued(VisualBubble bubble)
{
lock (_dbLock)
{
var bubbleId = bubble.ID;
using (var db = new SqlDatabase<NotQueuedEntry>(NotQueuedLocation))
{
// don't add a duplicate group into the queue
foreach (var possibleGroup in db.Store.Where(x => x.Guid == bubbleId))
{
db.Remove(possibleGroup);
}
}
}
}
示例9: Remove
internal static void Remove(string[] groupIds)
{
lock (_dbLock)
{
using (var db = new SqlDatabase<Entry>(Location, false))
{
if (!db.Failed)
{
foreach (var groupId in groupIds)
{
foreach (var item in db.Store.Where(x => !x.Unified && x.Guid == groupId))
{
db.Remove(item);
}
}
}
}
}
}