Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
 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));
     }
 }
Exemplo n.º 3
0
 public AjaxController(IAjaxService _ajaxService, IClanService _clanService, IPlanIProgramService _planIProgramService, IWebShopService _webShopService)
 {
     ajaxService         = _ajaxService;
     clanService         = _clanService;
     planIProgramService = _planIProgramService;
     webShopService      = _webShopService;
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
        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));
            }
        }
Exemplo n.º 6
0
 public void RemoveHandler(IAjaxService service)
 {
     handlers.Remove(service.Name);
 }
Exemplo n.º 7
0
 public void AddHandler(IAjaxService service)
 {
     handlers[service.Name] = service;
 }
Exemplo n.º 8
0
 public AjaxRequestDispatcher(ISecurityManager security, IAjaxService[] ajaxHandler)
 {
     this.security = security;
     foreach (var handler in ajaxHandler)
         AddHandler(handler);
 }
Exemplo n.º 9
0
 public void RemoveHandler(IAjaxService service)
 {
     handlers.Remove(service.ServiceName);
 }
Exemplo n.º 10
0
 public void AddHandler(IAjaxService service)
 {
     handlers[service.Name] = service;
 }