Exemplo n.º 1
0
        public ActionResult DataCollection(bool regenerate)
        {
            int count   = 0;
            var summary = new ProcessSummary();
            var time    = Stopwatch.StartNew();

            // scan folders to load the database
            using (var context = new BuildDb())
            {
                // create the database if it doesn't exist
                if (!context.Context.Database.Exists())
                {
                    context.Context.Database.Create();
                }
                else
                {
                    if (regenerate == true)
                    {
                        context.PurgeOldRecords(defaultDirectory);
                    }
                }

                count = context.hashDirectory(defaultDirectory);

                // display the database summary
                summary.NewRecords      = count;
                summary.TotalRecords    = context.Context.Images.Count();
                summary.LastProcessTime = time.Elapsed;
            }

            // todo: switch this to Json and let page handle display
            return(PartialView("_Summary", summary));
        }
Exemplo n.º 2
0
        public JsonResult <List <Image> > DuplicateList()
        {
            var records  = new List <Image>();
            var hashList = new List <string>();

            try
            {
                using (var context = new BuildDb())
                {
                    if (!context.Context.Database.Exists())
                    {
                        //"The database does not yet exist.  Create it and rerun this.";
                        return(null);
                    }

                    var dups = from image in context.Context.Images
                               group image.Hash by image.Hash into grouped
                               where grouped.Count() > 1
                               select grouped;
                    foreach (var duplicate in dups)
                    {
                        hashList.Add(duplicate.Key);
                    }

                    foreach (var hash in hashList)
                    {
                        var duplicateImages = from i in context.Context.Images
                                              where i.Hash == hash
                                              select i;
                        records.AddRange(duplicateImages);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            var json = Json(records);

            return(json);
        }