Ejemplo n.º 1
0
 public AssetTargetSettingsController(Func <string, AssetWeeklySettingsService> weeklySettingsService, ILoggingService loggingService, IAssetSettingsPublisher publisher, IAssetSettingsTypeHandler <AssetSettingsBase> converter)
 {
     _targetHoursTemplate = weeklySettingsService("AssetSettings");
     this._loggingService = loggingService;
     _publisher           = publisher;
     _converter           = converter;
     this._loggingService.CreateLogger(this.GetType());
 }
Ejemplo n.º 2
0
 public AssetSettingsOverlapHandler(IWeeklyAssetSettingsRepository assetSettingsRepo, IAssetSettingsPublisher assetSettingsPublisher, IAssetSettingsTypeHandler <AssetSettingsBase> assetSettingsOverlapHandler, ILoggingService loggingService)
 {
     _assetSettingsRepo      = assetSettingsRepo;
     _assetSettingsPublisher = assetSettingsPublisher;
     _assetOverlapHandler    = assetSettingsOverlapHandler;
     _loggingService         = loggingService;
     _loggingService.CreateLogger(typeof(AssetSettingsOverlapHandler));
 }
Ejemplo n.º 3
0
 public AssetProductivitySettingsController(Func <string, AssetWeeklySettingsService> weeklySettingsService, IAssetSettingsPublisher publisher, IAssetSettingsTypeHandler <AssetSettingsBase> converter, ILoggingService loggingService, IMapper mapper)
 {
     _mapper = mapper;
     _productivityTargetsService = weeklySettingsService("ProductivityTargets");
     _publisher      = publisher;
     _converter      = converter;
     _loggingService = loggingService;
     this._loggingService.CreateLogger(this.GetType());
 }
Ejemplo n.º 4
0
 public AssetSettingsTargets(ITransactions transactions, IWeeklyAssetSettingsRepository targetsRepo, IAssetSettingsTypeHandler <AssetSettingsBase> handler, AssetSettingsOverlapTemplate assetSettingsOverlap, IValidationHelper validationHelper, ILoggingService loggingService, IAssetSettingsPublisher assetSettingsPublisher) : base(transactions, loggingService)
 {
     _weekRepo               = targetsRepo;
     _Converter              = handler;
     _assetSettingsOverlap   = assetSettingsOverlap;
     _validationHelper       = validationHelper;
     _groupType              = Enums.GroupType.AssetTargets;
     _assetSettingsPublisher = assetSettingsPublisher;
     _loggingService         = loggingService;
     _loggingService.CreateLogger(typeof(AssetSettingsTargets));
 }
Ejemplo n.º 5
0
 public AssetSettingsService(IAssetConfigRepository assetSettingsRepository,
                             IAssetConfigTypeRepository assetConfigTypeRepository,
                             IAssetSettingsPublisher assetSettingsPublisher,
                             IEnumerable <IRequestValidator <AssetSettingsRequestBase> > assetSettingsValidators,
                             IEnumerable <IRequestValidator <IServiceRequest> > serviceRequestParametersValidators,
                             IMapper mapper,
                             ITransactions transactions,
                             ILoggingService loggingService) : base(assetSettingsRepository, assetConfigTypeRepository, assetSettingsPublisher, mapper, transactions, loggingService)
 {
     this._assetSettingsValidators            = assetSettingsValidators;
     this._serviceRequestParametersValidators = serviceRequestParametersValidators;
 }
Ejemplo n.º 6
0
 public AssetSettingsServiceBase(IAssetConfigRepository assetSettingsRepository,
                                 IAssetConfigTypeRepository assetConfigTypeRepository,
                                 IAssetSettingsPublisher assetSettingsPublisher,
                                 IMapper mapper,
                                 ITransactions transactions,
                                 ILoggingService loggingService)
 {
     this._assetSettingsRepository   = assetSettingsRepository;
     this._assetConfigTypeRepository = assetConfigTypeRepository;
     this._assetSettingsPublisher    = assetSettingsPublisher;
     this._mapper         = mapper;
     this._transactions   = transactions;
     this._loggingService = loggingService;
     this._loggingService.CreateLogger <AssetSettingsServiceBase>();
 }
