Exemplo n.º 1
0
 private static void ResetCache()
 {
     TriggerService.UpdateCronObjects();
     AppServices.ResetCache();
     AppServices.MainDataContext.SelectedDepartment.PublishEvent(EventTopicNames.SelectedDepartmentChanged);
     CommandManager.InvalidateRequerySuggested();
 }
Exemplo n.º 2
0
        private void Initialize(string url)
        {
            _serializerSettings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Converters        = new JsonConverter[]
                {
                    new Newtonsoft.Json.Converters.JavaScriptDateTimeConverter(),
                    new MaintenanceJsonConverter()
                }
            };

            Check.IsNotNullOrWhiteSpace(url, "ZabbixApi.url");

            _url        = url;
            _webClient  = new WebClient();
            _httpClient = new HttpClient();

            Actions            = new ActionService(this);
            Alerts             = new AlertService(this);
            ApiInfo            = new ApiInfoService(this);
            Applications       = new ApplicationService(this);
            Correlations       = new CorrelationService(this);
            DiscoveredHosts    = new DiscoveredHostService(this);
            DiscoveredServices = new DiscoveredServiceService(this);
            DiscoveryChecks    = new DiscoveryCheckService(this);
            DiscoveryRules     = new DiscoveryRuleService(this);
            Events             = new EventService(this);
            GraphItems         = new GraphItemService(this);
            GraphPrototypes    = new GraphPrototypeService(this);
            Graphs             = new GraphService(this);
            History            = new HistoryService(this);
            HostGroups         = new HostGroupService(this);
            HostInterfaces     = new HostInterfaceService(this);
            HostPrototypes     = new HostPrototypeService(this);
            Hosts               = new HostService(this);
            IconMaps            = new IconMapService(this);
            ServiceService      = new ServiceService(this);
            Images              = new ImageService(this);
            ItemPrototypes      = new ItemPrototypeService(this);
            Items               = new ItemService(this);
            LLDRules            = new LLDRuleService(this);
            Maintenance         = new MaintenanceService(this);
            Maps                = new MapService(this);
            MediaTypes          = new MediaTypeService(this);
            Proxies             = new ProxyService(this);
            ScreenItems         = new ScreenItemService(this);
            Screens             = new ScreenService(this);
            Scripts             = new ScriptService(this);
            TemplateScreenItems = new TemplateScreenItemService(this);
            TemplateScreens     = new TemplateScreenService(this);
            Templates           = new TemplateService(this);
            TriggerPrototypes   = new TriggerPrototypeService(this);
            Triggers            = new TriggerService(this);
            UserGroups          = new UserGroupService(this);
            GlobalMacros        = new GlobalMacroService(this);
            HostMacros          = new HostMacroService(this);
            Users               = new UserService(this);
            ValueMaps           = new ValueMapService(this);
        }
 public JobManagementService(TriggerService triggerService, JobService jobService, JobRunService jobRunService, IMapper mapper)
 {
     this.triggerService = triggerService;
     this.jobService     = jobService;
     this.jobRunService  = jobRunService;
     this.mapper         = mapper;
 }
        public async Task ProcessAllMessagesInQueue_TriggersDelivery()
        {
            // Setup
            Mock.Get(eventQueueStore)
            .SetupSequence(s => s.PeekEventAsync())
            .ReturnsAsync(new ServerEventMessage {
            })
            .ReturnsAsync(null);

            var  triggerService = new TriggerService();
            bool DeliverySet    = false;
            var  cts            = new CancellationTokenSource();
            var  waitingTask    = Task.Factory.StartNew(() =>
            {
                triggerService.DeliveryStart.WaitOne();
                DeliverySet = true;
            }, cts.Token);

            // Test
            var options = Options.Create(new EventServerOptions());
            var service = new HostedProcessingService(new TriggerService(), serviceProvider, logger, options);
            await service.ProcessAllMessagesInQueue();

            // Assert
            Mock.Get(eventQueueStore).Verify();
            Assert.IsTrue(DeliverySet, "DeliveryStart was not set");

            Mock.Get(objectUpdateService).VerifyNoOtherCalls();
            Mock.Get(metadataService).VerifyNoOtherCalls();
            Mock.Get(eventProcessingService).VerifyNoOtherCalls();
            cts.Cancel();
        }
