Fixed logging for Settings Controller and QualityProvider

Setup/Update of Default QualityProfiles will occur on start
pull/4/head
markus101 14 years ago
parent 519e2df560
commit 48e5b36936

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Web;
@ -9,6 +10,7 @@ using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Fakes;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.DataProviders;
using SubSonic.Query;
using SubSonic.Repository;
@ -76,6 +78,7 @@ namespace NzbDrone.Core
ForceMigration(_kernel.Get<IRepository>());
SetupIndexers(_kernel.Get<IRepository>()); //Setup the default set of indexers on start-up
SetupDefaultQualityProfiles(_kernel.Get<IRepository>()); //Setup the default QualityProfiles on start-up
}
}
@ -231,5 +234,134 @@ namespace NzbDrone.Core
repository.Update(nzbsrusIndexer);
}
}
private static void SetupDefaultQualityProfiles(IRepository repository)
{
var sdtv = new QualityProfile
{
Name = "SDTV",
Allowed = new List<QualityTypes> {QualityTypes.TV},
Cutoff = QualityTypes.TV
};
var dvd = new QualityProfile
{
Name = "DVD SD",
Allowed = new List<QualityTypes> {QualityTypes.DVD},
Cutoff = QualityTypes.DVD
};
var bdrip = new QualityProfile
{
Name = "BDRip",
Allowed = new List<QualityTypes> {QualityTypes.BDRip},
Cutoff = QualityTypes.BDRip
};
var hdtv = new QualityProfile
{
Name = "HDTV",
Allowed = new List<QualityTypes> {QualityTypes.HDTV},
Cutoff = QualityTypes.HDTV
};
var webdl = new QualityProfile
{
Name = "WEBDL",
Allowed = new List<QualityTypes> {QualityTypes.WEBDL},
Cutoff = QualityTypes.WEBDL
};
var bluray = new QualityProfile
{
Name = "Bluray",
Allowed = new List<QualityTypes> {QualityTypes.Bluray},
Cutoff = QualityTypes.Bluray
};
//Add or Update SDTV
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", sdtv.Name));
if (!repository.Exists<QualityProfile>(i => i.Name == sdtv.Name))
{
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", sdtv.Name));
repository.Add(sdtv);
}
else
{
Logger.Debug(String.Format("Updating default QualityProfile: {0}", sdtv.Name));
repository.Update(sdtv);
}
//Add or Update DVD
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", dvd.Name));
if (!repository.Exists<QualityProfile>(i => i.Name == dvd.Name))
{
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", dvd.Name));
repository.Add(dvd);
}
else
{
Logger.Debug(String.Format("Updating default QualityProfile: {0}", dvd.Name));
repository.Update(dvd);
}
//Add or Update BDRip
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", bdrip.Name));
if (!repository.Exists<QualityProfile>(i => i.Name == bdrip.Name))
{
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", bdrip.Name));
repository.Add(bdrip);
}
else
{
Logger.Debug(String.Format("Updating default QualityProfile: {0}", bdrip.Name));
repository.Update(bdrip);
}
//Add or Update HDTV
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", hdtv.Name));
if (!repository.Exists<QualityProfile>(i => i.Name == hdtv.Name))
{
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", hdtv.Name));
repository.Add(hdtv);
}
else
{
Logger.Debug(String.Format("Updating default QualityProfile: {0}", hdtv.Name));
repository.Update(hdtv);
}
//Add or Update WEBDL
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", webdl.Name));
if (!repository.Exists<QualityProfile>(i => i.Name == webdl.Name))
{
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", webdl.Name));
repository.Add(webdl);
}
else
{
Logger.Debug(String.Format("Updating default QualityProfile: {0}", webdl.Name));
repository.Update(webdl);
}
//Add or Update Bluray
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", bluray.Name));
if (!repository.Exists<QualityProfile>(i => i.Name == bluray.Name))
{
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", bluray.Name));
repository.Add(bluray);
}
else
{
Logger.Debug(String.Format("Updating default QualityProfile: {0}", bluray.Name));
repository.Update(bluray);
}
}
}
}

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;
@ -10,6 +11,7 @@ namespace NzbDrone.Core.Providers
public class QualityProvider : IQualityProvider
{
private IRepository _sonicRepo;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public QualityProvider(IRepository sonicRepo)
{
@ -27,8 +29,8 @@ namespace NzbDrone.Core.Providers
{
if (!_sonicRepo.Exists<QualityProfile>(q => q.ProfileId == profile.ProfileId))
{
//Log Error
throw new InvalidOperationException("Unable to update none existing profile");
Logger.Error("Unable to update non-existing profile");
throw new InvalidOperationException("Unable to update non-existing profile");
}
_sonicRepo.Update(profile);

@ -123,11 +123,12 @@ namespace NzbDrone.Web.Controllers
}
catch (Exception)
{
Logger.Error("Error saving settings.");
if (Request.IsAjaxRequest())
return Content("Settings Saved.");
return Content("Error saving settings.");
return Content("Settings Saved.");
Logger.Error("");
return Content("Error saving settings.");
}
@ -258,6 +259,29 @@ namespace NzbDrone.Web.Controllers
return Content("Settings Saved.");
}
[HttpPost]
public ActionResult SaveQuality(QualityModel data)
{
try
{
}
catch (Exception e)
{
Logger.ErrorException(e.Message, e);
if (Request.IsAjaxRequest())
return Content("Error Saving Settings, please fix any errors");
return Content("Error Saving Settings, please fix any errors");
}
if (Request.IsAjaxRequest())
return Content("Settings Saved.");
return Content("Settings Saved.");
}
[HttpPost]
public ActionResult SortedList(List<object > items)
{

@ -49,7 +49,6 @@
.ui-state-highlight { height: 1.5em; line-height: 1.2em; }
</style>
<script type="text/javascript">
$(function () {
$("#sortable").sortable({
@ -59,7 +58,7 @@
});
</script>
<% using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
<% using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
{%>
<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>

Loading…
Cancel
Save