コード例 #1
0
ファイル: LabelController.cs プロジェクト: tjdurant/Images
        public ActionResult Index()
        {
            ImageHandler ih = new ImageHandler();
            MemoryStream ms = new MemoryStream();

            var query = (from c in _db.OriginalCellData select new { c.ImagePath }).First();

            var imageRelativePath = query.ImagePath;
            var imageOpen = Image.FromFile(imageRelativePath);

            imageOpen.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            var imArray = ms.ToArray();

            string imageBase64Data = Convert.ToBase64String(imArray);
            string imageDataURL = string.Format("data:image/png;base64,{0}", imageBase64Data);
            ViewBag.ImageData = imageDataURL;

            return View();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges <CellToolContext>());

            using (var db = new CellToolContext())
            {
                ImageHandler ih = new ImageHandler();

                // C:\Users\thoma\Documents\00GitHub\00_LOCAL_ONLY\
                Console.Write("Enter path for new Cell Group: ");
                var imagePath = Console.ReadLine();
                Console.Write("Enter Cell Type(rbc or wbc): ");
                var cellType = Console.ReadLine();
                Console.Write("Enter Cell group name: ");
                var groupName = Console.ReadLine();

                string[] fileEntries = Directory.GetFiles(imagePath);

                foreach (string line in fileEntries)
                {
                    var cur = new CellGroup
                    {
                        CellType  = cellType,
                        GroupName = groupName,
                        ImagePath = line
                    };

                    // mapping to ef model and adding to virtual table
                    db.OriginalCellData.Add(cur);
                    db.SaveChanges();
                }
            }

            /*
             * In this article I will explain with an example, how to perform select, insert, edit, update,
             * delete using Entity Framework in ASP.Net using C# and VB.Net.
             * This process is also known as CRUD i.e. Create, Read, Update and Delete in
             * GridView using Entity Framework in ASP.Net.
             * //*/
            //SqlCommand cmd;
            //SqlConnection con;
            //SqlDataAdapter da;

            //con = new SqlConnection(@"Data Source =.\SQLEXPRESS; Initial Catalog = CellData; Integrated Security = True; MultipleActiveResultSets = True");



            //ImageHandler ih = new ImageHandler();


            //// Entity framework here
            //Database.SetInitializer(new CellToolInitializer());



            //string sourceDir = "C:/Users/thoma/Documents/00GitHub/00_LOCAL_ONLY/Symmetric_Rbc_Crop/";
            //// add file name; if in, don't add
            //string[] fileEntries = Directory.GetFiles(sourceDir);

            //console.writeline(sourcedir);
            //foreach (string line in fileentries)
            //{
            //    //console.writeline(line);
            //    byte[] arr;
            //    image img = image.fromfile(line);
            //    arr = imagetobytearray(img);

            //    sqlbulkimport(arr);



            //}
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: tjdurant/Images
        static void Main(string[] args)
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges<CellToolContext>());

            using (var db = new CellToolContext())
            {

                ImageHandler ih = new ImageHandler();

                // C:\Users\thoma\Documents\00GitHub\00_LOCAL_ONLY\
                Console.Write("Enter path for new Cell Group: ");
                var imagePath = Console.ReadLine();
                Console.Write("Enter Cell Type(rbc or wbc): ");
                var cellType = Console.ReadLine();
                Console.Write("Enter Cell group name: ");
                var groupName = Console.ReadLine();

                string[] fileEntries = Directory.GetFiles(imagePath);

                foreach (string line in fileEntries)
                {
                    var cur = new CellGroup
                    {
                        CellType = cellType,
                        GroupName = groupName,
                        ImagePath = line
                    };

                    // mapping to ef model and adding to virtual table
                    db.OriginalCellData.Add(cur);
                    db.SaveChanges();
                }

            }
            /*
            In this article I will explain with an example, how to perform select, insert, edit, update,
            delete using Entity Framework in ASP.Net using C# and VB.Net.
            This process is also known as CRUD i.e. Create, Read, Update and Delete in
            GridView using Entity Framework in ASP.Net.
            //*/
            //SqlCommand cmd;
            //SqlConnection con;
            //SqlDataAdapter da;

            //con = new SqlConnection(@"Data Source =.\SQLEXPRESS; Initial Catalog = CellData; Integrated Security = True; MultipleActiveResultSets = True");

            //ImageHandler ih = new ImageHandler();

            //// Entity framework here
            //Database.SetInitializer(new CellToolInitializer());

            //string sourceDir = "C:/Users/thoma/Documents/00GitHub/00_LOCAL_ONLY/Symmetric_Rbc_Crop/";
            //// add file name; if in, don't add
            //string[] fileEntries = Directory.GetFiles(sourceDir);

            //console.writeline(sourcedir);
            //foreach (string line in fileentries)
            //{
            //    //console.writeline(line);
            //    byte[] arr;
            //    image img = image.fromfile(line);
            //    arr = imagetobytearray(img);

            //    sqlbulkimport(arr);

            //}
        }