Exemplo n.º 5
0
 public LookupController(ILogger <LookupController> logger,
                         ServiceFacade.Controller context,
                         TriggerService triggerService) : base(context)
 {
     _logger         = Require.IsNotNull(logger, nameof(logger));
     _triggerService = Require.IsNotNull(triggerService, nameof(triggerService));
 }
        public void ServiceMustGet()
        {
            var service = new TriggerService(this.context);
            var result  = service.Get();

            Assert.NotNull(result);
        }
Exemplo n.º 7
0
        public ActionResult Trigger(string url, int viewid, TriggerInfo triggerInfo)
        {
            TriggerService trgSvr = new TriggerService();

            trgSvr.Handler(url, viewid, triggerInfo);
            return(Json(new ResultModel()));
        }
Exemplo n.º 8
0
 protected override void OnExit(ExitEventArgs e)
 {
     if (MessagingClient.IsConnected)
     {
         MessagingClient.Disconnect();
     }
     TriggerService.CloseTriggers();
 }
Exemplo n.º 9
0
        public void Current_WithSingleSession_ReturnsSession()
        {
            var subject   = new TriggerService(new TriggerDiscoveryServiceStub(), new NoRecursionStrategy(), new LoggerFactory(), new OptionsSnapshotStub <TriggerOptions>());
            var dbContext = new TestDbContext();

            var triggerSession = subject.CreateSession(dbContext, null);

            Assert.Equal(subject.Current, triggerSession);
        }
Exemplo n.º 10
0
 public LookupController(ILogger <LookupController> logger,
                         ServiceFacade.Controller context,
                         ChallengeService challengeService,
                         TriggerService triggerService) : base(context)
 {
     _logger           = logger ?? throw new ArgumentNullException(nameof(logger));
     _challengeService = challengeService
                         ?? throw new ArgumentNullException(nameof(challengeService));
     _triggerService = triggerService
                       ?? throw new ArgumentNullException(nameof(triggerService));
 }
Exemplo n.º 11
0
        private void Initialize(string url)
        {
            Check.IsNotNullOrWhiteSpace(url, "ZabbixApi.url");

            _url        = url;
            _webClient  = new WebClient();
            _httpClient = new HttpClient();

            Actions            = new ActionService(this);
            Alerts             = new AlertService(this);
            ApiInfo            = new ApiInfoService(this);
            Applications       = new ApplicationService(this);
            DiscoveredHosts    = new DiscoveredHostService(this);
            DiscoveredServices = new DiscoveredServiceService(this);
            DiscoveryChecks    = new DiscoveryCheckService(this);
            DiscoveryRules     = new DiscoveryRuleService(this);
            Events             = new EventService(this);
            GraphItems         = new GraphItemService(this);
            GraphPrototypes    = new GraphPrototypeService(this);
            Graphs             = new GraphService(this);
            History            = new HistoryService(this);
            HostGroups         = new HostGroupService(this);
            HostInterfaces     = new HostInterfaceService(this);
            HostPrototypes     = new HostPrototypeService(this);
            Hosts               = new HostService(this);
            IconMaps            = new IconMapService(this);
            ITServiceService    = new ITServiceService(this);
            Images              = new ImageService(this);
            ItemPrototypes      = new ItemPrototypeService(this);
            Items               = new ItemService(this);
            LLDRules            = new LLDRuleService(this);
            Maintenance         = new MaintenanceService(this);
            Maps                = new MapService(this);
            Medias              = new MediaService(this);
            MediaTypes          = new MediaTypeService(this);
            Proxies             = new ProxyService(this);
            ScreenItems         = new ScreenItemService(this);
            Screens             = new ScreenService(this);
            Scripts             = new ScriptService(this);
            TemplateScreenItems = new TemplateScreenItemService(this);
            TemplateScreens     = new TemplateScreenService(this);
            Templates           = new TemplateService(this);
            TriggerPrototypes   = new TriggerPrototypeService(this);
            Triggers            = new TriggerService(this);
            UserGroups          = new UserGroupService(this);
            GlobalMacros        = new GlobalMacroService(this);
            HostMacros          = new HostMacroService(this);
            Users               = new UserService(this);
        }
