Пример #1
0
        public void Execute(PerformContext context)
        {
            /*
             *   1. 顯示訊息
             *   2. 檢查目標是否存在
             *   3. 執行動作
             */
            // Arrange
            context.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} CalcSpaceJob 開始執行 ...");
            _action = context.GetJobData <CaleSpaceActoinType>("Type");
            context.WriteLine($"執行類別為:{_action}");
            _calc = GetCale(_action);
            // 取得目標位置
            var target = _calc.GetTarget(context);

            context.WriteLine($"目標位置:{target}");

            //Checking
            if (!_calc.TargetExists(target))
            {
                context.SetTextColor(ConsoleTextColor.Red);
                context.WriteLine($"目標位置不存在,位置為:{target}");
                context.ResetTextColor();
            }
            // Act
            context.WriteLine($"計算目標{target}");
            var searchPattern = context.GetJobData <string>("searchPattern");

            context.WriteLine($"搜尋模式字串:{searchPattern}");
            var result = _calc.Calculate(target, searchPattern);

            context.WriteLine("目標大小為:{0}", result);
            //  WriteTo("41DCF8A5ACB74AA38DD3DB8CB1EE5462", DateTime.Now, result);
        }
Пример #2
0
        private ICalcSpace GetCale(CaleSpaceActoinType actionType)
        {
            switch (actionType)
            {
            case CaleSpaceActoinType.Drive:
                return(new CaleDriveSpace());

            case CaleSpaceActoinType.Folder:
                return(new CaleFolderSpace());

            case CaleSpaceActoinType.Files:
                return(new CaleFileSpace());

            default:
                return(new CaleFolderSpace());
            }
        }