Bläddra i källkod

Detaillierteres Update-Handling!

Arne Diekmann 8 år sedan
förälder
incheckning
8ebd3b804a

+ 3 - 5
GreenTree.Nachtragsmanagement.Web/Controllers/AdminController.cs

@@ -557,7 +557,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
         /// Update check
         /// </summary>
         [HttpPost]
-        public ActionResult CheckUpdate()
+        public ActionResult PartialCheckUpdate()
         {
             _logger.Information("Updateüberprüfung gestartet.");
 
@@ -574,6 +574,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
                 using (var wc = new WebClient())
                 {
                     wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
+                    wc.Encoding = System.Text.Encoding.UTF8;
                     var webData = String.Format("Package={0}&CurrentVersion={1}", model.Package, model.CurrentVersion);
                     webResult = wc.UploadString(_configurationService.GetCurrentConfiguration().CheckUpdateUrl, webData);
                 }
@@ -588,10 +589,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
                 else
                     _logger.Information("Es kein Update verfügbar!");
 
-                return new JsonResult
-                {
-                    Data = result
-                };
+                return PartialView("~/Views/Admin/AppInfo/_UpdateNotesPartial.cshtml", result);
             }
             catch (Exception ex)
             {

+ 1 - 0
GreenTree.Nachtragsmanagement.Web/GreenTree.Nachtragsmanagement.Web.csproj

@@ -375,6 +375,7 @@
     <Content Include="Views\Admin\AppInfo\View.cshtml" />
     <Content Include="Views\Admin\Users\_UserSearchPartial.cshtml" />
     <Content Include="Views\Shared\_ChangePasswordPartial.cshtml" />
+    <Content Include="Views\Admin\AppInfo\_UpdateNotesPartial.cshtml" />
     <None Include="Web.Debug.config">
       <DependentUpon>Web.config</DependentUpon>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

+ 8 - 34
GreenTree.Nachtragsmanagement.Web/Views/Admin/AppInfo/View.cshtml

@@ -16,30 +16,14 @@
 		devLoadingPanelUpdate.Show();
 		$.ajax({
 			method: "POST",
-			url: '@Url.Action("CheckUpdate", "Admin")',
+			url: '@Url.Action("PartialCheckUpdate", "Admin")',
 			success: function (response) {
 				if (!response) return;
-				devLoadingPanelUpdate.Hide();
-				if (response.IsUpdateAvailable == true) {
-					devPopupControlDoUpdate.Show();
-				}
-			},
-			error: function () {
-				devLoadingPanelUpdate.Hide();
-				alert("error occured");
-			}
-		});
-	}
-
-	function update() {
-		devPopupControlDoUpdate.Hide();
-		devLoadingPanelUpdate.SetText("Update wird durchgeführt und die Anwendung anschließend neu gestartet... bitte warten!");
-		devLoadingPanelUpdate.Show();
-		$.ajax({
-			method: "POST",
-			url: '@Url.Action("Update", "Admin")',
-			success: function (response) {
-				window.location = '@Url.Action("ViewUpdateSuccess", "Admin")'
+				setTimeout(function () {
+					devLoadingPanelUpdate.Hide();
+					$(".updateContainer").remove();
+					$("body").append(response);
+				}, 200);
 			},
 			error: function () {
 				devLoadingPanelUpdate.Hide();
@@ -80,7 +64,7 @@
 						Aktuelle Programmpaketversion
 					</h3>
 					<div style="font-size: 40px; margin: 12px 0">
-						@GreenTree.Nachtragsmanagement.Core.AppendixVersion.CurrentVersion
+						v<span>@GreenTree.Nachtragsmanagement.Core.AppendixVersion.CurrentVersion</span>
 					</div>
 					@if (userContext.CurrentUser.HasFunction("Administration-AppInfo-Update"))
 					{
@@ -109,14 +93,4 @@
 	t.Text = "Es wird nach Updates geprüft... bitte warten!";
 	t.Modal = true;
 	t.Styles.LoadingDiv.Opacity = 0;
-}).GetHtml()
-
-@Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
-{
-	PopupName = "devPopupControlDoUpdate",
-	Content = "<div class='dialogText' style='padding: 12px'>" +
-		"Es ist ein Update verfügbar. Sind Sie sicher, dass Sie das Update durchführen möchten? " +
-		"Der Vorgang kann einige Zeit in Anspruch nehmen.</div>",
-	HeaderText = "Update durchführen",
-	YesFunction = "function (s, e) { update(); }"
-})
+}).GetHtml()

+ 68 - 0
GreenTree.Nachtragsmanagement.Web/Views/Admin/AppInfo/_UpdateNotesPartial.cshtml

@@ -0,0 +1,68 @@
+@using GreenTree.Nachtragsmanagement.Web.Models.Global;
+
+@model GreenTree.Nachtragsmanagement.Web.Models.Admin.AppInfo.AppUpdateDataModel
+
+<div class="updateContainer">
+
+	<script>
+
+		function update() {
+			devPopupControlDoUpdate.Hide();
+			devLoadingPanelUpdate.SetText("Update wird durchgeführt und die Anwendung anschließend neu gestartet... bitte warten!");
+			devLoadingPanelUpdate.Show();
+			$.ajax({
+				method: "POST",
+				url: '@Url.Action("Update", "Admin")',
+				success: function (response) {
+					window.location = '@Url.Action("ViewUpdateSuccess", "Admin")'
+				},
+				error: function () {
+					devLoadingPanelUpdate.Hide();
+					alert("error occured");
+				}
+			});
+		}
+
+	</script>
+
+	@Html.DevExpress().PopupControl(s =>
+	{
+		s.Name = "devPopupControlDoUpdate";
+		s.HeaderText = "Update durchführen";
+		s.Modal = true;
+		s.Width = new Unit(450, UnitType.Pixel);
+		s.CloseAction = CloseAction.CloseButton;
+		s.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
+		s.PopupVerticalAlign = PopupVerticalAlign.TopSides;
+		s.PopupVerticalOffset = 50;
+		s.AllowDragging = false;
+		s.AllowResize = false;
+		s.ShowFooter = false;
+		s.ShowOnPageLoad = true;
+		s.SetContent(() =>
+		{
+			ViewContext.Writer.Write(
+				"<div class='dialogText' style='padding: 12px'>" +
+					"<h2>Es ist ein Update verfügbar (v" + Model.UpdateVersion + ")</h2>" +
+					"Beschreibung:<br />" +
+					"<div style='margin: 6px 0 12px; padding: 6px 4px; border-top: 1px solid #009688; border-bottom: 1px solid #009688;" +
+					"min-height: 80px; max-height: 150px; overflow: auto'>" +
+					Model.UpdateDescription + "</div>" +
+					"<p><b>Sind Sie sicher, dass Sie das Update durchführen möchten? " +
+					"Der Vorgang kann einige Zeit in Anspruch nehmen.<br /><br />" +
+					"Die Anwendung wird anschließend neu gestartet!</b></p>" +
+				"</div>");
+			Html.RenderPartial(
+				"~/Views/Shared/_PopupButtonPanel.cshtml",
+				new GreenTree.Nachtragsmanagement.Web.Models.Global.PopupModel
+				{
+					PopupName = "devPopupControlDoUpdate",
+					AcceptFunction = "function (s, e) { update(); }"
+				}
+			);
+		});
+		s.Styles.Content.Paddings.Padding = new Unit(0);
+		s.Styles.ModalBackground.Opacity = 0;
+	}).GetHtml()
+
+</div>