Exemplo n.º 12
0
 public Activity(ILogger <Activity> logger,
                 ConfigureUserSite configureUserSite,
                 TriggerService triggerService,
                 ChallengeService challengeService,
                 UserService userService)
 {
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
     _configureUserSite = configureUserSite
                          ?? throw new ArgumentNullException(nameof(configureUserSite));
     _triggerService = triggerService
                       ?? throw new ArgumentNullException(nameof(triggerService));
     _userService      = userService ?? throw new ArgumentNullException(nameof(userService));
     _challengeService = challengeService
                         ?? throw new ArgumentNullException(nameof(challengeService));
 }
Exemplo n.º 13
0
 public TriggersController(ILogger <TriggersController> logger,
                           ServiceFacade.Controller context,
                           BadgeService badgeService,
                           SiteService siteService,
                           TriggerService triggerService,
                           VendorCodeService vendorCodeService)
     : base(context)
 {
     _logger            = Require.IsNotNull(logger, nameof(logger));
     _badgeService      = Require.IsNotNull(badgeService, nameof(badgeService));
     _siteService       = Require.IsNotNull(siteService, nameof(SiteService));
     _triggerService    = Require.IsNotNull(triggerService, nameof(triggerService));
     _vendorCodeService = Require.IsNotNull(vendorCodeService, nameof(vendorCodeService));
     PageTitle          = "Triggers";
 }
Exemplo n.º 14
0
 public EventsController(ILogger <EventsController> logger,
                         ServiceFacade.Controller context,
                         BadgeService badgeService,
                         EventImportService eventImportService,
                         EventService eventService,
                         SiteService siteService,
                         TriggerService triggerService)
     : base(context)
 {
     _logger             = Require.IsNotNull(logger, nameof(logger));
     _badgeService       = Require.IsNotNull(badgeService, nameof(badgeService));
     _eventImportService = Require.IsNotNull(eventImportService, nameof(eventImportService));
     _eventService       = Require.IsNotNull(eventService, nameof(eventService));
     _siteService        = Require.IsNotNull(siteService, nameof(SiteService));
     _triggerService     = Require.IsNotNull(triggerService, nameof(TriggerService));
     PageTitle           = "Events";
 }
