示例#1
0
 private static void GenerateKeys()
 {
     using (var context = new ProsisDTCContext())
     {
         if (context.BotKeys.FirstOrDefault() == null)
         {
             List <BotKeys> botKeys = new List <BotKeys>();
             for (int i = 0; i < 50; i++)
             {
                 botKeys.Add(new BotKeys {
                     Key          = Guid.NewGuid().ToString("D"),
                     InUse        = false,
                     CreationDate = DateTime.Now,
                 });
             }
             context.BotKeys.AddRange(botKeys);
             context.SaveChanges();
         }
         else
         {
             var keysNotUsed = context.BotKeys.Where(x => x.InUse == false);
             context.BotKeys.RemoveRange(context.BotKeys.Where(x => x.InUse == false));
             context.SaveChanges();
             List <BotKeys> botKeys = new List <BotKeys>();
             for (int i = 0; i < 50; i++)
             {
                 string key = Guid.NewGuid().ToString("D");
                 if (context.BotKeys.Where(x => x.Key == key) == null)
                 {
                     i--;
                     continue;
                 }
                 botKeys.Add(new BotKeys {
                     Key          = Guid.NewGuid().ToString("D"),
                     InUse        = false,
                     CreationDate = DateTime.Now,
                 });
             }
             context.BotKeys.AddRange(botKeys);
             context.SaveChanges();
         }
     }
 }
示例#2
0
 public DtcdatasController(ProsisDTCContext context)
 {
     _context = context;
 }
 public DtcusersController(ProsisDTCContext context)
 {
     _context = context;
 }