Ejemplo n.º 1
0
        public void ReadImageDimensions()
        {
            HalloContext context = new HalloContext();
            List<Image> list = context.Images.ToList();

            foreach (Image i in list) {
                System.Drawing.Image jpgImage = System.Drawing.Image.FromFile(@"c:\Hallo\Hallo\Images\articleImages\images\img" + i.Id + ".jpg");
                i.Width = jpgImage.Width;
                i.Height = jpgImage.Height;
            }

            context.SaveChanges();
        }
Ejemplo n.º 2
0
        // This method loads ArticleCategories from HK-online to a new Hallo-DB
        public void InitArticleCategories(HalloContext context)
        {
            if (context.Categories.Count() > 0) return;

            SqlConnection sourceConnection = GetSourceConnection();
            SqlCommand catCmd = new SqlCommand(
                "SELECT * from HK_ARTICLE_CATEGORIES order BY CategoriID",
                sourceConnection
            );
            SqlDataReader catReader = catCmd.ExecuteReader();
            while (catReader.Read()) {
                context.Categories.Add(new ArticleCategory {
                    Name = catReader["CategoriName"].ToString()
                });
            }
            context.SaveChanges();
            catReader.Close();
            sourceConnection.Close();
        }