Exemplo n.º 15
0
        private static async Task TriggerCalls(IConfiguration configuration, ServiceProvider serviceProvider)
        {
            var            databaseId = "pizzaDB"; var containerId = "pizzaHut";
            TriggerService tService = serviceProvider.GetService <TriggerService>();

            tService.SetContainer(databaseId, containerId);
            try
            {
                await tService.ViewTriggers();

                // await tService.CreateTrigger("PriceValidationTrigger", "Pre");
                // await tService.CreateNewPizzaPre();
                // await tService.DeleteTrigger("PriceValidationTrigger");

                // await tService.CreateTrigger("PizzaTypeTrigger", "Post");
                // await tService.CreateNewPizzaPost();
                // await tService.DeleteTrigger("PriceValidationTrigger");
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
Exemplo n.º 16
0
        private static void Run(Config config, ILog log, CancellationTokenSource cancelSource)
        {
            var trigger = new TriggerService(log, config.Trigger);
            var files   = new FileService(config.Files);

            using var mail   = new MailService(config.Mail, log);
            using var camera = new CameraService(config.Camera, cancelSource);
            using var image  = new Mat();

            if (!camera.TryRead(image))
            {
                return;
            }

            var oldDev = camera.MeanStdDev(image);

            while (!cancelSource.IsCancellationRequested)
            {
                camera.Delay(cancelSource.Token);

                if (!camera.TryRead(image))
                {
                    break;
                }

                var newDev = camera.MeanStdDev(image);
                var diff   = oldDev.Diff(newDev);

                if (trigger.ShouldTrigger(diff))
                {
                    var path = files.Write(image);
                    mail.Send(path, cancelSource.Token);
                }

                oldDev = newDev;
            }
        }
Exemplo n.º 17
0
 public TriggersController(ILogger <TriggersController> logger,
                           ServiceFacade.Controller context,
                           AvatarService avatarService,
                           BadgeService badgeService,
                           EventService eventService,
                           SiteService siteService,
                           TriggerService triggerService,
                           VendorCodeService vendorCodeService,
                           UserService userService)
     : base(context)
 {
     _logger        = logger ?? throw new ArgumentNullException(nameof(logger));
     _avatarService = avatarService
                      ?? throw new ArgumentNullException(nameof(avatarService));
     _badgeService   = badgeService ?? throw new ArgumentNullException(nameof(badgeService));
     _eventService   = eventService ?? throw new ArgumentNullException(nameof(eventService));
     _siteService    = siteService ?? throw new ArgumentNullException(nameof(siteService));
     _triggerService = triggerService
                       ?? throw new ArgumentNullException(nameof(triggerService));
     _vendorCodeService = vendorCodeService
                          ?? throw new ArgumentNullException(nameof(vendorCodeService));
     _userService = userService ?? throw new ArgumentNullException(nameof(userService));
     PageTitle    = "Triggers";
 }
 public ReportingController(ILogger <ReportingController> logger,
                            ServiceFacade.Controller context,
                            JobService jobService,
                            ReportService reportService,
                            SchoolService schoolService,
                            SiteService siteService,
                            TriggerService triggerService,
                            UserService userService,
                            VendorCodeService vendorCodeService) : base(context)
 {
     _logger        = logger ?? throw new ArgumentNullException(nameof(logger));
     _jobService    = jobService ?? throw new ArgumentNullException(nameof(jobService));
     _reportService = reportService
                      ?? throw new ArgumentNullException(nameof(reportService));
     _schoolService = schoolService
                      ?? throw new ArgumentNullException(nameof(schoolService));
     _siteService    = siteService ?? throw new ArgumentNullException(nameof(siteService));
     _triggerService = triggerService
                       ?? throw new ArgumentNullException(nameof(triggerService));
     _userService       = userService ?? throw new ArgumentNullException(nameof(userService));
     _vendorCodeService = vendorCodeService
                          ?? throw new ArgumentNullException(nameof(vendorCodeService));
     PageTitle = "Reporting";
 }
        public void Setup()
        {
            ctx = new Mock <ITriggerContext>();
            var triggers = new List <Trigger>()
            {
                new Trigger()
                {
                    Id         = 1,
                    CameraName = "Cam1",
                    TimeStamp  = DateTime.Now
                },
                new Trigger()
                {
                    Id         = 2,
                    CameraName = "Cam1",
                    TimeStamp  = DateTime.Now
                },
                new Trigger()
                {
                    Id         = 3,
                    CameraName = "Cam1",
                    TimeStamp  = DateTime.Now.AddDays(-5)
                },
                new Trigger()
                {
                    Id         = 4,
                    CameraName = "Cam1",
                    TimeStamp  = DateTime.Now.AddDays(-20)
                }
            };

            var mock = triggers.AsQueryable().BuildMockDbSet();

            ctx.Setup(x => x.Triggers).Returns(mock.Object);
            service = new TriggerService(ctx.Object);
        }
Exemplo n.º 20
0
        public MainWindowViewModel()
        {
            //TODO: Para birimi servisinden al.

            LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage);
            LocalSettings.SetTraceLogPath("term");

            LocalSettings.DefaultCurrencyFormat = "#,#0.00";
            LocalSettings.AppPath      = System.IO.Path.GetDirectoryName(Application.ResourceAssembly.Location);
            AppServices.MainDispatcher = Application.Current.Dispatcher;
            GenericRuleRegistator.RegisterOnce();
            TriggerService.UpdateCronObjects();

            LoggedInUserViewModel = new LoggedInUserViewModel();
            LoggedInUserViewModel.CloseButtonClickedEvent += LoggedInUserViewModelCloseButtonClickedEvent;

            LoginViewModel = new LoginViewModel();
            LoginViewModel.PinSubmitted += LoginViewModelPinSubmitted;

            TableScreenViewModel = new TableScreenViewModel();
            TableScreenViewModel.TableSelectedEvent += TableScreenViewModelTableSelectedEvent;

            TicketScreenViewModel = new TicketScreenViewModel();
            TicketScreenViewModel.TicketSelectedEvent += TicketScreenViewModelTicketSelectedEvent;

            DepartmentSelectorViewModel = new DepartmentSelectorViewModel();
            DepartmentSelectorViewModel.DepartmentSelected += DepartmentSelectorViewModelDepartmentSelected;

            TicketEditorViewModel = new TicketEditorViewModel();
            TicketEditorViewModel.OnAddMenuItemsRequested     += TicketEditorViewModel_OnAddMenuItemsRequested;
            TicketEditorViewModel.OnCloseTicketRequested      += TicketEditorViewModel_OnCloseTicketRequested;
            TicketEditorViewModel.OnSelectTableRequested      += TicketEditorViewModel_OnSelectTableRequested;
            TicketEditorViewModel.OnTicketNoteEditorRequested += TicketEditorViewModel_OnTicketNoteEditorRequested;
            TicketEditorViewModel.OnTicketTagEditorRequested  += TicketEditorViewModel_OnTicketTagEditorRequested;

            MenuItemSelectorViewModel = new MenuItemSelectorViewModel();
            MenuItemSelectorViewModel.OnTicketItemSelected += MenuItemSelectorViewModel_OnTicketItemSelected;

            SelectedTicketItemEditorViewModel             = new SelectedTicketItemEditorViewModel();
            SelectedTicketItemEditorViewModel.TagUpdated += SelectedTicketItemEditorViewModelTagUpdated;

            PermissionRegistry.RegisterPermission(PermissionNames.AddItemsToLockedTickets, PermissionCategories.Ticket, "Kilitli adisyona ekleme yapabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.GiftItems, PermissionCategories.Ticket, "İkram yapabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.VoidItems, PermissionCategories.Ticket, "İade alabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.MoveTicketItems, PermissionCategories.Ticket, "Adisyon satırlarını taşıyabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.MoveUnlockedTicketItems, PermissionCategories.Ticket, "Kilitlenmemiş adisyon satırlarını taşıyabilir");
            PermissionRegistry.RegisterPermission(PermissionNames.ChangeExtraProperty, PermissionCategories.Ticket, "Ekstra özellik girebilir");

            AppServices.MessagingService.RegisterMessageListener(new MessageListener());
            if (LocalSettings.StartMessagingClient)
            {
                AppServices.MessagingService.StartMessagingClient();
            }

            EventServiceFactory.EventService.GetEvent <GenericEvent <Message> >().Subscribe(
                x =>
            {
                if (SelectedIndex == 2 && x.Topic == EventTopicNames.MessageReceivedEvent &&
                    x.Value.Command == Messages.TicketRefreshMessage)
                {
                    TableScreenViewModel.Refresh();
                }
            });
        }
Exemplo n.º 21
0
 /// <summary>
 /// Constructeur
 /// </summary>
 public Trigger()
 {
     InitializeComponent();
     _Service = new TriggerService();
 }
Exemplo n.º 22
0
        protected override void InitializeShell()
        {
            LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage);

            LocalSettings.SetTraceLogPath("app");
            InteractionService.UserIntraction = ServiceLocator.Current.GetInstance <IUserInteraction>();
            InteractionService.UserIntraction.ToggleSplashScreen();

            AppServices.MainDispatcher = Application.Current.Dispatcher;

            AppServices.MessagingService.RegisterMessageListener(new MessageListener());

            if (LocalSettings.StartMessagingClient)
            {
                AppServices.MessagingService.StartMessagingClient();
            }

            GenericRuleRegistator.RegisterOnce();

            PresentationServices.Initialize();

            base.InitializeShell();

            try
            {
                var creationService = new DataCreationService();
                creationService.CreateData();
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(LocalSettings.ConnectionString))
                {
                    var connectionString =
                        InteractionService.UserIntraction.GetStringFromUser(
                            "Connection String",
                            Resources.DatabaseErrorMessage + e.Message,
                            LocalSettings.ConnectionString);

                    var cs = String.Join(" ", connectionString);

                    if (!string.IsNullOrEmpty(cs))
                    {
                        LocalSettings.ConnectionString = cs.Trim();
                    }

                    AppServices.LogError(e, Resources.CurrentErrorLoggedMessage);
                }
                else
                {
                    AppServices.LogError(e);
                    LocalSettings.ConnectionString = "";
                }
                LocalSettings.SaveSettings();
                Environment.Exit(1);
            }

            if (string.IsNullOrEmpty(LocalSettings.MajorCurrencyName))
            {
                LocalSettings.MajorCurrencyName    = Resources.Dollar;
                LocalSettings.MinorCurrencyName    = Resources.Cent;
                LocalSettings.PluralCurrencySuffix = Resources.PluralCurrencySuffix;
            }

            Application.Current.MainWindow = (Shell)Shell;
            Application.Current.MainWindow.Show();
            InteractionService.UserIntraction.ToggleSplashScreen();
            TriggerService.UpdateCronObjects();

            RuleExecutor.NotifyEvent(RuleEventNames.ApplicationStarted, new { CommandLineArguments = LocalSettings.StartupArguments });
        }
