Переглянути джерело

Update weitergearbeitet + kleinere Anpassungen!

Arne Diekmann 8 роки тому
батько
коміт
ffe0103bc8

+ 16 - 0
GreenTree.Nachtragsmanagement.Core/Configuration/AppendixConfigurationSection.cs

@@ -26,6 +26,22 @@ namespace GreenTree.Nachtragsmanagement.Core.Configuration
             }
         }
 
+        /// <summary>
+        /// The URL of the webservice providing updates for that application
+        /// </summary>
+        [ConfigurationProperty("checkUpdateUrl", IsRequired = false)]
+        public string CheckUpdateUrl
+        {
+            get
+            {
+                return (string)this["checkUpdateUrl"];
+            }
+            set
+            {
+                this["checkUpdateUrl"] = value;
+            }
+        }
+
         /// <summary>
         /// Settings for mailserver handling
         /// </summary>

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

@@ -15,6 +15,9 @@ using GreenTree.Nachtragsmanagement.Services.Logging;
 using GreenTree.Nachtragsmanagement.Web.Models.Admin.Plugins;
 using GreenTree.Nachtragsmanagement.Web.Models.Admin.AppInfo;
 using System.Reflection;
+using System.Net;
+using System.IO;
+using GreenTree.Nachtragsmanagement.Services.Configuration;
 
 namespace GreenTree.Nachtragsmanagement.Web.Controllers
 {
@@ -25,19 +28,22 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
         private readonly IPluginFinder _pluginFinder;
         private readonly ILogger _logger;
         private readonly IWebHelper _webHelper;
+        private readonly IConfigurationService _configurationService;
 
         public AdminController(
             IUserService userService,
             IUserHelper userHelper,
             IPluginFinder pluginFinder,
             ILogger logger,
-            IWebHelper webHelper)
+            IWebHelper webHelper,
+            IConfigurationService configurationService)
         {
             _userService = userService;
             _userHelper = userHelper;
             _pluginFinder = pluginFinder;
             _logger = logger;
             _webHelper = webHelper;
+            _configurationService = configurationService;
 
             ViewData["AllRoles"] = _userService.GetAllRoles();
             ViewData["AllFunctions"] = _userService.GetAllFunctions();
@@ -519,17 +525,22 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
         {
             var model = new AppUpdateDataModel
             {
+                Package = "GreenTree.Nachtragsmanagement",
                 CurrentVersion = AppendixVersion.CurrentVersion
             };
 
-            System.Threading.Thread.Sleep(2000);
+            var wc = new WebClient();
 
-            model.UpdateDescription = "Test";
-            model.UpdateVersion = "0.9.0.1";
+            wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
+            var webData = String.Format("Package={0}&CurrentVersion={1}", model.Package, model.CurrentVersion);
+            var webResult = wc.UploadString(_configurationService.GetCurrentConfiguration().CheckUpdateUrl, webData);
+
+            var jsonResult = JsonConvert.DeserializeObject<JsonResult>(webResult);
+            var result = JsonConvert.DeserializeObject<AppUpdateDataModel>(jsonResult.Data.ToString());
 
             return new JsonResult
             {
-                Data = model
+                Data = result
             };
         }
 

+ 64 - 1
GreenTree.Nachtragsmanagement.Web/Extensions/GridViewSettingsHelper.cs

@@ -203,13 +203,21 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
             });
             s.Columns.Add(column =>
             {
-                column.Caption = "VA-Summe";
+                column.Caption = "Ges. VA-Sum.";
                 column.FieldName = "DeviationValue";
                 column.PropertiesEdit.DisplayFormatString = "c2";
                 column.MinWidth = 120;
                 column.Width = new Unit(120, UnitType.Pixel);
             });
             s.Columns.Add(column =>
+            {
+                column.Caption = "Off. VA-Sum.";
+                column.FieldName = "SiteDeviationValue";
+                column.PropertiesEdit.DisplayFormatString = "c2";
+                column.MinWidth = 120;
+                column.Width = new Unit(120, UnitType.Pixel);
+            });
+            s.Columns.Add(column =>
             {
                 column.Caption = "Nachträge";
                 column.FieldName = "AppendixDescription";
@@ -217,6 +225,22 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
                 column.Width = new Unit(130, UnitType.Pixel);
             });
             s.Columns.Add(column =>
+            {
+                column.Caption = "Off. NT-Sum.";
+                column.FieldName = "AppendixValueRemaining";
+                column.PropertiesEdit.DisplayFormatString = "c2";
+                column.MinWidth = 120;
+                column.Width = new Unit(120, UnitType.Pixel);
+            });
+            s.Columns.Add(column =>
+            {
+                column.Caption = "Verh. NT-Sum.";
+                column.FieldName = "AppendixValueNegotiated";
+                column.PropertiesEdit.DisplayFormatString = "c2";
+                column.MinWidth = 120;
+                column.Width = new Unit(120, UnitType.Pixel);
+            });
+            s.Columns.Add(column =>
             {
                 column.Caption = "Mitarbeiter";
                 column.FieldName = "UserDescription";
@@ -303,6 +327,45 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
                 DisplayFormat = "VA ∑ = <i>{0:c2}</i>"
             });
 
