Exemplo n.º 1
0
 public static void InsertFUTItemProfit(FUTItemProfit item)
 {
     using (var context = new FUTLogsDatabase())
     {
         var dbItem = context.FUTItemProfits.FirstOrDefault(x => x.ItemID == item.ItemID);
         if (dbItem == null)
         {
             context.FUTItemProfits.Add(item);
             context.SaveChanges();
         }
         else
         {
             context.Entry(dbItem).CurrentValues.SetValues(item);
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 2
0
 public static void InsertFUTBotStatistics(FUTBotStatistics log)
 {
     using (var context = new FUTLogsDatabase())
     {
         context.FUTBotStatistics.Add(log);
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public static void ResetFUTBuys()
 {
     using (var context = new FUTLogsDatabase())
     {
         context.FUTBuys.RemoveRange(context.FUTBuys);
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public static void InsertFUTPriceCheck(FUTPriceCheck priceCheck)
 {
     using (var context = new FUTLogsDatabase())
     {
         context.FUTPriceChecks.Add(priceCheck);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public static void InsertFUTExceptionLog(FUTExceptionLog log)
 {
     using (var context = new FUTLogsDatabase())
     {
         context.FUTExceptionLogs.Add(log);
         context.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public static void InsertFUTSell(FUTSell sell)
 {
     using (var context = new FUTLogsDatabase())
     {
         context.FUTSells.Add(sell);
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public static void InsertFUTBuy(FUTBuy buy)
 {
     using (var context = new FUTLogsDatabase())
     {
         context.FUTBuys.Add(buy);
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
        public static void AddFUTNotification(string from, string data)
        {
            var logData = new FUTNotification(from, data);

            using (var context = new FUTLogsDatabase())
            {
                context.FUTNotifications.Add(logData);
                context.SaveChanges();
            }
        }
Exemplo n.º 9
0
 public static void RemoveFUTSell(long id)
 {
     using (var context = new FUTLogsDatabase())
     {
         var entity = context.FUTSells.FirstOrDefault(x => x.ID == id);
         if (entity != null)
         {
             context.FUTSells.Remove(entity);
             context.SaveChanges();
         }
     }
 }
Exemplo n.º 10
0
 public static void UpdateFUTItemProfitByItemID(long itemID, int sellPrice)
 {
     using (var context = new FUTLogsDatabase())
     {
         var dbItem = context.FUTItemProfits.FirstOrDefault(x => x.ItemID == itemID);
         if (dbItem == null)
         {
             return;
         }
         dbItem.SellPrice     = sellPrice;
         dbItem.Profit        = (int)(sellPrice * 0.95) - dbItem.BuyPrice;
         dbItem.SellTimestamp = Helper.CreateTimestamp();
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public static void RemoveFUTNotification(int id)
 {
     lock (_removeFUTNotificationLock)
     {
         using (var context = new FUTLogsDatabase())
         {
             var data = context.FUTNotifications.FirstOrDefault(x => x.ID == id);
             if (data != null)
             {
                 context.FUTNotifications.Remove(data);
                 context.SaveChanges();
             }
         }
     }
 }
Exemplo n.º 12
0
 public static void UpdateCoinsByFUTAccount(FUTAccount account, int coins)
 {
     using (var context = new FUTLogsDatabase())
     {
         var lastSession = context.FUTCoins.FirstOrDefault(x => x.EMail.ToLower() == account.EMail.ToLower());
         if (lastSession != null)
         {
             lastSession.Coins = coins;
         }
         else
         {
             var coinsNew = new FUTCoins
             {
                 EMail = account.EMail,
                 Coins = coins
             };
             context.FUTCoins.Add(coinsNew);
         }
         context.SaveChanges();
     }
 }
Exemplo n.º 13
0
        public static void DeleteOldLogs()
        {
            #region FUTBotLogs
            try
            {
                var twoDays = 172800000;
                var now     = Helper.CreateTimestamp();
                using (var context = new FUTLogsDatabase())
                {
                    var oldLogs = context.FUTBotLogs.OrderByDescending(x => x.ID).Where(x => (now - x.Timestamp) >= twoDays).ToList();
                    if (oldLogs.Any())
                    {
                        context.FUTBotLogs.RemoveRange(oldLogs);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
            }
            #endregion

            #region FUTBotStatistics
            try
            {
                var twoDays = 172800000;
                var now     = Helper.CreateTimestamp();
                using (var context = new FUTLogsDatabase())
                {
                    var oldLogs = context.FUTBotStatistics.OrderByDescending(x => x.ID).Where(x => (now - x.Timestamp) >= twoDays).ToList();
                    if (oldLogs.Any())
                    {
                        context.FUTBotStatistics.RemoveRange(oldLogs);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
            }
            #endregion

            #region FUTBuys
            try
            {
                var twoDays = 345600000;
                var now     = Helper.CreateTimestamp();
                using (var context = new FUTLogsDatabase())
                {
                    var oldLogs = context.FUTBuys.OrderByDescending(x => x.ID).Where(x => (now - x.Timestamp) >= twoDays).ToList();
                    if (oldLogs.Any())
                    {
                        context.FUTBuys.RemoveRange(oldLogs);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
            }
            #endregion

            #region FUTSells
            try
            {
                var twoDays = 172800000;
                var now     = Helper.CreateTimestamp();
                using (var context = new FUTLogsDatabase())
                {
                    var oldLogs = context.FUTSells.OrderByDescending(x => x.ID).Where(x => (now - x.Timestamp) >= twoDays).ToList();
                    if (oldLogs.Any())
                    {
                        context.FUTSells.RemoveRange(oldLogs);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
            }
            #endregion

            #region FUTExceptionLogs
            try
            {
                var twoDays = 172800000;
                var now     = Helper.CreateTimestamp();
                using (var context = new FUTLogsDatabase())
                {
                    var oldLogs = context.FUTExceptionLogs.OrderByDescending(x => x.ID).Where(x => (now - x.Timestamp) >= twoDays).ToList();
                    if (oldLogs.Any())
                    {
                        context.FUTExceptionLogs.RemoveRange(oldLogs);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
            }
            #endregion
        }