Beispiel #1
0
 public RFProcessingTracker GetProcessStatus(RFProcessingTrackerHandle trackerHandle)
 {
     try
     {
         Log.Debug(this, "GetProcessStatus {0}", trackerHandle.TrackerCode);
         LogRequest();
         RFProcessingTracker tracker = null;
         lock (_sync)
         {
             _trackers.TryGetValue(trackerHandle.TrackerCode, out tracker);
             if (tracker == null)
             {
                 Log.Warning(this, "Unable to find tracker for {0}; current cache size {1}", trackerHandle.TrackerCode, _trackers.Count);
             }
         }
         return(tracker);
     }
     catch (Exception ex)
     {
         Log.Exception(this, "GetProcessStatus", ex);
         var tracker = new RFProcessingTracker(trackerHandle.TrackerCode);
         tracker.CycleFinished("dummy", RFProcessingResult.Error(new string[] { ex.Message }, false));
         tracker.SetComplete();
         return(tracker);
     }
 }
Beispiel #2
0
        public RFProcessingTracker SaveEntry(RFCatalogEntry entry, RFUserLogEntry userLogEntry)
        {
            var trackerCode             = SaveEntry(entry, true, userLogEntry);
            RFProcessingTracker tracker = null;
            var sw = Stopwatch.StartNew();

            do
            {
                Thread.Sleep(250);
                tracker = GetService().GetProcessStatus(trackerCode);
            } while (!tracker.IsComplete && sw.ElapsedMilliseconds < 10000);
            return(tracker);
        }
Beispiel #3
0
        protected RFProcessingTrackerHandle RegisterTracker(RFProcessingTracker tracker)
        {
            var guid = Guid.NewGuid().ToString();

            lock (_sync)
            {
                _trackers.Add(guid, tracker);
            }
            return(new RFProcessingTrackerHandle
            {
                TrackerCode = guid
            });
        }
 public JsonResult ReportProcessingError(string action, RFProcessingTracker status)
 {
     if (status != null)
     {
         if (!status.IsComplete)
         {
             return(Json(JsonError.Throw(action, "Operation timeout - please contact support.")));
         }
         else if (status.IsError())
         {
             return(Json(JsonError.Throw(action, status.Error)));
         }
         else
         {
             return(Json(true));
         }
     }
     return(Json(JsonError.Throw(action, "Unknown error - please contact support.")));
 }
Beispiel #5
0
 public JsonResult RefreshProcessingStatus(string processKey)
 {
     try
     {
         if (processKey == "test")
         {
             var r = new Random();
             var f = r.Next(0, 10) + 4;
             var p = r.Next(0, 10) + 4;
             return(Json(new
             {
                 IsComplete = true,
                 CurrentProcess = "test",
                 FinishedCycles = f,
                 ProcessingCycles = p,
                 RemainingCycles = 300 - f - p,
                 Messages = new string[] { "Message 1", "Message 2" },
                 Keys = 5,
                 Time = "01:01",
                 IsValid = true,
                 IsError = false
             }));
         }
         Log.Info(this, "RefreshProcessingStatus {0}", processKey);
         var model = GetModelFromCache(processKey);
         RFProcessingTrackerHandle handle = null;
         if (model != null)
         {
             handle = model.Tracker;
         }
         else
         {
             handle = new RFProcessingTrackerHandle {
                 TrackerCode = processKey
             };
         }
         RFProcessingTracker trackerObject = null;
         using (var rfService = new RFServiceClient())
         {
             Log.Info(this, "Asking RF service for status on {0}", processKey);
             trackerObject = rfService.RFService.GetProcessStatus(handle);
         }
         if (trackerObject != null)
         {
             return(Json(new
             {
                 IsComplete = trackerObject.IsComplete,
                 CurrentProcess = trackerObject.CurrentProcess,
                 FinishedCycles = trackerObject.FinishedCycles,
                 ProcessingCycles = trackerObject.ProcessingCycles,
                 RemainingCycles = trackerObject.RemainingCycles,
                 Messages = ExtractMessages(trackerObject.Messages),
                 Keys = trackerObject.KeyCount,
                 Time = trackerObject.GetDuration().ToString(@"m'm 's's'"),
                 IsValid = true,
                 IsError = trackerObject.IsError()
             }));
         }
         return(Json(JsonError.Throw("ProcessingStatus", "Unable to retrieve information about request {0}", processKey)));
     }
     catch (Exception ex)
     {
         if (ex.Message.Contains("no endpoint listening"))
         {
             // fatal error
             return(Json(JsonError.Throw("ProcessingStatus", "System is offline - {0}", processKey)));
         }
         else
         {
             // recoverable error
             return(Json(new
             {
                 IsValid = false,
                 Error = ex.Message
             }));
         }
     }
 }