예제 #1
0
        public void addToRepositoryFromFile(string fileName)
        {
            ExelData exelData = new ExelData(fileName);

            exelData.setDataToCollection(context.Visitors);
            context.SaveChanges();
            foreach (var v in context.Visitors)
            {
                visitorCollection.Add(v);
            }
        }
예제 #2
0
        public void initRepositoryFromFile(string fileName)
        {
            ExelData exelData = new ExelData(fileName, progressChanged);

            progress.Status   = "Delete old visitors";
            progress.Progress = 0;
            using (var ctx = new ExContext())
            {
                int count      = 1;
                var collection = ctx.Visitors.ToList();
                var size       = collection.Count() + 1;
                foreach (var u in collection)
                {
                    progress.Progress = (int)(count * 100 / size);
                    progressChanged(progress);
                    ctx.Visitors.Remove(u);
                    count++;
                }
                ctx.SaveChanges();
            }
            exelData.setDataToCollection(context.Visitors, progressChanged);
            context.SaveChanges();
            progress.Status   = "Add new data to collection";
            progress.Progress = 0;
            int c   = 1;
            var col = context.Visitors;
            var s   = col.Count() + 1;

            foreach (var v in col)
            {
                progress.Progress = (int)(c * 100 / s);
                progressChanged(progress);
                visitorCollection.Add(v);
                c++;
            }
        }