Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 4
0
 public OptimizeImageManager()
 {
     _shell  = new ImageOptimizerShell();
     _status = new OptimizeImageManagerStatus();
 }