+            s.TotalSummary.Add(new ASPxSummaryItem
+            {
+                FieldName = "SiteDeviationValue",
+                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                DisplayFormat = "Off.VA ∑<br/><i>{0:c2}</i>"
+            });
+            s.GroupSummary.Add(new ASPxSummaryItem
+            {
+                FieldName = "SiteDeviationValue",
+                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                DisplayFormat = "Off.VA ∑ = <i>{0:c2}</i>"
+            });
+
+            s.TotalSummary.Add(new ASPxSummaryItem
+            {
+                FieldName = "AppendixValueRemaining",
+                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                DisplayFormat = "Off.NT ∑<br/><i>{0:c2}</i>"
+            });
+            s.GroupSummary.Add(new ASPxSummaryItem
+            {
+                FieldName = "AppendixValueRemaining",
+                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                DisplayFormat = "Off.NT ∑ = <i>{0:c2}</i>"
+            });
+
+            s.TotalSummary.Add(new ASPxSummaryItem
+            {
+                FieldName = "AppendixValueNegotiated",
+                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                DisplayFormat = "Verh.NT ∑<br/><i>{0:c2}</i>"
+            });
+            s.GroupSummary.Add(new ASPxSummaryItem
+            {
+                FieldName = "AppendixValueNegotiated",
+                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                DisplayFormat = "Verh.NT ∑ = <i>{0:c2}</i>"
+            });
+
             s.ClientLayout = (sender, e) =>
             {
                 if (e.LayoutMode == ClientLayoutMode.Loading)

+ 12 - 0
GreenTree.Nachtragsmanagement.Web/Implementations/AppendixNotificationPlugin.cs

@@ -163,6 +163,11 @@ namespace GreenTree.Nachtragsmanagement.Web.Implementations
         {
             if (mailNotifications == null || (mailNotifications != null && !mailNotifications.Any())) return;
 
+            _logger.Information(
+                String.Format(
+                    "Starte Verarbeitung Mail-Benachrichtigung in \"{0}\" für \"{1} ...", 
+                    SystemName, mailNotifications.First().NotificationJobSystemName));
+
             foreach (var notification in mailNotifications)
             {
                 try
@@ -193,8 +198,15 @@ namespace GreenTree.Nachtragsmanagement.Web.Implementations
                     _logger.Error(
                         String.Format(
                             "Fehler bei Mail-Benachrichtigung in \"{0}\" für \"{1}", SystemName, notification.NotificationJobSystemName), ex);
+
+                    continue;
                 }
             }
+
+            _logger.Information(
+                String.Format(
+                    "Verarbeitung Mail-Benachrichtigung in \"{0}\" für \"{1} erfolgreich abgeschlossen!",
+                    SystemName, mailNotifications.First().NotificationJobSystemName));
         }
 
         /// <summary>

+ 10 - 0
GreenTree.Nachtragsmanagement.Web/Implementations/DeviationNotificationPlugin.cs

@@ -147,6 +147,11 @@ namespace GreenTree.Nachtragsmanagement.Web.Implementations
         {
             if (mailNotifications == null || (mailNotifications != null && !mailNotifications.Any())) return;
 
+            _logger.Information(
+                String.Format(
+                    "Starte Verarbeitung Mail-Benachrichtigung in \"{0}\" für \"{1} ...",
+                    SystemName, mailNotifications.First().NotificationJobSystemName));
+
             foreach (var notification in mailNotifications)
             {
                 try
@@ -169,6 +174,11 @@ namespace GreenTree.Nachtragsmanagement.Web.Implementations
                             "Fehler bei Mail-Benachrichtigung in \"{0}\" für \"{1}", SystemName, notification.NotificationJobSystemName), ex);
                 }
             }
