Ejemplo n.º 1
0
        /// <inheritdoc />
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _currentStopwatch = Stopwatch.StartNew();

            if (filterContext.HttpContext.Request.Url != null)
            {
                RequestUrl = filterContext.HttpContext.Request.Url.ToString();
            }
            if (RequestUrl != null)
            {
                EnableAccessLog = true;
            }
            if (EnableAccessLog && (ExcludeUrlPrefixs != null) && (ExcludeUrlPrefixs.Length > 0))
            {
                foreach (var prefix in ExcludeUrlPrefixs)
                {
                    if (RequestUrl.ToLower().StartsWith(prefix.ToLower()))
                    {
                        EnableAccessLog = false;
                        break;
                    }
                }
            }
            if (EnableAccessLog && (AccessUrlPrefixs != null) && (AccessUrlPrefixs.Length > 0))
            {
                foreach (var prefix in AccessUrlPrefixs)
                {
                    if (RequestUrl.ToLower().StartsWith(prefix.ToLower()))
                    {
                        EnableAccessLog = true;
                        break;
                    }
                }
            }
            if (EnableAccessLog)
            {
                Action          = filterContext.ActionDescriptor.ActionName;
                HttpMethod      = filterContext.HttpContext.Request.HttpMethod;
                Controller      = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
                ClientIpAddress = filterContext.HttpContext.GetClientIpAddress();
                BrowserInfo     = filterContext.HttpContext.GetBrowserInfo();
            }
            base.OnActionExecuting(filterContext);
        }
Ejemplo n.º 2
0
        private ReportExecution initReportExecution(Report report, string viewGUID, string outputGUID, bool toResult)
        {
            Repository repository = report.Repository;

            report.ExecutionContext = toResult ? ReportExecutionContext.WebOutput : ReportExecutionContext.WebReport;
            report.SecurityContext  = WebUser;
            report.CurrentViewGUID  = report.ViewGUID;

            //Init Pre Input restrictions
            report.PreInputRestrictions.Clear();
            foreach (string key in Request.Form.Keys)
            {
                report.PreInputRestrictions.Add(key, Request.Form[key]);
            }
            foreach (string key in Request.Query.Keys)
            {
                report.PreInputRestrictions.Add(key, Request.Query[key]);
            }

            //execute to output
            if (!string.IsNullOrEmpty(outputGUID))
            {
                report.OutputToExecute = report.Outputs.FirstOrDefault(i => i.GUID == outputGUID);
                if (report.OutputToExecute == null)
                {
                    throw new Exception("Invalid report output to execute");
                }
                if (!report.OutputToExecute.PublicExec && !string.IsNullOrEmpty(report.OutputToExecute.UserName) && WebUser.Name != report.OutputToExecute.UserName)
                {
                    throw new Exception("This output is not public and can only be executed by:" + report.OutputToExecute.UserName);
                }
                report.ExecutionContext = ReportExecutionContext.WebOutput;
                report.CurrentViewGUID  = report.OutputToExecute.ViewGUID;
            }

            //execute with custom view
            if (!string.IsNullOrEmpty(viewGUID))
            {
                report.CurrentViewGUID = viewGUID;
            }

            ReportExecution execution = new ReportExecution()
            {
                Report = report
            };

            setSessionValue(report.ExecutionGUID, execution);
            int index = RequestUrl.ToLower().IndexOf("swexecutereport");

            if (index == -1)
            {
                throw new Exception("Invalid URL");
            }
            report.WebUrl = GetWebUrl(Request, Response);
            repository.WebApplicationPath = RequestPhysicalApplicationPath;

            //Purge temp files here
            FileHelper.PurgeTempApplicationDirectory();

            report.InitForExecution();
            initInputRestrictions(execution, report);
            //Apply input restrictions if any
            if (report.InputRestrictions.Count > 0)
            {
                execution.CheckInputRestrictions();
            }

            return(execution);
        }
Ejemplo n.º 3
0
 public virtual bool ShouldHandleRequest(HttpRequest request)
 {
     return(request.Path.ToString().ToLower() == RequestUrl.ToLower() && request.Method.ToLower() == RequestMethod.ToLower());
 }