Exemplo n.º 1
0
        public static void BatchInsert(TagViewModel tag, IEnumerable <ImageViewModel> images)
        {
            if (images == null || images.Count() == 0)
            {
                s_logger.Warn("No images set.");
                return;
            }

            using (var dataOpUnit = new DataOperationUnit())
            {
                dataOpUnit.Open(ConnectionManager.DefaultConnection);

                ImageTagDao dao = new ImageTagDao();
                Queue <List <ImageViewModel> > processPool = Split(images);

                foreach (var process in processPool)
                {
                    try
                    {
                        dao.BatchInsert(tag.ToEntity(), process.Select(i => i.ToEntity()), dataOpUnit.CurrentConnection);
                    }
                    catch (Exception e)
                    {
                        s_logger.Error(e);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void CopyImageTag(ILibrary libManager, BookViewModel book)
        {
            IDConversionDao idcDao = new IDConversionDao();
            ImageTagDao     itDao  = new ImageTagDao();

            var imageTags = itDao.FindByBookId(s_ANOTHER_DATABASE_ALIAS_NAME, book.ID, _dataOpUnit.CurrentConnection).ToList().ToViewModel();

            foreach (var imageTag in imageTags)
            {
                var byImageId = idcDao.FindBy(new Dictionary <string, object>()
                {
                    { "TableName", "Image" }, { "ForeignID", imageTag.ImageID }
                }, _dataOpUnit.CurrentConnection);
                var byTagId = idcDao.FindBy(new Dictionary <string, object>()
                {
                    { "TableName", "Tag" }, { "ForeignID", imageTag.ImageID }
                }, _dataOpUnit.CurrentConnection);
                if (byImageId.Count() == 1)
                {
                    imageTag.ImageID = byImageId.Single().DomesticID;
                }
                if (byTagId.Count() == 1)
                {
                    imageTag.TagID = byTagId.Single().DomesticID;
                }
                itDao.Insert(imageTag.ToEntity(), _dataOpUnit.CurrentConnection);

                libManager.TagManager.Chains.Add(imageTag);
            }

            libManager.TagManager.ObserveTagCount();
        }
Exemplo n.º 3
0
        public static void Insert(ImageTagViewModel target)
        {
            ImageTagDao dao = new ImageTagDao();

            dao.Insert(target.ToEntity());
            s_logger.Debug($"INSERT ImageTag:{target}");
        }
        public override void DropTable(IConnection connection)
        {
            ImageTagDao dao = new ImageTagDao(typeof(VersionOrigin));

            dao.CurrentConnection = connection;
            dao.DropTable();
            ++ModifiedCount;
        }
Exemplo n.º 5
0
        public static int CountByTagId(Guid tagId)
        {
            ImageTagDao dao = new ImageTagDao();

            return(dao.CountBy(new Dictionary <string, object>()
            {
                { "TagID", tagId }
            }));
        }
Exemplo n.º 6
0
        public static IEnumerable <ImageTagViewModel> FindByImageIds(IEnumerable <Guid> imageIds)
        {
            ImageTagDao dao = new ImageTagDao();

            return(dao.FindBy(new Dictionary <string, object>()
            {
                { "ImageID", imageIds.ToArray() }
            }).ToViewModel());
        }
Exemplo n.º 7
0
        public static void DeleteWhereIDIs(Guid imageId, Guid tagId)
        {
            ImageTagDao dao = new ImageTagDao();

            dao.Delete(new Dictionary <string, object>()
            {
                { "ImageID", imageId }, { "TagID", tagId }
            });
            s_logger.Debug($"DELETE ImageTag ImageId:{imageId}, TagId:{tagId}");
        }
        public override void CreateTable(IConnection connection)
        {
            ImageTagDao dao = new ImageTagDao(typeof(VersionOrigin));

            dao.CurrentConnection = connection;
            dao.CreateTableIfNotExists();
            ++ModifiedCount;
            dao.CreateIndexIfNotExists();
            ++ModifiedCount;
        }
Exemplo n.º 9
0
        internal static void DeleteByTagName(string tagName)
        {
            ImageTagDao dao = new ImageTagDao();

            dao.DeleteByTagName(tagName);
        }
Exemplo n.º 10
0
        public static long CountAll()
        {
            var dao = new ImageTagDao();

            return(dao.CountAll());
        }
Exemplo n.º 11
0
        public static IEnumerable <TagCountViewModel> FindAllAsCount()
        {
            ImageTagDao dao = new ImageTagDao();

            return(dao.FindAllAsTagCount().ToViewModel());
        }
Exemplo n.º 12
0
        public static IEnumerable <ImageTagViewModel> FindByTagId(Guid tagId)
        {
            ImageTagDao dao = new ImageTagDao();

            return(dao.FindByTagId(tagId).ToViewModel());
        }
Exemplo n.º 13
0
        public static IEnumerable <ImageTagViewModel> FindAll()
        {
            ImageTagDao dao = new ImageTagDao();

            return(dao.FindAll().ToViewModel());
        }