public PatientsService(IStorageHandler storageHandler, IMapper mapper, IOptions <Settings> settings, PatientsDbContext dbContext)
 {
     _mapper         = mapper;
     _dbContext      = dbContext;
     _storageHandler = storageHandler;
     _settings       = settings.Value.AppSettings;
 }
 /// <summary>
 /// Adds the storage handler.
 /// </summary>
 /// <param name="handler">The handler.</param>
 /// <returns>Itself</returns>
 public StorageCoordinator AddStorageHandler(IStorageHandler handler)
 {
     handler.Coordinator = this;
     handler.Configure();
     handlers.Add(handler);
     return(this);
 }
Esempio n. 3
0
        public string InitIO(string port)
        {
            var initLogString = $"{Utility.PluginName} MainPlugin InitIo started";

            Console.WriteLine(initLogString);
            _logging.Log(initLogString);
            _config = new MainConfig(_logging, _hs, _iniSettings, _callback, this);
            _config.RegisterConfigs();

            _callback.RegisterEventCB(Enums.HSEvent.VALUE_CHANGE, Utility.PluginName, "");

            _logging.Log($"Done creating configs");
            _iniSettings.IniSettingsChanged += _logging.IniSettingHasChanged;
            _homeSeerHandler = new HomeSeerHandler(_hs, _logging);
            _logging.Log($"Done creating HomeSeerHandler");

            _storageHandler = new StorageHandler(_logging, _iniSettings);
            _logging.Log($"Done creating StorageHandler");

            _triggerHandler = new TriggerHandler(_hs, _callback, _iniSettings, _logging, _collectionFactory, _homeSeerHandler, _storageHandler);
            _logging.Log($"Done creating _triggerHandler ");

            //_callback.RegisterEventCB(Enums.HSEvent.CONFIG_CHANGE, Utility.PluginName, "");
            //Register callback on every event of value change. This is the method to find if this is a value of a device we are following

            _logging.Log($"Done registering callback");
            _logging.Log($"{Utility.PluginName} MainPlugin InitIo Complete");
            return("");
        }
 public ReplyToDequeueFromPostOffice(
     IDequeueNotificationParser dequeueNotificationParser,
     IStorageHandler storageHandler)
 {
     _dequeueNotificationParser = dequeueNotificationParser;
     _storageHandler            = storageHandler;
 }
Esempio n. 5
0
 public BundleRepository(
     IStorageHandler storageHandler,
     IBundleRepositoryContainer repositoryContainer,
     IMarketOperatorDataStorageService marketOperatorDataStorageService)
 {
     _storageHandler      = storageHandler;
     _repositoryContainer = repositoryContainer;
     _marketOperatorDataStorageService = marketOperatorDataStorageService;
 }
Esempio n. 6
0
 public ReplyToRequestFromPostOffice(
     IRequestBundleParser requestBundleParser,
     IDataBundleResponseSender responseSender,
     IStorageHandler storageHandler)
 {
     _requestBundleParser = requestBundleParser;
     _responseSender      = responseSender;
     _storageHandler      = storageHandler;
 }