Exemplo n.º 23
0
        public ITriggerOutcome ProcessTrigger(ITriggerInput TriggerInput)
        {
            //If triggers are not active then just return Report as False
            if (!_TriggersActive)
            {
                return new TriggerOutcome()
                       {
                           Report = false
                       }
            }
            ;

            //Validate TriggerInput
            if (TriggerInput.CrudOperationType == RestEnum.CrudOperationType.None)
            {
                throw new System.NullReferenceException("TriggerInput.CrudOperationType cannot be None");
            }

            if (TriggerInput.CrudOperationType == RestEnum.CrudOperationType.Create ||
                TriggerInput.CrudOperationType == RestEnum.CrudOperationType.Update)
            {
                if (TriggerInput.InboundResource == null)
                {
                    throw new System.NullReferenceException("TriggerInput.InboundResource cannot be null");
                }
            }

            if (TriggerInput.CrudOperationType == RestEnum.CrudOperationType.Create ||
                TriggerInput.CrudOperationType == RestEnum.CrudOperationType.Update ||
                TriggerInput.CrudOperationType == RestEnum.CrudOperationType.Delete)
            {
                if (string.IsNullOrWhiteSpace(TriggerInput.InboundResourceId))
                {
                    throw new System.NullReferenceException("TriggerInput.InboundResourceId cannot be null or empty");
                }
                if (TriggerInput.ResourceType == ResourceType.Resource)
                {
                    throw new System.NullReferenceException("TriggerInput.ResourceType cannot be equal to 'Resource'");
                }
            }

            if (TriggerInput.CrudOperationType == RestEnum.CrudOperationType.Update ||
                TriggerInput.CrudOperationType == RestEnum.CrudOperationType.Delete)
            {
                if (TriggerInput.DbTokenIndexList == null)
                {
                    throw new System.NullReferenceException("TriggerInput.DbTokenIndexList cannot be null for Update or Delete actions");
                }
            }

            ITriggerOutcome TriggerOutcomeMain = null;

            //Resource Specific
            var ResourceSpecificList = ITriggerServiceList.Where(x => x.ResourceTypeToTriggerFor == TriggerInput.ResourceType);

            foreach (var TriggerService in ResourceSpecificList)
            {
                TriggerOutcomeMain = CollateOutcomes(TriggerOutcomeMain, TriggerService.ProcessTrigger(TriggerInput));
            }

            //All Resource Types
            ResourceSpecificList = ITriggerServiceList.Where(x => x.ResourceTypeToTriggerFor == ResourceType.Resource);
            foreach (var TriggerService in ResourceSpecificList)
            {
                TriggerOutcomeMain = CollateOutcomes(TriggerOutcomeMain, TriggerService.ProcessTrigger(TriggerInput));
            }

            return(TriggerOutcomeMain);
        }
Exemplo n.º 24
0
        public void Current_WithoutSession_ReturnsNull()
        {
            var subject = new TriggerService(new TriggerDiscoveryServiceStub(), new NoRecursionStrategy(), new LoggerFactory(), new OptionsSnapshotStub <TriggerOptions>());

            Assert.Null(subject.Current);
        }