113 lines
4.2 KiB
C#
113 lines
4.2 KiB
C#
using EnVisage.Code;
|
|
using EnVisage.Code.BLL;
|
|
using EnVisage.Models;
|
|
using System;
|
|
using System.Web.Mvc;
|
|
|
|
namespace EnVisage.Controllers
|
|
{
|
|
[Authorize]
|
|
public class HomeController : BaseController
|
|
{
|
|
#region Properties
|
|
|
|
//private int loopCount = 0;
|
|
|
|
#endregion
|
|
|
|
#region Actions
|
|
|
|
[ExportableToPdf("Prevu-Dashboard-{0:Md}.pdf")]
|
|
public ActionResult Index(string menuId, string pageModel, string additionalFilters)
|
|
{
|
|
|
|
//if (HttpContext.User.Identity.IsAuthenticated)
|
|
//{
|
|
// Logger.Log(NLog.LogLevel.Debug, "user authenicated.", this.Request.Url.Scheme);
|
|
// Logger.Log(NLog.LogLevel.Debug, "user Name: " + HttpContext.User.Identity.GetUserName(), this.Request.Url.Scheme);
|
|
// loopCount = 0;
|
|
// while (loopCount <= 3)
|
|
// {
|
|
// if (HttpContext.User.Identity.GetID() != Guid.Empty.ToString())
|
|
// break;
|
|
// SecurityManager.tryLogin();
|
|
// if (HttpContext.User.Identity.GetID() == Guid.Empty.ToString() && loopCount > 2)
|
|
// {
|
|
// // a.SSOLogOff();
|
|
// return Redirect("Account/SSOFailureNoLocalAccount");
|
|
// }
|
|
// else if (HttpContext.User.Identity.GetID() != Guid.Empty.ToString())
|
|
// {
|
|
// Logger.Log(NLog.LogLevel.Debug, "Name " + (string.IsNullOrEmpty(User.Identity.Name) ? " " : User.Identity.Name));
|
|
// Logger.Log(NLog.LogLevel.Debug, "GetName " + (string.IsNullOrEmpty(User.Identity.GetName()) ? " " : User.Identity.GetName()));
|
|
// Logger.Log(NLog.LogLevel.Debug, "Identity info " + (string.IsNullOrEmpty(User.Identity.GetIsAuthenicated()) ? " " : User.Identity.GetIsAuthenicated()));
|
|
// break;
|
|
// }
|
|
// loopCount++;
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// Logger.Log(NLog.LogLevel.Debug, "user not authenicated.", this.Request.Url.Scheme);
|
|
|
|
//}
|
|
if (HttpContext.User.Identity.IsAuthenticated && HttpContext.User.Identity.GetID() != Guid.Empty.ToString())
|
|
{
|
|
string userid = HttpContext.User.Identity.GetID();
|
|
|
|
if (!SecurityManager.IsDefaultPageAvailable(userid, "Index", "Home"))
|
|
{
|
|
SecurityManager.DefaultPageWithArea page = SecurityManager.RedirectToDefaultPage(userid);
|
|
return RedirectToAction(page.Action, page.Controller, page.Parameters);
|
|
}
|
|
}
|
|
|
|
var model = new ForecastDashboardOptionsModel
|
|
{
|
|
MenuId = menuId ?? "visibilitydropdown",
|
|
SourcePageModel = pageModel ?? string.Empty,
|
|
AdditionalFilterParams = additionalFilters
|
|
};
|
|
|
|
//we don't check for security attributes here so we need to manually call method that updates user's login and lastlogin dates
|
|
if (HttpContext.User.Identity.IsAuthenticated && HttpContext.User.Identity.GetID() != Guid.Empty.ToString())
|
|
{
|
|
string userid = HttpContext.User.Identity.GetID();
|
|
AccountManager manager = new AccountManager(null);
|
|
manager.SetLoginDates(userid);
|
|
}
|
|
|
|
return View("Dashboard", model);
|
|
}
|
|
|
|
public ActionResult ExportToPDF()
|
|
{
|
|
//Logger.Log(NLog.LogLevel.Debug, "PDF EXPORT REQUESTED URL:" + Url.Action("Index", "Home", null, this.Request.Url.Scheme));
|
|
|
|
PDFExporter exporter = new PDFExporter();
|
|
byte[] pdfBuffer = exporter.ExportPage(Url.Action("Index", "Home", null, this.Request.Url.Scheme), 3, true, Request.Cookies);
|
|
|
|
// send the PDF file to browser
|
|
FileResult fileResult = new FileContentResult(pdfBuffer, "application/pdf");
|
|
fileResult.FileDownloadName = "Prevu-Dashboard-" + DateTime.Today.Month + "-" + DateTime.Today.Day + ".pdf";
|
|
|
|
return fileResult;
|
|
}
|
|
|
|
public ActionResult AccessDenied()
|
|
{
|
|
if (HttpContext.User.Identity.IsAuthenticated && HttpContext.User.Identity.GetID() != Guid.Empty.ToString())
|
|
return View();
|
|
return Redirect("Account/SSOFailureNoLocalAccount");
|
|
}
|
|
|
|
public ActionResult StressTest()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
} |