Esempio n. 7
0
        /*/ Constructors /*/

        /// <summary>
        /// Initializes a new instance of the <see cref="JuvoClient"/> class.
        /// </summary>
        /// <param name="configuration">Bot's configuration.</param>
        /// <param name="serviceProvider">Service provider.</param>
        /// <param name="discordBotFactory">Factory object for Discord bots.</param>
        /// <param name="ircBotFactory">Factory object for IRC bots.</param>
        /// <param name="slackBotFactory">Factory object for Slack bots.</param>
        /// <param name="logManager">Log manager.</param>
        /// <param name="webHostBuilder">Webhost builder object for creating a web server.</param>
        /// <param name="storageHandler">Storage handler for working with files/dirs.</param>
        /// <param name="httpClient">HTTP client instance for web-based requests.</param>
        /// <param name="resetEvent">Manual reset object for thread.</param>
        public JuvoClient(
            Config configuration,
            IServiceProvider serviceProvider,
            IDiscordBotFactory discordBotFactory,
            IIrcBotFactory ircBotFactory,
            ISlackBotFactory slackBotFactory,
            ILogManager logManager,
            IWebHostBuilder webHostBuilder,
            IStorageHandler storageHandler,
            IHttpClient httpClient,
            ManualResetEvent?resetEvent = null)
        {
            this.Config            = configuration ?? throw new ArgumentException(nameof(configuration));
            this.discordBotFactory = discordBotFactory ?? throw new ArgumentNullException(nameof(discordBotFactory));
            this.httpClient        = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
            this.ircBotFactory     = ircBotFactory ?? throw new ArgumentNullException(nameof(ircBotFactory));
            this.resetEvent        = resetEvent ?? new ManualResetEvent(false);
            this.serviceProvider   = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            this.slackBotFactory   = slackBotFactory ?? throw new ArgumentNullException(nameof(slackBotFactory));
            this.storageHandler    = storageHandler ?? throw new ArgumentNullException(nameof(storageHandler));
            this.webHostToken      = default;
            this.webHostBuilder    = webHostBuilder;

            this.bots             = new List <IBot>();
            this.commandQueue     = new Queue <IBotCommand>();
            this.commandTimer     = new Timer(this.CommandTimerTick, null, TimerTickRate, TimerTickRate);
            this.lastPerfLock     = new Mutex();
            this.Logger           = logManager?.GetLogger(typeof(JuvoClient));
            this.plugins          = new Dictionary <string[], IBotPlugin>();
            this.started          = DateTime.UtcNow;
            this.State            = JuvoState.Idle;
            this.webServerRunning = false;

            this.httpClient.DefaultRequestHeaders.Add(
                "User-Agent",
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.0 Safari/537.36 Edg/89.0.774.4");

            // this block maps the bots internal commands to the appropriate
            // internal methods.
            // ?: should these commands be overridable in some way, for example
            // if a plugin/module wanted to handle one of these.
            this.commands = new Dictionary <string[], Func <IBotCommand, Task> >
            {
                { new[] { "echo" }, this.CommandEcho },
                { new[] { "shutdown", "die" }, this.CommandShutdown },
                { new[] { "perf", "performance" }, this.CommandPerf },
                { new[] { "csc", "ros", "roslyn" }, this.CommandRoslyn },
                { new[] { "set" }, this.CommandSet },
                { new[] { "status" }, this.CommandStatus }
            };
        }
Esempio n. 8
0
        public TriggerHandler(IHSApplication hs, IAppCallbackAPI callback, IIniSettings iniSettings,
                              ILogging logging, IHsCollectionFactory collectionFactory, IHomeSeerHandler homeSeerHandler, IStorageHandler storageHandler)
        {
            _hs                = hs;
            _callback          = callback;
            _iniSettings       = iniSettings;
            _logging           = logging;
            _collectionFactory = collectionFactory;
            _homeSeerHandler   = homeSeerHandler;
            _storageHandler    = storageHandler;
            _logging.LogDebug("Creating trigger types");
            _triggerTypes = CreateTriggerTypes();

            _logging.LogDebug("Starting thread to fetch triggers");
            GetPluginTriggersFromHomeSeerInNewThread();

            _logging.LogDebug("Done init TriggerHandler");
        }
        public bool TriggerTrue(IPlugInAPI.strTrigActInfo actionInfo, IStorageHandler storageHandler)
        {
            _triggerSettings = GetSettingsFromTriggerInfo(actionInfo);
            if (_triggerSettings != null && _triggerSettings.GetTriggerConfigured())
            {
                var thresholdValue           = _triggerSettings.ThresholdValue;
                var numberOfLastMeasurements = _triggerSettings.NumberOfLastMeasurements ?? 10;
                var dataPoints = storageHandler.GetLastValuesForDevice(_triggerSettings.DeviceIdChosen.Value, numberOfLastMeasurements);
                var lastValue  = dataPoints.Last();
                if (!ThresholdReached(lastValue.Value, thresholdValue, _triggerSettings.AscendingOrDescending))
                {
                    return(false);
                }

                return(_dataCurveComputationHandler.TriggerTrue(dataPoints, _triggerSettings.AscendingOrDescending, thresholdValue.Value, numberOfLastMeasurements));
            }
            return(false);
        }
Esempio n. 10
0
        private void Init()
        {
            _defaultStorageProvider = _storageManager.GetProvider(_settings.Provider);
            if (_defaultStorageProvider == null)
            {
                throw new ArgumentException("Invalid, missing or unresolved provider name.");
            }

            if (_settings.Params?.Count > 0)
            {
                _defaultStorageProvider.SetParameters(_settings.Params);
            }

            DefaultHandler = _defaultStorageProvider.Produce();
            if (DefaultHandler == null)
            {
                throw new InvalidOperationException("Failed to construct Storage handler.");
            }
        }
Esempio n. 11
0
        public bool TriggerTrue(IPlugInAPI.strTrigActInfo actionInfo, IStorageHandler storageHandler)
        {
            _triggerSettings = GetSettingsFromTriggerInfo(actionInfo);
            if (_triggerSettings != null && _triggerSettings.GetTriggerConfigured())
            {
                var fromDate   = SystemDateTime.Now().AddHours(_triggerSettings.TimeSpanChosen.Value.TotalHours * -1);
                var dataPoints = storageHandler.GetValuesForDevice(_triggerSettings.DeviceIdChosen.Value, fromDate,
                                                                   SystemDateTime.Now());

                //_logging.LogDebug($"calling trigger for computation _dataCurveComputationHandler==null={_dataCurveComputationHandler==null}");

                if (_triggerSettings.UseFutureComputation && _triggerSettings.GetTriggerConfigured())
                {
                    return(_dataCurveComputationHandler.TriggerTrue(dataPoints, _triggerSettings.AscendingOrDescending, _triggerSettings.FutureThresholdValue, _triggerSettings.FutureComputationTimeSpan));
                }

                return(_dataCurveComputationHandler.TriggerTrue(dataPoints, _triggerSettings.AscendingOrDescending));
            }
            return(false);
        }
Esempio n. 12
0
        public Preferences(IStorageHandler storageHandler, params object[] rawpreferences)
        {
            _storageHandler = storageHandler;

            foreach (object rawPreference in rawpreferences)
            {
                PropertyInfo[] properties = rawPreference.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                foreach (PropertyInfo propertyInfo in properties)
                {
                    if (!propertyInfo.CanRead || !propertyInfo.CanWrite)
                    {
                        continue;
                    }
                    else if (Preference.TryInvestigate(propertyInfo, rawPreference, out var itemToAttatch))
                    {
                        _preferences.Add(itemToAttatch.Name, itemToAttatch);
                    }
                }
            }
        }
Esempio n. 13
0
        public MainViewModel()
        {
            IStorageController <CategoryModel> categoryController = new StorageController <CategoryModel>(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), SecureManager.CategoriesFileName));
            IStorageController <DataModel>     dataController     = new StorageController <DataModel>(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), SecureManager.DataFileName), new Cryptographer(SecureManager.Key));

            storageHandler = new StorageHandler(categoryController, dataController);

            CategoriesControl = new Views.CategoryView();
            CategoryViewModel categoryVM = new CategoryViewModel(storageHandler);

            CategoriesControl.DataContext = categoryVM;

            DataControl = new Views.DataView();
            DataViewModel dataVM = new DataViewModel(storageHandler);

            DataControl.DataContext = dataVM;

            categoryVM.OnCategoryChanged   += dataVM.CategoryChanged;
            dataVM.OnNeededCurrentCategory += categoryVM.ShareSelectedCategory;
            dataVM.OnDataChanged           += categoryVM.DataChanged;
        }
Esempio n. 14
0
 public LocalStorage(IStorageHandler handler)
 {
     this._handler = handler;
 }
Esempio n. 15
0
 public Preferences(IStorageHandler storageHandler, params Preference[] preferences)
 {
     _storageHandler = storageHandler;
 }
Esempio n. 16
0
 ChatService()
 {
     _storageHandler  = new FileStorage();
     _registeredUsers = _storageHandler.GetRegisteredUsers();
 }
 public FileController(StorageHandlerHelper storageHelper)
 {
     _storageHandler = storageHelper.DefaultHandler;
 }
Esempio n. 18
0
 public DataViewModel(IStorageHandler <CategoryModel, DataModel> storageHandler)
 {
     this.storageHandler = storageHandler;
 }
 public MarketOperatorDataStorageService(IStorageHandler storageHandler)
 {
     _storageHandler = storageHandler;
 }
Esempio n. 20
0
 public CategoryViewModel(IStorageHandler <CategoryModel, DataModel> storageHandler)
 {
     this.storageHandler = storageHandler;
     GetCategories();
 }