public void Dispose()
 {
     TestApplicationDbContext.Dispose();
     TestMainContext.Dispose();
     Client.Dispose();
     Server.Dispose();
 }
Ejemplo n.º 2
0
 private void InsertPriceInDB(List <Data> prices)
 {
     System.Threading.Thread.Sleep(10000);
     using (MainContext db = new MainContext(new DbContextOptionsBuilder <MainContext>().UseMySql(
                                                 ConfigurationManager.AppSetting.GetConnectionString("DefaultConnection")
                                                 ).Options))
     {
         var query = (from Print in db.Print
                      join p in prices on Print.Id equals p.Id
                      where Print.Card.Id == p.Oracle_id
                      select new Print
         {
             Id = Print.Id,
             price = p.Eur != null ? (int)(decimal.Parse(p.Eur)) : 0,
             foil = Print.foil,
             nonfoil = Print.nonfoil,
             oversized = Print.oversized,
             borderColor = Print.borderColor,
             collectorsNumber = Print.collectorsNumber,
             fullArt = Print.fullArt
         });
         db.UpdateRange(query);
         db.SaveChanges();
         db.Dispose();
     }
 }
        public Cryptocurrency[] Parse(IHtmlDocument document)
        {
            var list = new List <Cryptocurrency>();

            var Ranks               = document.QuerySelectorAll("td").Where(m => m.ClassName != null && m.ClassName.Contains("text-center"));
            var Names               = document.QuerySelectorAll("a").Where(m => m.ClassName != null && m.ClassName.Contains("currency-name-container"));
            var Symbols             = document.QuerySelectorAll("td").Where(m => m.ClassName != null && m.ClassName.Contains("text-left col-symbol"));
            var MarketCaps          = document.QuerySelectorAll("td").Where(m => m.ClassName != null && m.ClassName.Contains("no-wrap market-cap text-right"));
            var PricesUSD           = document.QuerySelectorAll("a").Where(m => m.ClassName != null && m.ClassName.Contains("price"));
            var DailyVolumes        = document.QuerySelectorAll("a").Where(m => m.ClassName != null && m.ClassName.Contains("volume"));
            var CirculatingSupplies = document.QuerySelectorAll("span").Where(m => m.GetAttribute("data-supply") != null);

            for (int i = 0; i < Ranks.Count(); i++)
            {
                list.Add(new Cryptocurrency
                {
                    Rank              = Int32.Parse(Ranks.ElementAt(i).TextContent),
                    Name              = Names.ElementAt(i).TextContent,
                    Symbol            = Symbols.ElementAt(i).TextContent,
                    MarketCap         = GetElements(MarketCaps, i),
                    PriceUSD          = GetElements(PricesUSD, i),
                    DailyVolume       = GetElements(DailyVolumes, i),
                    CirculatingSupply = GetElements(CirculatingSupplies, i),
                    TimeStamp         = DateTime.Now
                });
            }

            MainContext db = new MainContext();

            db.Cryptocurrencies.AddRange(list);
            db.SaveChanges();
            db.Dispose();

            return(list.ToArray());
        }
        public void WeeklyAverages()
        {
            MainContext           dbCrypto = new MainContext();
            List <Cryptocurrency> cryptos  = (from u in dbCrypto.Cryptocurrencies select u).ToList();
            var      list     = new List <WeeklyAverage>();
            DateTime BackTime = DateTime.Now.AddDays(-5);

            var avgs = from t in cryptos
                       where t.TimeStamp >= BackTime
                       orderby t.MarketCap descending
                       group t by t.Name into g
                       select new
            {
                Name = g.Key,
                WeeklyAvgMarketCap   = g.Average(n => n.MarketCap),
                WeeklyAvgPriceUSD    = g.Average(n => n.PriceUSD),
                WeeklyAvgDailyVolume = g.Average(n => n.DailyVolume)
            };

            foreach (var item in avgs)
            {
                list.Add(new WeeklyAverage
                {
                    Name = item.Name,
                    WeeklyAvgMarketCap   = item.WeeklyAvgMarketCap,
                    WeeklyAvgPriceUSD    = item.WeeklyAvgPriceUSD,
                    WeeklyAvgDailyVolume = item.WeeklyAvgDailyVolume,
                    TimeStamp            = DateTime.Now
                });
            }

            dbCrypto.WeeklyAverages.AddRange(list);
            dbCrypto.SaveChanges();
            dbCrypto.Dispose();
        }
Ejemplo n.º 5
0
 protected override void DisposeCore()
 {
     if (dataContext != null)
     {
         dataContext.Dispose();
     }
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _db.Dispose();
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 7
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         goodsGroupRepository.Dispose();
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 8
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         GC.SuppressFinalize(this);
         _db.Dispose();
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 9
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         unitRepository.Dispose();
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 10
0
 public virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
     this.disposed = true;
 }
Ejemplo n.º 11
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
     _disposed = true;
 }
Ejemplo n.º 12
0
 public virtual void Dispose(bool disposing)
 {
     if (!_Disposed)
     {
         if (disposing)
         {
             _Context.Dispose();
         }
         _Disposed = true;
     }
 }
