コード例 #1
0
        /// <inheritdoc />
        protected override void OnFilePackingBegin()
        {
            var tasks  = ZipTasks.ToArray();
            var random = new Random();

            _packagingStartTime     = DateTime.Now;
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine($"building {ZipTasks.Count()} update packages(using parallel building: {Project.UseParallelBuilding.ToString().ToUpper()})...");
            Console.ForegroundColor = ConsoleColor.Yellow;
            _timer = new Timer(_ =>
            {
                var runningTasks = new List <ZipTask>();
                tasks.Where(s => s.State != ZipTaskState.Done && s.State != ZipTaskState.Queue).ForEach(s => runningTasks.Add(s));

                var running   = runningTasks.Count;
                var done      = tasks.Count(s => s.State == ZipTaskState.Done);
                var showIndex = random.Next(running);
                var task      = running == 0 ? null : runningTasks[showIndex];

                var str        = task == null ? $"[{done}/{tasks.Length}] waiting..." : $"[{done}/{tasks.Length}] {running} running -> {task.State.ToString().ToLower()}/{(task.Percentage == -1 ? "" : task.Percentage)}% @ {task.PackageDescription}".GetSubString(Console.WindowWidth - 1, "..");
                var widthCount = str.Sum(s => s > 255 ? 2 : 1);
                if (widthCount < Console.WindowWidth - 1)
                {
                    str = str.PadRight(Console.WindowWidth - 1 - (str.Length - widthCount), ' ');
                }
                Console.Write("\r");
                Console.Write(str);
            },
                               null,
                               0,
                               200);

            base.OnFilePackingBegin();
        }
コード例 #2
0
        /// <inheritdoc />
        protected override void OnFilePackingBegin()
        {
            var tasks  = ZipTasks.ToArray();
            var random = new Random();

            _timer = new Timer(_ =>
            {
                var runningTasks = new List <ZipTask>();
                tasks.Where(s => s.State != ZipTaskState.Done && s.State != ZipTaskState.Queue).ForEach(s => runningTasks.Add(s));

                var running   = runningTasks.Count;
                var done      = tasks.Count(s => s.State == ZipTaskState.Done);
                var showIndex = random.Next(running);
                var task      = running == 0 ? null : runningTasks[showIndex];

                var str        = task == null ? $"[parallel:{Project.UseParallelBuilding}/{done}/{tasks.Length}] waiting..." : $"[{done}/{tasks.Length}] {running} running -> {task.State.ToString().ToLower()}/{(task.Percentage == -1 ? "" : task.Percentage)}% @ {task.PackageDescription}";
                var totalCount = tasks.Length * 100;
                var percentage = done * 100 + runningTasks.Sum(x => x.Percentage);

                _form.SetProgress(false, (int)Math.Round(percentage * 1.0 / totalCount * 100), str);
            },
                               null,
                               0,
                               200);

            base.OnFilePackingBegin();
        }
コード例 #3
0
 /// <inheritdoc />
 protected override void OnFilePackingEnd()
 {
     _timer.Change(-1, -1);
     Console.Write("\r");
     Console.ForegroundColor = ConsoleColor.Magenta;
     Console.WriteLine($"{ZipTasks.Count()} packages built in {(DateTime.Now - _packagingStartTime).TotalSeconds:F3} seconds.".PadRight(Console.WindowWidth - 1, ' '));
     base.OnFilePackingEnd();
 }