/// <summary> /// Explicit algorithm for trying to handle an error ticket. /// </summary> public override void TryHandleTicket(ErrorTicket ticket) { bool handled = false; // 1) Try local support if (!handled) { handled = _localSupport.TryHandle(ticket); } // 2) Try national support if (!handled) { handled = _nationalSupport.TryHandle(ticket); } // 3) Try regional support (must translate ticket to English first) if (!handled) { _translatorService.TranslateToEnglish(ticket); handled = _regionalSupport.TryHandle(ticket); } // 4) Try world support (ticket has already been translated) if (!handled) { handled = _worldSupport.TryHandle(ticket); } // 5) If all else fails, add to unhandled ticket list if (!handled) { UnhandledTickets.Add(ticket); } }
public override void TryHandleTicket(ErrorTicket ticket) { if (_handler == null) { throw new ArgumentException("SupportCenterCoR::TryHandleTicket -> Handler not set!"); } _handler.Handle(ticket); }
/// <summary> /// Try to handle all open tickets. After calling this method, it should hold that: /// 1) No tickets are in the Open list /// 2) Tickets successfully handled are in the Closed list /// 3) Tickets unsuccessfully handled are in the Unhandled list /// </summary> public void HandleOpenTickets() { while (OpenTicketCount > 0) { // Take a ticket from the list ErrorTicket ticket = OpenTickets[OpenTicketCount - 1]; OpenTickets.RemoveAt(OpenTicketCount - 1); // Try to handle it TryHandleTicket(ticket); } }
/// <summary> /// General algorithm for trying to handle a single error ticket. /// If a ticket can be handled, it is set to Solved, and placed /// in the list of Closed error tickets. /// </summary> public bool TryHandle(ErrorTicket ticket) { bool canHandle = CanHandle(ticket); if (canHandle) { ticket.Level = ErrorLevel.Solved; _supportCenter.ClosedTickets.Add(ticket); } return(canHandle); }
/// <summary> /// General algorithm for how a support handler class /// handles an error ticket. /// </summary> public virtual void Handle(ErrorTicket ticket) { // First try to handle the ticket, by calling (abstract) TryHandle if (!TryHandle(ticket)) { // TryHandle failed, try to forward ticket if (CanForward(ticket)) { Forward(ticket); } else { UnhandledAction(ticket); } } }
/// <summary> /// Defines response to not being able to handle the ticket. /// Can be overrided in derived classes. /// </summary> public virtual void UnhandledAction(ErrorTicket ticket) { throw new ArgumentException($"SupportHandlerBase::Handle -> Could not handle ticket: {ticket}"); }
/// <summary> /// Specific algorithms for trying to handle a ticket /// must be defined in derived classes. /// </summary> public abstract bool TryHandle(ErrorTicket ticket);
/// <summary> /// Forward the ticket down the CoR /// </summary> public void Forward(ErrorTicket ticket) { _nextHandler?.Handle(ticket); }
/// <summary> /// Ticket can be forwarded if another handler /// is available down the CoR. /// </summary> public bool CanForward(ErrorTicket ticket) { return(_nextHandler != null); }
public void UnhandledAction(ErrorTicket ticket) { // Intentionally blank, cannot happen }
// Not used, since we are overriding Handle public override bool TryHandle(ErrorTicket ticket) { return(false); }
/// <summary> /// Submit a single error ticket, which will be placed /// in the list of Open tickets. /// </summary> public void SubmitTicket(ErrorTicket ticket) { _openTickets.Add(ticket); }
/// <summary> /// Specific Support Center classes need to define a specific /// algorithm for how to handle an error ticket. /// </summary> public abstract void TryHandleTicket(ErrorTicket ticket);
/// <summary> /// Specific support classes need to define specific /// criteria for being able to handle an error ticket. /// </summary> public abstract bool CanHandle(ErrorTicket ticket);
/// <summary> /// National support must handle tickets with /// 1) Level: Moderate /// 2) Any language /// </summary> public override bool CanHandle(ErrorTicket ticket) { return(ticket.Level == ErrorLevel.Moderate); }
public bool CanForward(ErrorTicket ticket) { return(false); }
/// <summary> /// Local support must handle tickets with /// 1) Level: Light /// 2) Any language /// </summary> public override bool CanHandle(ErrorTicket ticket) { return(ticket.Level == ErrorLevel.Light); }
/// <summary> /// Simulate a translation to English. /// </summary> public void TranslateToEnglish(ErrorTicket ticket) { ticket.Language = ErrorLanguage.English; }
public override void Handle(ErrorTicket ticket) { // Translate the incoming ticket, and forward it unconditionally. _translatorService.TranslateToEnglish(ticket); Forward(ticket); }
public void Handle(ErrorTicket ticket) { _supportCenter.UnhandledTickets.Add(ticket); }
/// <summary> /// World support must handle tickets with /// 1) Level: Catastrophic /// 2) English language /// </summary> public override bool CanHandle(ErrorTicket ticket) { return((ticket.Level == ErrorLevel.Catastrophic) && (ticket.Language == ErrorLanguage.English)); }
public void Forward(ErrorTicket ticket) { // Intentionally blank, cannot happen }
/// <summary> /// Try to handle ticket by delegating to ISupport implementation. /// </summary> public override bool TryHandle(ErrorTicket ticket) { return(_actualHandler.TryHandle(ticket)); }
public override bool CanHandle(ErrorTicket ticket) { return(true); }