void heart_Beat(object sender, EventArgs e) { for (int i = 0; i < actions.Count; i++) { ScheduledAction action = actions[i]; if (action.ShouldExecute()) { action.IsExecuting = true; worker.DoWork(delegate { try { logger.Debug("Executing " + action.GetType().Name); action.Engine = engine; action.Execute(); action.ErrorCount = 0; } catch (Exception ex) { action.ErrorCount++; action.OnError(ex); // wayne: call custom action error handler } finally { try { IClosable closable = action as IClosable; if (closable != null) { closable.Dispose(); } } catch (Exception ex) { errorHandler.Notify(ex); } } action.LastExecuted = Utility.CurrentTime(); action.IsExecuting = false; try { context.Close(); } catch (Exception ex) { errorHandler.Notify(ex); } }); if (action.Repeat == Repeat.Once) { actions.RemoveAt(i); --i; } } } }
public virtual PathData ResolveUrl(Url url) { try { var path = parser.FindPath(url.RemoveDefaultDocument(Url.DefaultDocument).RemoveExtension(observedExtensions)); path.CurrentItem = path.CurrentPage; if (draftRepository.Versions.TryParseVersion(url[PathData.VersionQueryKey], url["versionKey"], path)) { return(path); } string viewPreferenceParameter = url.GetQuery(WebExtensions.ViewPreferenceQueryString); if (viewPreferenceParameter == WebExtensions.DraftQueryValue && draftRepository.HasDraft(path.CurrentItem)) { var draft = draftRepository.Versions.GetVersion(path.CurrentPage); path.TryApplyVersion(draft, url["versionKey"]); } return(path); } catch (Exception ex) { errorHandler.Notify(ex); } return(PathData.Empty); }
/// <summary> /// Install languages from the given xml file /// </summary> /// <param name="languagesXmlFileLocation">The languages XML file location.</param> public void Install(string languagesXmlFileLocation) { // Let's first delete everything _languageService.DeleteAll(); var languages = _languageFileParser.DeserializeLanguagesFile(languagesXmlFileLocation); try { foreach (var language in languages) { // insert the language _languageService.InsertLanguage(language.First); // update all the resources with the new id of the language Array.ForEach(language.Second.ToArray(), (resource) => resource.LanguageId = language.First.Id); // batch insert them! _localizationService.InsertLocaleStringResources(language.Second.ToArray()); } } catch (Exception ex) { Trace.WriteLine("Problem installing languages. " + ex.Message); _errorNotifier.Notify(ex); } }
private void AppendError(Action original, Exception ex) { errors.Notify(ex); lock (errorQueue) { errorQueue.Enqueue(original); } }
protected virtual void Application_Error(object sender, EventArgs e) { var application = sender as HttpApplication; if (application != null) { Exception ex = application.Server.GetLastError(); if (ex != null && new HttpException(null, ex).GetHttpCode() != 404) // we should not notify 404 errors, otherwise, the maxErrorReportsPerHour limit will soon be exceeds. { errors.Notify(ex); } } }
public void ConvertTo_WhenFailed_NotSuccessful() { _workflowResult = WorkflowResult.Error; var printJobAdapter = BuildPrintJobAdapter(); _directory.Exists("X:\\").Returns(true); _conversionWorkflow.When(x => x.RunWorkflow(_job)).Do(x => { _errorNotifier.Notify(new ActionResult(ErrorCode.Conversion_UnknownError)); }); Assert.Throws <COMException>(() => printJobAdapter.ConvertTo("X:\\test.pdf")); Assert.IsTrue(printJobAdapter.IsFinished); Assert.IsFalse(printJobAdapter.IsSuccessful); }
public virtual PathData ResolveUrl(Url url) { try { if (IsObservable(url)) { return(parser.ResolvePath(url.RemoveDefaultDocument(Url.DefaultDocument).RemoveExtension(observedExtensions))); } } catch (Exception ex) { errorHandler.Notify(ex); } return(PathData.Empty); }
void HeartBeat(object sender, EventArgs e) { for (int i = 0; i < _actions.Count; i++) { ScheduledAction action = _actions[i]; if (action.ShouldExecute()) { action.IsExecuting = true; _worker.DoWork(delegate { try { Debug.WriteLine("Executing " + action.GetType().Name); action.Execute(); action.ErrorCount = 0; } catch (Exception ex) { action.ErrorCount++; action.OnError(ex); } finally { try { var closable = action as IClosable; if (closable != null) { closable.Dispose(); } } catch (Exception ex) { _errorHandler.Notify(ex); } } action.LastExecuted = CommonHelper.CurrentTime(); action.IsExecuting = false; }); if (action.Repeat == Repeat.Once) { _actions.RemoveAt(i); --i; } } } }
private ActionResult CreateUser(UserRegistrationModel model) { string un = model.RegisterUserName; string pw = model.RegisterPassword; Membership.CreateUser(un, pw, model.RegisterEmail); Roles.AddUserToRoles(un, CurrentItem.Roles.ToArray <string>()); MembershipUser user = Membership.GetUser(un); if (CurrentItem.RequireVerification) { user.IsApproved = false; Membership.UpdateUser(user); string crypto = FormsAuthentication.Encrypt(new FormsAuthenticationTicket(un, true, 60 * 24 * 7)); var route = new UrlHelper(ControllerContext.RequestContext).Action("verify", new { item = CurrentItem, ticket = crypto }); var url = new Url(Request.Url.Scheme, Request.Url.Authority, route); string subject = CurrentItem.VerificationSubject; string body = CurrentItem.VerificationText.Replace("{VerificationUrl}", url); try { mailSender.Send(CurrentItem.VerificationSender, model.RegisterEmail, subject, body); if (CurrentItem.SuccessPage != null) { return(Redirect(CurrentItem.SuccessPage.Url)); } } catch (InvalidOperationException ex) { ModelState.AddModelError("general", ex.Message); errorHandler.Notify(ex); return(ViewParentPage()); } } else if (CurrentItem.SuccessPage != null) { return(Redirect(CurrentItem.SuccessPage.Url)); } return(ViewParentPage()); }
private void AppendError(Work work, Exception ex) { logger.Error("Error while processing " + work.Name); errors.Notify(ex); lock (workQueue) { work.ErrorCount++; if (work.ErrorCount < maxErrorsPerWorkItem) { workQueue.Enqueue(work); } else { logger.WarnFormat("Maximum numer of errors per work item ({0}) reached, dropping work '{1}'", work.ErrorCount, work.Name); } } }
public virtual PathData ResolveUrl(Url url) { // simple cache to help with multiple requests for same URL - PoC if ((lastUrl != null) && (lastUrl.Item1 == url.ToString())) { var result = lastUrl.Item2; lastUrl = null; return(result); } try { var path = parser.FindPath(url.RemoveDefaultDocument(Url.DefaultDocument).RemoveExtension(observedExtensions)); path.CurrentItem = path.CurrentPage; if (draftRepository.Versions.TryParseVersion(url[PathData.VersionIndexQueryKey], url["versionKey"], path)) { lastUrl = new Tuple <string, PathData>(url, path); return(path); } string viewPreferenceParameter = url.GetQuery(WebExtensions.ViewPreferenceQueryString); if (viewPreferenceParameter == WebExtensions.DraftQueryValue && draftRepository.HasDraft(path.CurrentItem)) { var draft = draftRepository.Versions.GetVersion(path.CurrentPage); path.TryApplyVersion(draft, url["versionKey"]); } lastUrl = new Tuple <string, PathData>(url, path); return(path); } catch (Exception ex) { errorHandler.Notify(ex); } return(PathData.Empty); }
public void Notify(Exception ex) { notifier.Notify(ex); }
protected override void HandleError(ErrorCode errorCode) { _errorNotifier.Notify(new ActionResult(errorCode)); }
/// <summary>Executes the scheduled actions that are scheduled for executions.</summary> public void ExecuteActions() { if (!enabled) { return; } if (Debugger.IsAttached && !runWhileDebuggerAttached) { return; } for (int i = 0; i < actions.Count; i++) { ScheduledAction action = actions[i]; if (action.ShouldExecute()) { Action work = delegate { try { var config = ((System.Web.Configuration.GlobalizationSection)System.Configuration.ConfigurationManager.GetSection("system.web/globalization")); if (!string.IsNullOrEmpty(config.Culture)) { Thread.CurrentThread.CurrentCulture = new CultureInfo(config.Culture); } if (!string.IsNullOrEmpty(config.UICulture)) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(config.UICulture); } } catch (Exception ex) { logger.Warn(ex); } try { logger.Debug("Executing " + action.GetType().Name); action.Engine = engine; action.Execute(); action.ErrorCount = 0; } catch (Exception ex) { action.ErrorCount++; action.OnError(ex); // wayne: call custom action error handler } finally { try { IClosable closable = action as IClosable; if (closable != null) { closable.Dispose(); } } catch (Exception ex) { errorHandler.Notify(ex); } } action.LastExecuted = Utility.CurrentTime(); action.IsExecuting = false; try { context.Close(); } catch (Exception ex) { errorHandler.Notify(ex); } }; action.IsExecuting = true; if (asyncActions) { worker.DoWork(work); } else { work(); } if (action.Repeat == Repeat.Once) { actions.RemoveAt(i); --i; } } } }