public void OnException(ExceptionContext filterContext) { var e = filterContext.Exception; if (e is UnauthorizedAccessException) { filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.StatusCode = 403; filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; return; } var rootException = ExceptionUtil.DigRootException(e); Log.Error(rootException, e); // var errorResponse = filterContext.HttpContext.Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorDto(rootException)); filterContext.ExceptionHandled = true; filterContext.Result = new ContentResult(); var controllerName = (string)filterContext.RouteData.Values["controller"]; var actionName = (string)filterContext.RouteData.Values["action"]; var model = new HandleErrorInfo(rootException, controllerName, actionName); filterContext.ExceptionHandled = true; var result = new ViewResult { ViewData = new ViewDataDictionary <HandleErrorInfo>(model), TempData = filterContext.Controller.TempData }; filterContext.Result = result; filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.StatusCode = 200; filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; }
public virtual object InvokeProxy() { try { var result = Proxy.CallMethod(MethodName(), new[] { RootInterfaceObject.GetType() }, new[] { RootInterfaceObject }); return(result); } catch (Exception e) { var rootException = ExceptionUtil.DigRootException(e); throw rootException; } }
public override object InvokeProxy() { var arg0 = SerializeIntegrationObject(); var before = Stopwatch.StartNew(); try { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var soapEnvelopeXml = new XmlDocument(); var isChange = Metadata.Name.Equals("wochange", StringComparison.InvariantCultureIgnoreCase); var path = isChange ? MetadataProvider.GlobalProperty("globaservletpath_chg") : MetadataProvider.GlobalProperty("globaservletpath_inc"); Log.InfoFormat("PERFORMANCE - ISM WS request started at {0}.", DateTime.Now); Log.DebugFormat("Calling ISM WS on {0}. Content: {1}", path, arg0); soapEnvelopeXml.LoadXml(@arg0); var webRequest = CreateWebRequest(path); webRequest.Timeout = ApplicationConfiguration.MaximoRequestTimeout; using (Stream stream = webRequest.GetRequestStream()) { soapEnvelopeXml.Save(stream); } // begin async call to web request. var asyncResult = webRequest.BeginGetResponse(null, null); // suspend this thread until call is complete. You might want to // do something usefull here like update your UI. asyncResult.AsyncWaitHandle.WaitOne(); // get the response from the completed web request. var result = ""; using (var webResponse = webRequest.EndGetResponse(asyncResult)) { using (var rd = new StreamReader(webResponse.GetResponseStream())) { result = rd.ReadToEnd(); } } return(result); } catch (Exception e) { Log.Error("Error invoking ISM proxy", e); var rootException = ExceptionUtil.DigRootException(e); throw rootException; } finally { var msDelta = LoggingUtil.MsDelta(before); Log.InfoFormat("PERFORMANCE - ISM WS request took {0} ms to be executed.", msDelta); } }
public override void OnException(HttpActionExecutedContext context) { var e = context.Exception; HttpResponseMessage errorResponse; if (e is UnauthorizedAccessException) { errorResponse = context.Request.CreateResponse(HttpStatusCode.Forbidden); Log.Warn(e); throw new HttpResponseException(errorResponse); } var rootException = ExceptionUtil.DigRootException(e); Log.Error(rootException, e); errorResponse = context.Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorDto(rootException)); throw new HttpResponseException(errorResponse); }
public override object InvokeProxy() { var parameterList = MifUtils.GetParameterList(RootInterfaceObject); var types = new Type[parameterList.Length]; try { for (int i = 0; i < parameterList.Length; i++) { types.SetValue(parameterList.GetValue(i).GetType(), i); } var result = Proxy.CallMethod(MethodName(), types, parameterList); return(result); } catch (Exception e) { var rootException = ExceptionUtil.DigRootException(e); throw rootException; } }
public ActionResult Input([NotNull] string application, string json, ClientPlatform platform, [NotNull] string currentSchemaKey, string nextSchemaKey) { var user = SecurityFacade.CurrentUser(); Log.Info("receiving ie9 attachment request"); var currentSchema = _nextSchemaRouter.GetSchemaKeyFromString(application, currentSchemaKey, platform); var applicationMetadata = MetadataProvider .Application(application) .ApplyPolicies(currentSchema, user, ClientPlatform.Web); var queryStrings = HttpUtility.ParseQueryString(Request.UrlReferrer.Query); var popupmode = queryStrings["popupmode"]; var datamap = JObject.Parse(json); var entityId = datamap[applicationMetadata.Schema.IdFieldName].ToString(); try { PopulateFilesInJson(datamap, String.IsNullOrWhiteSpace(entityId)); PopulateInputsInJson(datamap); var mockMaximo = MockingUtils.IsMockingMaximoModeActive(datamap); IApplicationResponse response; if (String.IsNullOrWhiteSpace(entityId)) { Log.DebugFormat("redirecting to datacontroller post with datamap " + datamap); response = _dataController.Post(application, datamap, platform, currentSchemaKey, nextSchemaKey, mockMaximo); } else { Log.DebugFormat("redirecting to datacontroller put"); response = _dataController.Put(application, entityId, datamap, platform, currentSchemaKey, nextSchemaKey, mockMaximo); } return(RedirectToAction("RedirectToAction", "Home", BuildParameter(entityId, application, platform, response, popupmode, applicationMetadata))); } catch (Exception e) { var rootException = ExceptionUtil.DigRootException(e); //TODO: handle error properly Log.Error(rootException, e); return(RedirectToAction("RedirectToAction", "Home", BuildErrorParameter(entityId, application, platform, popupmode, applicationMetadata, e))); } }
internal override object FindById(Object id) { InMemoryUser curUser = SecurityFacade.CurrentUser(); Type type = _queryProxy.ProxyType; MethodInfo mi = type.GetMethod(_MethodName); ParameterInfo pi = mi.GetParameters().First(); object queryInterface = r.InstanceFromType(pi.ParameterType); var header = r.InstantiateProperty(queryInterface, "Header"); w.SetValue(header, "operation", "Query"); w.SetValue(header, "maxItems", "10"); w.SetValue(header, "rsStart", "0"); w.SetValue(header, "CreationDateTime", DateTime.Now.FromServerToRightKind()); w.SetValue(header, "SenderID", SwConstants.ExternalSystemName); w.SetValue(header, "uniqueResult", true, true); r.SetProperty(queryInterface, "Header", header); var rootQueryObject = r.InstantiateArrayReturningSingleElement(queryInterface, "Content"); object queryObject = r.InstantiateProperty(rootQueryObject, 0); w.SetQueryValue(queryObject, Metadata.Schema.IdAttribute.Name, id); try { var rawReponse = _queryProxy.CallMethod(MethodName(), new Type[] { queryInterface.GetType() }, new object[] { queryInterface }); var respArr = (Array)r.GetProperty(rawReponse, "Content"); if (respArr.Length == 0) { return(null); } var rootResponse = respArr.GetValue(0); return(r.GetProperty(rootResponse, 0)); } catch (Exception e) { var rootException = ExceptionUtil.DigRootException(e); throw rootException; } }