init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
176
KretaWeb/App_Start/ApiCustomExceptionAttribute.cs
Normal file
176
KretaWeb/App_Start/ApiCustomExceptionAttribute.cs
Normal file
|
@ -0,0 +1,176 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web;
|
||||
using System.Web.Http.Filters;
|
||||
using Kreta.Core.Enum;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Core.Validation.Exceptions;
|
||||
using Kreta.Core.Validation.Exceptions.Enum;
|
||||
using Kreta.Core.Validation.Extensions;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Framework.Entities;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Helpers.Error;
|
||||
using Kreta.Web.Logging.Extensions;
|
||||
using Kreta.Web.Logging.Logger;
|
||||
|
||||
namespace Kreta.Web.App_Start
|
||||
{
|
||||
public class ApiCustomExceptionAttribute : ExceptionFilterAttribute
|
||||
{
|
||||
public override void OnException(HttpActionExecutedContext context)
|
||||
{
|
||||
Guid? logId;
|
||||
if (Areas.MobileApi.ModelConverter.MobileUserModelConverter.TryLoadFromHttpContext(out _))
|
||||
{
|
||||
HandleMobilExeptionFormat(context, out logId);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleWebExeptionFormat(context, out logId);
|
||||
}
|
||||
|
||||
if (logId.HasValue)
|
||||
{
|
||||
if (!context.Exception.Data.Contains(RequestResponseLoggingFields.Server.ExceptionId))
|
||||
{
|
||||
context.Exception.Data.Add(RequestResponseLoggingFields.Server.ExceptionId, logId);
|
||||
}
|
||||
|
||||
HttpContext.Current.AddException(context.Exception);
|
||||
}
|
||||
}
|
||||
|
||||
private bool HandleMobilExeptionFormat(HttpActionExecutedContext context, out Guid? logId)
|
||||
{
|
||||
logId = null;
|
||||
if (context.Exception is ValidationException vException)
|
||||
{
|
||||
context.Response = context.Request.CreateResponse(vException.GetHttpStatusCode(), vException);
|
||||
return false;
|
||||
}
|
||||
if (context.Exception is BlException blException)
|
||||
{
|
||||
var validationErrorType = GetValidationErrorTypeByBlExceptionType(blException.ExceptionType);
|
||||
|
||||
var validationException = new ValidationException(validationErrorType, blException.Message);
|
||||
context.Response = context.Request.CreateResponse(validationException.GetHttpStatusCode(), validationException);
|
||||
|
||||
return false;
|
||||
}
|
||||
if (context.Exception is StatusError statusError)
|
||||
{
|
||||
bool logException = false;
|
||||
if (statusError.UnHandledException != null)
|
||||
{
|
||||
logId = LogInDb(statusError.UnHandledException, context.Request.Headers.Host);
|
||||
logException = true;
|
||||
}
|
||||
|
||||
if (statusError.StatusCode != (int)HttpStatusCode.InternalServerError || !logException)
|
||||
{
|
||||
var validationException = new ValidationException(ValidationErrorType.Undefined, statusError.Message);/*TODO:statuskód átadása jelenleg nincs rá ehetőség*/
|
||||
context.Response = context.Request.CreateResponse(validationException.GetHttpStatusCode(), validationException);
|
||||
}
|
||||
else
|
||||
{
|
||||
var generalExeption = new Exception(StringResourcesUtil.GetString(45));
|
||||
context.Response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, generalExeption);
|
||||
}
|
||||
|
||||
return logException;
|
||||
}
|
||||
|
||||
if (context.Exception is EntityNotFoundException)
|
||||
{
|
||||
logId = LogInDb(context.Exception, context.Request.Headers.Host);
|
||||
var validationException = new ValidationException(ValidationErrorType.ResourceNotFound, ErrorResource.AzElemNemTalalhato);
|
||||
context.Response = context.Request.CreateResponse(validationException.GetHttpStatusCode(), validationException);
|
||||
return true;
|
||||
}
|
||||
|
||||
logId = LogInDb(context.Exception, context.Request.Headers.Host);
|
||||
var exception = new Exception(StringResourcesUtil.GetString(45));
|
||||
context.Response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, exception);
|
||||
return true;
|
||||
}
|
||||
|
||||
private ValidationErrorType GetValidationErrorTypeByBlExceptionType(BlExceptionType exceptionType)
|
||||
{
|
||||
if (exceptionType == BlExceptionType.IntezmenyMarTanevetValtott)
|
||||
{
|
||||
return ValidationErrorType.IntezmenyMarTanevetValtott;
|
||||
}
|
||||
|
||||
return ValidationErrorType.Undefined;
|
||||
}
|
||||
|
||||
private bool HandleWebExeptionFormat(HttpActionExecutedContext context, out Guid? logId)
|
||||
{
|
||||
logId = null;
|
||||
|
||||
if (context.Exception is StatusError)
|
||||
{
|
||||
var ex = context.Exception as StatusError;
|
||||
bool logException = false;
|
||||
if (ex.UnHandledException != null)
|
||||
{
|
||||
logId = LogInDb(ex.UnHandledException, context.Request.Headers.Host);
|
||||
logException = true;
|
||||
}
|
||||
|
||||
context.Response = context.Request.CreateResponse((HttpStatusCode)ex.StatusCode, new ErrorModel
|
||||
{
|
||||
Message = ex.Message,
|
||||
Json = ex.Json,
|
||||
Status = ex.StatusCode,
|
||||
IsMvc = false,
|
||||
ErrorCode = logId,
|
||||
CloseFunction = ex.CloseFunction
|
||||
});
|
||||
|
||||
return logException;
|
||||
}
|
||||
|
||||
if (context.Exception is ValidationException)
|
||||
{
|
||||
var ex = context.Exception as ValidationException;
|
||||
var text = string.Empty;
|
||||
foreach (var error in ex.ValidationItems)
|
||||
{
|
||||
text = text + Environment.NewLine + error.Message;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
text = ex.Message;
|
||||
}
|
||||
|
||||
context.Response = context.Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorModel
|
||||
{
|
||||
Message = text,
|
||||
Status = (int)HttpStatusCode.BadRequest,
|
||||
IsMvc = false,
|
||||
ErrorCode = logId
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
logId = LogInDb(context.Exception, context.Request.Headers.Host);
|
||||
context.Response = context.Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorModel
|
||||
{
|
||||
Message = StringResourcesUtil.GetString(45)/*Hiba történt az oldalon*/,
|
||||
Status = (int)HttpStatusCode.InternalServerError,
|
||||
IsMvc = false,
|
||||
ErrorCode = logId
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Guid? LogInDb(Exception ex, string host)
|
||||
{
|
||||
return SDAServer.Instance.Logger.ExceptionThrown(ex, host);
|
||||
}
|
||||
}
|
||||
}
|
248
KretaWeb/App_Start/BundleConfig.cs
Normal file
248
KretaWeb/App_Start/BundleConfig.cs
Normal file
|
@ -0,0 +1,248 @@
|
|||
using System.Web.Optimization;
|
||||
|
||||
namespace Kreta.Web.Areas
|
||||
{
|
||||
public class BundleConfig
|
||||
{
|
||||
public static void RegisterBundles(BundleCollection bundles)
|
||||
{
|
||||
bundles.Add(new ScriptBundle("~/bundles/kreta").Include(
|
||||
"~/Scripts/_MasterLayout.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
|
||||
"~/libs/modernizr/modernizr.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
|
||||
"~/libs/kendo/jszip.min.js",
|
||||
"~/libs/kendo/kendo.all.js",
|
||||
"~/libs/kendo/kendo.aspnetmvc.js",
|
||||
"~/libs/kendo/kendo.culture.hu-HU.js",
|
||||
"~/Scripts/KendoHelper/KretaMaskedDatepicker.js",
|
||||
"~/Scripts/KendoHelper/KretaMaskedDateTimepicker.js",
|
||||
"~/Scripts/KendoHelper/KretaMaskedTimepicker.js",
|
||||
"~/Scripts/KendoHelper/kendo.messages.hu-HU.js"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/App_Themes/css").Include(
|
||||
"~/libs/fullcalendar/fullcalendar.css",
|
||||
"~/Content/custom-fullcalendar.css",
|
||||
"~/App_Themes/Skin_Kreta_Gfx/jquery-ui.css",
|
||||
"~/App_Themes/Skin_Kreta_Gfx/jquery.datepicker.css",
|
||||
"~/App_Themes/Skin_Kreta_Gfx/jquery.widget.css",
|
||||
"~/App_Themes/Skin_Kreta_Gfx/skin_kreta_gfx.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/css").Include(
|
||||
"~/libs/font-awesome/css/font-awesome.css",
|
||||
"~/Content/Site.css",
|
||||
"~/libs/bootstrap/css/bootstrap.css",
|
||||
"~/Content/bootstrap-big-grid.css",
|
||||
"~/Content/pdfExport.css",
|
||||
"~/Content/KendoBootstrapFix.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/kretaCss").Include(
|
||||
"~/Content/wkretaMVC.css",
|
||||
"~/Content/ugyfelszolgalat.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/kretaMobileCss").Include(
|
||||
"~/Content/wkretaMVC_mobile.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/Faliujsag").Include(
|
||||
"~/Content/faliujsagertesites.css",
|
||||
"~/Content/faliujsag.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/Ertesitesek").Include(
|
||||
"~/Content/faliujsagertesites.css",
|
||||
"~/Content/ertesitesek.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/JqueryContext").Include(
|
||||
"~/libs/jquery-contextmenu/jquery.contextMenu.css"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/JqueryContext").Include(
|
||||
"~/libs/jquery-contextmenu/jquery.ui.postition.js",
|
||||
"~/libs/jquery-contextmenu/jquery.contextMenu.js"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/RendszerHibaErtesitesek").Include(
|
||||
"~/Content/rendszerHibaErtesitesek.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle(Constants.General.TanuloErtekelesCSS).Include(
|
||||
"~/Content/tanuloertekeles.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle(Constants.General.ImportExportCSS).Include(
|
||||
"~/Content/importExport.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle(Constants.General.HRModulCSS).Include(
|
||||
"~/Content/hrmodul.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle(Constants.General.FeljegyzesekCSS).Include(
|
||||
"~/Content/feljegyzesek.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/Termekportal").Include(
|
||||
"~/Content/termekportal.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/Nyomtatvanyok").Include(
|
||||
"~/Content/nyomtatvanyok.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle(Constants.General.KretaEditorCSS).Include(
|
||||
Constants.General.KretaEditorCSS
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/Mulasztasok").Include(
|
||||
"~/Content/mulasztasok.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/NaplozasAutoFeljegyzes").Include(
|
||||
"~/Content/naplozasAutoFeljegyzes.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/kretaControls").Include(
|
||||
"~/Content/KendoHelper/KretaGrid.css",
|
||||
"~/Content/KendoHelper/KretaWindow.css",
|
||||
"~/Content/KendoHelper/KretaSearchPanel.css",
|
||||
"~/Content/KendoHelper/KretaValidation.css",
|
||||
"~/Content/KendoHelper/KretaSwitchButton.css",
|
||||
"~/Content/KendoHelper/KretaCheckBox.css",
|
||||
"~/Content/KendoHelper/KretaLabel.css",
|
||||
"~/Content/KendoHelper/KretaTooltip.css",
|
||||
"~/Content/KendoHelper/KretaTimepicker.css"
|
||||
));
|
||||
|
||||
bundles.Add(new StyleBundle("~/Content/nexius").Include(
|
||||
"~/Content/nexius.css"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
|
||||
"~/libs/jquery/jquery.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
|
||||
"~/libs/bootstrap/js/bootstrap.js",
|
||||
"~/libs/pako/pako_deflate.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/js").Include(
|
||||
"~/Scripts/Common.js",
|
||||
"~/Scripts/AjaxHelper.js",
|
||||
"~/Scripts/SearchPanelHelper.js",
|
||||
"~/Scripts/jquery-serializeObject.js",
|
||||
"~/libs/jquery-ui/jquery-ui.js",
|
||||
"~/libs/jquery-validate/jquery.validate.js",
|
||||
"~/libs/jquery-validate/localization/messages_hu.js",
|
||||
"~/libs/jquery-validate-unobtrusive/jquery.validate.unobtrusive.js",
|
||||
"~/Scripts/mvcfoolproof.unobtrusive.min.js",
|
||||
"~/libs/jquery-validate/additional-methods.js",
|
||||
"~/libs/jquery-cookie/jquery.cookie.js",
|
||||
"~/Scripts/jquery.tmpl.js",
|
||||
"~/libs/multiselect/dist/js/multiselect.js",
|
||||
"~/Scripts/SessionHandler.js",
|
||||
"~/Scripts/KendoHelper/KretaForm.js",
|
||||
"~/Scripts/JiraRestHelper.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/ErrorHandler").Include(
|
||||
"~/Scripts/ErrorHandler.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/KendoGrid").Include(
|
||||
"~/Scripts/KendoHelper/KretaGridHelper.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaImportGridHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaImportGridHelper.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/OsztalyCsoportbaSorolas").Include(
|
||||
"~/Scripts/OsztalyCsoportbaSorolas.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaWindowHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaWindowHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaDateTimeHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaDateTimeHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaTooltipHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaTooltipHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaSwitchButtonHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaSwitchButtonHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaComboBoxHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaComboBoxHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaMultiSelectHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaMultiSelectHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaCheckBoxHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaCheckBoxHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaDropDownListHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaDropDownListHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaPanelBarHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaPanelBarHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaRadioButtonListHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaRadioButtonListHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaOsztalybaSorolasHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaOsztalybaSorolasHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaFileUpload").Include(
|
||||
"~/Scripts/KendoHelper/KretaFileUpload.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaWizard").Include(
|
||||
"~/Scripts/KendoHelper/KretaWizard.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/KretaNumericHelper").Include(
|
||||
"~/Scripts/KendoHelper/KretaNumericHelper.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/Calendar").Include(
|
||||
"~/libs/fullcalendar/fullcalendar.js",
|
||||
"~/libs/fullcalendar/lang/hu.js",
|
||||
"~/Scripts/SDAFullCalendar.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/moment").Include(
|
||||
"~/libs/moment/moment-with-locales.js",
|
||||
"~/Scripts/setMomentLocaleToHu.js"
|
||||
));
|
||||
bundles.Add(new ScriptBundle("~/bundles/IskolaorUzenetKuldes").Include(
|
||||
"~/Scripts/IskolaorUzenetKuldes.js"));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/OsztalyBevitelVisibilityHelper").Include(
|
||||
"~/Scripts/OsztalyBevitelVisibilityHelper.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/AmiKepzesiJellemzokHelper").Include(
|
||||
"~/Scripts/AmiKepzesiJellemzokHelper.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/JegyzekAdatokHelper").Include(
|
||||
"~/Scripts/JegyzekAdatokHelper.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/document-register-element").Include(
|
||||
"~/libs/document-register-element/document-register-element.js"
|
||||
));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/KirSzinkronHelper").Include(
|
||||
"~/Scripts/KirSzinkronHelper.js"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
25
KretaWeb/App_Start/FilterConfig.cs
Normal file
25
KretaWeb/App_Start/FilterConfig.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System.Web.Http.Filters;
|
||||
using System.Web.Mvc;
|
||||
using Kreta.Web.Attributes;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.App_Start
|
||||
{
|
||||
public class FilterConfig
|
||||
{
|
||||
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
|
||||
{
|
||||
filters.Add(new MvcCustomExceptionAttribute());
|
||||
filters.Add(new MvcSessionAuthorizeAttribute());
|
||||
filters.Add(new MvcRoleClaimsAuthorizeAttribute());
|
||||
}
|
||||
|
||||
public static void RegisterGlobalApiFilters(HttpFilterCollection filters)
|
||||
{
|
||||
filters.Add(new ApiRoleClaimsAuthorizeAttribute());
|
||||
filters.Add(new ApiCustomExceptionAttribute());
|
||||
filters.Add(new KretaGlobalValidationFilter());
|
||||
filters.Add(new ApiSessionAuthorizeAttribute());
|
||||
}
|
||||
}
|
||||
}
|
160
KretaWeb/App_Start/MvcCustomExceptionAttribute.cs
Normal file
160
KretaWeb/App_Start/MvcCustomExceptionAttribute.cs
Normal file
|
@ -0,0 +1,160 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Kreta.Core.Validation.Exceptions;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Web.Helpers.Error;
|
||||
using Kreta.Web.Logging.Extensions;
|
||||
using Kreta.Web.Logging.Logger;
|
||||
|
||||
namespace Kreta.Web
|
||||
{
|
||||
public class MvcCustomExceptionAttribute : FilterAttribute, IExceptionFilter
|
||||
{
|
||||
public void OnException(ExceptionContext filterContext)
|
||||
{
|
||||
Guid? logId = null;
|
||||
if (filterContext.HttpContext.Request.Headers.AllKeys.Contains(KliensTipusEnum.Mobile.ToString()))
|
||||
{
|
||||
if (filterContext.Exception is System.Web.Http.HttpResponseException exception)
|
||||
{
|
||||
filterContext.Result = new HttpStatusCodeResult((int)exception.Response.StatusCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
filterContext.Result = new HttpStatusCodeResult((int)CustomHTTPStatusEnum.KezeletlenHiba);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var statusError = filterContext.Exception as StatusError;
|
||||
var validationError = filterContext.Exception as ValidationException;
|
||||
if (statusError != null)
|
||||
{
|
||||
filterContext.HttpContext.Response.StatusCode = statusError.StatusCode;
|
||||
|
||||
#if !DEBUG
|
||||
if (statusError.UnHandledException != null)
|
||||
{
|
||||
logId = SDAServer.Instance.Logger.ExceptionThrown(statusError.UnHandledException, filterContext.HttpContext.Request.UserHostAddress);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (statusError.Redirect != null)
|
||||
{
|
||||
filterContext.Result = new RedirectToRouteResult(statusError.Redirect);
|
||||
}
|
||||
else
|
||||
{
|
||||
filterContext.Result = new JsonResult
|
||||
{
|
||||
ContentType = "application/json",
|
||||
Data = new ErrorModel
|
||||
{
|
||||
Message = statusError.Message,
|
||||
Json = statusError.Json,
|
||||
Status = statusError.StatusCode,
|
||||
IsMvc = true,
|
||||
ErrorCode = logId
|
||||
},
|
||||
JsonRequestBehavior = JsonRequestBehavior.AllowGet
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (validationError != null)
|
||||
{
|
||||
filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||
|
||||
filterContext.Result = new JsonResult
|
||||
{
|
||||
ContentType = "application/json",
|
||||
Data = new ErrorModel
|
||||
{
|
||||
Message = validationError.Message,
|
||||
Json = string.Empty,
|
||||
Status = (int)HttpStatusCode.BadRequest,
|
||||
IsMvc = true,
|
||||
ErrorCode = logId
|
||||
},
|
||||
JsonRequestBehavior = JsonRequestBehavior.AllowGet
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !DEBUG
|
||||
logId = SDAServer.Instance.Logger.ExceptionThrown(filterContext.Exception, filterContext.HttpContext.Request.UserHostAddress);
|
||||
#endif
|
||||
if (filterContext.HttpContext.Request.IsAjaxRequest() || filterContext.HttpContext.Request.Files.Count > 0)/*a kendo file upload egy iframet postol és ajaxosan kezeli le ami megtréfálja a logikát*/
|
||||
{
|
||||
filterContext.Result = new JsonResult
|
||||
{
|
||||
ContentType = "application/json",
|
||||
Data = new ErrorModel
|
||||
{
|
||||
IsStatusError = false,
|
||||
Message = StringResourcesUtil.GetString(45)/*Hiba történt az oldalon*/,
|
||||
Status = (int)HttpStatusCode.InternalServerError,
|
||||
IsMvc = true,
|
||||
ErrorCode = logId
|
||||
},
|
||||
JsonRequestBehavior = JsonRequestBehavior.AllowGet
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
|
||||
{
|
||||
controller = "HibaOldal",
|
||||
action = "Index",
|
||||
area = string.Empty
|
||||
}));
|
||||
}
|
||||
|
||||
filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||
}
|
||||
}
|
||||
|
||||
filterContext.ExceptionHandled = true;
|
||||
filterContext.HttpContext.Response.Clear();
|
||||
filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
|
||||
|
||||
if (!filterContext.Exception.Data.Contains(RequestResponseLoggingFields.Server.ExceptionId))
|
||||
{
|
||||
filterContext.Exception.Data.Add(RequestResponseLoggingFields.Server.ExceptionId, logId);
|
||||
}
|
||||
|
||||
filterContext.HttpContext.ApplicationInstance.Context.AddException(filterContext.Exception);
|
||||
}
|
||||
|
||||
protected virtual ActionResult CreateActionResult(ExceptionContext filterContext)
|
||||
{
|
||||
var ctx = new ControllerContext(filterContext.RequestContext, filterContext.Controller);
|
||||
|
||||
var viewName = SelectFirstView(ctx, "~/Views/ErrorHandler/CustomError.cshtml");
|
||||
|
||||
var controllerName = (string)filterContext.RouteData.Values["controller"];
|
||||
var actionName = (string)filterContext.RouteData.Values["action"];
|
||||
var model = new HandleErrorInfo(filterContext.Exception, controllerName, actionName);
|
||||
var result = new PartialViewResult
|
||||
{
|
||||
ViewName = viewName,
|
||||
ViewData = new ViewDataDictionary<HandleErrorInfo>(model),
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
protected string SelectFirstView(ControllerContext ctx, params string[] viewNames)
|
||||
{
|
||||
return viewNames.First(view => ViewExists(ctx, view));
|
||||
}
|
||||
|
||||
protected bool ViewExists(ControllerContext ctx, string name)
|
||||
{
|
||||
var result = ViewEngines.Engines.FindView(ctx, name, null);
|
||||
return result.View != null;
|
||||
}
|
||||
}
|
||||
}
|
28
KretaWeb/App_Start/RouteConfig.cs
Normal file
28
KretaWeb/App_Start/RouteConfig.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Kreta.Web.App_Start
|
||||
{
|
||||
public class RouteConfig
|
||||
{
|
||||
public static void RegisterRoutes(RouteCollection routes)
|
||||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
|
||||
routes.IgnoreRoute("{resource}.ashx/{*pathInfo}");
|
||||
routes.IgnoreRoute("{resource}.svc/{*pathInfo}");
|
||||
|
||||
routes.IgnoreRoute("{*staticfile}", new { staticfile = @".*\.(ico|css|js|gif|jpg|woff|eot|svg|eot|ttf|otf|png|map)(/.*)?" });
|
||||
|
||||
/* Minden amiben van .js vagy .css azt ignorálja */
|
||||
routes.Ignore("{*alljs}", new { alljs = @".*\.js(/.*)?" });
|
||||
routes.Ignore("{*allcss}", new { allcss = @".*\.css(/.*)?" });
|
||||
|
||||
routes.MapRoute(
|
||||
name: Constants.RouteKey.Default,
|
||||
url: "{controller}/{action}/{id}",
|
||||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
34
KretaWeb/App_Start/SecureCookieManager.cs
Normal file
34
KretaWeb/App_Start/SecureCookieManager.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using Microsoft.Owin;
|
||||
using Microsoft.Owin.Infrastructure;
|
||||
|
||||
namespace Kreta.Web.App_Start
|
||||
{
|
||||
public class SecureCookieManager : ICookieManager
|
||||
{
|
||||
private readonly ICookieManager _innerManager;
|
||||
|
||||
public SecureCookieManager() : this(new CookieManager())
|
||||
{
|
||||
}
|
||||
|
||||
public SecureCookieManager(ICookieManager innerManager)
|
||||
{
|
||||
_innerManager = innerManager;
|
||||
}
|
||||
public void AppendResponseCookie(IOwinContext context, string key, string value, CookieOptions options)
|
||||
{
|
||||
options.Secure = true;
|
||||
_innerManager.AppendResponseCookie(context, key, value, options);
|
||||
}
|
||||
|
||||
public void DeleteCookie(IOwinContext context, string key, CookieOptions options)
|
||||
{
|
||||
_innerManager.DeleteCookie(context, key, options);
|
||||
}
|
||||
|
||||
public string GetRequestCookie(IOwinContext context, string key)
|
||||
{
|
||||
return _innerManager.GetRequestCookie(context, key);
|
||||
}
|
||||
}
|
||||
}
|
611
KretaWeb/App_Start/Startup.cs
Normal file
611
KretaWeb/App_Start/Startup.cs
Normal file
|
@ -0,0 +1,611 @@
|
|||
using System;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Mvc;
|
||||
using Hangfire;
|
||||
using IdentityModel;
|
||||
using Kreta.BusinessLogic;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Helpers.SystemSettings;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
using Kreta.Client.CoreApi.Configuration;
|
||||
using Kreta.Client.Eugyintezes;
|
||||
using Kreta.Client.Eugyintezes.Configuration;
|
||||
using Kreta.Client.KGR.Configuration;
|
||||
using Kreta.Client.Leltar.Configuration;
|
||||
using Kreta.Client.SzirApi.Configuration;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.Configuratiaton;
|
||||
using Kreta.Core.Configuratiaton.Interface;
|
||||
using Kreta.Core.Elearning.Nexius;
|
||||
using Kreta.Core.FeatureToggle;
|
||||
using Kreta.Core.FeatureToggle.Configuration;
|
||||
using Kreta.Core.FileService;
|
||||
using Kreta.Core.FileService.Configuration;
|
||||
using Kreta.Core.KIR.Factory;
|
||||
using Kreta.Core.KIR.Factory.Interface;
|
||||
using Kreta.Core.KIR.Infrastructure.Interface;
|
||||
using Kreta.Core.Logic;
|
||||
using Kreta.Core.SAP;
|
||||
using Kreta.Job.Tasks;
|
||||
using Kreta.Job.Tasks.Core;
|
||||
using Kreta.Web.Classes;
|
||||
using Kreta.Web.Configuration;
|
||||
using Kreta.Web.HangfireJobActivator;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Logger;
|
||||
using Kreta.Web.Logging.Logger;
|
||||
using Kreta.Web.Security;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||
using Microsoft.Owin;
|
||||
using Microsoft.Owin.Host.SystemWeb;
|
||||
using Microsoft.Owin.Security;
|
||||
using Microsoft.Owin.Security.Cookies;
|
||||
using Microsoft.Owin.Security.Notifications;
|
||||
using Microsoft.Owin.Security.OpenIdConnect;
|
||||
using Newtonsoft.Json;
|
||||
using Owin;
|
||||
using SimpleInjector;
|
||||
using SimpleInjector.Integration.Web.Mvc;
|
||||
using SimpleInjector.Integration.WebApi;
|
||||
using CoreConstants = Kreta.Core.Constants;
|
||||
using HangfireGlobalConfiguration = Hangfire.GlobalConfiguration;
|
||||
using HttpGlobalConfiguration = System.Web.Http.GlobalConfiguration;
|
||||
using Poszeidon = Kreta.Core.Iktato.Poszeidon;
|
||||
|
||||
[assembly: OwinStartup(typeof(Kreta.Web.App_Start.Startup))]
|
||||
namespace Kreta.Web.App_Start
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public void Configuration(IAppBuilder app)
|
||||
{
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
var idpConfiguration = (IdpConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.IdpConfiguration);
|
||||
|
||||
app.UseCookieAuthentication(new CookieAuthenticationOptions
|
||||
{
|
||||
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
|
||||
CookieName = "kreta.application",
|
||||
CookieSecure = CookieSecureOption.Always,
|
||||
CookieSameSite = SameSiteMode.None
|
||||
});
|
||||
|
||||
if (idpConfiguration.LoginEnabled)
|
||||
{
|
||||
var openIdConnectAuthenticationOptions = new OpenIdConnectAuthenticationOptions
|
||||
{
|
||||
SignInAsAuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
|
||||
|
||||
Authority = idpConfiguration.Authority,
|
||||
ClientId = idpConfiguration.ClientId,
|
||||
//ClientSecret = "secret",
|
||||
Scope = idpConfiguration.Scope,
|
||||
|
||||
//RequireHttpsMetadata = false,
|
||||
UseTokenLifetime = false,
|
||||
|
||||
RedeemCode = true,
|
||||
//SaveTokens = true,
|
||||
|
||||
ResponseType = OpenIdConnectResponseType.Code,
|
||||
ResponseMode = OpenIdConnectResponseMode.FormPost,
|
||||
|
||||
CookieManager = new SecureCookieManager(new SystemWebCookieManager()),
|
||||
|
||||
Notifications = new OpenIdConnectAuthenticationNotifications
|
||||
{
|
||||
RedirectToIdentityProvider = n =>
|
||||
{
|
||||
string instituteCode = CommonUtils.GetOrganizationIdentifier();
|
||||
|
||||
if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.Authentication)
|
||||
{
|
||||
string encodedInstituteData = GetEncodedInstituteData();
|
||||
|
||||
if (idpConfiguration.RequirePkce)
|
||||
{
|
||||
// generate code verifier and code challenge
|
||||
string codeVerifier = CryptoRandom.CreateUniqueId(32);
|
||||
|
||||
string codeChallenge;
|
||||
using (var sha256 = SHA256.Create())
|
||||
{
|
||||
byte[] challengeBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(codeVerifier));
|
||||
codeChallenge = Base64Url.Encode(challengeBytes);
|
||||
}
|
||||
|
||||
// set code_challenge parameter on authorization request
|
||||
n.ProtocolMessage.SetParameter("code_challenge", codeChallenge);
|
||||
n.ProtocolMessage.SetParameter("code_challenge_method", "S256");
|
||||
|
||||
// remember code_verifier (adapted from OWIN nonce cookie)
|
||||
RememberCodeVerifier(n, codeVerifier);
|
||||
}
|
||||
|
||||
|
||||
n.ProtocolMessage.Parameters["institute_code"] = instituteCode;
|
||||
n.ProtocolMessage.Parameters["institute_data"] = encodedInstituteData;
|
||||
|
||||
n.ProtocolMessage.Prompt = OpenIdConnectPrompt.Login;
|
||||
n.ProtocolMessage.RedirectUri = string.Format(idpConfiguration.RedirectUri, instituteCode);
|
||||
}
|
||||
else if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.Logout)
|
||||
{
|
||||
string idToken = n.OwinContext.Authentication.User.FindFirst("id_token")?.Value;
|
||||
n.ProtocolMessage.IdTokenHint = idToken;
|
||||
n.ProtocolMessage.PostLogoutRedirectUri = string.Format(idpConfiguration.PostLogoutRedirectUri, instituteCode);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
|
||||
//MessageReceived = n =>
|
||||
//{
|
||||
// return Task.CompletedTask;
|
||||
//},
|
||||
|
||||
AuthorizationCodeReceived = n =>
|
||||
{
|
||||
if (idpConfiguration.RequirePkce)
|
||||
{
|
||||
// get code_verifier
|
||||
string codeVerifier = RetrieveCodeVerifier(n);
|
||||
|
||||
// attach code_verifier
|
||||
n.TokenEndpointRequest.SetParameter("code_verifier", codeVerifier);
|
||||
}
|
||||
|
||||
string instituteCode = CommonUtils.GetOrganizationIdentifier();
|
||||
|
||||
n.TokenEndpointRequest.RedirectUri = string.Format(idpConfiguration.RedirectUri, instituteCode);
|
||||
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
|
||||
//SecurityTokenReceived = n =>
|
||||
//{
|
||||
// return Task.CompletedTask;
|
||||
//},
|
||||
|
||||
//SecurityTokenValidated = n =>
|
||||
//{
|
||||
// return Task.CompletedTask;
|
||||
//},
|
||||
|
||||
TokenResponseReceived = n =>
|
||||
{
|
||||
var accessToken = new JwtSecurityToken(n.TokenEndpointResponse.AccessToken);
|
||||
|
||||
string instituteCode = CommonUtils.GetOrganizationIdentifier();
|
||||
|
||||
string instituteCodeFromToken = accessToken.Claims.FirstOrDefault(c => c.Type == "kreta:institute_code")?.Value;
|
||||
if (!string.Equals(instituteCode, instituteCodeFromToken, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
throw new Exception($"A tokenben szereplő intézmény ({instituteCodeFromToken}) és az aktuális intézmény ({instituteCode}) nem egyezik!");
|
||||
}
|
||||
|
||||
string userNameFromToken = accessToken.Claims.First(c => c.Type == "kreta:user_name").Value;
|
||||
|
||||
string GetClientIP()
|
||||
{
|
||||
var clientIp = n.Request.RemoteIpAddress.Trim();
|
||||
try
|
||||
{
|
||||
var xForwardedFor = n.Request.Headers["X-Forwarded-For"];
|
||||
if (!string.IsNullOrWhiteSpace(xForwardedFor))
|
||||
{
|
||||
clientIp = xForwardedFor;
|
||||
}
|
||||
return clientIp;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return clientIp;
|
||||
}
|
||||
}
|
||||
|
||||
using (var loginManager = new LoginManager())
|
||||
{
|
||||
ClaimsIdentity claimsIdentity = loginManager.LoginByIdp(userNameFromToken, GetClientIP());
|
||||
claimsIdentity.AddClaim(new Claim("id_token", n.TokenEndpointResponse.IdToken));
|
||||
|
||||
n.OwinContext.Authentication.AuthenticationResponseGrant = new AuthenticationResponseGrant(new ClaimsPrincipal(claimsIdentity), new AuthenticationProperties() { IsPersistent = false }); // ha IsPersistent true akkor belépve marad a felhasználó
|
||||
}
|
||||
|
||||
// Dashboard popup üzenetekhez:
|
||||
var popupCookie = new System.Web.HttpCookie("DisplayedPopups")
|
||||
{
|
||||
HttpOnly = true,
|
||||
SameSite = System.Web.SameSiteMode.None,
|
||||
Secure = true
|
||||
};
|
||||
|
||||
System.Web.HttpContext.Current.Response.Cookies.Add(popupCookie);
|
||||
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
|
||||
AuthenticationFailed = context =>
|
||||
{
|
||||
context.HandleResponse();
|
||||
KretaServer.KretaServer.Instance.Logger.ExceptionThrown(context.Exception);
|
||||
var urlHelper = new UrlHelper(System.Web.HttpContext.Current.Request.RequestContext);
|
||||
context.Response.Redirect(urlHelper.Action("Index", "Home", new { area = string.Empty }));
|
||||
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
app.UseOpenIdConnectAuthentication(openIdConnectAuthenticationOptions);
|
||||
}
|
||||
|
||||
var featureContext = FeatureContext.Instance;
|
||||
|
||||
var container = new Container();
|
||||
container.Options.DefaultScopedLifestyle = Lifestyle.CreateHybrid(new SimpleInjector.Integration.Web.WebRequestLifestyle(), new SimpleInjector.Lifestyles.AsyncScopedLifestyle());
|
||||
|
||||
container.Register<IEmailJob, EmailJob>(Lifestyle.Transient);
|
||||
container.Register<IDeleteInvalidLinksJob, DeleteInvalidLinksJob>(Lifestyle.Transient);
|
||||
container.Register<IUpdateCOVIDFlagJob, UpdateCOVIDFlagJob>(Lifestyle.Transient);
|
||||
container.Register(() => (IktatoServiceConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.KretaPoszeidonConfig), Lifestyle.Singleton);
|
||||
container.Register(() => (IktatasJobConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.IktatasJobConfig), Lifestyle.Singleton);
|
||||
container.Register<Poszeidon.Infrastructure.Interface.IWcfServiceContext>(() => new Poszeidon.Infrastructure.WcfServiceContext() { CorrelationId = Guid.NewGuid().ToString() }, Lifestyle.Scoped);
|
||||
container.Register<Poszeidon.Factory.Interface.IIktatoRepositoryFactory, Poszeidon.Factory.IktatoRepositoryFactory>(Lifestyle.Scoped);
|
||||
container.Register<IktatasJob>(Lifestyle.Transient);
|
||||
container.Register<FeltoltesJob>(Lifestyle.Transient);
|
||||
container.Register<INotificationJob, NotificationJob>(Lifestyle.Transient);
|
||||
container.Register(() => (KretaJobConfig)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.KretaJobConfig), Lifestyle.Singleton);
|
||||
container.Register<IFeatureContext>(() => featureContext, Lifestyle.Singleton);
|
||||
container.Register<IKretaAuthorization, KretaAuthorization>(Lifestyle.Transient);
|
||||
container.Register<IUploadFileValidationConfiguration>(() => (UploadFileValidationConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.UploadFileValidation), Lifestyle.Singleton);
|
||||
container.Register<IUploadFileValidator, UploadFileValidator>(Lifestyle.Singleton);
|
||||
container.Register<INexiusCourseServiceConfiguration>(() => (NexiusCourseServiceConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.NexiusCourseService), Lifestyle.Singleton);
|
||||
container.Register<Nexius.Common.Infrastructure.Logging.ILogger, NullLogger>(Lifestyle.Singleton);
|
||||
container.Register<INexiusCourseService, NexiusCourseService>(Lifestyle.Transient);
|
||||
container.Register<IEugyintezesClientConfiguration>(() => (EugyintezesClientConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.EugyintezesClientConfiguration), Lifestyle.Singleton);
|
||||
container.Register<IEugyintezesClient, EugyintezesClient>(Lifestyle.Singleton);
|
||||
container.Register<IEugyintezesJob, EugyintezesJob>(Lifestyle.Transient);
|
||||
container.Register<IFileServiceConfiguration>(() => (FileServiceConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FileServiceConfiguration), Lifestyle.Singleton);
|
||||
container.Register<IFileService, FileService>(Lifestyle.Singleton);
|
||||
container.Register<ISAPConfiguration>(() => (SapConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.SapConfiguration), Lifestyle.Singleton);
|
||||
container.Register<ISapJob, SapJob>(Lifestyle.Transient);
|
||||
container.Register<ISAPService, SAPService>(Lifestyle.Transient);
|
||||
container.Register<ITavolletJob, TavolletJob>(Lifestyle.Transient);
|
||||
container.Register<IKirConfiguration>(() => (KirConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.KirConfiguration), Lifestyle.Singleton);
|
||||
container.Register<IAuthenticationServiceFactory, AuthenticationServiceFactory>(Lifestyle.Singleton);
|
||||
container.Register<IKirServiceFactory, KirServiceFactory>(Lifestyle.Singleton);
|
||||
container.Register<IKir2ServiceFactory, Kir2ServiceFactory>(Lifestyle.Singleton);
|
||||
container.Register<IIdpConfiguration>(() => idpConfiguration, Lifestyle.Singleton);
|
||||
container.Register<ILepConfiguration>(() => (LepConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.LEPKozpontiKretaConfig), Lifestyle.Singleton);
|
||||
container.Register<ITananyagtarConfiguration>(() => (TananyagtarConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.TananyagtarConfiguration), Lifestyle.Singleton);
|
||||
container.Register<IMkbBankszamlaIgenylesConfiguration>(() => (MkbBankszamlaIgenylesConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.MkbBankszamlaIgenylesConfiguration), Lifestyle.Singleton);
|
||||
container.Register<IOtpBankszamlaIgenylesConfiguration>(() => (OtpBankszamlaIgenylesConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.OtpBankszamlaIgenylesConfiguration), Lifestyle.Singleton);
|
||||
container.Register<IMkbBankszamlaIgenylesJob, MkbBankszamlaIgenylesJob>(Lifestyle.Transient);
|
||||
container.Register<IOtpBankszamlaIgenylesJob, OtpBankszamlaIgenylesJob>(Lifestyle.Transient);
|
||||
container.Register<ICoreApiClientConfiguration>(() => ConfigurationLogic.GetConfigurationSection<CoreApiClientConfiguration>(CoreConstants.ConfigurationSectionNames.CoreApiClientConfiguration), Lifestyle.Singleton);
|
||||
container.Register<IKGRClientConfiguration>(() => ConfigurationLogic.GetConfigurationSection<KGRClientConfiguration>(CoreConstants.ConfigurationSectionNames.KGRClientConfiguration), Lifestyle.Singleton);
|
||||
container.Register<ILeltarClientConfiguration>(() => ConfigurationLogic.GetConfigurationSection<LeltarClientConfiguration>(CoreConstants.ConfigurationSectionNames.LeltarClientConfiguration), Lifestyle.Singleton);
|
||||
container.Register<ISzirApiClientConfiguration>(() => ConfigurationLogic.GetConfigurationSection<SzirApiClientConfiguration>(CoreConstants.ConfigurationSectionNames.SzirApiClientConfiguration), Lifestyle.Singleton);
|
||||
container.Register<ISzakkepzesiJuttatasUpdateJob, SzakkepzesiJuttatasUpdateJob>(Lifestyle.Transient);
|
||||
container.Register<IConnectionStringCacheJob, ConnectionStringCacheJob>(Lifestyle.Transient);
|
||||
container.Register(() => (EESZTConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.EESZTConfig), Lifestyle.Singleton);
|
||||
container.Register<IEESZTInterfaceJob, EESZTInterfaceJob>(Lifestyle.Singleton);
|
||||
container.Register<IFirebaseConfiguration>(() => (FirebaseConfiguration)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FirebaseConfiguration), Lifestyle.Singleton);
|
||||
container.Register<IUpdateTanuloDualisSzerzodeseiJob, UpdateTanuloDualisSzerzodeseiJob>(Lifestyle.Transient);
|
||||
container.Register<ITavolletIktatasJob, TavolletIktatasJob>(Lifestyle.Transient);
|
||||
container.Register(() => TraceLoggerFactory.Create(System.Web.HttpContext.Current), Lifestyle.Scoped);
|
||||
|
||||
container.InjectBusinessLogic();
|
||||
|
||||
container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
|
||||
container.RegisterWebApiControllers(HttpGlobalConfiguration.Configuration);
|
||||
|
||||
container.Verify();
|
||||
|
||||
DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
|
||||
HttpGlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
|
||||
|
||||
HangfireLogger.SerilogGlobalConfiguration();
|
||||
|
||||
HangfireGlobalConfiguration.Configuration.UseActivator(new ContainerJobActivator(container));
|
||||
HangfireGlobalConfiguration.Configuration.UseSqlServerStorage(Core.Constants.General.HangfireConnectionString);
|
||||
|
||||
HangfireGlobalConfiguration.Configuration.UseSerilogLogProvider();
|
||||
|
||||
app.UseHangfireDashboard();
|
||||
if (featureContext.IsEnabled(Core.Constants.FeatureName.HangfireServer))
|
||||
{
|
||||
app.UseHangfireServer();
|
||||
}
|
||||
|
||||
var sendErtekelesNotificationFeature = new SendErtekelesNotificationFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendErtekelesNotificationFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("ErtekelesPush", n => n.SendErtekelesNotification(),
|
||||
GetCronMinuteIntervalWithStartAndEndHour(sendErtekelesNotificationFeature.SendItervalInMinute, sendErtekelesNotificationFeature.RunningIntervalStartHour, sendErtekelesNotificationFeature.RunningIntervalEndHour));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("ErtekelesPush");
|
||||
}
|
||||
|
||||
var sendHazifeladatNotificationFeature = new SendHazifeladatNotificationFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendHazifeladatNotificationFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("HazifeladatPush", n => n.SendHazifeladatNotification(),
|
||||
GetCronMinuteIntervalWithStartAndEndHour(sendHazifeladatNotificationFeature.SendItervalInMinute, sendHazifeladatNotificationFeature.RunningIntervalStartHour, sendHazifeladatNotificationFeature.RunningIntervalEndHour));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("HazifeladatPush");
|
||||
}
|
||||
|
||||
var sendRendszerUzenetNotificationFeature = new SendRendszerUzenetNotificationFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendRendszerUzenetNotificationFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("RendszerUzenetPush", n => n.SendRendszerUzenetNotification(),
|
||||
GetCronMinuteIntervalWithStartAndEndHour(sendRendszerUzenetNotificationFeature.SendItervalInMinute, sendRendszerUzenetNotificationFeature.RunningIntervalStartHour, sendRendszerUzenetNotificationFeature.RunningIntervalEndHour));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("RendszerUzenetPush");
|
||||
}
|
||||
|
||||
var sendMulasztasNotificationFeature = new SendMulasztasNotificationFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendMulasztasNotificationFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("MulasztasPush", n => n.SendMulasztasNotification(),
|
||||
GetCronMinuteIntervalWithStartAndEndHour(sendMulasztasNotificationFeature.SendItervalInMinute, sendMulasztasNotificationFeature.RunningIntervalStartHour, sendMulasztasNotificationFeature.RunningIntervalEndHour));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("MulasztasPush");
|
||||
}
|
||||
|
||||
var sendBejelentettSzamonkeresNotificationFeature = new SendBejelentettSzamonkeresNotificationFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendBejelentettSzamonkeresNotificationFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("BejelentettSzamonkeresPush", n => n.SendBejelentettSzamonkeresNotification(),
|
||||
GetCronMinuteIntervalWithStartAndEndHour(sendBejelentettSzamonkeresNotificationFeature.SendItervalInMinute, sendBejelentettSzamonkeresNotificationFeature.RunningIntervalStartHour, sendBejelentettSzamonkeresNotificationFeature.RunningIntervalEndHour));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("BejelentettSzamonkeresPush");
|
||||
}
|
||||
|
||||
var sendFeljegyzesNotificationFeature = new SendFeljegyzesNotificationFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendFeljegyzesNotificationFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("FeljegyzesPush", n => n.SendFeljegyzesNotification(),
|
||||
GetCronMinuteIntervalWithStartAndEndHour(sendFeljegyzesNotificationFeature.SendItervalInMinute, sendFeljegyzesNotificationFeature.RunningIntervalStartHour, sendFeljegyzesNotificationFeature.RunningIntervalEndHour));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("FeljegyzesPush");
|
||||
}
|
||||
|
||||
var sendKozelgoFogadooraMailFeature = new SendKozelgoFogadooraMailFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendKozelgoFogadooraMailFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("KozelgoFogadooraMail", n => n.SendKozelgoFogadooraMail(), Cron.Daily(8, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("KozelgoFogadooraMail");
|
||||
}
|
||||
|
||||
var sendNemNaplozottTanorakMailFeature = new SendNemNaplozottTanorakMailFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendNemNaplozottTanorakMailFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("SendNemNaplozottTanorakMail", n => n.SendNemNaplozottTanorakMail(), sendNemNaplozottTanorakMailFeature.CustomCronExpression);
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("SendNemNaplozottTanorakMail");
|
||||
}
|
||||
|
||||
var sendOrarendValtozasNotificationFeature = new SendOrarendValtozasNotificationFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sendOrarendValtozasNotificationFeature.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<INotificationJob>("OrarendValtozasPush", n => n.SendOrarendValtozasNotification(null), sendOrarendValtozasNotificationFeature.CustomCronExpression);
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("OrarendValtozasPush");
|
||||
}
|
||||
|
||||
var deleteInvalidLinks = new DeleteInvalidLinksFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (deleteInvalidLinks.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<IDeleteInvalidLinksJob>("DeleteInvalidLinks", n => n.DeleteInvalidLinks(), Cron.Weekly(DayOfWeek.Sunday, 03, 30));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("DeleteInvalidLinks");
|
||||
}
|
||||
|
||||
var updateCOVIDFlag = new UpdateCOVIDFlagFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (updateCOVIDFlag.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<IUpdateCOVIDFlagJob>("UpdateCOVIDFlag", n => n.UpdateCOVIDFlag(), Cron.Daily(1, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("UpdateCOVIDFlag");
|
||||
}
|
||||
|
||||
var sapSync = new sapSyncFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (sapSync.IsEnabled)
|
||||
{
|
||||
RecurringJob.RemoveIfExists("SapTavolletSync"); //El lesz távolítva...
|
||||
//RecurringJob.AddOrUpdate<ISapJob>("SapTavolletSync", n => n.SyncJobKeretEsTavollet(), Cron.Weekly(DayOfWeek.Saturday, 02));
|
||||
RecurringJob.AddOrUpdate<ITavolletJob>("TavolletDokSync", n => n.SyncTavolletIktatott(), Cron.MinuteInterval(15));
|
||||
RecurringJob.AddOrUpdate<ITavolletJob>("SendOutTavolletReminderEmails", n => n.SendOutTavolletReminderEmails(), Cron.Monthly(25));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("SapTavolletSync");
|
||||
RecurringJob.RemoveIfExists("TavolletDokSync");
|
||||
}
|
||||
|
||||
RecurringJob.AddOrUpdate<ISzakkepzesiJuttatasUpdateJob>("SzakkepzesiJuttatasUpdate", n => n.UpdateSzakkepzesiJuttatasok(), Cron.Monthly(16));
|
||||
//jöhetne ez a 4-es konfigból esetleg :)
|
||||
RecurringJob.AddOrUpdate<IConnectionStringCacheJob>("ConnectionStringCacheSync", n => n.ResetAllConnectionString(), Cron.Daily(4));
|
||||
// RecurringJob.AddOrUpdate<INotificationJob>("SendFogadooraNotification", n => n.SendFogadooraNotification(), Cron.Daily(1, 0));
|
||||
|
||||
if (featureContext.IsEnabled(Core.Constants.FeatureName.EESZTInterfaceUsage))
|
||||
{
|
||||
RecurringJob.AddOrUpdate<IEESZTInterfaceJob>("EESZTInterfaceJob", x => x.GetEESZTAllomany(), Cron.Daily(1, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("EESZTInterfaceJob");
|
||||
}
|
||||
|
||||
if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/bin/Aspose.Total.lic")))
|
||||
{
|
||||
Aspose.Pdf.License license = new Aspose.Pdf.License();
|
||||
license.SetLicense("Aspose.Total.lic");
|
||||
Aspose.Cells.License licenseCells = new Aspose.Cells.License();
|
||||
licenseCells.SetLicense("Aspose.Total.lic");
|
||||
Aspose.Words.License licenseWords = new Aspose.Words.License();
|
||||
licenseWords.SetLicense("Aspose.Total.lic");
|
||||
Aspose.BarCode.License barCodeLicense = new Aspose.BarCode.License();
|
||||
barCodeLicense.SetLicense("Aspose.Total.lic");
|
||||
}
|
||||
|
||||
var mkbBankszamlaIgenyles = new MkbBankszamlaIgenylesFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (mkbBankszamlaIgenyles.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<IMkbBankszamlaIgenylesJob>("MkbBankszamlaIgenylesJob", n => n.MkbBankszamlaIgenyles(), Cron.Daily(02, 00));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("MkbBankszamlaIgenylesJob");
|
||||
}
|
||||
|
||||
var otpBankszamlaIgenyles = new OtpBankszamlaIgenylesFeature((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (otpBankszamlaIgenyles.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<IOtpBankszamlaIgenylesJob>("OtpBankszamlaIgenylesJob", n => n.OtpBankszamlaIgenyles(), Cron.Daily(03, 30));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("OtpBankszamlaIgenylesJob");
|
||||
}
|
||||
|
||||
var updateTanuloDualisSzerzodesei = new UpdateTanuloDualisSzerzodesei((FeatureConfigurationSection)ConfigurationManager.GetSection(CoreConstants.ConfigurationSectionNames.FeatureConfig));
|
||||
if (updateTanuloDualisSzerzodesei.IsEnabled)
|
||||
{
|
||||
RecurringJob.AddOrUpdate<IUpdateTanuloDualisSzerzodeseiJob>("UpdateTanuloDualisSzerzodesei", n => n.UpdateTanuloDualisSzerzodesei(), Cron.Daily(00, 00));
|
||||
}
|
||||
else
|
||||
{
|
||||
RecurringJob.RemoveIfExists("UpdateTanuloDualisSzerzodesei");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RememberCodeVerifier(RedirectToIdentityProviderNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> n, string codeVerifier)
|
||||
{
|
||||
var properties = new AuthenticationProperties();
|
||||
properties.Dictionary.Add("cv", codeVerifier);
|
||||
n.Options.CookieManager.AppendResponseCookie(
|
||||
n.OwinContext,
|
||||
GetCodeVerifierKey(n.ProtocolMessage.State),
|
||||
Convert.ToBase64String(Encoding.UTF8.GetBytes(n.Options.StateDataFormat.Protect(properties))),
|
||||
new CookieOptions
|
||||
{
|
||||
SameSite = SameSiteMode.None,
|
||||
HttpOnly = true,
|
||||
Secure = true, //n.Request.IsSecure,
|
||||
Expires = DateTime.UtcNow.AddDays(1) // DateTime.UtcNow + n.Options.ProtocolValidator.NonceLifetime
|
||||
});
|
||||
}
|
||||
|
||||
private string RetrieveCodeVerifier(AuthorizationCodeReceivedNotification n)
|
||||
{
|
||||
string key = GetCodeVerifierKey(n.ProtocolMessage.State);
|
||||
|
||||
string codeVerifierCookie = n.Options.CookieManager.GetRequestCookie(n.OwinContext, key);
|
||||
if (codeVerifierCookie != null)
|
||||
{
|
||||
var cookieOptions = new CookieOptions
|
||||
{
|
||||
SameSite = SameSiteMode.None,
|
||||
HttpOnly = true,
|
||||
Secure = true, //n.Request.IsSecure
|
||||
};
|
||||
|
||||
n.Options.CookieManager.DeleteCookie(n.OwinContext, key, cookieOptions);
|
||||
|
||||
AuthenticationProperties cookieProperties = n.Options.StateDataFormat.Unprotect(Encoding.UTF8.GetString(Convert.FromBase64String(codeVerifierCookie)));
|
||||
cookieProperties.Dictionary.TryGetValue("cv", out var codeVerifier);
|
||||
|
||||
return codeVerifier;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetCodeVerifierKey(string state)
|
||||
{
|
||||
using (var hash = SHA256.Create())
|
||||
{
|
||||
return OpenIdConnectAuthenticationDefaults.CookiePrefix + "cv." + Convert.ToBase64String(hash.ComputeHash(Encoding.UTF8.GetBytes(state)));
|
||||
}
|
||||
}
|
||||
|
||||
private string GetEncodedInstituteData()
|
||||
{
|
||||
var systemSettingsHelper = new SystemSettingsHelper(ConnectionTypeExtensions.GetOrganizationConnectionType());
|
||||
|
||||
var csokkentettGondviseloEnable = systemSettingsHelper
|
||||
.GetSystemSettingValue<bool>(Enums.RendszerBeallitasTipusEnum.Csokkentett_gondviselok_kezelese);
|
||||
|
||||
var intemzenyRovidnevBeallitasa = systemSettingsHelper
|
||||
.GetSystemSettingValue<bool>(Enums.RendszerBeallitasTipusEnum.Intezmeny_rovid_nevenek_beallitasa);
|
||||
|
||||
var intezmenyHelper = new IntezmenyHelper(ConnectionTypeExtensions.GetOrganizationConnectionType());
|
||||
|
||||
var loginData = intezmenyHelper.GetOrganizationNameAndCode();
|
||||
var isSuccessAuthorizedDate = !intezmenyHelper.IsSuccessAuthorizedDate();
|
||||
|
||||
string institute_data = JsonConvert.SerializeObject(new
|
||||
{
|
||||
next_update_date_time = new AdminHelper(ConnectionTypeExtensions.GetOrganizationConnectionType()).GetKovTelepitesDatum().ToString("yyyy.MM.dd. HH:mm"),
|
||||
is_szir_institute = loginData.Tables[0].Rows[0].Field<bool>("IsSzirIntezmeny_BOOL"),
|
||||
is_licence_valid = (loginData.Tables[0].Rows[0][2].ToString() == "F"),
|
||||
is_archive = loginData.Tables[0].Rows[0].Field<bool>("IsArchivIntezmeny_BOOL"),
|
||||
is_csokkentett_gondviselo = csokkentettGondviseloEnable,
|
||||
is_intezmeny_rovidnev = intemzenyRovidnevBeallitasa,
|
||||
is_success_authorized_date = isSuccessAuthorizedDate
|
||||
});
|
||||
|
||||
byte[] plainTextBytes = Encoding.UTF8.GetBytes(institute_data);
|
||||
|
||||
return Convert.ToBase64String(plainTextBytes);
|
||||
}
|
||||
|
||||
private string GetCronMinuteIntervalWithStartAndEndHour(int interval, int? startHour, int? endHour)
|
||||
{
|
||||
if (startHour.HasValue && endHour.HasValue)
|
||||
{
|
||||
return $"*/{interval} {startHour.Value}-{endHour.Value} * * *";
|
||||
}
|
||||
|
||||
return Cron.MinuteInterval(interval);
|
||||
}
|
||||
}
|
||||
}
|
55
KretaWeb/App_Start/WebApiConfig.cs
Normal file
55
KretaWeb/App_Start/WebApiConfig.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System.Globalization;
|
||||
using System.Web.Http;
|
||||
using Kreta.Core.JsonConverter;
|
||||
using Kreta.Core.ModelBinder;
|
||||
using Kreta.Web.ModelBinder;
|
||||
using Newtonsoft.Json;
|
||||
using CoreConstants = Kreta.Core.Constants;
|
||||
|
||||
namespace Kreta.Web.App_Start
|
||||
{
|
||||
public class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
// Web API configuration and services
|
||||
System.Net.Http.Formatting.JsonMediaTypeFormatter formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
|
||||
|
||||
formatter.SerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
TypeNameHandling = TypeNameHandling.None,
|
||||
Culture = CultureInfo.CreateSpecificCulture(CoreConstants.General.HungarianCulture)
|
||||
};
|
||||
|
||||
formatter.SerializerSettings.Converters.Add(new StringTrimConverter());
|
||||
|
||||
// Web API routes
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: Constants.RouteKey.ActionApi,
|
||||
routeTemplate: "api/{controller}/{action}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: Constants.RouteKey.DefaultApi,
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
|
||||
config.BindParameter(typeof(double), new DoubleModelBinder());
|
||||
config.BindParameter(typeof(double?), new DoubleModelBinder());
|
||||
|
||||
config.BindParameter(typeof(decimal), new DecimalModelBinder());
|
||||
config.BindParameter(typeof(decimal?), new DecimalModelBinder());
|
||||
|
||||
config.BindParameter(typeof(int), new IntegerModelBinder());
|
||||
config.BindParameter(typeof(int?), new IntegerModelBinder());
|
||||
|
||||
config.BindParameter(typeof(string), new StringTrimModelBinder());
|
||||
config.BindParameter(typeof(Kendo.Mvc.UI.DataSourceRequest), new DataSourceRequestModelBinder());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue