Example #1
0
        /// <summary>
        ///     Opens a database connection with the settings specified by the
        ///     <see cref="P:System.Data.Common.DbConnection.ConnectionString" />.
        /// </summary>
        public override void Open()
        {
            EffortConnectionStringBuilder connectionString =
                new EffortConnectionStringBuilder(this.ConnectionString);

            string instanceId = connectionString.InstanceId;

            if (this.lastContainerId == instanceId)
            {
                // The id was not changed, so the appropriate container is associated
                this.ChangeConnectionState(ConnectionState.Open);
                return;
            }

            this.container =
                DbContainerStore.GetDbContainer(instanceId, this.CreateDbContainer);

            this.containerConfiguration = new DbContainerManagerWrapper(this.container);

            this.lastContainerId = instanceId;
            this.ChangeConnectionState(ConnectionState.Open);
        }
Example #2
0
        private static async Task <long> CreateThumbnails(DbContainer container, string outputFolder, FileType typeFilter)
        {
            var sw = new Stopwatch();

            sw.Start();

            int numThreads = 4;

            var photos = photoRep.SelectAll();
            var count  = photos.Count();

            var partial = count / numThreads;

            List <Task <long> > tasks = new List <Task <long> >();

            for (int i = 0; i < numThreads; i++)
            {
                var skip          = i * partial;
                var partialPhotos = photoRep.Select(skip, partial, null, false).ToList();
                var files         = container.FileSet.Select(a => a).ToList();

                var task = new Task <long>(() => ThumbTask(partialPhotos, files, outputFolder, typeFilter, i));
                task.Start();
                tasks.Add(task);
            }

            var mainTask = Task.WhenAll(tasks);

            var results = await mainTask;

            for (int i = 0; i < numThreads; i++)
            {
                Console.WriteLine($"Thread NÂș{results} took {results[i]}ms.");
            }
            sw.Stop();
            return(sw.ElapsedMilliseconds);
        }
Example #3
0
 public YZJ_GradeRepository(DbContainer db) : base(db)
 {
 }
 public async Task UpdateAsync(string id, User user)
 {
     await DbContainer.UpsertItemAsync <User>(user, new PartitionKey(id));
 }
 public async Task AddAsync(User user)
 {
     await DbContainer.CreateItemAsync <User>(user, new PartitionKey(user.Id.ToString()));
 }
Example #6
0
 public YZJ_StatusTypeRepository(DbContainer db) : base(db)
 {
 }
Example #7
0
 public SysRoleRepository(DbContainer db) : base(db)
 {
 }
 public MobilesRep(DbContainer db, IMapper _mapper)
 {
     this.db = db;
     mapper  = _mapper;
 }
Example #9
0
 public YZJ_StdGraduationRecordRepository(DbContainer db) : base(db)
 {
 }
Example #10
0
 public HomeController(DbContainer dbContainer)
 {
     _container = dbContainer;
 }
Example #11
0
 public YZJ_InfoRepository(DbContainer db) : base(db)
 {
 }
 public SysPermissionRepository(DbContainer db) : base(db)
 {
 }
Example #13
0
 public SysUserRepository(DbContainer db) : base(db)
 {
 }
Example #14
0
 public async Task UpdateAsync(string id, Contact Contact)
 {
     await DbContainer.UpsertItemAsync <Contact>(Contact, new PartitionKey(id));
 }
Example #15
0
 public async Task AddAsync(Contact Contact)
 {
     await DbContainer.CreateItemAsync <Contact>(Contact, new PartitionKey(Contact.Id.ToString()));
 }
 public EmployeesController(DbContainer context)
 {
     _context = context;
 }
Example #17
0
 public YZJ_ScoreRepository(DbContainer db) : base(db)
 {
 }
Example #18
0
 public IQueryable <SysException> GetList(DbContainer db)
 {
     return(db.SysException);
 }
Example #19
0
 public IQueryable <SysLog> GetList(DbContainer db)
 {
     return(db.SysLog);
 }
Example #20
0
 public IQueryable<SysSample> GetList(DbContainer db)
 {
     return db.SysSample.AsQueryable();
 }
Example #21
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ActionContext" /> class.
 /// </summary>
 /// <param name="container"> The container. </param>
 public ActionContext(DbContainer container)
 {
     this.container  = container;
     this.parameters = new List <CommandActionParameter>();
 }