+
+            _logger.Information(
+                String.Format(
+                    "Verarbeitung Mail-Benachrichtigung in \"{0}\" für \"{1} erfolgreich abgeschlossen!",
+                    SystemName, mailNotifications.First().NotificationJobSystemName));
         }
 
         /// <summary>

+ 1 - 0
GreenTree.Nachtragsmanagement.Web/Models/Admin/AppInfo/AppUpdateDataModel.cs

@@ -7,6 +7,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Models.Admin.AppInfo
 {
     public class AppUpdateDataModel
     {
+        public string Package { get; set; }
         public string CurrentVersion { get; set; }
         public string UpdateVersion { get; set; }
         public string UpdateDescription { get; set; }

+ 25 - 1
GreenTree.Nachtragsmanagement.Web/Models/Site/SiteDataModel.cs

@@ -44,7 +44,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Models.Site
             }
         }
         public decimal? DeviationValue { get; set; }
-
+        public decimal? SiteDeviationValue { get; set; }
         public ICollection<int> AppendixValues { get; set; }
         public ICollection<string> AppendixDescriptions { get; set; }
         public ICollection<AppendixDataModel> Appendices { get; set; }
@@ -58,6 +58,8 @@ namespace GreenTree.Nachtragsmanagement.Web.Models.Site
                     return String.Join(", ", AppendixDescriptions);
             }
         }
+        public decimal? AppendixValueRemaining { get; set; }
+        public decimal? AppendixValueNegotiated { get; set; }
         public ICollection<int> UserValues { get; set; }
         public ICollection<string> UserDescriptions { get; set; }
         public ICollection<UserDataModel> Users { get; set; }
@@ -88,6 +90,9 @@ namespace GreenTree.Nachtragsmanagement.Web.Models.Site
             if (siteEntity == null && !newWhenIsNull)
                 throw new ArgumentNullException("siteEntity", "Cannot create SiteDataModel from NULL site entity.");
 
+            var remainingAppendixStatuses = configurationService.TryGetConfigItemValue<int[]>(
+                "GreenTree.Nachtragsmanagement.SiteGrid.RemainingAppendixStatuses", new[] { 1, 5, 6, 7, 11, 12, 13 });
+
             return new SiteDataModel
             {
                 Id = siteEntity.Id,
@@ -123,6 +128,11 @@ namespace GreenTree.Nachtragsmanagement.Web.Models.Site
                             .Sum(r => r.Value.HasValue && r.Percentage.HasValue
                                 ? r.Value * r.Percentage.Value
                                 : 0),
+                SiteDeviationValue =
+                    siteEntity.Deviations
+                        .Sum(r => r.Value.HasValue && r.Percentage.HasValue
+                            ? r.Value * r.Percentage.Value
+                            : 0),
                 AppendixValues =
                     siteEntity.Appendices
                         .Select(r => r.Id)
@@ -149,6 +159,20 @@ namespace GreenTree.Nachtragsmanagement.Web.Models.Site
                         .OrderBy(r => r.Roles)
                         .Select(r => String.Format("{0}|({1})", r.LastName, r.Roles))
                         .ToList(),
+                AppendixValueRemaining =
+                    siteEntity.Appendices
+                        .Where(r => remainingAppendixStatuses.Contains(r.StateId ?? 0))
+                        .Sum(r => 
+                            r.Value.HasValue && r.Percentage.HasValue
+                                ? r.Value.Value * r.Percentage.Value
+                                : 0),
+                AppendixValueNegotiated =
+                    siteEntity.Appendices
+                        .Where(r => !remainingAppendixStatuses.Contains(r.StateId ?? 0))
+                        .Sum(r =>
+                            r.Value.HasValue && r.Percentage.HasValue
+                                ? r.Value.Value * r.Percentage.Value
+                                : 0),
                 UserDescription =
                     String.Join(", ",
                         siteEntity.Users

+ 1 - 1
GreenTree.Nachtragsmanagement.Web/Web.config

@@ -28,7 +28,7 @@
     <add key="vs:EnableBrowserLink" value="false" />
   </appSettings>
   <appendixSectionGroup>
-    <appendixConfigSection iisAnonymousUser="IUSR">
+    <appendixConfigSection iisAnonymousUser="IUSR" checkUpdateUrl="http://localhost:53759/api/Update/CheckUpdate">
       <mailServer smtpServer="greentreestudios.de" port="25" username="a.diekmann@greentreestudios.de" domain="" password="14595809ad." useSsl="false">
       </mailServer>
       <ldapServer ldapServer="" administriveUser="" password="">