Skip to content

Commit a18abd6

Browse files
committed
Improvements to last commit
1 parent 6b1e5c9 commit a18abd6

2 files changed

Lines changed: 27 additions & 22 deletions

File tree

src/Libraries/SmartStore.Data/Migrations/201605111140288_ImportExtraData.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
6363
builder.AddOrUpdate("Admin.Common.HttpStatus",
6464
"HTTP status {0} ({1}).",
6565
"HTTP-Status {0} ({1}).");
66+
67+
builder.AddOrUpdate("Admin.System.Warnings.SitemapReachable.MethodNotAllowed",
68+
"The reachability of the sitemap could not be validated.",
69+
"Die Erreichbarkeit der Sitemap konnte nicht überprüft werden.");
6670
}
6771
}
6872
}

src/Presentation/SmartStore.Web/Administration/Controllers/CommonController.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ public ActionResult Warnings()
519519
}
520520

521521
// sitemap reachability
522-
HttpStatusCode? sitemapStatusCode = null;
523522
string sitemapUrl = null;
524523
try
525524
{
@@ -530,35 +529,37 @@ public ActionResult Warnings()
530529

531530
using (var response = (HttpWebResponse)request.GetResponse())
532531
{
533-
sitemapStatusCode = response.StatusCode;
532+
var status = response.StatusCode;
533+
var warningModel = new SystemWarningModel();
534+
warningModel.Level = (status == HttpStatusCode.OK ? SystemWarningLevel.Pass : SystemWarningLevel.Warning);
535+
536+
switch (status)
537+
{
538+
case HttpStatusCode.OK:
539+
warningModel.Text = T("Admin.System.Warnings.SitemapReachable.OK");
540+
break;
541+
default:
542+
if (status == HttpStatusCode.MethodNotAllowed)
543+
warningModel.Text = T("Admin.System.Warnings.SitemapReachable.MethodNotAllowed");
544+
else
545+
warningModel.Text = T("Admin.System.Warnings.SitemapReachable.Wrong");
546+
547+
warningModel.Text = string.Concat(warningModel.Text, " ", T("Admin.Common.HttpStatus", (int)status, status.ToString()));
548+
break;
549+
}
550+
551+
model.Add(warningModel);
534552
}
535553
}
536554
catch (WebException exception)
537555
{
538-
Logger.Warning(sitemapUrl.IsEmpty() ? "SitemapSEO" : sitemapUrl, exception);
539-
}
540-
541-
if (sitemapStatusCode.HasValue && sitemapStatusCode.Value == HttpStatusCode.OK)
542-
{
543-
model.Add(new SystemWarningModel
544-
{
545-
Level = SystemWarningLevel.Pass,
546-
Text = T("Admin.System.Warnings.SitemapReachable.OK")
547-
});
548-
}
549-
else
550-
{
551-
var warningText = T("Admin.System.Warnings.SitemapReachable.Wrong");
552-
if (sitemapStatusCode.HasValue)
553-
{
554-
warningText = string.Concat(warningText, " ", T("Admin.Common.HttpStatus", (int)sitemapStatusCode.Value, sitemapStatusCode.Value.ToString()));
555-
}
556-
557556
model.Add(new SystemWarningModel
558557
{
559558
Level = SystemWarningLevel.Warning,
560-
Text = warningText
559+
Text = T("Admin.System.Warnings.SitemapReachable.Wrong")
561560
});
561+
562+
Logger.Warning(sitemapUrl.IsEmpty() ? "SitemapSEO" : sitemapUrl, exception);
562563
}
563564

564565
//primary exchange rate currency

0 commit comments

Comments
 (0)