public WorkEventLogTest()
        {
            this.address           = this.addressFactory.Create();
            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.contractRegistry  = new ContractRegistry();
            this.workTracker       = new WorkTracker.WorkTracker(this.addressFactory.Create(), this.contractRegistry,
                                                                 this.permissionManager.Address);
            var perm    = new Permission(typeof(TrackWorkAction));
            var addPerm = new AddPermissionAction(string.Empty, this.workTracker.Address, perm,
                                                  this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.workTracker);

            this.permissionManager.ExecuteAction(addPerm);

            var eventSet = new HashSet <WorkEventArgs>()
            {
                new WorkEventArgs(5, new DateTime(2019, 5, 13), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 14), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 15), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 16), this.address),
            };

            this.eventLog = new WorkEventLog(30, eventSet, this.workTracker);
        }
        private void InitializeEventLogAndGuards()
        {
            var eventSet = new HashSet <WorkEventArgs>()
            {
                new WorkEventArgs(5, new DateTime(2019, 5, 13), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 14), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 15), this.address),
                new WorkEventArgs(5, new DateTime(2019, 5, 16), this.address),
            };

            this.workTracker = new WorkTracker.WorkTracker(this.addressFactory.Create(), this.contractRegistry,
                                                           this.permissionManager.Address);
            this.contractRegistry.RegisterContract(this.workTracker);
            this.ConfigurePermissions();

            this.eventLog = new WorkEventLog(30, eventSet, this.workTracker);
            var addGuard = new AddTrackerGuardAction(string.Empty, this.workTracker.Address,
                                                     new WeeklyTrackerGuard(this.eventLog));

            this.permissionManager.ExecuteAction(addGuard);
            addGuard = new AddTrackerGuardAction(string.Empty, this.workTracker.Address,
                                                 new MonthlyTrackerGuard(this.eventLog));
            this.permissionManager.ExecuteAction(addGuard);
            addGuard = new AddTrackerGuardAction(string.Empty, this.workTracker.Address, new FutureDateTrackerGuard());
            this.permissionManager.ExecuteAction(addGuard);
        }
예제 #3
0
        public WorkEventLog(
            decimal historyClearPeriodInDays,
            HashSet <WorkEventArgs> eventsHistory,
            WorkTracker workTracker)
        {
            this.PeriodDate = DateTime.Now;
            this.HistoryClearPeriodInDays = historyClearPeriodInDays;
            this.EventsHistory            = eventsHistory ?? new HashSet <WorkEventArgs>();

            workTracker.TrackedWork += (_, actionArgs) => this.HandleTrackedWork(actionArgs);
        }
 public WorkTrackerController(
     Address address,
     ContractRegistry registry,
     Address permissionManager,
     WorkEventLog eventLog,
     List <TrackerGuardBase> trackGuards,
     WorkTracker workTracker)
     : base(address, registry, permissionManager)
 {
     this.workTracker =
         workTracker ?? new WorkTracker(null, null, this.Address);
     this.eventLog =
         eventLog ?? new WorkEventLog(30, new HashSet <WorkEventArgs>(), this.workTracker);
 }
예제 #5
0
        public MonthlyTrackerGuardTest()
        {
            this.address = this.addressFactory.Create();
            var eventSet = new HashSet <WorkEventArgs>()
            {
                new WorkEventArgs(40, new DateTime(2019, 5, 13), this.address),
                new WorkEventArgs(40, new DateTime(2019, 5, 14), this.address),
                new WorkEventArgs(40, new DateTime(2019, 5, 15), this.address),
                new WorkEventArgs(40, new DateTime(2019, 5, 16), this.address),
            };

            this.workTracker  = new WorkTracker.WorkTracker(null, null, null);
            this.eventLog     = new WorkEventLog(30, eventSet, this.workTracker);
            this.trackerGuard = new MonthlyTrackerGuard(this.eventLog, 176);
        }
        public WorkTrackerTest()
        {
            this.address           = this.addressFactory.Create();
            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.contractRegistry  = new ContractRegistry();
            this.workTracker       = new WorkTracker.WorkTracker(
                this.addressFactory.Create(),
                this.contractRegistry,
                this.permissionManager.Address);

            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.workTracker);

            this.ConfigurePermissions();
        }
예제 #7
0
 public TaskWorkMediator(WorkTracker.WorkTracker workTracker, TrackWorkHours callback)
 {
     workTracker.TrackedWork += (_, actionArgs) => this.HandleTrackedWork(actionArgs);
     this.trackCallback       = callback;
 }