Esempio n. 1
0
        public async Task <string> StartDataPackage(JobSubmission job, RequestedTime dateMode, int?year, int?month, int?day, List <string> variables)
        {
            var time = new TimeMode();

            if (dateMode == RequestedTime.Before)
            {
                time.Kind = "before";
                time.Date = new Date()
                {
                    Year = year.Value, Month = month, Day = day
                };
            }
            else if (dateMode == RequestedTime.Exact)
            {
                time.Kind = "exact";
                time.Date = new Date()
                {
                    Year = year.Value, Month = month, Day = day
                };
            }
            else
            {
                time.Kind = "latest";
            }

            var command = new JobSubmissionRequest()
            {
                East      = job.East,
                West      = job.West,
                North     = job.North,
                South     = job.South,
                Variables = GetCustomRequest(variables),
                TimeMode  = time
            };

            try {
                var result = await _connection.SubmitJobAsync(command);

                return(result.Id.ToString());
            } catch (Exception e)
            {
                _logger.LogCritical("Job could not be submitted to the geotemporal engine. The error was: " + e.Message);
                return(null);
            }
        }
 public void OnPostView(string startDate, string endDate)
 {
     if (DateTime.TryParse(startDate, out DateTime sd) && DateTime.TryParse(endDate, out DateTime ed))
     {
         StartDate = sd;
         if ((DateTime.Today.AddDays(8) - StartDate).Days > 0)
         {
             ErrorMessages.Add($"Start Date must be beyond { DateTime.Today.AddDays(7).ToLongDateString()}");
         }
         if (ed.Ticks > 0)
         {
             EndDate = ed;
             if (StartDate.DayOfWeek != EndDate.DayOfWeek)
             {
                 ErrorMessages.Add($"Day of week for Start Date ({StartDate.DayOfWeek.ToString()}) does not match day of week for End Date({EndDate.DayOfWeek.ToString()})");
             }
         }
         else
         {
             ErrorMessages.Add("Please select an End Date");
         }
         if (!(ErrorMessages?.Any() ?? false))
         {
             TempData[nameof(StartDate)] = StartDate;
             TempData[nameof(EndDate)]   = EndDate;
             Domain.CBS requestDirector = new Domain.CBS(userManager.FindByNameAsync(User.Identity.Name).GetAwaiter().GetResult().Id,
                                                         Startup.ConnectionString);
             STTRequests = requestDirector.ViewStandingTeeTimeRequests(StartDate, EndDate);
             TempData.Put("PermissableTimes", from time in STTRequests where time.Members is null select time.RequestedTime.ToString("HH:mm"));
             return;
         }
     }
     TempData.Put(nameof(ErrorMessages), ErrorMessages);
 }