public void ExecuteDashboardTask(DashboardItemInfo dashboardTaskInfo) { try { var dashboardGuid = dashboardTaskInfo.DashboardGuid.ToString() .Replace("-", "_").ToLower(); var classTypeName = (string.Format(@"_{0}", dashboardGuid)); Type dashboardClassType; if (!DashboardTaskClassTypes.TryGetValue(classTypeName, out dashboardClassType)) { throw new UnknownWorkerTaskTypeException(string.Format(@"A Class Type could not be found in the loaded modules to instantiate " + @"the dashboard task for execution. Dashboard Task GUID {0}." + @"(Have you registered all your modules? Please see " + @"""CloudCore.Deployment.VirtualWorker.Worker.RegisterWorkerModules()"" " + @"for more information.)", dashboardTaskInfo.DashboardGuid)); } var dashboardTask = ((IScheduledTask)Activator.CreateInstance(dashboardClassType)); dashboardTask.Execute(); UpdateDashboardTask(dashboardTaskInfo, DashboardTaskStatus.Pending); } catch (Exception ex) { try { var exceptionMessage = FlattenExceptionsIntoOneMessage(ex); DashboardTaskFailed(dashboardTaskInfo, exceptionMessage); } finally { Logger.Info(ex.Message, OperationContext.LoggingCategory); ExitStrategy.Quitting = true; } } }
private void DashboardTaskFailed(DashboardItemInfo dashboardTaskInfo, string failureReason) { using (var database = new CloudCoreDB()) { database.Cloudcore_DashboardFailed(dashboardTaskInfo.DashboardId, failureReason, (byte)DashboardTaskStatus.Failed); } }
private void UpdateDashboardTask(DashboardItemInfo dashboardTaskInfo, DashboardTaskStatus status) { OperationContext.ThreadSafeDataAccess.DataAccessOperation(() => { using (var database = new CloudCoreDB()) { database.Cloudcore_DashboardTaskUpdate( dashboardTaskInfo.DashboardId, (byte)status); } }); }