public virtual void Handle(HttpContextBase context) { try { string action = context.Request["action"]; if (!Handlers.ContainsKey(action)) { throw new InvalidOperationException("Couln't find any handler for the action: " + action); } IAjaxService service = Handlers[action]; if (service.RequiresEditAccess && !security.IsEditor(context.User)) { throw new PermissionDeniedException(null, context.User); } if (!service.IsValidHttpMethod(context.Request.HttpMethod)) { throw new HttpException((int)HttpStatusCode.MethodNotAllowed, "This service requires HTTP POST method"); } service.Handle(context); } catch (Exception ex) { context.Response.Status = ((int)HttpStatusCode.InternalServerError).ToString() + " Internal Server Error"; context.Response.Write(WriteException(ex, context.User)); } }
public virtual string Handle(IRequestParameters requestparams) { try { string action = requestparams.ServiceName; //get the IAjaxService and perform the action if (Handlers.ContainsKey(action)) { IAjaxService service = Handlers[action]; //TODO: Add a security check here object responseobject = service.Handle(requestparams); if (responseobject != null) { return(TransformResponse(responseobject, service.OutputType)); } else { return(null); } } else { throw new CuyahogaAjaxException("Couln't find any handler for the action: " + action); } } catch (Exception ex) { return(String.Concat(ex.Message, " stacktrace:", ex.StackTrace)); } }
public AjaxController(IAjaxService _ajaxService, IClanService _clanService, IPlanIProgramService _planIProgramService, IWebShopService _webShopService) { ajaxService = _ajaxService; clanService = _clanService; planIProgramService = _planIProgramService; webShopService = _webShopService; }
public void AddHandler(IAjaxService service) { try { if (!handlers.ContainsKey(service.ServiceName)) { handlers[service.ServiceName] = service; } else { throw new CuyahogaAjaxException("Cannot add ajaxservice to dispatcher"); } } catch (Exception ex) { throw new CuyahogaAjaxException("Can not add ajaxservice to dispacther", ex); } }
public virtual string Handle(HttpContext context) { try { string action = context.Request["action"]; if (Handlers.ContainsKey(action)) { IAjaxService service = Handlers[action]; if (service.RequiresEditAccess && !security.IsEditor(context.User)) { throw new PermissionDeniedException(null, context.User); } string responseText = service.Handle(context.Request.QueryString); return(responseText); } throw new N2Exception("Couln't find any handler for the action: " + action); } catch (Exception ex) { return(WriteException(ex, context.User)); } }
public void RemoveHandler(IAjaxService service) { handlers.Remove(service.Name); }
public void AddHandler(IAjaxService service) { handlers[service.Name] = service; }
public AjaxRequestDispatcher(ISecurityManager security, IAjaxService[] ajaxHandler) { this.security = security; foreach (var handler in ajaxHandler) AddHandler(handler); }
public void RemoveHandler(IAjaxService service) { handlers.Remove(service.ServiceName); }