public void Save()
        {
            if (this.CanSave())
            {
                int result;
                var data = this.DataContext as DataCollectionViewEntity;
                if (data.Id == -1)
                {
                    result = new DataCollectionService().Add(data);
                }
                else
                {
                    result = new DataCollectionService().Update(data);
                }

                if (result == 0)
                {
                    MessageBox.Show("Dati Salvati!");
                }
                else
                {
                    MessageBox.Show("Errore durante il salvataggio!");
                }
            }
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            var selectedItem = this.lvDataCollection.SelectedItem;

            if (selectedItem != null)
            {
                DataCollectionEntity item = selectedItem as DataCollectionEntity;

                DataCollectionService service = new DataCollectionService();
                if (MessageBox.Show("Sei sicuro di voler eliminare l'elemento selezionato?", "Elimina riga", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    if (service.Delete(item) == 0)
                    {
                        MessageBox.Show("cancellato!");
                        this.RefreshData();
                    }
                    else
                    {
                        MessageBox.Show("NON cancellato!");
                    }
                }
                else
                {
                    MessageBox.Show("NON cancellato!");
                }
            }
        }
Exemplo n.º 3
0
        public MainForm()
        {
            InitializeComponent();

            var dataCollectionService = new DataCollectionService(new OcrImageService());
            var alertService          = new AlertService();

            var resultsFile =
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                             "Vitals Monitor", "results.csv");

            if (!Directory.Exists(Path.GetDirectoryName(resultsFile)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(resultsFile));
            }

            dataCollectionService.ResultsFilePath = resultsFile;
            this.Model   = new Model(new Lazy <Effects>(() => this.Effects));
            this.Effects = new Effects(
                this,
                new PagerDutyService("<?>"),
                new AlertService(),
                dataCollectionService
                );
            this.Mediator = new Mediator <MainForm, Model, Effects>(this, this.Model, this.Effects);
            this.emailTextBox.TextChanged += EmailTextBox_TextChanged;
        }
Exemplo n.º 4
0
 public Effects(MainForm mainForm,
                ISendAlertService sendAlertService,
                AlertService alertService,
                DataCollectionService dataCollectionService)
 {
     this.mainForm = mainForm;
     this.dataCollectionService = dataCollectionService;
     this._alertService         = alertService;
     this._sendAlertService     = sendAlertService;
 }
        public override async Task InitializeAsync()
        {
            await base.InitializeAsync();

            // Add custom logs on failure if they haven't already been.
            if (!s_customLoggersAdded)
            {
                DataCollectionService.RegisterCustomLogger(RazorOutputPaneLogger, RazorOutputLogId, "log");
                DataCollectionService.RegisterCustomLogger(RazorLogHubLogger, LogHubLogId, "zip");

                s_customLoggersAdded = true;
            }

            await TestServices.SolutionExplorer.CreateSolutionAsync("BlazorSolution", HangMitigatingCancellationToken);

            await TestServices.SolutionExplorer.AddProjectAsync("BlazorProject", WellKnownProjectTemplates.BlazorProject, groupId : WellKnownProjectTemplates.GroupIdentifiers.Server, templateId : null, LanguageName, HangMitigatingCancellationToken);

            await TestServices.SolutionExplorer.RestoreNuGetPackagesAsync(HangMitigatingCancellationToken);

            await TestServices.Workspace.WaitForProjectSystemAsync(HangMitigatingCancellationToken);

            await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.LanguageServer, HangMitigatingCancellationToken);

            // We open the Index.razor file, and wait for 3 RazorComponentElement's to be classified, as that
            // way we know the LSP server is up, running, and has processed both local and library-sourced Components
            await TestServices.SolutionExplorer.AddFileAsync(BlazorProjectName, ModifiedIndexRazorFile, IndexPageContent, open : true, HangMitigatingCancellationToken);

            // Razor extension doesn't launch until a razor file is opened, so wait for it to equalize
            await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.LanguageServer, HangMitigatingCancellationToken);

            await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.Workspace, HangMitigatingCancellationToken);

            await TestServices.Workspace.WaitForProjectSystemAsync(HangMitigatingCancellationToken);

            await EnsureExtensionInstalledAsync(HangMitigatingCancellationToken);

            try
            {
                await TestServices.Editor.WaitForClassificationAsync(HangMitigatingCancellationToken, expectedClassification : RazorComponentElementClassification, count : 3);
            }
            catch (OperationCanceledException)
            {
                // DataCollectionService does not fire in the case that errors or exceptions are thrown during Initialization.
                // Let's capture some of the things we care about most manually.
                var logHubFilePath = CreateLogFileName(LogHubLogId, "zip");
                RazorLogHubLogger(logHubFilePath);
                var outputPaneFilePath = CreateLogFileName(RazorOutputLogId, "log");
                RazorOutputPaneLogger(outputPaneFilePath);
                throw;
            }

            // Close the file we opened, just in case, so the test can start with a clean slate
            await TestServices.Editor.CloseDocumentWindowAsync(HangMitigatingCancellationToken);
 public DataCollectionWorker(ILogger <DataCollectionWorker> logger, DataCollectionService dc, ServiceConfiguration sc)
 {
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     if (dc == null)
     {
         throw new ArgumentNullException(nameof(dc));
     }
     if (sc == null)
     {
         throw new ArgumentNullException(nameof(sc));
     }
     _logger = logger;
     _dc     = dc;
     _sc     = sc;
     _logger.LogInformation($"Scheduling Data Collection Worker to run every {TimeSpan.FromMilliseconds(_sc.FetchInterval):hh\\:mm\\:ss}");
 }