Exemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DbCS"].ConnectionString;

            var options = new SqlServerStorageOptions
            {
                QueuePollInterval = TimeSpan.FromSeconds(30)// Default value
            };


            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console(Serilog.Events.LogEventLevel.Debug)
                         .WriteTo.Console(Serilog.Events.LogEventLevel.Error)
                         .WriteTo.Console(Serilog.Events.LogEventLevel.Warning)
                         .WriteTo.Console(Serilog.Events.LogEventLevel.Information)
                         .WriteTo.File(@"C:\tempLog\JobAgentLog.txt")
                         .CreateLogger();

            GlobalConfiguration.Configuration
            .UseSqlServerStorage(connectionString, options);

            app.UseHangfireDashboard("/jobs");

            ServiceScheduler.ScheduleJobs();
        }
        public IActionResult Post([FromBody] ServiceScheduler value, string postType)
        {
            var service = ServiceScheduler.ScheduledTasks.First(i => i.ServiceId == value.ServiceId.ToUpper());

            if (postType == "start")
            {
                service.ActualStartDateTime = DateTime.Now;
                service.Status = Status.Started;
            }
            if (postType == "stop")
            {
                service.ActualEndDateTime = DateTime.Now;
                service.Status            = Status.Completed;
            }
            if (postType == "cancel")
            {
                service.ActualStartDateTime = DateTime.Now;
                service.ActualEndDateTime   = DateTime.Now;
                service.Status = Status.Cancelled;
            }
            if (value.WorkerTracker != null && value.WorkerTracker.Any())
            {
                if (service.WorkerTracker == null)
                {
                    service.WorkerTracker = new List <LocationTracker>();
                }

                service.WorkerTracker.Add(new LocationTracker
                {
                    Latitude    = value.WorkerTracker.First().Latitude,
                    Longitude   = value.WorkerTracker.First().Longitude,
                    Time        = DateTime.Now,
                    TrackerType = postType == "sos" ? TrackerType.SOS : TrackerType.Regular
                });
            }
            return(Ok());
        }
 public string Get(int id)
 {
     ServiceScheduler.PopulateData();
     return("rawdata added");
 }