Ejemplo n.º 1
0
        public bool LoadXml(string aXmlPath)
        {
            if (!File.Exists(aXmlPath))
            {
                MController.Status(this, "config xml not found:{0}", aXmlPath);
                return(false);
            }

            _listItems = ImageItem.Load(aXmlPath);

            if (_listItems == null)
            {
                MController.Status(this, "config xml Loading failed:{0}", aXmlPath);
                return(false);
            }

            foreach (var item in _listItems)
            {
                item.IsExist = File.Exists(Path.Combine(ImageItem.Dir, item.FileName));
                item.Erase   = item.Use;
                Log.v("Partition ID={0} Name={1}, FileName={2}, Use={3}", item.Id, item.Name,
                      item.Use ? item.FileName : "(not exist!)", item.Use);
            }

            this.ConfigPath = aXmlPath;


            return(true);
        }
Ejemplo n.º 2
0
        private void Tif_AppProgressEvent(ProgressArgs arg)
        {
            int idx = _listItems.FindIndex(x => x.Id == arg.ImageID && (int)x.Protocol == arg.ExtraInfo);

            if (idx >= 0 && arg.TotalBytes > 0) // 유효한 파일 다운로드 중..
            {
                var item     = _listItems[idx];
                int progress = (int)(arg.SentBytes * 100 / arg.TotalBytes);

                if (item.Progress == progress)
                {
                    return;
                }

                item.Progress = progress;

                int count = 0;
                int total = 0;
                foreach (var m in _listItems)
                {
                    if (m.Use)
                    {
                        total += m.Progress;
                        count++;
                    }
                }

                this.FileProgress  = progress;
                this.TotalProgress = count > 0 ? total / count : 0;
                if (_lastName != item.Name)
                {
                    _lastName = item.Name;
                    MController.Status(this, "{0}/{1}", item.Name, item.FileName);
                }
            }
            else if (arg.ExtraInfo == (int)QProtocol.All)
            {
                this.TotalProgress = 100;

                Print(LogLevels.Info, "====== Downloaded Images  ======");
                foreach (var m in _listItems)
                {
                    if (m.Use)
                    {
                        Print(LogLevels.Info, "Name:{0} File:{1}", m.Name, m.FileName);
                    }
                }
                _lastName = "";
            }
        }
Ejemplo n.º 3
0
        public bool PrepareTargetWrapper(string aDllPath)
        {
            if (_tif != null)
            {
                _tif.Dispose();
                _tif = null;
            }

            _tif = new TargetWrapper();
            if (!_tif.Load(aDllPath))
            {
                MController.Status(this, "Load Protocol library failed :{0}", aDllPath);
                return(false);
            }

            _tif.AppLogEvent += _tif_AppLogEvent;

            return(true);
        }