2020-05-27 18:15:54 +02:00
|
|
|
|
using System;
|
2023-02-09 20:47:52 +01:00
|
|
|
|
using System.Diagnostics;
|
2020-05-27 18:15:54 +02:00
|
|
|
|
using System.Web.Mvc;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
using System.Web.Security;
|
2025-06-11 22:56:25 +02:00
|
|
|
|
using BeWo.Data.Access;
|
|
|
|
|
|
using BeWo.Data.Entities;
|
|
|
|
|
|
using BeWo.Service.DCEntityMapper;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
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;
|
2021-10-13 16:00:33 +02:00
|
|
|
|
using ReportingService.ServiceContracts;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
|
|
|
|
|
|
namespace BeWoPlanerMobil.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract class AbstractBaseController : Controller
|
2020-01-15 16:14:39 +01:00
|
|
|
|
{
|
2021-11-08 20:24:26 +01:00
|
|
|
|
protected readonly ICustomerService CustomerService = new MobileSessionFacade().CustomerService;
|
2016-06-27 01:45:38 +02:00
|
|
|
|
protected readonly IOperationsService OperationsService = new MobileSessionFacade().OperationsService;
|
2021-11-08 20:24:26 +01:00
|
|
|
|
protected readonly IEmployeeService EmployeeService = new MobileSessionFacade().EmployeeService;
|
|
|
|
|
|
protected readonly IValueListService ValueListService = new MobileSessionFacade().ValueListService;
|
|
|
|
|
|
protected readonly IResourceService KalenderService = new MobileSessionFacade().ResourceService;
|
|
|
|
|
|
protected readonly IUserService UserService = new MobileSessionFacade().UserService;
|
|
|
|
|
|
protected readonly IDownloadService DownloadService = new MobileSessionFacade().DownloadService;
|
|
|
|
|
|
protected readonly IReportService ReportService = new MobileSessionFacade().ReportService;
|
2023-03-27 17:41:58 +02:00
|
|
|
|
protected readonly IQueryService QueryService = new MobileSessionFacade().QueryService;
|
|
|
|
|
|
|
2023-02-09 20:47:52 +01: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";
|
|
|
|
|
|
|
2025-06-11 22:56:25 +02:00
|
|
|
|
private UserDC loggedInUserDc = null;
|
|
|
|
|
|
private EmployeeDC loggedInEmployeeDC = null;
|
2020-05-27 18:15:54 +02:00
|
|
|
|
|
|
|
|
|
|
protected ActionResult Logout()
|
2016-06-27 01:45:38 +02:00
|
|
|
|
{
|
2023-02-09 20:47:52 +01:00
|
|
|
|
#if DEBUG
|
2025-06-27 13:11:10 +02:00
|
|
|
|
Debug.WriteLine($"+++>Logout aufrufende Methode: {new StackTrace().GetFrame(1).GetMethod().Name}");
|
2023-02-09 20:47:52 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
MobileSessionFacade.LogUserOut();
|
2016-06-27 01:45:38 +02:00
|
|
|
|
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
|
|
|
|
|
2025-06-11 22:56:25 +02:00
|
|
|
|
protected virtual void InitModel(AbstractModel model)
|
2018-03-02 16:33:39 +01:00
|
|
|
|
{
|
2025-06-11 22:56:25 +02:00
|
|
|
|
model.LoggedInUser = LoggedInUser;
|
|
|
|
|
|
model.LoggedInEmployee = LoggedInEmployee;
|
|
|
|
|
|
model.Mandator = Mandator;
|
|
|
|
|
|
|
|
|
|
|
|
if (model.SessionModel != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
String sessionkey = model.GetType().Name;
|
|
|
|
|
|
|
|
|
|
|
|
if (Session[sessionkey] is null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Session[sessionkey] = model.SessionModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-09-09 00:44:55 +02:00
|
|
|
|
model.SessionModel = (BaseSessionModel)Session[sessionkey];
|
2025-06-11 22:56:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected UserDC LoggedInUser
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (loggedInUserDc == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var user = DAOFactory.GenericDAO.LoadByID<ApplicationUser>(MobileSessionFacade.LoggedInUserOid.Value);
|
|
|
|
|
|
loggedInUserDc = MapperFactory.UserDC_User.MapToNewDC(user);
|
|
|
|
|
|
loggedInEmployeeDC = MapperFactory.EmployeeDC_Employee.MapToNewDC(user.Employee);
|
|
|
|
|
|
}
|
|
|
|
|
|
return loggedInUserDc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected EmployeeDC LoggedInEmployee
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2025-06-12 15:42:52 +02:00
|
|
|
|
if(loggedInEmployeeDC == null)
|
2025-06-11 22:56:25 +02:00
|
|
|
|
{
|
|
|
|
|
|
var tmp = LoggedInUser; //Sets employee
|
|
|
|
|
|
}
|
|
|
|
|
|
return loggedInEmployeeDC;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected MokMandator Mandator
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return MobileSessionFacade.Mandator;
|
|
|
|
|
|
}
|
2018-03-02 16:33:39 +01:00
|
|
|
|
}
|
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}";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-12 15:12:30 +02:00
|
|
|
|
public static int TimeoutLimit => System.Web.HttpContext.Current.Session.Timeout;
|
2021-04-19 04:38:29 +02:00
|
|
|
|
|
2025-07-15 14:26:03 +02:00
|
|
|
|
public bool IsUserLoggedIn()
|
|
|
|
|
|
{
|
|
|
|
|
|
return MobileSessionFacade.IsUserLoggedIn();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-19 04:38:29 +02:00
|
|
|
|
[Authorize]
|
2022-09-07 13:19:08 +02:00
|
|
|
|
public ActionResult UpdateApplicationSettings(string pKey, string pValue)
|
2021-04-19 04:38:29 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
2025-06-11 22:56:25 +02:00
|
|
|
|
var userSettings = LoggedInUser.Settings;
|
2021-04-19 04:38:29 +02:00
|
|
|
|
|
2025-06-11 22:56:25 +02:00
|
|
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, pKey, pValue, userSettings);
|
2021-04-19 04:38:29 +02:00
|
|
|
|
|
2025-06-11 22:56:25 +02:00
|
|
|
|
if(LoggedInUser?.UserOid.HasValue ?? false)
|
2021-04-19 04:38:29 +02:00
|
|
|
|
{
|
2025-06-11 22:56:25 +02:00
|
|
|
|
UserService.UpdateUserSettings(LoggedInUser.UserOid.Value, userSettings);
|
2021-04-19 04:38:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return RedirectToAction("Main");
|
|
|
|
|
|
}
|
2022-09-07 13:19:08 +02:00
|
|
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
public void UpdateUserSettingsWithoutReload(string key, string value)
|
|
|
|
|
|
{
|
2025-06-11 22:56:25 +02:00
|
|
|
|
var userSettings = LoggedInUser.Settings;
|
2022-09-07 13:19:08 +02:00
|
|
|
|
|
|
|
|
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, key, value, userSettings);
|
|
|
|
|
|
|
2025-06-11 22:56:25 +02:00
|
|
|
|
var loggedInUser = LoggedInUser;
|
2022-09-07 13:19:08 +02:00
|
|
|
|
|
|
|
|
|
|
if(loggedInUser?.UserOid.HasValue ?? false)
|
|
|
|
|
|
{
|
|
|
|
|
|
UserService.UpdateUserSettings(loggedInUser.UserOid.Value, userSettings);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-25 17:36:15 +01:00
|
|
|
|
|
|
|
|
|
|
public abstract string SaveCollapsibleStatus(bool isOpen, string identifier);
|
2025-07-24 10:21:01 +02:00
|
|
|
|
|
|
|
|
|
|
public ActionResult Error()
|
|
|
|
|
|
{
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
|
ViewBag.ErrorMessage = "[HIER KOMMT DIE FEHLERMELDUNG HIN]";
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
return View("Error");
|
|
|
|
|
|
}
|
2016-06-27 01:45:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|