Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     try
     {
         for (int i = 0; i < args.Length; i++)
         {
             if (args[i] == "-h")
             {
                 PrintHelp();
             }
             else if (args[i] == "-host")
             {
                 if (i++ < args.Length)
                 {
                     Console.WriteLine($"Using host: {args[i]}");
                     BackgroundJobClient.JobUrl = $"http://{args[i]}:8888/api";
                 }
                 else
                 {
                     Console.WriteLine("Missing argument for host");
                     break;
                 }
             }
             else if (args[i] == "-view-config")
             {
                 var config = BackgroundJobClient.GetConfig();
                 Console.WriteLine(config);
             }
             else if (args[i] == "-view-data")
             {
                 PrintOverviewData(BackgroundJobClient.GetOverviewData());
                 Console.WriteLine();
                 PrintSensorData(BackgroundJobClient.GetMeasuredData());
             }
             else if (args[i] == "-set-location")
             {
                 if (i++ < args.Length)
                 {
                     Console.WriteLine($"Using location: {args[i]}");
                     var config = BackgroundJobClient.GetConfig();
                     config.Location = args[i];
                     BackgroundJobClient.UpdateConfig(config);
                 }
                 else
                 {
                     Console.WriteLine("Missing argument for location");
                     break;
                 }
             }
         }
     } catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     if (args.Length == 0)
     {
         PrintHelp();
     }
 }
Ejemplo n.º 2
0
 private void Run(object sender, DoWorkEventArgs e)
 {
     Log.Info("Started");
     while (!backroundWorker.CancellationPending)
     {
         try
         {
             SensorsDataViewModel.GetSensorsDataViewModel().Update(BackgroundJobClient.GetMeasuredData());
             OverviewDataViewModel.GetOverviewDataViewModel().Update(BackgroundJobClient.GetOverviewData());
         }
         catch (Exception ex)
         {
             Log.Error("Error", ex);
         }
         Thread.Sleep(15000);
     }
     if (backroundWorker.CancellationPending)
     {
         e.Cancel = true;
     }
     Log.Info("Stopped");
 }