Example #22
0
        private static long LoadFiles(DbContainer container, DirectoryInfo origin, bool update, int?parentId = null)
        {
            Console.WriteLine($"Loading Files on folder [{origin.FullName}].");
            var sw = new Stopwatch();

            sw.Start();

            var originFolder = container.FolderSet.FirstOrDefault(f => f.Name == origin.Name && f.ParentId == parentId);

            if (originFolder != null)
            {
                var added   = 0;
                var updated = 0;
                foreach (var folderFile in origin.EnumerateFiles())
                {
                    Console.WriteLine($"[ONGOING] {folderFile.FullName} executionTime: {sw.ElapsedMilliseconds} ");

                    var type = FileTypes.Find(type => type.Name == folderFile.Extension[1..].ToUpper());
                    if (type == null)
                    {
                        continue;
                    }

                    var file = container.FileSet.FirstOrDefault(f => f.Fullpath == folderFile.FullName);
                    if (file == null)
                    {
                        file = GetFile(folderFile, originFolder.Id, type.Id);
                        container.Add(file);
                        container.SaveChanges();
                    }

                    var photo = container.PhotoSet.FirstOrDefault(f => f.FileId == file.Id);
                    if (photo == null)
                    {
                        added++;
                        photo = photos.Load(file.Fullpath);
                        if (photo != null)
                        {
                            if (type.Name != FileTypeEnum.CR2.ToString())
                            {
                                var image = Image.FromFile(file.Fullpath);

                                var thumb = image.Width > 0 && image.Height > 0 ?
                                            image.GetThumbnailImage(image.Width / Constants.ImageProperties.ThumbMultiplier, image.Height / Constants.ImageProperties.ThumbMultiplier, () => false, IntPtr.Zero) :
                                            image.GetThumbnailImage(Constants.ImageProperties.ThumbWidth, Constants.ImageProperties.ThumbHeight, () => false, IntPtr.Zero);

                                photo.Thumbnail = new ImageConverter().ConvertTo(thumb, typeof(byte[])) as byte[];
                                image.Dispose();
                                thumb.Dispose();
                            }
                            photoRep.Add(photo);
                            container.SaveChanges();
                        }
                    }
                    else
                    {
                        var newPhoto = photos.Load(file.Fullpath);
                        photo ??= new Photo();
                        photo.Iso         = newPhoto.Iso;
                        photo.Height      = newPhoto.Height;
                        photo.Width       = newPhoto.Width;
                        photo.FocalLength = newPhoto.FocalLength;
                        photo.FStop       = newPhoto.FStop;
                        photo.DateTaken   = newPhoto.DateTaken;

                        photoRep.Update(photo);
                        container.SaveChanges();
                        updated++;
                    }
                }
                container.SaveChanges();
                Console.WriteLine($"Added: {added}; updated/skipped: {updated}; executionTime: {sw.ElapsedMilliseconds} ");

                var dirs = origin.EnumerateDirectories();
                foreach (var folder in dirs)
                {
                    LoadFiles(container, folder, true, originFolder.Id);
                }
            }

            sw.Stop();
            return(sw.ElapsedMilliseconds);
        }
Example #23
0
 public YZJ_CredentialsTypeRepository(DbContainer db) : base(db)
 {
 }
 public static List <ITable> GetAllTables(
     DbContainer container)
 {
     return((List <ITable>)container.GetAllTables());
 }
        public bool PermanentlyDelete(UserMessage record)
        {
            var userMessage = Container.Table_Message.Remove(Container.Table_Message.Find(record.Id));

            return(DbContainer.SaveChanges() == 1);
        }
 public YZJ_CheckTypeRepository(DbContainer db) : base(db)
 {
 }
Example #27
0
 public async Task DeleteAsync(string id)
 {
     await DbContainer.DeleteItemAsync <User>(id, new PartitionKey(id));
 }
Example #28
0
 public BaseRepository(DbContainer db)
 {
     this.db = db;
 }
Example #29
0
 public YZJ_CheckRecordRepository(DbContainer db) : base(db)
 {
 }
Example #30
0
 public SysLogRepository(DbContainer db) : base(db)
 {
 }