Example #1
0
 public ActionResult RetryError(string dp, string returnUrl = null)
 {
     try
     {
         using (var rfService = new RFServiceClient())
         {
             RFProcessingTrackerHandle trackerKey = null;
             trackerKey = rfService.RFService.RetryError(dp, new RFUserLogEntry
             {
                 Action       = "Retry",
                 Description  = String.Format("Retried error on process {0}", dp),
                 IsUserAction = true,
                 IsWarning    = false,
                 Username     = Username
             });
             AddModelToCache(trackerKey.TrackerCode, new ProcessingModel
             {
                 Tracker       = trackerKey,
                 ProcessingKey = trackerKey.TrackerCode,
                 FileKey       = string.Empty,
                 FileName      = String.Format("Retry Error for {0}", dp),
                 FileSize      = 0,
                 ReturnUrl     = returnUrl
             });
             return(RedirectToAction("ProcessingStatus", new { processKey = trackerKey.TrackerCode }));
         }
     }
     catch (Exception ex)
     {
         Log.Exception(this, "RetryError", ex);
         return(Error("Index", "Home", null, "Error retrying error process: {0}", ex.Message));
     }
 }
Example #2
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);
     }
 }
Example #3
0
 public ActionResult TrackProcess(RFProcessingTrackerHandle handle, string continueAction, string continueController, object routeValues)
 {
     ProcessController.SubmitModel(new Models.IO.ProcessingModel
     {
         Tracker          = handle,
         ProcessingKey    = handle.TrackerCode,
         ReturnAction     = continueAction,
         ReturnController = continueController,
         ReturnValues     = routeValues
     });
     return(RedirectToAction("ProcessingStatus", "Process", new { area = "", processKey = handle.TrackerCode }));
 }
