2020-05-27 18:15:54 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Web.Mvc;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
using System.Web.Security;
|
|
|
|
|
|
using BeWo.Service.ServiceContracts;
|
2020-05-27 18:15:54 +02:00
|
|
|
|
using BeWoPlanerMobil.Models;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
using BeWoPlanerMobil.Service;
|
2021-04-19 04:38:29 +02:00
|
|
|
|
using BS.Shared;
|
|
|
|
|
|
using BS.Shared.Core;
|
2018-03-02 16:33:39 +01:00
|
|
|
|
using BS.Shared.DataContracts;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
|
|
|
|
|
|
namespace BeWoPlanerMobil.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract class AbstractBaseController : Controller
|
2020-01-15 16:14:39 +01:00
|
|
|
|
{
|
2016-06-27 01:45:38 +02:00
|
|
|
|
protected readonly ICustomerService CustomerService = new MobileSessionFacade().CustomerService;
|
|
|
|
|
|
protected readonly IOperationsService OperationsService = new MobileSessionFacade().OperationsService;
|
|
|
|
|
|
protected readonly IEmployeeService EmployeeService = new MobileSessionFacade().EmployeeService;
|
|
|
|
|
|
protected readonly IValueListService ValueListService = new MobileSessionFacade().ValueListService;
|
|
|
|
|
|
protected readonly IResourceService KalenderService = new MobileSessionFacade().ResourceService;
|
2018-03-02 16:33:39 +01:00
|
|
|
|
protected readonly IUserService UserService = new MobileSessionFacade().UserService;
|
2020-10-07 19:42:17 +02:00
|
|
|
|
protected const string _LeerzeichenFuerGetMethoden = " ";
|
2016-06-27 01:45:38 +02:00
|
|
|
|
|
2020-01-15 16:14:39 +01:00
|
|
|
|
protected static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
2016-06-27 01:45:38 +02:00
|
|
|
|
|
2020-05-27 18:15:54 +02:00
|
|
|
|
public static readonly string IsSessionTimedOut = "isSessionTimedOut";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected ActionResult Logout()
|
2016-06-27 01:45:38 +02:00
|
|
|
|
{
|
|
|
|
|
|
MobileSessionFacade.LogUserOut();
|
|
|
|
|
|
FormsAuthentication.SignOut();
|
2020-05-27 18:15:54 +02:00
|
|
|
|
|
|
|
|
|
|
AbstractModel.TimeOfLastAction = null;
|
|
|
|
|
|
|
2017-03-06 14:45:35 +01:00
|
|
|
|
return RedirectToActionPermanent("Index", "Login", new {tenant = MobileSessionFacade.Tenant});
|
2016-06-27 01:45:38 +02:00
|
|
|
|
}
|
2018-03-02 16:33:39 +01:00
|
|
|
|
|
|
|
|
|
|
protected UserDC GetUser()
|
|
|
|
|
|
{
|
|
|
|
|
|
return UserService.LoadUser(MobileSessionFacade.LoggedInUser.Oid.Value);
|
|
|
|
|
|
}
|
2020-05-27 18:15:54 +02:00
|
|
|
|
|
|
|
|
|
|
protected override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(MobileSessionFacade.IsUserLoggedIn())
|
|
|
|
|
|
{
|
|
|
|
|
|
AbstractModel.TimeOfLastAction = $"{DateTime.Now:yyyy-MM-dd}T{DateTime.Now:HH:mm:ss}";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int TimeoutLimit
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var timeUntilUILock = BS.Shared.Settings.ApplicationSettings.TimeUntilUILock;
|
|
|
|
|
|
|
|
|
|
|
|
if(timeUntilUILock > 0 && System.Web.HttpContext.Current.Session.Timeout > timeUntilUILock)
|
|
|
|
|
|
{
|
|
|
|
|
|
return timeUntilUILock;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return System.Web.HttpContext.Current.Session.Timeout;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-04-19 04:38:29 +02:00
|
|
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
public ActionResult UpdateSettings(string pKey, string pValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
var userSettings = GetUser().Settings;
|
|
|
|
|
|
|
|
|
|
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, pKey, pValue, userSettings);
|
|
|
|
|
|
|
|
|
|
|
|
var loggedInUser = GetUser();
|
|
|
|
|
|
|
|
|
|
|
|
if(loggedInUser?.UserOid.HasValue ?? false)
|
|
|
|
|
|
{
|
|
|
|
|
|
UserService.UpdateUserSettings(loggedInUser.UserOid.Value, userSettings);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return RedirectToAction("Main");
|
|
|
|
|
|
}
|
2016-06-27 01:45:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|