diff --git a/Disco.BI/BI/Interop/ActiveDirectory/ActiveDirectoryUpdateLastNetworkLogonDateJob.cs b/Disco.BI/BI/Interop/ActiveDirectory/ActiveDirectoryUpdateLastNetworkLogonDateJob.cs index c1eddb4d..32ac0fd8 100644 --- a/Disco.BI/BI/Interop/ActiveDirectory/ActiveDirectoryUpdateLastNetworkLogonDateJob.cs +++ b/Disco.BI/BI/Interop/ActiveDirectory/ActiveDirectoryUpdateLastNetworkLogonDateJob.cs @@ -1,293 +1,261 @@ -using Disco.Data.Repository; -using Disco.Services.Logging; -using Disco.Models.Repository; -using Quartz; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.DirectoryServices; -using System.Linq; -using System.Linq.Expressions; -using System.Net.NetworkInformation; -using System.Reflection; -using Disco.Services.Tasks; -namespace Disco.BI.Interop.ActiveDirectory -{ - public class ActiveDirectoryUpdateLastNetworkLogonDateJob : ScheduledTask - { - - public override string TaskName { get { return "Active Directory - Update Last Network Logon Dates Task"; } } - public override bool SingleInstanceTask { get { return true; } } - public override bool CancelInitiallySupported { get { return false; } } - - public override void InitalizeScheduledTask(DiscoDataContext dbContext) - { - // ActiveDirectoryUpdateLastNetworkLogonDateJob @ 11:30pm - TriggerBuilder triggerBuilder = TriggerBuilder.Create(). - WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(23, 30)); - - this.ScheduleTask(triggerBuilder); - } - - protected override void ExecuteTask() - { - int changeCount; - - this.Status.UpdateStatus(1, "Starting", "Connecting to the Database and initializing the environment"); - using (DiscoDataContext dbContext = new DiscoDataContext()) - { - UpdateLastNetworkLogonDates(dbContext, this.Status); - this.Status.UpdateStatus(95, "Updating Database", "Writing last network logon dates to the Database"); - changeCount = dbContext.SaveChanges(); - this.Status.UpdateStatus(100, "Finished", string.Format("{0} Device last network logon dates updated", changeCount)); - } - - SystemLog.LogInformation(new string[] - { - "Updated LastNetworkLogon Device Property for Device/s", - changeCount.ToString() - }); - } - - //public void InitalizeScheduledTask(DiscoDataContext dbContext, IScheduler Scheduler) - //{ - // // UpdateLastNetworkLogonDates @ 11:30pm - // IJobDetail jobDetail = new JobDetailImpl("UpdateLastNetworkLogonDates", typeof(ActiveDirectoryUpdateLastNetworkLogonDateJob)); - // ITrigger trigger = TriggerBuilder.Create(). - // WithIdentity("UpdateLastNetworkLogonDatesTrigger"). - // StartNow(). - // WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(23, 30)). - // Build(); - // Scheduler.ScheduleJob(jobDetail, trigger); - //} - - //void IJob.Execute(IJobExecutionContext context) - //{ - // DiscoDataContext dbContext = new DiscoDataContext(); - // try - // { - // ActiveDirectoryUpdateLastNetworkLogonDateJob.UpdateLastNetworkLogonDates(dbContext); - // int changeCount = dbContext.SaveChanges(); - // SystemLog.LogInformation(new string[] - // { - // "Updated LastNetworkLogon Device Property for Device/s", - // changeCount.ToString() - // }); - // } - // catch (System.Exception ex) - // { - // SystemLog.LogException("ActiveDirectoryUpdateLastNetworkLogonDateJob", ex); - // } - // finally - // { - // bool flag = dbContext != null; - // if (flag) - // { - // ((System.IDisposable)dbContext).Dispose(); - // } - // } - //} - public static bool UpdateLastNetworkLogonDate(Device Device) - { - System.DateTime? computerLastLogonDate = Device.LastNetworkLogonDate; - if (!string.IsNullOrEmpty(Device.ComputerName)) - { - foreach (var dcName in ActiveDirectoryHelpers.DefaultDomainDCNames) - { - try - { - Ping p = new Ping(); - PingReply pr; - try - { - pr = p.Send(dcName, 500); - } - finally - { - if (p != null) - { - ((System.IDisposable)p).Dispose(); - } - } - if (pr.Status == IPStatus.Success) - { - using (DirectoryEntry dRootEntry = ActiveDirectoryHelpers.DefaultDCLdapRoot(dcName)) - { - DirectorySearcher dSearcher = new DirectorySearcher(dRootEntry, string.Format("(&(objectClass=computer)(sAMAccountName={0}$))", ActiveDirectoryHelpers.EscapeLdapQuery(Device.ComputerName)), new string[] - { - "lastLogon" - }, SearchScope.Subtree); - SearchResult dResult = dSearcher.FindOne(); - if (dResult != null) - { - ResultPropertyValueCollection dProp = dResult.Properties["lastLogon"]; - if (dProp != null && dProp.Count > 0) - { - long lastLogonInt = (long)dProp[0]; - if (lastLogonInt > 0L) - { - System.DateTime computerNameDate = System.DateTime.FromFileTime(lastLogonInt); - if (computerLastLogonDate.HasValue) - { - if (System.DateTime.Compare(computerLastLogonDate.Value, computerNameDate) < 0) - { - computerLastLogonDate = computerNameDate; - } - } - else - { - computerLastLogonDate = computerNameDate; - } - } - } - } - - } - } - else - { - SystemLog.LogError(new string[] - { - string.Format("Unable to ping Domain Controller: '{0}' (ref: Disco.BI.Interop.ActiveDirectory.ActiveDirectoryUpdateLastNetworkLogonDateJob.UpdateDeviceLastNetworkLogonDate)", dcName) - }); - } - } - catch (System.Exception ex) - { - SystemLog.LogException("UpdateDeviceLastNetworkLogonDate", ex); - } - } - } - bool UpdateLastNetworkLogonDate; - if (computerLastLogonDate.HasValue) - { - if (!Device.LastNetworkLogonDate.HasValue) - { - Device.LastNetworkLogonDate = computerLastLogonDate; - UpdateLastNetworkLogonDate = true; - return UpdateLastNetworkLogonDate; - } - if (System.DateTime.Compare(computerLastLogonDate.Value, Device.LastNetworkLogonDate.Value) > 0) - { - Device.LastNetworkLogonDate = computerLastLogonDate; - UpdateLastNetworkLogonDate = true; - return UpdateLastNetworkLogonDate; - } - } - UpdateLastNetworkLogonDate = false; - return UpdateLastNetworkLogonDate; - } - public static void UpdateLastNetworkLogonDates(DiscoDataContext context, ScheduledTaskStatus status = null) - { - System.Collections.Generic.Dictionary computerLastLogonDates = new System.Collections.Generic.Dictionary(); - - int progressDCCountTotal = ActiveDirectoryHelpers.DefaultDomainDCNames.Count; - int progressDCCount = 0; - double progressDCProgress = 0; - if (progressDCCountTotal > 0) - progressDCProgress = 90 / progressDCCountTotal; - - foreach (var dcName in ActiveDirectoryHelpers.DefaultDomainDCNames) - { - try - { - PingReply pr; - using (Ping p = new Ping()) - { - pr = p.Send(dcName, 2000); - } - if (pr.Status == IPStatus.Success) - { - using (DirectoryEntry dRootEntry = ActiveDirectoryHelpers.DefaultDCLdapRoot(dcName)) - { - double progressDCStart = 5 + (progressDCCount * progressDCProgress); - if (status != null) - { - status.UpdateStatus(progressDCStart, string.Format("Querying Domain Controller: {0}", dcName), "Searching..."); - } - - using (DirectorySearcher dSearcher = new DirectorySearcher(dRootEntry, "(objectClass=computer)", new string[] { "sAMAccountName", "lastLogon" }, SearchScope.Subtree)) - { - using (SearchResultCollection dResults = dSearcher.FindAll()) - { - - int progressItemCount = 0; - double progressItemProgress = dResults.Count == 0 ? 0 : (progressDCProgress / dResults.Count); - - foreach (SearchResult dResult in dResults) - { - ResultPropertyValueCollection dProp = dResult.Properties["sAMAccountName"]; - if (dProp != null && dProp.Count > 0) - { - string computerName = ((string)dProp[0]).TrimEnd(new char[] { '$' }).ToUpper(); - - if (status != null) - if (progressItemCount % 150 == 0) // Only Update Status every 150 devices - status.UpdateStatus(progressDCStart + (progressItemProgress * progressItemCount), string.Format("Analysing Device: {0}", computerName)); - - dProp = dResult.Properties["lastLogon"]; - if (dProp != null && dProp.Count > 0) - { - long lastLogonInt = (long)dProp[0]; - if (lastLogonInt > 0L) - { - System.DateTime computerNameDate = System.DateTime.FromFileTime(lastLogonInt); - System.DateTime existingDate; - if (computerLastLogonDates.TryGetValue(computerName, out existingDate)) - { - if (System.DateTime.Compare(existingDate, computerNameDate) < 0) - { - computerLastLogonDates[computerName] = computerNameDate; - } - } - else - { - computerLastLogonDates[computerName] = computerNameDate; - } - } - } - } - progressItemCount++; - } - } - } - } - } - else - { - SystemLog.LogError(new string[] - { - string.Format("Unable to ping Domain Controller: '{0}' (ref: Disco.BI.Interop.ActiveDirectory.ActiveDirectoryUpdateLastNetworkLogonDateJob.UpdateLastNetworkLogonDates)", dcName) - }); - } - } - catch (System.Exception ex) - { - SystemLog.LogException("UpdateLastNetworkLogonDates", ex); - } - progressDCCount++; - } - - - foreach (Device d in context.Devices.Where(device => device.ComputerName != null)) - { - DateTime computerLastLogonDate; - if (computerLastLogonDates.TryGetValue(d.ComputerName.ToUpper(), out computerLastLogonDate)) - { - if (d.LastNetworkLogonDate.HasValue) - { - if (System.DateTime.Compare(d.LastNetworkLogonDate.Value, computerLastLogonDate) < 0) - { - d.LastNetworkLogonDate = computerLastLogonDate; - } - } - else - { - d.LastNetworkLogonDate = computerLastLogonDate; - } - } - } - } - } -} +using Disco.Data.Repository; +using Disco.Services.Logging; +using Disco.Models.Repository; +using Quartz; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.DirectoryServices; +using System.Linq; +using System.Linq.Expressions; +using System.Net.NetworkInformation; +using System.Reflection; +using Disco.Services.Tasks; +namespace Disco.BI.Interop.ActiveDirectory +{ + public class ActiveDirectoryUpdateLastNetworkLogonDateJob : ScheduledTask + { + + public override string TaskName { get { return "Active Directory - Update Last Network Logon Dates Task"; } } + public override bool SingleInstanceTask { get { return true; } } + public override bool CancelInitiallySupported { get { return false; } } + + public override void InitalizeScheduledTask(DiscoDataContext dbContext) + { + // ActiveDirectoryUpdateLastNetworkLogonDateJob @ 11:30pm + TriggerBuilder triggerBuilder = TriggerBuilder.Create(). + WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(23, 30)); + + this.ScheduleTask(triggerBuilder); + } + + protected override void ExecuteTask() + { + int changeCount; + + this.Status.UpdateStatus(1, "Starting", "Connecting to the Database and initializing the environment"); + using (DiscoDataContext dbContext = new DiscoDataContext()) + { + UpdateLastNetworkLogonDates(dbContext, this.Status); + this.Status.UpdateStatus(95, "Updating Database", "Writing last network logon dates to the Database"); + changeCount = dbContext.SaveChanges(); + this.Status.Finished(string.Format("{0} Device last network logon dates updated", changeCount), "/Config/SystemConfig"); + } + + SystemLog.LogInformation(new string[] + { + "Updated LastNetworkLogon Device Property for Device/s", + changeCount.ToString() + }); + } + + public static ScheduledTaskStatus ScheduleImmediately() + { + var existingTask = ScheduledTasks.GetTaskStatuses(typeof(ActiveDirectoryUpdateLastNetworkLogonDateJob)).Where(s => s.IsRunning).FirstOrDefault(); + if (existingTask != null) + return existingTask; + + var instance = new ActiveDirectoryUpdateLastNetworkLogonDateJob(); + return instance.ScheduleTask(); + } + + public static bool UpdateLastNetworkLogonDate(Device Device) + { + System.DateTime? computerLastLogonDate = Device.LastNetworkLogonDate; + if (!string.IsNullOrEmpty(Device.ComputerName)) + { + foreach (var dcName in ActiveDirectoryHelpers.DefaultDomainDCNames) + { + try + { + Ping p = new Ping(); + PingReply pr; + try + { + pr = p.Send(dcName, 500); + } + finally + { + if (p != null) + { + ((System.IDisposable)p).Dispose(); + } + } + if (pr.Status == IPStatus.Success) + { + using (DirectoryEntry dRootEntry = ActiveDirectoryHelpers.DefaultDCLdapRoot(dcName)) + { + DirectorySearcher dSearcher = new DirectorySearcher(dRootEntry, string.Format("(&(objectClass=computer)(sAMAccountName={0}$))", ActiveDirectoryHelpers.EscapeLdapQuery(Device.ComputerName)), new string[] + { + "lastLogon" + }, SearchScope.Subtree); + SearchResult dResult = dSearcher.FindOne(); + if (dResult != null) + { + ResultPropertyValueCollection dProp = dResult.Properties["lastLogon"]; + if (dProp != null && dProp.Count > 0) + { + long lastLogonInt = (long)dProp[0]; + if (lastLogonInt > 0L) + { + System.DateTime computerNameDate = System.DateTime.FromFileTime(lastLogonInt); + if (computerLastLogonDate.HasValue) + { + if (System.DateTime.Compare(computerLastLogonDate.Value, computerNameDate) < 0) + { + computerLastLogonDate = computerNameDate; + } + } + else + { + computerLastLogonDate = computerNameDate; + } + } + } + } + + } + } + else + { + SystemLog.LogError(new string[] + { + string.Format("Unable to ping Domain Controller: '{0}' (ref: Disco.BI.Interop.ActiveDirectory.ActiveDirectoryUpdateLastNetworkLogonDateJob.UpdateDeviceLastNetworkLogonDate)", dcName) + }); + } + } + catch (System.Exception ex) + { + SystemLog.LogException("UpdateDeviceLastNetworkLogonDate", ex); + } + } + } + bool UpdateLastNetworkLogonDate; + if (computerLastLogonDate.HasValue) + { + if (!Device.LastNetworkLogonDate.HasValue) + { + Device.LastNetworkLogonDate = computerLastLogonDate; + UpdateLastNetworkLogonDate = true; + return UpdateLastNetworkLogonDate; + } + if (System.DateTime.Compare(computerLastLogonDate.Value, Device.LastNetworkLogonDate.Value) > 0) + { + Device.LastNetworkLogonDate = computerLastLogonDate; + UpdateLastNetworkLogonDate = true; + return UpdateLastNetworkLogonDate; + } + } + UpdateLastNetworkLogonDate = false; + return UpdateLastNetworkLogonDate; + } + private static void UpdateLastNetworkLogonDates(DiscoDataContext context, ScheduledTaskStatus status) + { + System.Collections.Generic.Dictionary computerLastLogonDates = new System.Collections.Generic.Dictionary(); + + int progressDCCountTotal = ActiveDirectoryHelpers.DefaultDomainDCNames.Count; + int progressDCCount = 0; + double progressDCProgress = 0; + if (progressDCCountTotal > 0) + progressDCProgress = 90 / progressDCCountTotal; + + foreach (var dcName in ActiveDirectoryHelpers.DefaultDomainDCNames) + { + try + { + PingReply pr; + using (Ping p = new Ping()) + { + pr = p.Send(dcName, 2000); + } + if (pr.Status == IPStatus.Success) + { + using (DirectoryEntry dRootEntry = ActiveDirectoryHelpers.DefaultDCLdapRoot(dcName)) + { + double progressDCStart = 5 + (progressDCCount * progressDCProgress); + status.UpdateStatus(progressDCStart, string.Format("Querying Domain Controller: {0}", dcName), "Searching..."); + + using (DirectorySearcher dSearcher = new DirectorySearcher(dRootEntry, "(objectClass=computer)", new string[] { "sAMAccountName", "lastLogon" }, SearchScope.Subtree)) + { + using (SearchResultCollection dResults = dSearcher.FindAll()) + { + + int progressItemCount = 0; + double progressItemProgress = dResults.Count == 0 ? 0 : (progressDCProgress / dResults.Count); + + foreach (SearchResult dResult in dResults) + { + ResultPropertyValueCollection dProp = dResult.Properties["sAMAccountName"]; + if (dProp != null && dProp.Count > 0) + { + string computerName = ((string)dProp[0]).TrimEnd(new char[] { '$' }).ToUpper(); + + if (progressItemCount % 150 == 0) // Only Update Status every 150 devices + status.UpdateStatus(progressDCStart + (progressItemProgress * progressItemCount), string.Format("Analysing Device: {0}", computerName)); + + dProp = dResult.Properties["lastLogon"]; + if (dProp != null && dProp.Count > 0) + { + long lastLogonInt = (long)dProp[0]; + if (lastLogonInt > 0L) + { + System.DateTime computerNameDate = System.DateTime.FromFileTime(lastLogonInt); + System.DateTime existingDate; + if (computerLastLogonDates.TryGetValue(computerName, out existingDate)) + { + if (System.DateTime.Compare(existingDate, computerNameDate) < 0) + { + computerLastLogonDates[computerName] = computerNameDate; + } + } + else + { + computerLastLogonDates[computerName] = computerNameDate; + } + } + } + } + progressItemCount++; + } + } + } + } + } + else + { + SystemLog.LogError(new string[] + { + string.Format("Unable to ping Domain Controller: '{0}' (ref: Disco.BI.Interop.ActiveDirectory.ActiveDirectoryUpdateLastNetworkLogonDateJob.UpdateLastNetworkLogonDates)", dcName) + }); + } + } + catch (System.Exception ex) + { + SystemLog.LogException("UpdateLastNetworkLogonDates", ex); + } + progressDCCount++; + } + + + foreach (Device d in context.Devices.Where(device => device.ComputerName != null)) + { + DateTime computerLastLogonDate; + if (computerLastLogonDates.TryGetValue(d.ComputerName.ToUpper(), out computerLastLogonDate)) + { + if (d.LastNetworkLogonDate.HasValue) + { + if (System.DateTime.Compare(d.LastNetworkLogonDate.Value, computerLastLogonDate) < 0) + { + d.LastNetworkLogonDate = computerLastLogonDate; + } + } + else + { + d.LastNetworkLogonDate = computerLastLogonDate; + } + } + } + } + } +} diff --git a/Disco.Web/Areas/API/Controllers/SystemController.cs b/Disco.Web/Areas/API/Controllers/SystemController.cs index c1287b25..e8409d45 100644 --- a/Disco.Web/Areas/API/Controllers/SystemController.cs +++ b/Disco.Web/Areas/API/Controllers/SystemController.cs @@ -1,230 +1,220 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using Disco.BI; -using Disco.BI.Extensions; -using System.IO; -using System.Drawing; -using System.Text; -using Disco.Services.Tasks; -using Disco.BI.Interop.ActiveDirectory; -using Disco.Models.Repository; - -namespace Disco.Web.Areas.API.Controllers -{ - public partial class SystemController : dbAdminController - { - - public virtual ActionResult UpdateLastNetworkLogonDates() - { - //ActiveDirectoryUpdateLastNetworkLogonDateJob updateJob = new ActiveDirectoryUpdateLastNetworkLogonDateJob(); - - ActiveDirectoryUpdateLastNetworkLogonDateJob.UpdateLastNetworkLogonDates(dbContext); - - var resultCount = dbContext.SaveChanges(); - - var model = new Models.System.UpdateLastNetworkLogonDatesModel() - { - Result = "OK", - UpdateCount = resultCount - }; - - return Json(model, JsonRequestBehavior.AllowGet); - } - - public virtual ActionResult UpdateAttachmentThumbnails() - { - // Device Attachments - var das = dbContext.DeviceAttachments.Where(da => da.MimeType == "application/pdf"); - foreach (var da in das) - { - var fileName = da.RepositoryThumbnailFilename(dbContext); - if (!System.IO.File.Exists(fileName)) - { - da.GenerateThumbnail(dbContext); - } - } - - // User Attachments - var uas = dbContext.UserAttachments.Where(ua => ua.MimeType == "application/pdf"); - foreach (var ua in uas) - { - var fileName = ua.RepositoryThumbnailFilename(dbContext); - if (!System.IO.File.Exists(fileName)) - { - ua.GenerateThumbnail(dbContext); - } - } - - // Job Attachments - var jas = dbContext.JobAttachments.Where(ja => ja.MimeType == "application/pdf"); - foreach (var ja in jas) - { - var fileName = ja.RepositoryThumbnailFilename(dbContext); - if (!System.IO.File.Exists(fileName)) - { - ja.GenerateThumbnail(dbContext); - } - } - - return Content("Done", "text/text"); - } - - public virtual ActionResult UpdateCheck() - { - var ts = Disco.BI.Interop.Community.UpdateCheckTask.ScheduleNow(); - ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index())); - return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId)); - } - - #region Organisation - - #region Organisation Name - public virtual ActionResult UpdateOrganisationName(string OrganisationName, bool redirect = false) - { - if (string.IsNullOrWhiteSpace(OrganisationName)) - dbContext.DiscoConfiguration.OrganisationName = null; - else - dbContext.DiscoConfiguration.OrganisationName = OrganisationName; - - dbContext.SaveChanges(); - - DiscoApplication.OrganisationName = dbContext.DiscoConfiguration.OrganisationName; - - if (redirect) - return RedirectToAction(MVC.Config.Organisation.Index()); - else - return Json("OK", JsonRequestBehavior.AllowGet); - } - #endregion - - #region Organisation Logo - [OutputCache(Duration = 31536000, Location = System.Web.UI.OutputCacheLocation.Any, VaryByParam = "*")] - public virtual ActionResult OrganisationLogo(int Width = 256, int Height = 256, string v = null) - { - if (Width < 1) - throw new ArgumentOutOfRangeException("Width"); - if (Height < 1) - throw new ArgumentOutOfRangeException("Height"); - - using (Stream logoStream = dbContext.DiscoConfiguration.OrganisationLogo) - { - using (Image logoBitmap = Bitmap.FromStream(logoStream)) - { - return File(logoBitmap.ResizeImage(Width, Height).SavePng(), "image/png"); - } - } - } - [HttpPost] - public virtual ActionResult OrganisationLogo(bool redirect, HttpPostedFileBase Image, bool? ResetLogo = null) - { - if (ResetLogo.HasValue && ResetLogo.Value) - { - dbContext.DiscoConfiguration.OrganisationLogo = null; - - if (redirect) - return RedirectToAction(MVC.Config.Organisation.Index()); - else - return Json("OK", JsonRequestBehavior.AllowGet); - } - - if (Image != null && Image.ContentLength > 0) - { - if (Image.ContentType.StartsWith("image/", StringComparison.InvariantCultureIgnoreCase)) - { - dbContext.DiscoConfiguration.OrganisationLogo = Image.InputStream; - - if (redirect) - return RedirectToAction(MVC.Config.Organisation.Index()); - else - return Json("OK", JsonRequestBehavior.AllowGet); - } - else - { - if (redirect) - return RedirectToAction(MVC.Config.Organisation.Index()); - else - return Json("Invalid Content Type", JsonRequestBehavior.AllowGet); - } - } - if (redirect) - return RedirectToAction(MVC.Config.Organisation.Index()); - else - return Json("No Image Supplied", JsonRequestBehavior.AllowGet); - } - #endregion - - #region Organisation Addresses - - public virtual ActionResult UpdateOrganisationAddress(Disco.Models.BI.Config.OrganisationAddress organisationAddress, bool redirect = false) - { - if (organisationAddress == null) - { - ModelState.AddModelError("Address", "No address was supplied"); - } - if (ModelState.IsValid) - { - dbContext.DiscoConfiguration.OrganisationAddresses.SetAddress(organisationAddress); - dbContext.SaveChanges(); - if (redirect) - return RedirectToAction(MVC.Config.Organisation.Index()); - else - return Json("OK", JsonRequestBehavior.AllowGet); - } - else - { - // Build Error Message - var em = new StringBuilder(); - em.AppendLine("Error:"); - foreach (var item in ModelState) - { - foreach (var errorItem in item.Value.Errors) - { - em.Append(item.Key); - em.Append(": "); - em.AppendLine(errorItem.ErrorMessage); - } - } - if (redirect) - throw new InvalidOperationException(em.ToString()); - else - return Json(em.ToString(), JsonRequestBehavior.AllowGet); - } - } - public virtual ActionResult DeleteOrganisationAddress(int Id, bool redirect = false) - { - dbContext.DiscoConfiguration.OrganisationAddresses.RemoveAddress(Id); - dbContext.SaveChanges(); - - if (redirect) - return RedirectToAction(MVC.Config.Organisation.Index()); - else - return Json("OK", JsonRequestBehavior.AllowGet); - } - - #endregion - - #region MultiSiteMode - - public virtual ActionResult UpdateMultiSiteMode(bool MultiSiteMode, bool redirect = false) - { - dbContext.DiscoConfiguration.MultiSiteMode = MultiSiteMode; - - dbContext.SaveChanges(); - - DiscoApplication.MultiSiteMode = dbContext.DiscoConfiguration.MultiSiteMode; - - if (redirect) - return RedirectToAction(MVC.Config.Organisation.Index()); - else - return Json("OK", JsonRequestBehavior.AllowGet); - } - - #endregion - - #endregion - - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Disco.BI; +using Disco.BI.Extensions; +using System.IO; +using System.Drawing; +using System.Text; +using Disco.Services.Tasks; +using Disco.BI.Interop.ActiveDirectory; +using Disco.Models.Repository; + +namespace Disco.Web.Areas.API.Controllers +{ + public partial class SystemController : dbAdminController + { + + public virtual ActionResult UpdateLastNetworkLogonDates() + { + var taskStatus = ActiveDirectoryUpdateLastNetworkLogonDateJob.ScheduleImmediately(); + + return RedirectToAction(MVC.Config.Logging.TaskStatus(taskStatus.SessionId)); + } + + public virtual ActionResult UpdateAttachmentThumbnails() + { + // Device Attachments + var das = dbContext.DeviceAttachments.Where(da => da.MimeType == "application/pdf"); + foreach (var da in das) + { + var fileName = da.RepositoryThumbnailFilename(dbContext); + if (!System.IO.File.Exists(fileName)) + { + da.GenerateThumbnail(dbContext); + } + } + + // User Attachments + var uas = dbContext.UserAttachments.Where(ua => ua.MimeType == "application/pdf"); + foreach (var ua in uas) + { + var fileName = ua.RepositoryThumbnailFilename(dbContext); + if (!System.IO.File.Exists(fileName)) + { + ua.GenerateThumbnail(dbContext); + } + } + + // Job Attachments + var jas = dbContext.JobAttachments.Where(ja => ja.MimeType == "application/pdf"); + foreach (var ja in jas) + { + var fileName = ja.RepositoryThumbnailFilename(dbContext); + if (!System.IO.File.Exists(fileName)) + { + ja.GenerateThumbnail(dbContext); + } + } + + return Content("Done", "text/text"); + } + + public virtual ActionResult UpdateCheck() + { + var ts = Disco.BI.Interop.Community.UpdateCheckTask.ScheduleNow(); + ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index())); + return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId)); + } + + #region Organisation + + #region Organisation Name + public virtual ActionResult UpdateOrganisationName(string OrganisationName, bool redirect = false) + { + if (string.IsNullOrWhiteSpace(OrganisationName)) + dbContext.DiscoConfiguration.OrganisationName = null; + else + dbContext.DiscoConfiguration.OrganisationName = OrganisationName; + + dbContext.SaveChanges(); + + DiscoApplication.OrganisationName = dbContext.DiscoConfiguration.OrganisationName; + + if (redirect) + return RedirectToAction(MVC.Config.Organisation.Index()); + else + return Json("OK", JsonRequestBehavior.AllowGet); + } + #endregion + + #region Organisation Logo + [OutputCache(Duration = 31536000, Location = System.Web.UI.OutputCacheLocation.Any, VaryByParam = "*")] + public virtual ActionResult OrganisationLogo(int Width = 256, int Height = 256, string v = null) + { + if (Width < 1) + throw new ArgumentOutOfRangeException("Width"); + if (Height < 1) + throw new ArgumentOutOfRangeException("Height"); + + using (Stream logoStream = dbContext.DiscoConfiguration.OrganisationLogo) + { + using (Image logoBitmap = Bitmap.FromStream(logoStream)) + { + return File(logoBitmap.ResizeImage(Width, Height).SavePng(), "image/png"); + } + } + } + [HttpPost] + public virtual ActionResult OrganisationLogo(bool redirect, HttpPostedFileBase Image, bool? ResetLogo = null) + { + if (ResetLogo.HasValue && ResetLogo.Value) + { + dbContext.DiscoConfiguration.OrganisationLogo = null; + + if (redirect) + return RedirectToAction(MVC.Config.Organisation.Index()); + else + return Json("OK", JsonRequestBehavior.AllowGet); + } + + if (Image != null && Image.ContentLength > 0) + { + if (Image.ContentType.StartsWith("image/", StringComparison.InvariantCultureIgnoreCase)) + { + dbContext.DiscoConfiguration.OrganisationLogo = Image.InputStream; + + if (redirect) + return RedirectToAction(MVC.Config.Organisation.Index()); + else + return Json("OK", JsonRequestBehavior.AllowGet); + } + else + { + if (redirect) + return RedirectToAction(MVC.Config.Organisation.Index()); + else + return Json("Invalid Content Type", JsonRequestBehavior.AllowGet); + } + } + if (redirect) + return RedirectToAction(MVC.Config.Organisation.Index()); + else + return Json("No Image Supplied", JsonRequestBehavior.AllowGet); + } + #endregion + + #region Organisation Addresses + + public virtual ActionResult UpdateOrganisationAddress(Disco.Models.BI.Config.OrganisationAddress organisationAddress, bool redirect = false) + { + if (organisationAddress == null) + { + ModelState.AddModelError("Address", "No address was supplied"); + } + if (ModelState.IsValid) + { + dbContext.DiscoConfiguration.OrganisationAddresses.SetAddress(organisationAddress); + dbContext.SaveChanges(); + if (redirect) + return RedirectToAction(MVC.Config.Organisation.Index()); + else + return Json("OK", JsonRequestBehavior.AllowGet); + } + else + { + // Build Error Message + var em = new StringBuilder(); + em.AppendLine("Error:"); + foreach (var item in ModelState) + { + foreach (var errorItem in item.Value.Errors) + { + em.Append(item.Key); + em.Append(": "); + em.AppendLine(errorItem.ErrorMessage); + } + } + if (redirect) + throw new InvalidOperationException(em.ToString()); + else + return Json(em.ToString(), JsonRequestBehavior.AllowGet); + } + } + public virtual ActionResult DeleteOrganisationAddress(int Id, bool redirect = false) + { + dbContext.DiscoConfiguration.OrganisationAddresses.RemoveAddress(Id); + dbContext.SaveChanges(); + + if (redirect) + return RedirectToAction(MVC.Config.Organisation.Index()); + else + return Json("OK", JsonRequestBehavior.AllowGet); + } + + #endregion + + #region MultiSiteMode + + public virtual ActionResult UpdateMultiSiteMode(bool MultiSiteMode, bool redirect = false) + { + dbContext.DiscoConfiguration.MultiSiteMode = MultiSiteMode; + + dbContext.SaveChanges(); + + DiscoApplication.MultiSiteMode = dbContext.DiscoConfiguration.MultiSiteMode; + + if (redirect) + return RedirectToAction(MVC.Config.Organisation.Index()); + else + return Json("OK", JsonRequestBehavior.AllowGet); + } + + #endregion + + #endregion + + } +} diff --git a/Disco.Web/Areas/Config/Views/SystemConfig/Index.cshtml b/Disco.Web/Areas/Config/Views/SystemConfig/Index.cshtml index cde67b8f..7e4fc010 100644 --- a/Disco.Web/Areas/Config/Views/SystemConfig/Index.cshtml +++ b/Disco.Web/Areas/Config/Views/SystemConfig/Index.cshtml @@ -1,178 +1,179 @@ -@model Disco.Web.Areas.Config.Models.SystemConfig.IndexModel -@{ - ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "System"); -} -@using (Html.BeginForm()) -{ -
- - - - - - - - - - - - - -
Disco Version: - -
- @Model.DiscoVersion.ToString(4) -
-
- Built @Model.DiscoVersionBuilt.ToFuzzy("Unknown") -
-
Database Connection: - - - - - - - - - - - - - - - @{if (Model.DatabaseSqlAuthUsername != null) - { - - - - - } - } -
Server:@Model.DatabaseServer
Database:@Model.DatabaseName
Authentication:@Model.DatabaseAuthentication
SQL User:@Model.DatabaseSqlAuthUsername
-
Data Store Location: - - @Model.DataStoreLocation - @* @Html.EditorFor(m => m.DataStoreLocation)
- @Html.ValidationMessageFor(m => m.DataStoreLocation)*@ -
-
-
-

Updates

- - @{ - if (Model.UpdateLatestResponse == null) - { - - - - - } - else - { - - - - - if (Model.UpdateLatestResponse.IsUpdatable(typeof(DiscoApplication).Assembly.GetName().Version)) - { - - - - - } - else - { - - - - - } - } - } - - - - -
Last Check: - -
Never
-
Last Run: - - @CommonHelpers.FriendlyDate(Model.UpdateLatestResponse.ResponseTimestamp) -
Update Available: - -
- Version @(Model.UpdateLatestResponse.Version) is available -
-
- [Released @(CommonHelpers.FriendlyDate(Model.UpdateLatestResponse.VersionReleasedTimestamp))] -
-
@(new HtmlString(Model.UpdateLatestResponse.Blurb))
- Download Now -
Status: - - The latest version is installed -
Check for Update:@{ - if (Model.UpdateBetaDeployment) - { -
Beta Deployment
- } - } -
- @{ - if (Model.UpdateRunningStatus == null) - { -
@Html.ActionLink("Check Now", MVC.API.System.UpdateCheck())
- } - else - { -
Running now - @Html.ActionLink("Check Status", MVC.Config.Logging.TaskStatus(Model.UpdateRunningStatus.SessionId))
- } - } -
- Next Scheduled: @CommonHelpers.FriendlyDate(Model.UpdateNextScheduled, "Unknown") -
-
-
-
-

Proxy Settings

- - - - - - - - - - - - - - - - - -
Address: - - @Html.EditorFor(m => m.ProxyAddress)
- @Html.ValidationMessageFor(m => m.ProxyAddress) -
Port: - - @Html.EditorFor(m => m.ProxyPort)
- @Html.ValidationMessageFor(m => m.ProxyPort) -
Username: - - @Html.EditorFor(m => m.ProxyUsername)
- @Html.ValidationMessageFor(m => m.ProxyUsername) -
Password: - - @Html.EditorFor(m => m.ProxyPassword)
- @Html.ValidationMessageFor(m => m.ProxyPassword) -
-
-
- -
-} +@model Disco.Web.Areas.Config.Models.SystemConfig.IndexModel +@{ + ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "System"); +} +@using (Html.BeginForm()) +{ +
+ + + + + + + + + + + + + +
Disco Version: + +
+ @Model.DiscoVersion.ToString(4) +
+
+ Built @Model.DiscoVersionBuilt.ToFuzzy("Unknown") +
+
Database Connection: + + + + + + + + + + + + + + + @{if (Model.DatabaseSqlAuthUsername != null) + { + + + + + } + } +
Server:@Model.DatabaseServer
Database:@Model.DatabaseName
Authentication:@Model.DatabaseAuthentication
SQL User:@Model.DatabaseSqlAuthUsername
+
Data Store Location: + + @Model.DataStoreLocation + @* @Html.EditorFor(m => m.DataStoreLocation)
+ @Html.ValidationMessageFor(m => m.DataStoreLocation)*@ +
+
+
+

Updates

+ + @{ + if (Model.UpdateLatestResponse == null) + { + + + + + } + else + { + + + + + if (Model.UpdateLatestResponse.IsUpdatable(typeof(DiscoApplication).Assembly.GetName().Version)) + { + + + + + } + else + { + + + + + } + } + } + + + + +
Last Check: + +
Never
+
Last Run: + + @CommonHelpers.FriendlyDate(Model.UpdateLatestResponse.ResponseTimestamp) +
Update Available: + +
+ Version @(Model.UpdateLatestResponse.Version) is available +
+
+ [Released @(CommonHelpers.FriendlyDate(Model.UpdateLatestResponse.VersionReleasedTimestamp))] +
+
@(new HtmlString(Model.UpdateLatestResponse.Blurb))
+ Download Now +
Status: + + The latest version is installed +
Check for Update:@{ + if (Model.UpdateBetaDeployment) + { +
Beta Deployment
+ } + } +
+ @{ + if (Model.UpdateRunningStatus == null) + { +
@Html.ActionLink("Check Now", MVC.API.System.UpdateCheck())
+ } + else + { +
Running now - @Html.ActionLink("Check Status", MVC.Config.Logging.TaskStatus(Model.UpdateRunningStatus.SessionId))
+ } + } +
+ Next Scheduled: @CommonHelpers.FriendlyDate(Model.UpdateNextScheduled, "Unknown") +
+
+
+
+

Proxy Settings

+ + + + + + + + + + + + + + + + + +
Address: + + @Html.EditorFor(m => m.ProxyAddress)
+ @Html.ValidationMessageFor(m => m.ProxyAddress) +
Port: + + @Html.EditorFor(m => m.ProxyPort)
+ @Html.ValidationMessageFor(m => m.ProxyPort) +
Username: + + @Html.EditorFor(m => m.ProxyUsername)
+ @Html.ValidationMessageFor(m => m.ProxyUsername) +
Password: + + @Html.EditorFor(m => m.ProxyPassword)
+ @Html.ValidationMessageFor(m => m.ProxyPassword) +
+
+
+ @Html.ActionLinkButton("Update Device Last Network Logons", MVC.API.System.UpdateLastNetworkLogonDates()) + +
+} diff --git a/Disco.Web/Areas/Config/Views/SystemConfig/Index.generated.cs b/Disco.Web/Areas/Config/Views/SystemConfig/Index.generated.cs index 3fc8c127..db7bda4d 100644 --- a/Disco.Web/Areas/Config/Views/SystemConfig/Index.generated.cs +++ b/Disco.Web/Areas/Config/Views/SystemConfig/Index.generated.cs @@ -1,626 +1,637 @@ -#pragma warning disable 1591 -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.17929 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Disco.Web.Areas.Config.Views.SystemConfig -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Text; - using System.Web; - using System.Web.Helpers; - using System.Web.Mvc; - using System.Web.Mvc.Ajax; - using System.Web.Mvc.Html; - using System.Web.Routing; - using System.Web.Security; - using System.Web.UI; - using System.Web.WebPages; - using Disco.BI.Extensions; - using Disco.Models.Repository; - using Disco.Web; - using Disco.Web.Extensions; - - [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")] - [System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/SystemConfig/Index.cshtml")] - public class Index : System.Web.Mvc.WebViewPage - { - public Index() - { - } - public override void Execute() - { - - #line 2 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - - ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "System"); - - - #line default - #line hidden -WriteLiteral("\r\n"); - - - #line 5 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - using (Html.BeginForm()) -{ - - - #line default - #line hidden -WriteLiteral(" \r\n \r\n \r\n Disco Version:\r\n \r\n \r\n \r\n " + -" \r\n Database Connection:\r\n \r\n \r\n \r\n " + -" \r\n \r\n \r\n " + -" \r\n \r\n \r\n \r\n " + -" \r\n \r\n \r\n"); - - - #line 38 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - - - #line default - #line hidden - - #line 38 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - if (Model.DatabaseSqlAuthUsername != null) - { - - - #line default - #line hidden -WriteLiteral(" \r\n \r\n \r\n \r\n"); - - - #line 44 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - } - - - #line default - #line hidden -WriteLiteral("\r\n
\r\n " + -"
\r\n "); - - - #line 14 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Model.DiscoVersion.ToString(4)); - - - #line default - #line hidden -WriteLiteral("\r\n
\r\n (Model.DiscoVersionBuilt.ToFullDateTime() - - #line default - #line hidden -, 554), false) -); - -WriteLiteral(">\r\n Built "); - - - #line 17 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Model.DiscoVersionBuilt.ToFuzzy("Unknown")); - - - #line default - #line hidden -WriteLiteral("\r\n \r\n
\r\n " + -" \r\n
Server:"); - - - #line 28 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Model.DatabaseServer); - - - #line default - #line hidden -WriteLiteral("
Database:"); - - - #line 32 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Model.DatabaseName); - - - #line default - #line hidden -WriteLiteral("
Authentication:" + -""); - - - #line 36 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Model.DatabaseAuthentication); - - - #line default - #line hidden -WriteLiteral("
SQL Us" + -"er:"); - - - #line 42 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Model.DatabaseSqlAuthUsername); - - - #line default - #line hidden -WriteLiteral("
\r\n \r\n \r\n " + -" \r\n Data Store Location:\r\n \r\n \r\n " + -" "); - - - #line 53 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Model.DataStoreLocation); - - - #line default - #line hidden -WriteLiteral("\r\n "); - -WriteLiteral("\r\n \r\n \r\n \r\n \r\n"); - -WriteLiteral(" \r\n

Updates

\r\n \r\n"); - - - #line 63 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - - - #line default - #line hidden - - #line 63 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - - if (Model.UpdateLatestResponse == null) - { - - - #line default - #line hidden -WriteLiteral(" \r\n Last Check:\r\n \r\n \r\n \r\n"); - - - #line 73 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - } - else - { - - - #line default - #line hidden -WriteLiteral(" \r\n Last Run:\r\n \r\n \r\n \r\n"); - - - #line 83 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - if (Model.UpdateLatestResponse.IsUpdatable(typeof(DiscoApplication).Assembly.GetName().Version)) - { - - - #line default - #line hidden -WriteLiteral(" \r\n Update Available:\r\n \r\n \r\n \r\n"); - - - #line 99 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - } - else - { - - - #line default - #line hidden -WriteLiteral(" \r\n Status:\r\n \r\n \r\n" + -" \r\n"); - - - #line 109 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - } - } - - - #line default - #line hidden -WriteLiteral("\r\n \r\n Check for Update:"); - - - #line 113 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - - if (Model.UpdateBetaDeployment) - { - - - #line default - #line hidden -WriteLiteral(" Beta Deployment\r\n"); - - - #line 117 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - } - - - #line default - #line hidden -WriteLiteral("\r\n \r\n \r\n \r\n <" + -"/table>\r\n \r\n"); - -WriteLiteral(" \r\n

Proxy Settings

\r\n
\r\n " + -" Never\r\n
\r\n " + -" "); - - - #line 80 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(CommonHelpers.FriendlyDate(Model.UpdateLatestResponse.ResponseTimestamp)); - - - #line default - #line hidden -WriteLiteral("\r\n
\r\n " + -"
\r\n Version "); - - - #line 90 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Model.UpdateLatestResponse.Version); - - - #line default - #line hidden -WriteLiteral(" is available\r\n
\r\n \r\n [Released "); - - - #line 93 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(CommonHelpers.FriendlyDate(Model.UpdateLatestResponse.VersionReleasedTimestamp)); - - - #line default - #line hidden -WriteLiteral("]\r\n \r\n "); - - - #line 95 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(new HtmlString(Model.UpdateLatestResponse.Blurb)); - - - #line default - #line hidden -WriteLiteral("\r\n (Model.UpdateLatestResponse.UrlLink - - #line default - #line hidden -, 4136), false) -); - -WriteLiteral(" target=\"_blank\""); - -WriteLiteral(">Download Now\r\n
\r\n " + -" The latest version is installed\r\n
\r\n"); - - - #line 121 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - - - #line default - #line hidden - - #line 121 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - - if (Model.UpdateRunningStatus == null) - { - - - #line default - #line hidden -WriteLiteral("
"); - - - #line 124 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.ActionLink("Check Now", MVC.API.System.UpdateCheck())); - - - #line default - #line hidden -WriteLiteral("
\r\n"); - - - #line 125 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - } - else - { - - - #line default - #line hidden -WriteLiteral("
Running now - "); - - - #line 128 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.ActionLink("Check Status", MVC.Config.Logging.TaskStatus(Model.UpdateRunningStatus.SessionId))); - - - #line default - #line hidden -WriteLiteral("
\r\n"); - - - #line 129 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - } - - - #line default - #line hidden -WriteLiteral("\r\n \r\n Next Scheduled: "); - - - #line 132 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(CommonHelpers.FriendlyDate(Model.UpdateNextScheduled, "Unknown")); - - - #line default - #line hidden -WriteLiteral("\r\n \r\n
\r\n \r\n " + -" Address:\r\n \r\n \r\n \r\n \r\n Port:\r\n \r\n \r\n \r\n \r\n Username:\r\n \r\n \r\n \r\n \r\n Password:\r\n \r\n \r\n \r\n
\r\n"); - -WriteLiteral(" "); - - - #line 145 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.EditorFor(m => m.ProxyAddress)); - - - #line default - #line hidden -WriteLiteral("
\r\n"); - -WriteLiteral(" "); - - - #line 146 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.ValidationMessageFor(m => m.ProxyAddress)); - - - #line default - #line hidden -WriteLiteral("\r\n
\r\n"); - -WriteLiteral(" "); - - - #line 153 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.EditorFor(m => m.ProxyPort)); - - - #line default - #line hidden -WriteLiteral("
\r\n"); - -WriteLiteral(" "); - - - #line 154 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.ValidationMessageFor(m => m.ProxyPort)); - - - #line default - #line hidden -WriteLiteral("\r\n
\r\n"); - -WriteLiteral(" "); - - - #line 161 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.EditorFor(m => m.ProxyUsername)); - - - #line default - #line hidden -WriteLiteral("
\r\n"); - -WriteLiteral(" "); - - - #line 162 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.ValidationMessageFor(m => m.ProxyUsername)); - - - #line default - #line hidden -WriteLiteral("\r\n
\r\n"); - -WriteLiteral(" "); - - - #line 169 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.EditorFor(m => m.ProxyPassword)); - - - #line default - #line hidden -WriteLiteral("
\r\n"); - -WriteLiteral(" "); - - - #line 170 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" - Write(Html.ValidationMessageFor(m => m.ProxyPassword)); - - - #line default - #line hidden -WriteLiteral("\r\n
\r\n \r\n"); - -WriteLiteral(" \r\n \r\n \r\n"); - - - #line 178 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" -} - - - #line default - #line hidden - } - } -} -#pragma warning restore 1591 +#pragma warning disable 1591 +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Disco.Web.Areas.Config.Views.SystemConfig +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Text; + using System.Web; + using System.Web.Helpers; + using System.Web.Mvc; + using System.Web.Mvc.Ajax; + using System.Web.Mvc.Html; + using System.Web.Routing; + using System.Web.Security; + using System.Web.UI; + using System.Web.WebPages; + using Disco.BI.Extensions; + using Disco.Models.Repository; + using Disco.Web; + using Disco.Web.Extensions; + + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")] + [System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/SystemConfig/Index.cshtml")] + public class Index : System.Web.Mvc.WebViewPage + { + public Index() + { + } + public override void Execute() + { + + #line 2 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + + ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "System"); + + + #line default + #line hidden +WriteLiteral("\r\n"); + + + #line 5 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + using (Html.BeginForm()) +{ + + + #line default + #line hidden +WriteLiteral(" \r\n \r\n \r\n Disco Version:\r\n \r\n \r\n \r\n " + +" \r\n Database Connection:\r\n \r\n \r\n \r\n " + +" \r\n \r\n \r\n " + +" \r\n \r\n \r\n \r\n " + +" \r\n \r\n \r\n"); + + + #line 38 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + + + #line default + #line hidden + + #line 38 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + if (Model.DatabaseSqlAuthUsername != null) + { + + + #line default + #line hidden +WriteLiteral(" \r\n \r\n \r\n \r\n"); + + + #line 44 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + } + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n " + +"
\r\n "); + + + #line 14 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Model.DiscoVersion.ToString(4)); + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n (Model.DiscoVersionBuilt.ToFullDateTime() + + #line default + #line hidden +, 554), false) +); + +WriteLiteral(">\r\n Built "); + + + #line 17 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Model.DiscoVersionBuilt.ToFuzzy("Unknown")); + + + #line default + #line hidden +WriteLiteral("\r\n \r\n
\r\n " + +" \r\n
Server:"); + + + #line 28 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Model.DatabaseServer); + + + #line default + #line hidden +WriteLiteral("
Database:"); + + + #line 32 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Model.DatabaseName); + + + #line default + #line hidden +WriteLiteral("
Authentication:" + +""); + + + #line 36 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Model.DatabaseAuthentication); + + + #line default + #line hidden +WriteLiteral("
SQL Us" + +"er:"); + + + #line 42 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Model.DatabaseSqlAuthUsername); + + + #line default + #line hidden +WriteLiteral("
\r\n \r\n \r\n " + +" \r\n Data Store Location:\r\n \r\n \r\n " + +" "); + + + #line 53 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Model.DataStoreLocation); + + + #line default + #line hidden +WriteLiteral("\r\n "); + +WriteLiteral("\r\n \r\n \r\n \r\n \r\n"); + +WriteLiteral(" \r\n

Updates

\r\n \r\n"); + + + #line 63 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + + + #line default + #line hidden + + #line 63 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + + if (Model.UpdateLatestResponse == null) + { + + + #line default + #line hidden +WriteLiteral(" \r\n Last Check:\r\n \r\n \r\n \r\n"); + + + #line 73 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + } + else + { + + + #line default + #line hidden +WriteLiteral(" \r\n Last Run:\r\n \r\n \r\n \r\n"); + + + #line 83 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + if (Model.UpdateLatestResponse.IsUpdatable(typeof(DiscoApplication).Assembly.GetName().Version)) + { + + + #line default + #line hidden +WriteLiteral(" \r\n Update Available:\r\n \r\n \r\n \r\n"); + + + #line 99 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + } + else + { + + + #line default + #line hidden +WriteLiteral(" \r\n Status:\r\n \r\n \r\n" + +" \r\n"); + + + #line 109 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + } + } + + + #line default + #line hidden +WriteLiteral("\r\n \r\n Check for Update:"); + + + #line 113 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + + if (Model.UpdateBetaDeployment) + { + + + #line default + #line hidden +WriteLiteral(" Beta Deployment\r\n"); + + + #line 117 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + } + + + #line default + #line hidden +WriteLiteral("\r\n \r\n \r\n \r\n <" + +"/table>\r\n \r\n"); + +WriteLiteral(" \r\n

Proxy Settings

\r\n
\r\n " + +" Never\r\n
\r\n " + +" "); + + + #line 80 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(CommonHelpers.FriendlyDate(Model.UpdateLatestResponse.ResponseTimestamp)); + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n " + +"
\r\n Version "); + + + #line 90 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Model.UpdateLatestResponse.Version); + + + #line default + #line hidden +WriteLiteral(" is available\r\n
\r\n \r\n [Released "); + + + #line 93 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(CommonHelpers.FriendlyDate(Model.UpdateLatestResponse.VersionReleasedTimestamp)); + + + #line default + #line hidden +WriteLiteral("]\r\n \r\n "); + + + #line 95 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(new HtmlString(Model.UpdateLatestResponse.Blurb)); + + + #line default + #line hidden +WriteLiteral("\r\n (Model.UpdateLatestResponse.UrlLink + + #line default + #line hidden +, 4136), false) +); + +WriteLiteral(" target=\"_blank\""); + +WriteLiteral(">Download Now\r\n
\r\n " + +" The latest version is installed\r\n
\r\n"); + + + #line 121 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + + + #line default + #line hidden + + #line 121 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + + if (Model.UpdateRunningStatus == null) + { + + + #line default + #line hidden +WriteLiteral("
"); + + + #line 124 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.ActionLink("Check Now", MVC.API.System.UpdateCheck())); + + + #line default + #line hidden +WriteLiteral("
\r\n"); + + + #line 125 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + } + else + { + + + #line default + #line hidden +WriteLiteral("
Running now - "); + + + #line 128 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.ActionLink("Check Status", MVC.Config.Logging.TaskStatus(Model.UpdateRunningStatus.SessionId))); + + + #line default + #line hidden +WriteLiteral("
\r\n"); + + + #line 129 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + } + + + #line default + #line hidden +WriteLiteral("\r\n \r\n Next Scheduled: "); + + + #line 132 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(CommonHelpers.FriendlyDate(Model.UpdateNextScheduled, "Unknown")); + + + #line default + #line hidden +WriteLiteral("\r\n \r\n
\r\n \r\n " + +" Address:\r\n \r\n \r\n \r\n \r\n Port:\r\n \r\n \r\n \r\n \r\n Username:\r\n \r\n \r\n \r\n \r\n Password:\r\n \r\n \r\n \r\n
\r\n"); + +WriteLiteral(" "); + + + #line 145 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.EditorFor(m => m.ProxyAddress)); + + + #line default + #line hidden +WriteLiteral("
\r\n"); + +WriteLiteral(" "); + + + #line 146 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.ValidationMessageFor(m => m.ProxyAddress)); + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n"); + +WriteLiteral(" "); + + + #line 153 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.EditorFor(m => m.ProxyPort)); + + + #line default + #line hidden +WriteLiteral("
\r\n"); + +WriteLiteral(" "); + + + #line 154 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.ValidationMessageFor(m => m.ProxyPort)); + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n"); + +WriteLiteral(" "); + + + #line 161 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.EditorFor(m => m.ProxyUsername)); + + + #line default + #line hidden +WriteLiteral("
\r\n"); + +WriteLiteral(" "); + + + #line 162 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.ValidationMessageFor(m => m.ProxyUsername)); + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n"); + +WriteLiteral(" "); + + + #line 169 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.EditorFor(m => m.ProxyPassword)); + + + #line default + #line hidden +WriteLiteral("
\r\n"); + +WriteLiteral(" "); + + + #line 170 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.ValidationMessageFor(m => m.ProxyPassword)); + + + #line default + #line hidden +WriteLiteral("\r\n
\r\n \r\n"); + +WriteLiteral(" \r\n"); + +WriteLiteral(" "); + + + #line 176 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" + Write(Html.ActionLinkButton("Update Device Last Network Logons", MVC.API.System.UpdateLastNetworkLogonDates())); + + + #line default + #line hidden +WriteLiteral("\r\n \r\n \r\n"); + + + #line 179 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" +} + + + #line default + #line hidden + } + } +} +#pragma warning restore 1591