Example #4
0
        public ActionResult RunProcess(bool isGraph, string processName, string instanceName, RFDate?instanceDate, string returnUrl = null)
        {
            try
            {
                var graphInstance = /*isGraph ? */ new RFGraphInstance
                {
                    Name      = string.IsNullOrWhiteSpace(instanceName) ? RFGraphInstance.DEFAULT_INSTANCE : instanceName,
                    ValueDate = instanceDate.HasValue ? instanceDate.Value : RFDate.NullDate
                };// : null;

                using (var rfService = new RFServiceClient())
                {
                    RFProcessingTrackerHandle trackerKey = null;
                    trackerKey = rfService.RFService.RunProcess(isGraph, processName, graphInstance, new RFUserLogEntry
                    {
                        Action       = "Run",
                        Description  = String.Format("Manually run process {0}", processName),
                        ValueDate    = instanceDate ?? RFDate.NullDate,
                        IsUserAction = true,
                        IsWarning    = false,
                        Username     = Username
                    });
                    AddModelToCache(trackerKey.TrackerCode, new ProcessingModel
                    {
                        Tracker       = trackerKey,
                        ProcessingKey = trackerKey.TrackerCode,
                        FileKey       = string.Empty,
                        FileName      = String.Format("Process: {0} for value date {1}", processName, instanceDate),
                        FileSize      = 0,
                        ReturnUrl     = returnUrl
                    });
                    return(RedirectToAction("ProcessingStatus", new { processKey = trackerKey.TrackerCode }));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(this, "RunProcess", ex);
                return(Error("Index", "Home", null, "Error running process: {0}", ex.Message));
            }
        }
        public ActionResult UpdateInputReport(long keyReference, string updates)
        {
            try
            {
                var activity = new RFInputReportsActivity(Context);
                var report   = activity.GetInputReportDocument(keyReference);
                if (report != null)
                {
                    var section = report.GetContent <RFRawReport>().GetFirstSection();
                    foreach (var update in JsonConvert.DeserializeObject <List <dynamic> >(updates))
                    {
                        int rowNum = update.rowNum;
                        if (section.Rows.Count >= rowNum)
                        {
                            var row = section.Rows.Skip(rowNum - 1).First();
                            foreach (JToken token in ((JObject)update.data).Children())
                            {
                                if (token is JProperty)
                                {
                                    row.SetString((token as JProperty).Name, (token as JProperty).Value.ToString());
                                }
                            }
                        }
                    }

                    using (var rfService = new RFServiceClient())
                    {
                        RFProcessingTrackerHandle trackerKey = null;
                        trackerKey = rfService.RFService.SubmitAndProcess(new List <RFCatalogEntryDTO> {
                            new RFCatalogEntryDTO(report)
                        }, new RFUserLogEntry
                        {
                            Action       = "Update Input Report",
                            Description  = String.Format("Manually updated report {0}", report.Key.FriendlyString()),
                            IsUserAction = true,
                            IsWarning    = false,
                            Processor    = null,
                            ValueDate    = report.Key.GraphInstance.ValueDate.Value,
                            Username     = Username
                        });

                        ProcessController.SubmitModel(new ProcessingModel
                        {
                            Tracker       = trackerKey,
                            ProcessingKey = trackerKey.TrackerCode,
                            FileKey       = (report.Key as RFRawReportKey).ReportCode,
                            FileName      = (report.Key as RFRawReportKey).FriendlyString(),
                            FileSize      = 0,
                            ReturnUrl     = null
                        });

                        return(RedirectToAction("ProcessingStatus", "Process", new { processKey = trackerKey.TrackerCode }));
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(this, ex, "Error updating input report {0}", keyReference);
            }
            return(null);
        }
Example #6
0
        public ActionResult SubmitFiles(
            RFDate?valueDate = null,
            string returnUrl = null,
            string instance  = null
            )
        {
            try
            {
                if (Request.Files == null || Request.Files.Count == 0)
                {
                    throw new RFSystemException(this, "No files submitted.");
                }

                var processKey  = String.Format("{0}_web", DateTime.Now.ToString("yyyyMMdd_HHmmss"));
                var submittable = new List <RFCatalogEntryDTO>();
                int uqIdx       = 1;

                foreach (var knownFileEnum in RIFF.Web.Core.App_Start.RIFFStart.Config.GetInputFileKeys())
                {
                    // match up by string (or could have registered an enum type...)
                    foreach (string inputFileKey in Request.Files.Keys)
                    {
                        if (knownFileEnum.ToString() == inputFileKey)
                        {
                            var inputFile = Request.Files[inputFileKey] as HttpPostedFileBase;
                            if (inputFile != null && inputFile.ContentLength > 0)
                            {
                                var uniqueKey = String.Format("{0}_web_{1}", DateTime.Now.ToString("yyyyMMdd_HHmmss"), uqIdx++);

                                var doc = RFDocument.Create(
                                    RFFileKey.Create(
                                        EngineConfig.KeyDomain,
                                        knownFileEnum,
                                        uniqueKey),
                                    new RFFile
                                {
                                    Attributes = new RFFileTrackedAttributes
                                    {
                                        FileName     = inputFile.FileName,
                                        FullPath     = inputFile.FileName,
                                        FileSize     = inputFile.ContentLength,
                                        ModifiedDate = DateTime.Now
                                    },
                                    Data      = RFStreamHelpers.ReadBytes(inputFile.InputStream),
                                    FileKey   = knownFileEnum,
                                    ValueDate = valueDate,
                                    UniqueKey = uniqueKey
                                });

                                if (instance.NotBlank() && valueDate.HasValue)
                                {
                                    doc.Key.GraphInstance = new RFGraphInstance {
                                        Name = instance, ValueDate = valueDate.Value
                                    };
                                }

                                submittable.Add(new RFCatalogEntryDTO(doc));
                            }
                        }
                    }
                }

                using (var rfService = new RFServiceClient())
                {
                    RFProcessingTrackerHandle trackerKey = null;
                    trackerKey = rfService.RFService.SubmitAndProcess(submittable, new RFUserLogEntry
                    {
                        Action       = "Upload Files",
                        Description  = String.Format("Uploaded {0} files for processing", submittable.Count),
                        IsUserAction = true,
                        IsWarning    = false,
                        Processor    = null,
                        ValueDate    = valueDate.HasValue ? valueDate.Value : RFDate.NullDate,
                        Username     = Username
                    });
                    //lock (sSync)
                    {
                        AddModelToCache(processKey, new ProcessingModel
                        {
                            Tracker       = trackerKey,
                            ProcessingKey = processKey,
                            ReturnUrl     = returnUrl
                        });
                    }
                    return(RedirectToAction("ProcessingStatus", new { processKey = processKey }));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(this, "SubmitFiles", ex);
                return(Error("InputFiles", "System", null, "Error submitting files: {0}", ex.Message));
            }
        }
Example #7
0
        public ActionResult SubmitFile(
            string fileKey,
            HttpPostedFileBase fileData,
            RFDate?valueDate,
            string returnUrl = null,
            string instance  = null)
        {
            try
            {
                if (fileData == null && Request.Files != null && Request.Files.Count > 0)
                {
                    fileData = Request.Files[0];
                }
                var uniqueKey = String.Format("{0}_web", DateTime.Now.ToString("yyyyMMdd_HHmmss"));
                if (fileData == null || fileData.FileName == null || fileData.InputStream == null)
                {
                    throw new RFSystemException(this, "No file submitted.");
                }

                var fileName = Path.GetFileName(fileData.FileName);

                var newFileEntry = RFDocument.Create(
                    RFFileKey.Create(
                        EngineConfig.KeyDomain,
                        RFEnum.FromString(fileKey),
                        uniqueKey),
                    new RFFile
                {
                    Attributes = new RFFileTrackedAttributes
                    {
                        FileName     = fileName,
                        FullPath     = fileData.FileName,
                        FileSize     = fileData.ContentLength,
                        ModifiedDate = DateTime.Now
                    },
                    Data      = RFStreamHelpers.ReadBytes(fileData.InputStream),
                    FileKey   = RFEnum.FromString(fileKey),
                    ValueDate = valueDate,
                    UniqueKey = uniqueKey
                });

                // the file will have graph instance attached
                if (instance.NotBlank() && valueDate.HasValue)
                {
                    newFileEntry.Key.GraphInstance = new RFGraphInstance
                    {
                        Name      = instance,
                        ValueDate = valueDate.Value
                    };
                }

                using (var rfService = new RFServiceClient())
                {
                    RFProcessingTrackerHandle trackerKey = null;
                    trackerKey = rfService.RFService.SubmitAndProcess(new List <RFCatalogEntryDTO> {
                        new RFCatalogEntryDTO(newFileEntry)
                    }, new RFUserLogEntry
                    {
                        Action       = "Upload File",
                        Description  = String.Format("Uploaded file {0} for processing", fileName),
                        IsUserAction = true,
                        IsWarning    = false,
                        Processor    = null,
                        ValueDate    = valueDate.HasValue ? valueDate.Value : RFDate.NullDate,
                        Username     = Username
                    });
                    //lock (sSync)
                    {
                        AddModelToCache(uniqueKey, new ProcessingModel
                        {
                            Tracker       = trackerKey,
                            ProcessingKey = uniqueKey,
                            FileKey       = fileKey,
                            FileName      = fileName,
                            FileSize      = fileData.ContentLength,
                            ReturnUrl     = returnUrl
                        });
                    }
                    return(RedirectToAction("ProcessingStatus", new { processKey = uniqueKey }));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(this, "SubmitFile", ex);
                return(Error("InputFiles", "System", null, "Error submitting file: {0}", ex.Message));
            }
        }
Example #8
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
             }));
         }
     }
 }
Example #9
0
 public RFProcessingTracker GetStatus(RFProcessingTrackerHandle trackerHandle)
 {
     return(GetService().GetProcessStatus(trackerHandle));
 }