qol: interpolated strings

This commit is contained in:
Gary Sharp
2025-07-20 11:56:34 +10:00
parent 4e518d6684
commit 7faebe56a8
108 changed files with 342 additions and 350 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ namespace Disco.Web
// Scripts - Modules
#if DEBUG
foreach (FileInfo f in new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ClientSource/Scripts/Modules")).EnumerateFiles("*.js", SearchOption.TopDirectoryOnly))
BundleTable.Add(new FileBundle(string.Format("~/ClientScripts/Modules/{0}", f.Name.Substring(0, f.Name.Length - 3)), f.FullName));
BundleTable.Add(new FileBundle($"~/ClientScripts/Modules/{f.Name.Substring(0, f.Name.Length - 3)}", f.FullName));
#else
foreach (FileInfo f in new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ClientSource/Scripts/Modules")).EnumerateFiles("*.min.js", SearchOption.TopDirectoryOnly))
BundleTable.Add(new FileBundle(string.Format("~/ClientScripts/Modules/{0}", f.Name.Substring(0, f.Name.Length - 7)), f.FullName));
@@ -52,7 +52,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -114,7 +114,7 @@ namespace Disco.Web.Areas.API.Controllers
var invalidSubjects = subjects.Where(s => s.Item2 == null).ToList();
if (invalidSubjects.Count > 0)
throw new ArgumentException(string.Format("Subjects not found: {0}", string.Join(", ", invalidSubjects)), "Subjects");
throw new ArgumentException($"Subjects not found: {string.Join(", ", invalidSubjects)}", "Subjects");
var proposedSubjects = subjects.Select(s => s.Item2.Id).OrderBy(s => s).ToArray();
var currentSubjects = AuthorizationRole.SubjectIds == null ? new string[0] : AuthorizationRole.SubjectIds.Split(',');
@@ -170,7 +170,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -200,7 +200,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -229,7 +229,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -253,7 +253,7 @@ namespace Disco.Web.Areas.API.Controllers
var invalidSubjects = subjects.Where(s => s.Item2 == null).ToList();
if (invalidSubjects.Count > 0)
throw new ArgumentException(string.Format("Subjects not found: {0}", string.Join(", ", invalidSubjects)), "Subjects");
throw new ArgumentException($"Subjects not found: {string.Join(", ", invalidSubjects)}", "Subjects");
proposedSubjects = subjects.Select(s => s.Item2.Id).OrderBy(s => s).ToArray();
var currentSubjects = UserService.AdministratorSubjectIds;
@@ -25,7 +25,7 @@ namespace Disco.Web.Areas.API.Controllers
}
catch (Exception ex)
{
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
public virtual ActionResult MacSshPassword(string MacSshPassword)
@@ -45,7 +45,7 @@ namespace Disco.Web.Areas.API.Controllers
}
catch (Exception ex)
{
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -116,7 +116,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -235,7 +235,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.DeviceBatch.Configure)]
@@ -267,7 +267,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#endregion
@@ -534,7 +534,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -595,7 +595,7 @@ namespace Disco.Web.Areas.API.Controllers
start = bi.PurchaseDate,
end = bi.WarrantyValidUntil,
caption = bi.DefaultModelDescription,
title = string.Format("{0} [{1} x{2}]", bi.Name, bi.DefaultModelDescription, bi.DeviceCount),
title = $"{bi.Name} [{bi.DefaultModelDescription} x{bi.DeviceCount}]",
textColor = "#000",
description = bi.Comments ?? string.Empty,
color = ColorTranslator.ToHtml(color),
@@ -16,7 +16,7 @@ namespace Disco.Web.Areas.API.Controllers
{
throw new Exception("Invalid Device Certificate Id");
}
return File(wc.Content, "application/x-pkcs12", string.Format("{0}.pfx", wc.Name));
return File(wc.Content, "application/x-pkcs12", $"{wc.Name}.pfx");
}
}
@@ -106,7 +106,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -131,7 +131,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
@@ -75,7 +75,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -223,7 +223,7 @@ namespace Disco.Web.Areas.API.Controllers
// DataStore Failed - Use Generic Images
if (m.ModelType != null)
{
var modelTypePath = Server.MapPath(string.Format("~/ClientSource/Style/Images/DeviceTypes/{0}.png", m.ModelType));
var modelTypePath = Server.MapPath($"~/ClientSource/Style/Images/DeviceTypes/{m.ModelType}.png");
if (System.IO.File.Exists(modelTypePath))
{
return File(modelTypePath, "image/png");
@@ -295,7 +295,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -121,7 +121,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -375,7 +375,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.DeviceProfile.Configure)]
@@ -407,7 +407,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#endregion
@@ -467,7 +467,7 @@ namespace Disco.Web.Areas.API.Controllers
var featureManifest = Plugins.GetPluginFeature(certificateProviderId, typeof(CertificateProviderFeature));
if (featureManifest == null)
{
throw new Exception(string.Format("Invalid Certificate Provider Plugin Id: [{0}]", certificateProviderId));
throw new Exception($"Invalid Certificate Provider Plugin Id: [{certificateProviderId}]");
}
else
{
@@ -503,7 +503,7 @@ namespace Disco.Web.Areas.API.Controllers
var featureManifest = Plugins.GetPluginFeature(certificateAuthorityProviderId, typeof(CertificateAuthorityProviderFeature));
if (featureManifest == null)
{
throw new Exception(string.Format("Invalid Certificate Authority Provider Plugin Id: [{0}]", certificateAuthorityProviderId));
throw new Exception($"Invalid Certificate Authority Provider Plugin Id: [{certificateAuthorityProviderId}]");
}
else
{
@@ -539,7 +539,7 @@ namespace Disco.Web.Areas.API.Controllers
var featureManifest = Plugins.GetPluginFeature(wirelessProfileProviderId, typeof(WirelessProfileProviderFeature));
if (featureManifest == null)
{
throw new Exception(string.Format("Invalid Wireless Profile Provider Plugin Id: [{0}]", wirelessProfileProviderId));
throw new Exception($"Invalid Wireless Profile Provider Plugin Id: [{wirelessProfileProviderId}]");
}
else
{
@@ -728,7 +728,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -758,7 +758,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -792,7 +792,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -104,7 +104,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -120,7 +120,7 @@ namespace Disco.Web.Areas.API.Controllers
var filename = documentTemplate.RepositoryFilename(Database);
if (System.IO.File.Exists(filename))
{
return File(filename, DocumentTemplate.PdfMimeType, string.Format("{0}.pdf", documentTemplate.Id));
return File(filename, DocumentTemplate.PdfMimeType, $"{documentTemplate.Id}.pdf");
}
else
{
@@ -151,7 +151,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -235,7 +235,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -269,7 +269,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -302,7 +302,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#endregion
@@ -498,7 +498,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult ImporterThumbnail(string SessionId, int PageNumber)
{
var dataStoreSessionPagesCacheLocation = DataStore.CreateLocation(Database, "Cache\\DocumentDropBox_SessionPages");
var filename = System.IO.Path.Combine(dataStoreSessionPagesCacheLocation, string.Format("{0}-{1}", SessionId, PageNumber));
var filename = System.IO.Path.Combine(dataStoreSessionPagesCacheLocation, $"{SessionId}-{PageNumber}");
if (System.IO.File.Exists(filename))
return File(filename, "image/png");
else
@@ -1318,7 +1318,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -76,7 +76,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -111,7 +111,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -165,7 +165,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -381,7 +381,7 @@ namespace Disco.Web.Areas.API.Controllers
var timeStamp = DateTime.Now;
var pdf = package.GeneratePdfPackageBulk(Database, UserService.CurrentUser, timeStamp, InsertBlankPage, dataIds);
return File(pdf, "application/pdf", string.Format("{0}_Bulk_{1:yyyyMMdd-HHmmss}.pdf", package.Id, timeStamp));
return File(pdf, "application/pdf", $"{package.Id}_Bulk_{timeStamp:yyyyMMdd-HHmmss}.pdf");
}
public virtual ActionResult Generate(string id, string TargetId)
@@ -455,7 +455,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -306,7 +306,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -1476,7 +1476,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -1519,7 +1519,7 @@ namespace Disco.Web.Areas.API.Controllers
JobId = job.Id,
TechUserId = CurrentUser.UserId,
Timestamp = DateTime.Now,
Comments = string.Format("# Added Flag\r\n**{0}**\r\n{1}", flagStatus.Item1, string.IsNullOrWhiteSpace(Reason) ? "<no reason provided>" : Reason)
Comments = $"# Added Flag\r\n**{flagStatus.Item1}**\r\n{(string.IsNullOrWhiteSpace(Reason) ? "<no reason provided>" : Reason)}"
};
Database.JobLogs.Add(jobLog);
@@ -1542,7 +1542,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -1573,7 +1573,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -1604,7 +1604,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -2192,9 +2192,9 @@ namespace Disco.Web.Areas.API.Controllers
if (locRef.References != null && locRef.References.Count > 0)
{
if (locRef.References.Count == 1)
reference = string.Format("Job {0}", locRef.References[0].JobId);
reference = $"Job {locRef.References[0].JobId}";
else
reference = string.Format("{0} jobs", locRef.References.Count);
reference = $"{locRef.References.Count} jobs";
}
return new Models.Job.DeviceHeldLocationModel()
@@ -71,7 +71,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -139,7 +139,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -170,7 +170,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -199,7 +199,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#endregion
@@ -295,7 +295,7 @@ namespace Disco.Web.Areas.API.Controllers
var invalidSubjects = subjects.Where(s => s.Item2 == null).ToList();
if (invalidSubjects.Count > 0)
throw new ArgumentException(string.Format("Subjects not found: {0}", string.Join(", ", invalidSubjects)), "Subjects");
throw new ArgumentException($"Subjects not found: {string.Join(", ", invalidSubjects)}", "Subjects");
var proposedSubjects = subjects.Select(s => s.Item2.Id).OrderBy(s => s).ToArray();
@@ -364,7 +364,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#endregion
@@ -50,7 +50,7 @@ namespace Disco.Web.Areas.API.Controllers
throw new Exception("Invalid Job Queue Job Id");
}
if (redirect.HasValue && redirect.Value)
return Redirect(string.Format("{0}#jobDetailTab-Queues", Url.Action(MVC.Job.Show(jobQueueJob.JobId))));
return Redirect($"{Url.Action(MVC.Job.Show(jobQueueJob.JobId))}#jobDetailTab-Queues");
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
@@ -59,7 +59,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -104,7 +104,7 @@ namespace Disco.Web.Areas.API.Controllers
throw new Exception("Invalid Job Queue Job Id");
}
if (redirect.HasValue && redirect.Value)
return Redirect(string.Format("{0}#jobDetailTab-Queues", Url.Action(MVC.Job.Show(jobQueueJob.JobId))));
return Redirect($"{Url.Action(MVC.Job.Show(jobQueueJob.JobId))}#jobDetailTab-Queues");
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
@@ -113,7 +113,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#endregion
@@ -195,7 +195,7 @@ namespace Disco.Web.Areas.API.Controllers
var jobQueueJob = job.OnAddQueue(Database, jobQueueToken.JobQueue, CurrentUser, Comment, SLAExpires, Priority);
Database.SaveChanges();
return Redirect(string.Format("{0}#jobDetailTab-Queues", Url.Action(MVC.Job.Show(job.Id))));
return Redirect($"{Url.Action(MVC.Job.Show(job.Id))}#jobDetailTab-Queues");
}
[DiscoAuthorizeAny(Claims.Job.Actions.RemoveAnyQueues, Claims.Job.Actions.RemoveOwnQueues)]
@@ -223,7 +223,7 @@ namespace Disco.Web.Areas.API.Controllers
Database.SaveChanges();
}
return Redirect(string.Format("{0}#jobDetailTab-Queues", Url.Action(MVC.Job.Show(job.Id))));
return Redirect($"{Url.Action(MVC.Job.Show(job.Id))}#jobDetailTab-Queues");
}
#endregion
@@ -85,7 +85,7 @@ namespace Disco.Web.Areas.API.Controllers
if (Plugins.PluginInstalled(libraryItem.Id))
throw new InvalidOperationException("This plugin is already installed");
var tempPluginLocation = Path.Combine(Database.DiscoConfiguration.PluginPackagesLocation, string.Format("{0}.discoPlugin", libraryItem.Id));
var tempPluginLocation = Path.Combine(Database.DiscoConfiguration.PluginPackagesLocation, $"{libraryItem.Id}.discoPlugin");
var status = InstallPluginTask.InstallPlugin(libraryItem.LatestCompatibleRelease(libraryIncompatibility).DownloadUrl, tempPluginLocation, true);
@@ -275,7 +275,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -75,7 +75,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -131,7 +131,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.UserFlag.Configure)]
@@ -174,7 +174,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.UserFlag.Configure)]
@@ -207,7 +207,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#endregion
@@ -371,7 +371,7 @@ namespace Disco.Web.Areas.API.Controllers
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
@@ -17,7 +17,7 @@ namespace Disco.Web.Areas.API.Models.DeviceModel
Id = dc.Id,
Description = dc.Description,
Cost = dc.Cost.ToString("C"),
JobSubTypes = dc.JobSubTypes.Select(j => string.Format("{0}_{1}", j.JobTypeId, j.Id)).ToList()
JobSubTypes = dc.JobSubTypes.Select(j => $"{j.JobTypeId}_{j.Id}").ToList()
};
}
@@ -13,7 +13,7 @@ namespace Disco.Web.Areas.API.Models.DocumentTemplate
return new ImporterUndetectedDataIdLookupModel
{
value = item.Id,
label = string.Format("{0} - {1} - {2}", item.Id, item.ComputerName, item.DeviceModelDescription)
label = $"{item.Id} - {item.ComputerName} - {item.DeviceModelDescription}"
};
}
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(JobTableItemModel item)
@@ -21,7 +21,7 @@ namespace Disco.Web.Areas.API.Models.DocumentTemplate
return new ImporterUndetectedDataIdLookupModel
{
value = item.JobId.ToString(),
label = string.Format("{0} ({1}; {2})", item.JobId, item.DeviceSerialNumber, item.UserDisplayName)
label = $"{item.JobId} ({item.DeviceSerialNumber}; {item.UserDisplayName})"
};
}
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(UserSearchResultItem item)
@@ -29,7 +29,7 @@ namespace Disco.Web.Areas.API.Models.DocumentTemplate
return new ImporterUndetectedDataIdLookupModel
{
value = item.Id,
label = string.Format("{0} - {1}", item.Id, item.DisplayName)
label = $"{item.Id} - {item.DisplayName}"
};
}
@@ -15,7 +15,7 @@ namespace Disco.Web.Areas.Config.Models.DeviceModel
public override string ToString()
{
if (string.IsNullOrEmpty(Name))
return string.Format("{0} {1}", Manufacturer, Model);
return $"{Manufacturer} {Model}";
else
return Name;
}
@@ -67,7 +67,7 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
{
if (model.Types != null && model.SubTypes != null)
{
var typeId = string.Format("{0}_", model.Types);
var typeId = $"{model.Types}_";
model.SubTypes = model.SubTypes.Where(m => model.Types.Contains(m.Substring(0, m.IndexOf("_")))).ToList();
}
}
@@ -70,7 +70,7 @@ namespace Disco.Web.Areas.Config.Models.JobPreferences
var current = LongRunningJobDaysThreshold;
if (!options.Any(o => o.Key == current))
{
options.Add(new KeyValuePair<int, string>(current, string.Format("{0} Days", current)));
options.Add(new KeyValuePair<int, string>(current, $"{current} Days"));
options = options.OrderBy(o => o.Key).ToList();
}
@@ -106,7 +106,7 @@ namespace Disco.Web.Areas.Config.Models.JobPreferences
var current = StaleJobMinutesThreshold;
if (!options.Any(o => o.Key == current))
{
options.Add(new KeyValuePair<int, string>(current, string.Format("{0} Minutes", current)));
options.Add(new KeyValuePair<int, string>(current, $"{current} Minutes"));
options = options.OrderBy(o => o.Key).ToList();
}
@@ -87,7 +87,7 @@ namespace Disco.Web.Areas.Services.Controllers
}
}
}
throw new MissingMethodException(string.Format("Unknown Feature: {0}", feature));
throw new MissingMethodException($"Unknown Feature: {feature}");
}
[Authorize]
@@ -136,7 +136,7 @@ namespace Disco.Web.Areas.Services.Controllers
return Json(enrolResponse);
}
}
throw new MissingMethodException(string.Format("Unknown Feature: {0}", feature));
throw new MissingMethodException($"Unknown Feature: {feature}");
}
public virtual ActionResult ClientError(string SessionId, string DeviceIdentifier, string JsonException)
+1 -1
View File
@@ -240,7 +240,7 @@ namespace Disco.Web.Controllers
.FirstOrDefault(d => d.SerialNumber == id);
if (m.Device == null)
throw new ArgumentException(string.Format("Unknown Device: [{0}]", id), "id");
throw new ArgumentException($"Unknown Device: [{id}]", "id");
// No Necessary - Yet...
//if (!string.IsNullOrWhiteSpace(m.Device.ComputerName))
@@ -150,11 +150,11 @@ namespace Disco.Web.Controllers
if (sqlException != null)
{
ModelState.AddModelError(string.Empty, string.Format("Unable to create or migrate the database to the latest version: [{0}] {1}", sqlException.GetType().Name, sqlException.Message));
ModelState.AddModelError(string.Empty, $"Unable to create or migrate the database to the latest version: [{sqlException.GetType().Name}] {sqlException.Message}");
}
else
{
ModelState.AddModelError(string.Empty, string.Format("Unable to create or migrate the database to the latest version: [{0}] {1}", innermostException.GetType().Name, innermostException.Message));
ModelState.AddModelError(string.Empty, $"Unable to create or migrate the database to the latest version: [{innermostException.GetType().Name}] {innermostException.Message}");
}
}
@@ -232,7 +232,7 @@ namespace Disco.Web.Controllers
}
catch (Exception ex)
{
ModelState.AddModelError(string.Empty, string.Format("Unable to extract File Store template: [{0}] {1}", ex.GetType().Name, ex.Message));
ModelState.AddModelError(string.Empty, $"Unable to extract File Store template: [{ex.GetType().Name}] {ex.Message}");
}
}
@@ -313,7 +313,7 @@ namespace Disco.Web.Controllers
var invalidSubjects = subjects.Where(s => s.Item2 == null).ToList();
if (invalidSubjects.Count > 0)
throw new ArgumentException(string.Format("Subjects not found: {0}", string.Join(", ", invalidSubjects)), "Subjects");
throw new ArgumentException($"Subjects not found: {string.Join(", ", invalidSubjects)}", "Subjects");
proposedSubjects = subjects.Select(s => s.Item2.Id).OrderBy(s => s).ToArray();
var currentSubjects = UserService.AdministratorSubjectIds;
+6 -6
View File
@@ -69,7 +69,7 @@ namespace Disco.Web.Controllers
if (queueToken == null)
throw new ArgumentException("Invalid Job Queue Id", "id");
var m = new Models.Job.ListModel() { Title = string.Format("Queue: {0}", queueToken.JobQueue.Name) };
var m = new Models.Job.ListModel() { Title = $"Queue: {queueToken.JobQueue.Name}" };
m.JobTable = ManagedJobList.OpenJobsTable(q => q.Where(j => j.ActiveJobQueues.Any(jqj => jqj.QueueId == queueToken.JobQueue.Id)));
// UI Extensions
@@ -326,7 +326,7 @@ namespace Disco.Web.Controllers
.FirstOrDefault(j => j.Id == id.Value);
if (m.Job == null)
throw new ArgumentException(string.Format("Unknown Job: [{0}]", id), "id");
throw new ArgumentException($"Unknown Job: [{id}]", "id");
// Validate Authorization
switch (m.Job.JobTypeId)
@@ -695,14 +695,14 @@ namespace Disco.Web.Controllers
else
{
model.JobDetailsSupported = false;
model.JobDetailsNotSupportedMessage = string.Format("Plugin '{0} ({1})' (Warranty Provider for '{2}') doesn't support Job Details", providerInstance.Manifest.Name, providerInstance.Manifest.Id, providerInstance.WarrantyProviderId);
model.JobDetailsNotSupportedMessage = $"Plugin '{providerInstance.Manifest.Name} ({providerInstance.Manifest.Id})' (Warranty Provider for '{providerInstance.WarrantyProviderId}') doesn't support Job Details";
return View(model);
}
}
}
model.JobDetailsSupported = false;
model.JobDetailsNotSupportedMessage = string.Format("Warranty Provider '{0}' is not integrated with Disco ICT", job.JobMetaWarranty.ExternalName);
model.JobDetailsNotSupportedMessage = $"Warranty Provider '{job.JobMetaWarranty.ExternalName}' is not integrated with Disco ICT";
return View(model);
}
else
@@ -874,14 +874,14 @@ namespace Disco.Web.Controllers
else
{
model.JobDetailsSupported = false;
model.JobDetailsNotSupportedMessage = string.Format("Plugin '{0} ({1})' (Repair Provider for '{2}') doesn't support Job Details", providerInstance.Manifest.Name, providerInstance.Manifest.Id, providerInstance.ProviderId);
model.JobDetailsNotSupportedMessage = $"Plugin '{providerInstance.Manifest.Name} ({providerInstance.Manifest.Id})' (Repair Provider for '{providerInstance.ProviderId}') doesn't support Job Details";
return View(model);
}
}
}
model.JobDetailsSupported = false;
model.JobDetailsNotSupportedMessage = string.Format("Repair Provider '{0}' is not integrated with Disco ICT", job.JobMetaNonWarranty.RepairerName);
model.JobDetailsNotSupportedMessage = $"Repair Provider '{job.JobMetaNonWarranty.RepairerName}' is not integrated with Disco ICT";
return View(model);
}
else
@@ -32,7 +32,7 @@ namespace Disco.Web.Controllers
catch (AccessDeniedException accessDeniedException)
{
if (UserService.CurrentUserId != null)
AuthorizationLog.LogAccessDenied(UserService.CurrentUserId, string.Format("{0} [{1}]", accessDeniedException.Resource, Request.RawUrl), accessDeniedException.Message);
AuthorizationLog.LogAccessDenied(UserService.CurrentUserId, $"{accessDeniedException.Resource} [{Request.RawUrl}]", accessDeniedException.Message);
return new HttpUnauthorizedResult();
}
+5 -5
View File
@@ -88,7 +88,7 @@ namespace Disco.Web.Controllers
break;
}
}
m.FriendlyTerm = string.Format("Device Model: {0}", term);
m.FriendlyTerm = $"Device Model: {term}";
m.Success = false;
m.ErrorMessage = "Invalid Device Model Id";
break;
@@ -105,7 +105,7 @@ namespace Disco.Web.Controllers
break;
}
}
m.FriendlyTerm = string.Format("Device Profile: {0}", term);
m.FriendlyTerm = $"Device Profile: {term}";
m.Success = false;
m.ErrorMessage = "Invalid Device Profile Id";
break;
@@ -122,7 +122,7 @@ namespace Disco.Web.Controllers
break;
}
}
m.FriendlyTerm = string.Format("Device Batch: {0}", term);
m.FriendlyTerm = $"Device Batch: {term}";
m.Success = false;
m.ErrorMessage = "Invalid Device Batch Id";
break;
@@ -239,7 +239,7 @@ namespace Disco.Web.Controllers
var flag = Database.UserFlags.Find(userFlagId);
if (flag != null)
{
m.FriendlyTerm = string.Format("User Flag: {0}", flag.ToString());
m.FriendlyTerm = $"User Flag: {flag.ToString()}";
m.Users = Services.Searching.Search.SearchUserFlag(Database, flag.Id);
break;
}
@@ -256,7 +256,7 @@ namespace Disco.Web.Controllers
var flag = Database.DeviceFlags.Find(deviceFlagId);
if (flag != null)
{
m.FriendlyTerm = string.Format("Device Flag: {0}", flag.ToString());
m.FriendlyTerm = $"Device Flag: {flag.ToString()}";
m.Devices = Services.Searching.Search.SearchDeviceFlag(Database, flag.Id);
break;
}
+3 -3
View File
@@ -126,7 +126,7 @@ namespace Disco.Web
{
int jobId;
if (int.TryParse(match.Groups[2].Value, out jobId))
return string.Format("<a href=\"{2}\" title=\"Job {1}\">{0}</a>", match.Value, jobId, urlHelper.Action(MVC.Job.Show(jobId)));
return $"<a href=\"{urlHelper.Action(MVC.Job.Show(jobId))}\" title=\"Job {jobId}\">{match.Value}</a>";
else
return match.Value;
});
@@ -149,7 +149,7 @@ namespace Disco.Web
if (!ActiveDirectory.IsValidDomainAccountId(userId))
return match.Value;
return string.Format("<a href=\"{2}\" title=\"User {1}\">{0}</a>", match.Value, ActiveDirectory.FriendlyAccountId(userId), urlHelper.Action(MVC.User.Show(userId)));
return $"<a href=\"{urlHelper.Action(MVC.User.Show(userId))}\" title=\"User {ActiveDirectory.FriendlyAccountId(userId)}\">{match.Value}</a>";
}
catch (Exception)
{
@@ -166,7 +166,7 @@ namespace Disco.Web
if (string.IsNullOrWhiteSpace(deviceSerialNumber))
return match.Value;
return string.Format("<a href=\"{2}\" title=\"Device {1}\">{0}</a>", match.Value, deviceSerialNumber, urlHelper.Action(MVC.Device.Show(deviceSerialNumber)));
return $"<a href=\"{urlHelper.Action(MVC.Device.Show(deviceSerialNumber))}\" title=\"Device {deviceSerialNumber}\">{match.Value}</a>";
});
}
catch (Exception)
+1 -1
View File
@@ -126,7 +126,7 @@ namespace Disco.Web
private static Lazy<string> _Version = new Lazy<string>(() =>
{
var AssemblyVersion = typeof(DiscoApplication).Assembly.GetName().Version;
return string.Format("{0}.{1}.{2:0000}.{3:0000}", AssemblyVersion.Major, AssemblyVersion.Minor, AssemblyVersion.Build, AssemblyVersion.Revision);
return $"{AssemblyVersion.Major}.{AssemblyVersion.Minor}.{AssemblyVersion.Build:0000}.{AssemblyVersion.Revision:0000}";
});
public static string Version
{
@@ -58,7 +58,7 @@ namespace Disco.Web.Models.InitialConfig
wReq.KeepAlive = false;
// End Added: 2013-02-08 G#
wReq.Method = WebRequestMethods.Http.Get;
wReq.UserAgent = string.Format("Disco/{0} (Initial Config; Org: {1})", DiscoApplication.Version, DiscoApplication.OrganisationName);
wReq.UserAgent = $"Disco/{DiscoApplication.Version} (Initial Config; Org: {DiscoApplication.OrganisationName})";
using (HttpWebResponse wRes = (HttpWebResponse)wReq.GetResponse())
{
if (wRes.StatusCode == HttpStatusCode.OK)
@@ -67,7 +67,7 @@ namespace Disco.Web.Models.InitialConfig
}
else
{
DiscoIctComAuWebResult = new Exception(string.Format("Server returned response: [{0}] {1}", wRes.StatusCode, wRes.StatusDescription));
DiscoIctComAuWebResult = new Exception($"Server returned response: [{wRes.StatusCode}] {wRes.StatusDescription}");
}
}
}
@@ -67,7 +67,7 @@ namespace Disco.Web.Models.InitialConfig
}
catch (Exception ex)
{
return new ValidationResult(string.Format("Unable to Create Directory '{0}'; [{1}] {2}", info.FullName, ex.GetType().Name, ex.Message));
return new ValidationResult($"Unable to Create Directory '{info.FullName}'; [{ex.GetType().Name}] {ex.Message}");
}
}
}
+2 -2
View File
@@ -132,7 +132,7 @@ namespace Disco.Web.Models.Job
if (SubTypes != null)
{
var subTypes = SubTypes;
return JobTypes.SelectMany(jt => jt.JobSubTypes).Where(m => subTypes.Contains(String.Format("{0}_{1}", m.JobTypeId, m.Id))).ToList();
return JobTypes.SelectMany(jt => jt.JobSubTypes).Where(m => subTypes.Contains($"{m.JobTypeId}_{m.Id}")).ToList();
}
return null;
}
@@ -146,7 +146,7 @@ namespace Disco.Web.Models.Job
if (!string.IsNullOrEmpty(model.Type) && model.SubTypes != null)
{
var typeId = string.Format("{0}_", model.Type);
var typeId = $"{model.Type}_";
model.SubTypes = model.SubTypes.Where(m => m.StartsWith(typeId)).ToList();
if (model.SubTypes.Count == 0)
{
+1 -1
View File
@@ -13,7 +13,7 @@ namespace Disco.Web.Models.Job
{
get
{
return string.Format("{0} ({1})", Title, JobTable.Items.Count());
return $"{Title} ({JobTable.Items.Count()})";
}
}
}