示例#1
0
 internal static async Task ClearTeamsTable()
 {
     using (var context = new SyncDbContext())
     {
         await context.Database.ExecuteSqlRawAsync("TRUNCATE TABLE TeamsTable");
     }
 }
示例#2
0
 internal static async Task ClearResourcesAsync()
 {
     using (var context = new SyncDbContext())
     {
         await context.Database.ExecuteSqlRawAsync("TRUNCATE TABLE Resources");
     }
 }
示例#3
0
 public static IList <TeamTable> GetTeams(int limit)
 {
     using (var context = new SyncDbContext())
     {
         return(context.TeamsTable.OrderBy(o => o.CreatedDateTime).Take(limit).ToList());
     }
 }
示例#4
0
 public static async Task UpdatePerformanceAsync(Performance per)
 {
     using (var context = new SyncDbContext())
     {
         context.Performances.Update(per);
         await context.SaveChangesAsync();
     }
 }
示例#5
0
 public static async Task UpdateSourcesAsync(Source source)
 {
     using (var context = new SyncDbContext())
     {
         context.Sources.Add(source);
         await context.SaveChangesAsync();
     }
 }
示例#6
0
 public static async Task AddExceptionsAsync(IList <Exceptions> exceptions)
 {
     using (var context = new SyncDbContext())
     {
         context.Exceptions.AddRange(exceptions);
         await context.SaveChangesAsync();
     }
 }
示例#7
0
 public static async Task UpdateResourcesAsync(IList <Resource> resources)
 {
     using (var context = new SyncDbContext())
     {
         context.Resources.AddRange(resources);
         await context.SaveChangesAsync();
     }
 }
示例#8
0
 public static async Task AddTeamsToTable(IList <TeamTable> teams)
 {
     using (var context = new SyncDbContext())
     {
         context.TeamsTable.AddRange(teams);
         await context.SaveChangesAsync();
     }
 }
示例#9
0
 private static async Task UpdateDbAsync()
 {
     using (var context = new SyncDbContext())
     {
         context.Resources.AddRange(resources);
         await context.SaveChangesAsync();
         resources= resources = new List<Resource>();
     }
 }
示例#10
0
 internal static int GetAverageSync()
 {
     try
     {
         using (var context = new SyncDbContext())
         {
             return((int)context.Resources.ToList().Where(w => w.TimeDif < 50).Average(a => a.TimeDif));
         }
     }
     catch { return(0); }
 }