Ejemplo n.º 7
0
        public AssetSettingsServiceTests()
        {
            this._customerUid       = Guid.NewGuid();
            this._userUid           = Guid.NewGuid();
            this._assetUIDs         = new List <Guid>();
            this._assetSettingsDtos = new List <AssetSettingsDto>();
            for (int i = 0; i < 10; i++)
            {
                this._assetUIDs.Add(Guid.NewGuid());
            }

            for (int i = 0; i < 10; i++)
            {
                this._assetSettingsDtos.Add(new AssetSettingsDto
                {
                    AssetConfigUID = Guid.NewGuid(),
                    AssetUID       = this._assetUIDs[i],
                    InsertUTC      = DateTime.UtcNow,
                    UpdateUTC      = DateTime.UtcNow,
                    StartDate      = DateTime.Now.Date,
                    TargetType     = AssetTargetType.BucketVolumeinCuMeter.ToString(),
                    TargetValue    = 5500.00
                });
            }
            this._assetConfigTypeDtos = new List <AssetConfigTypeDto>();
            this._assetConfigTypeDtos.AddRange(
                new List <AssetConfigTypeDto> {
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 0,
                    ConfigTypeName    = "IdletimeHours"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 1,
                    ConfigTypeName    = "RuntimeHours"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 2,
                    ConfigTypeName    = "Runtime"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 3,
                    ConfigTypeName    = "OdometerinKmsPerWeek"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 4,
                    ConfigTypeName    = "BucketVolumeinCuMeter"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 5,
                    ConfigTypeName    = "PayloadinTonnes"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 6,
                    ConfigTypeName    = "CycleCount"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 7,
                    ConfigTypeName    = "VolumeinCuMeter"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 8,
                    ConfigTypeName    = "IdlingBurnRateinLiPerHour"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 9,
                    ConfigTypeName    = "WorkingBurnRateinLiPerHour"
                },
                new AssetConfigTypeDto
                {
                    AssetConfigTypeID = 10,
                    ConfigTypeName    = "PayloadPerCycleInTonnes"
                }
            });
            this._stubTransactions = Substitute.For <ITransactions>();
            this._stubAssetSettingsListRepository = Substitute.For <IAssetSettingsListRepository>();
            this._stubAssetSettingsListRepository.FetchValidAssetUIds(Arg.Any <List <string> >(), Arg.Any <AssetSettingsListRequestDto>()).Returns(
                x =>
            {
                var request = (AssetSettingsListRequestDto)x[1];
                if (request.CustomerUid == _customerUid.ToString("N") && request.UserUid == _userUid.ToString("N"))
                {
                    return(_assetUIDs.Where(y => ((List <string>)x[0]).Contains(y.ToString())).Select(z => z.ToString()));
                }
                else
                {
                    return(new List <string>());
                }
            });
            this._stubAssetConfigTypeRepository = Substitute.For <IAssetConfigTypeRepository>();
            this._stubAssetSettingsRepository   = Substitute.For <IAssetConfigRepository>();
            this._stubKafkaPublisher            = Substitute.For <IPublisher>();
            this._stubInjectConfig = Substitute.For <IInjectConfig>();
            this._stubInjectConfig.ResolveKeyed <IPublisher>(Arg.Any <string>()).Returns(this._stubKafkaPublisher);

            this._stubAssetSettingsRepository.FetchAssetConfig(Arg.Any <List <string> >(), Arg.Any <AssetSettingsDto>()).Returns(x => Task.FromResult(_assetSettingsDtos.Where(y => ((List <string>)x[0]).Contains(y.AssetUID.ToString()))));
            this._stubAssetConfigTypeRepository.FetchByConfigTypeNames(Arg.Any <AssetConfigTypeDto>()).Returns(callInfo => Task.FromResult(_assetConfigTypeDtos.Where(x => ((AssetConfigTypeDto)callInfo[0]).ConfigTypeNames.Contains(x.ConfigTypeName))));

            this._stubLoggingService = Substitute.For <ILoggingService>();
            this._stubLoggingService.CreateLogger(this.GetType());

            this._stubCustomerRepository = Substitute.For <ICustomerRepository>();

            this._serviceRequestParametersValidators = new List <IRequestValidator <IServiceRequest> >
            {
                new CustomerUidValidator(this._stubCustomerRepository, this._stubLoggingService),
                new UserUidValidator(this._stubLoggingService)
            };
            this._assetSettingsValidators = new List <IRequestValidator <AssetSettingsRequestBase> >
            {
                new AssetUIDsValidator(this._stubAssetSettingsListRepository, this._stubLoggingService)
            };
            this._stubConfigurations = Options.Create <Configurations>(new Configurations
            {
                KafkaSettings = new KafkaSettings
                {
                    PublisherTopics = new PublisherTopics
                    {
                        AssetWeeklySettingsTopicName     = "VSS.VISIONLINK.INTERFACES.ASSETWEEKLYTARGETS",
                        UserAssetSettingsTopicName       = "VSS.VISIONLINK.INTERFACES.USERASSETTARGETS",
                        AssetSettingsTopicName           = "VSS.VISIONLINK.INTERFACES.ASSETTARGETS",
                        UserAssetWeeklySettingsTopicName = "VSS.VISIONLINK.INTERFACES.USERASSETWEEKLYTARGETS"
                    }
                }
            });
            this._assetSettingsPublisher = new AssetSettingsPublisher(_stubConfigurations, _stubTransactions, _stubLoggingService);
            var mapperConfig = new MapperConfiguration(config =>
            {
                config.CreateMap <AssetSettingsListDto, AssetSettingsDetails>();
                config.CreateMap <AssetSettingsDto, AssetSettingsResponse>();
            });

            //var databaseManager = new DatabaseManager("");
            this._mapper = mapperConfig.CreateMapper();
            this._assetSettingsService = new AssetSettingsService(_stubAssetSettingsRepository, _stubAssetConfigTypeRepository, _assetSettingsPublisher, _assetSettingsValidators, _serviceRequestParametersValidators, _mapper, _stubTransactions, _stubLoggingService);
        }