66 lines
2.3 KiB
C#
66 lines
2.3 KiB
C#
using EnVisage.Code.Cache;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using EnVisage.Code;
|
|
using Microsoft.AspNet.Identity;
|
|
using EnVisage.Code.Session;
|
|
|
|
namespace EnVisage.Controllers
|
|
{
|
|
[Authorize]
|
|
public class HomeController : BaseController
|
|
{
|
|
public ActionResult Index()
|
|
{
|
|
|
|
if (HttpContext.User.Identity.IsAuthenticated)
|
|
{
|
|
if (HttpContext.User.Identity.GetID() == Guid.Empty.ToString())
|
|
{
|
|
AccountController a = new AccountController();
|
|
a.SSOLoginConfirmation();
|
|
if (HttpContext.User.Identity.GetID() == Guid.Empty.ToString())
|
|
{
|
|
// a.SSOLogOff();
|
|
return Redirect("Account/SSOFailureNoLocalAccount");
|
|
}
|
|
}
|
|
}
|
|
string userid = HttpContext.User.Identity.GetID();
|
|
var user = new UsersCache().Value.FirstOrDefault(x => x.Id == new Guid(userid));
|
|
if (user != null)
|
|
{
|
|
ViewBag.IsUOMHours = !user.PreferredResourceAllocation;
|
|
//if (SessionManager.Exists(Constants.USERVOICE_SSO_TOKEN))
|
|
//{
|
|
// ViewBag.ssoToken = SessionManager.GetValue<string>(Constants.USERVOICE_SSO_TOKEN);
|
|
//}
|
|
//else
|
|
//{
|
|
// if (Request.Cookies[Constants.USERVOICE_COOKIE_CONTEXT] != null)
|
|
// {
|
|
// ViewBag.ssoToken = Request.Cookies[Constants.USERVOICE_COOKIE_CONTEXT][Constants.USERVOICE_SSO_TOKEN];
|
|
// }
|
|
//}
|
|
|
|
}
|
|
return View();
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |