예제 #1
0
        private void OptmizeAsynch(Item rootItem, bool thisFolderOnly, bool force, OptimizeImageManagerStatus status)
        {
            MediaItem mi = rootItem;

            if ((mi.MimeType == "image/jpg") || (mi.MimeType == "image/jpeg") || (mi.MimeType == "image/png"))
            {
                if (force || rootItem["Image Optimizer Allready Optimized"] != "1")
                {
                    _shell.Optimize(mi);
                    status.AlreadyOptimized++;
                }
                else
                {
                    status.Skipped++;
                }
            }

            if (!thisFolderOnly)
            {
                foreach (Item child in rootItem.Children)
                {
                    this.OptmizeAsynch(child, thisFolderOnly, force, status);
                }
            }
        }
예제 #2
0
        public Guid Optimize(Database db, string rootItemID, bool thisFolderOnly, bool force)
        {
            ID   rootId   = ID.Parse(rootItemID);
            Item rootItem = db.GetItem(rootId);

            OptimizeImageManagerStatus status = new OptimizeImageManagerStatus();

            status.Status = OptimizeImageManagerStatusEnum.Initializing;

            Guid processGuid = Guid.NewGuid();

            processes.Add(processGuid, status);

            //This part of the method is executed in background
            Task.Factory.StartNew(() => InitOptmizeAsynch(rootItem, thisFolderOnly, force, status));

            return(processGuid);
        }
예제 #3
0
        private void InitOptmizeAsynch(Item rootItem, bool thisFolderOnly, bool force, OptimizeImageManagerStatus status)
        {
            status.Status = OptimizeImageManagerStatusEnum.Running;

            foreach (Item child in rootItem.Children)
            {
                OptmizeAsynch(child, thisFolderOnly, force, status);
            }

            status.Status = OptimizeImageManagerStatusEnum.Finished;
        }
예제 #4
0
 public OptimizeImageManager()
 {
     _shell  = new ImageOptimizerShell();
     _status = new OptimizeImageManagerStatus();
 }