Ejemplo n.º 13
0
        public static void ShowErrorMsg(string msg, MainContext mainContext)
        {
            ErrorMessage errorMessage = new ErrorMessage();

            errorMessage.Message.Text = msg;
            errorMessage.ShowDialog();
            errorMessage.Closed += ErrorMessage_Closed;
            void ErrorMessage_Closed(object sender, EventArgs e)
            {
                mainContext.Dispose();
            }
        }
Ejemplo n.º 14
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposed)
     {
         return;
     }
     if (disposing)
     {
         // Free any other managed objects here.
         _dbContext.Dispose();
     }
     disposed = true;
 }
Ejemplo n.º 15
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                _context.Dispose();
            }

            disposed = true;
        }
Ejemplo n.º 16
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    db.Dispose();
                }

                LstAdd    = null;
                LstDelete = null;

                disposedValue = true;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 清除临时属性
        /// 一般用于插件执行完毕后执行
        /// </summary>
        private void ClearCache()
        {
            MD5AccountPath        = string.Empty;
            WeChatAccount         = null;
            WeChatAccountShowName = string.Empty;

            MainContext?.Dispose();
            MainContext = null;

            FtsContext?.Dispose();
            FtsContext = null;

            LsAllFriends?.Clear();
            LsAllFriends = null;

            LsAllGroupFriends?.Clear();
            LsAllGroupFriends = null;
        }
Ejemplo n.º 18
0
        public void Should_Get_Log_Properties_After_Creation()
        {
            var fakeContext = new FakeContext("LogGetter");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions))
            {
                var logbuilder = new LogBuilder(context);
                var repository = new LogRepository(context);
                var validator  = new LogValidator();
                var service    = new LogService(repository, validator, context);

                var logTest = new Log();
                logTest.Name          = "Error testing";
                logTest.Description   = "Testing log getter and setters";
                logTest.UserId        = 1;
                logTest.LevelId       = 2;
                logTest.LayerId       = 2;
                logTest.EnvironmentId = 2;
                logTest.StatusId      = 1;
                logTest.CreatedAt     = new DateTime(2020, 05, 21, 14, 35, 01);
                service.Create(logTest);

                var createdLog = (from l in service.GetAllFull()
                                  where l.Name == "Error testing"
                                  select l).FirstOrDefault();

                Assert.Equal("Error testing", createdLog.Name);
                Assert.Equal("Testing log getter and setters", createdLog.Description);
                Assert.Equal(1, createdLog.UserId);
                Assert.Equal(2, createdLog.LevelId);
                Assert.Equal(2, createdLog.LayerId);
                Assert.Equal(2, createdLog.EnvironmentId);
                Assert.Equal(1, createdLog.StatusId);
                Assert.Equal(new DateTime(2020, 05, 21, 14, 35, 01), createdLog.CreatedAt);
                Assert.Equal("José da Silva", createdLog.User.FullName);
                Assert.Equal("Warning", createdLog.Level.Name);
                Assert.Equal("Frontend", createdLog.Layer.Name);
                Assert.Equal("Homologação", createdLog.Environment.Name);
                Assert.Equal("Arquivado", createdLog.Status.Name);
                context.Dispose();
            }
        }
Ejemplo n.º 19
0
        public void Should_Get_Log_Info_Right(int id)
        {
            var fakeContext = new FakeContext("LogInfo");

            fakeContext.FillWith <Log>();

            using (var context = new MainContext(fakeContext.FakeOptions))
            {
                var logbuilder = new LogBuilder(context);
                var repository = new LogRepository(context);
                var validator  = new LogValidator();
                var service    = new LogService(repository, validator, context);
                var logTest    = service.GetById(id);

                Assert.NotEqual(0, logTest.UserId);
                Assert.NotNull(logbuilder.GetPayload(logTest));
                Assert.NotEqual(0, logTest.EnvironmentId);
                Assert.NotEqual(0, logTest.LayerId);
                Assert.NotEqual(0, logTest.LevelId);
                Assert.NotEqual(0, logTest.StatusId);
                context.Dispose();
            }
        }
Ejemplo n.º 20
0
 public void Dispose()
 {
     ctx.Dispose();
 }
 public void Dispose()
 {
     TestMainContext.Dispose();
     Client.Dispose();
     Server.Dispose();
 }
Ejemplo n.º 22
0
 public void Dispose()
 {
     Db.Dispose();
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 23
0
 public void Dispose()
 {
     dbContext.Dispose();
 }
Ejemplo n.º 24
0
 public void Dispose()
 {
     _context.Dispose();
 }
 public void Rollback()
 {
     _transaction.Rollback();
     _transaction.Dispose();
     MainContext.Dispose();
 }
Ejemplo n.º 26
0
 //this is needed for the cleanup
 protected override void Dispose(bool disposing)
 {
     _context.Dispose();
 }
Ejemplo n.º 27
0
 public void Dispose()
 {
     _context.Dispose();
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 28
0
 public void Dispose()
 {
     Db.Dispose();
 }