Parcourir la source

Benachrichtigungen abgeschlossen!

Arne Diekmann il y a 8 ans
Parent
commit
21dbd5de42

BIN
GreenTree.Nachtragsmanagement.Web/Content/Images/logo.png


+ 1 - 1
GreenTree.Nachtragsmanagement.Web/Content/login.css

@@ -10,7 +10,7 @@
 }
 
 .outerCenterWrapper {
-    margin: 200px auto 0;
+    margin: 120px auto 0;
     width: 400px;
     font-size: 22px;
     border: 1px solid #009688;

+ 2 - 1
GreenTree.Nachtragsmanagement.Web/Controllers/MiscController.cs

@@ -3,6 +3,7 @@ using DevExpress.Web;
 using DevExpress.Web.ASPxThemes;
 using DevExpress.Web.Mvc;
 using DevExpress.XtraPrinting;
+using DevExpress.XtraScheduler;
 using GreenTree.Nachtragsmanagement.Core.Domain.Deviation;
 using GreenTree.Nachtragsmanagement.Core.Domain.User;
 using GreenTree.Nachtragsmanagement.Services.Appendix;
@@ -206,7 +207,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
             }
 
             if (mailNotificationModel.CronExpression.Split(' ').Length == 5)
-                mailNotificationModel.CronExpression = mailNotificationModel.CronExpression.Insert(0, "0 ");
+                mailNotificationModel.CronExpression = mailNotificationModel.CronExpression + " *";
 
             var selectedUsers = _userService.GetUsersByIds(mailNotificationModel.UserValues.ToArray());
 

+ 40 - 0
GreenTree.Nachtragsmanagement.Web/Extensions/ControlHelper.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+
+namespace GreenTree.Nachtragsmanagement.Web.Extensions
+{
+    public static class ControlHelper
+    {
+        public static Control[] GetAllSubControlsOfTypes(this Control control, params Type[] types)
+        {
+            var result = new List<Control>();
+
+            GetSubControls(control, result, types);
+
+            return result.ToArray();
+        }
+
+        private static void GetSubControls(Control parent, List<Control> result, Type[] types)
+        {
+            if (parent == null) return;
+
+            foreach (Control subControl in parent.Controls)
+            {
+                if (subControl.Controls.Count > 0)
+                    GetSubControls(subControl, result, types);
+
+                foreach (var type in types)
+                {
+                    if (subControl.GetType() == type)
+                    {
+                        result.Add(subControl);
+                        break;
+                    }
+                }
+            }
+        }
+    }
+}

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

@@ -787,7 +787,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
             {
                 column.Caption = "Mitarbeiter";
                 column.MinWidth = 150;
-                column.Width = new Unit(30, UnitType.Percentage);
+                column.Width = new Unit(20, UnitType.Percentage);
                 column.SetDataItemTemplateContent(c =>
                 {
                     var userDescriptions = DataBinder.Eval(c.DataItem, "UserDescriptions") as List<string>;

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

@@ -61,6 +61,7 @@
     <Reference Include="CronExpressionDescriptor, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
       <HintPath>..\packages\CronExpressionDescriptor.2.0.2\lib\netstandard1.1\CronExpressionDescriptor.dll</HintPath>
     </Reference>
+    <Reference Include="DevExpress.XtraScheduler.v17.1.Core, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
     <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
     </Reference>
@@ -202,6 +203,7 @@
     <Content Include="Content\Images\function-Site-Sites-32.png" />
     <Content Include="Content\Images\function-Misc-32.png" />
     <Content Include="Content\Images\function-Misc-MailNotifications-32.png" />
+    <Content Include="Content\Images\logo.png" />
     <Content Include="Content\Images\maximize-16.png" />
     <Content Include="Content\Images\minimize-16.png" />
     <Content Include="Content\Images\function-Appendix-Claims-32.png" />
@@ -314,6 +316,7 @@
     <Content Include="Views\Misc\_MailNotificationGridPartial.cshtml" />
     <Content Include="Views\Misc\_MailNotificationEditPartial.cshtml" />
     <Content Include="Views\Misc\_MailNotificationPluginJobsPartial.cshtml" />
+    <Content Include="Views\Misc\_MailNotificationCronPartial.cshtml" />
     <None Include="Web.Debug.config">
       <DependentUpon>Web.config</DependentUpon>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -330,6 +333,7 @@
     <Compile Include="App_Start\RouteConfig.cs" />
     <Compile Include="App_Start\WebApiConfig.cs" />
     <Compile Include="Controllers\MiscController.cs" />
+    <Compile Include="Extensions\ControlHelper.cs" />
     <Compile Include="Models\Misc\MailNotificationDataModel.cs" />
     <Compile Include="Implementations\DeviationNotificationPlugin.cs" />
     <Compile Include="Implementations\AppendixNotificationPlugin.cs" />

+ 1 - 1
GreenTree.Nachtragsmanagement.Web/Views/Deviations/View.cshtml

@@ -7,7 +7,7 @@
 <script>
 	var deleteId;
 	var gridScrollHeight;
-	var gridScrollOffset = 350;
+	var gridScrollOffset = 280;
 	var resizeFinished;
 
 	$(document).ready(function () {

+ 1 - 0
GreenTree.Nachtragsmanagement.Web/Views/Login/Index.cshtml

@@ -8,6 +8,7 @@
 <link rel="stylesheet" type="text/css" href="~/Content/login.css" />
 
 <div class="outerCenterWrapper">
+	<img src="@Url.Content("~/Content/Images/logo.png")" alt="Schweerbau Logo" />
 	<h2>Nachtragsmanagement 2.0</h2>
 	<div class="innerCenterWrapper">
 		<h4>Anmeldung</h4>

+ 152 - 0
GreenTree.Nachtragsmanagement.Web/Views/Misc/_MailNotificationCronPartial.cshtml

@@ -0,0 +1,152 @@
+
+<script>
+
+	if (!String.prototype.format) {
+		String.prototype.format = function () {
+			var args = arguments;
+			return this.replace(/{(\d+)}/g, function (match, number) {
+				return typeof args[number] != 'undefined'
+					? args[number]
+					: match;
+			});
+		};
+	}
+
+	function translateWeekDayCodeToWeekDays(weekDayCode) {
+		switch (weekDayCode) {
+			case 1: return "SUN";
+			case 2: return "MON";
+			case 4: return "TUE";
+			case 8: return "WED";
+			case 16: return "THU";
+			case 32: return "FRI";
+			case 64: return "SAT";
+			case 62: return "MON,TUE,WED,THU,FRI";
+			case 65: return "SAT,SUN";
+			case 127: return "MON,TUE,WED,THU,FRI,SAT,SUN";
+			default: return "*;"
+		}
+	}
+
+	function generateCronExpression(baseName) {
+		var controls = ASPxClientControl.GetControlCollection();
+		var radioButtonList = ASPxClientRadioButtonList.Cast(controls.GetByName(baseName + "_AptRecCtl_TypeEdt"));
+		var checkRecurrenceType = radioButtonList.GetValue();
+		var timeEditDate = ASPxClientTimeEdit.Cast(devTimeEditCron).GetDate();
+		var time = timeEditDate.getSeconds() + " " + timeEditDate.getMinutes() + " " + timeEditDate.getHours();
+		var result = "* * * * * *";
+		switch (checkRecurrenceType) {
+			case 0:
+				var repeatNDaysCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Daily_RbDay"));
+				var repeatNDaysSpinEdit = ASPxClientSpinEdit.Cast(controls.GetByName(baseName + "_AptRecCtl_Daily_SpnDayCnt"));
+				var repeatEveryDayCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Daily_RbEvrDay"));
+				if (repeatEveryDayCheckBox.GetChecked()) {
+					result = "{0} ? * MON-FRI *".format(time);
+				} else {
+					result = "{0} 1/{1} * ? *".format(time, repeatNDaysSpinEdit.GetValue());
+				}
+				break;
+			case 1:
+				var repeatNWeeksSpinEdit = ASPxClientSpinEdit.Cast(controls.GetByName(baseName + "_AptRecCtl_Weekly_SpnWeekCnt"));
+				var repeatWeekDaysMondayCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Weekly_WeekDaysEdt_Monday0"));
+				var repeatWeekDaysTuesdayCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Weekly_WeekDaysEdt_Tuesday1"));
+				var repeatWeekDaysWednesdayCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Weekly_WeekDaysEdt_Wednesday2"));
+				var repeatWeekDaysThursdayCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Weekly_WeekDaysEdt_Thursday3"));
+				var repeatWeekDaysFridayCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Weekly_WeekDaysEdt_Friday4"));
+				var repeatWeekDaysSaturdayCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Weekly_WeekDaysEdt_Saturday5"));
+				var repeatWeekDaysSundayCheckBox = ASPxClientCheckBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Weekly_WeekDaysEdt_Sunday6"));
+				var weekValue = repeatNWeeksSpinEdit.GetValue();
+				if (weekValue == 1) {
+					var weekDays = [];
+					if (repeatWeekDaysMondayCheckBox.GetChecked()) { weekDays.push("MON"); }
+					if (repeatWeekDaysTuesdayCheckBox.GetChecked()) { weekDays.push("TUE"); }
+					if (repeatWeekDaysWednesdayCheckBox.GetChecked()) { weekDays.push("WED"); }
+					if (repeatWeekDaysThursdayCheckBox.GetChecked()) { weekDays.push("THU"); }
+					if (repeatWeekDaysFridayCheckBox.GetChecked()) { weekDays.push("FRI"); }
+					if (repeatWeekDaysSaturdayCheckBox.GetChecked()) { weekDays.push("SAT"); }
+					if (repeatWeekDaysSundayCheckBox.GetChecked()) { weekDays.push("SUN"); }
+					result = "{0} ? * {1} *".format(time, weekDays.join(","));
+				} else {
+					result = "{0} 1/{1} * ? *".format(time, weekValue * 7);
+				}
+				break;
+			case 2:
+				var repeatNDayOfMonthRadioButton = ASPxClientRadioButton.Cast(controls.GetByName(baseName + "_AptRecCtl_Monthly_RbDay"));
+				var repeatNDayOfMonthSpinEdit = ASPxClientSpinEdit.Cast(controls.GetByName(baseName + "_AptRecCtl_Monthly_SpnMnthDay"));
+				var repeatNMonthsForDaySpinEdit = ASPxClientSpinEdit.Cast(controls.GetByName(baseName + "_AptRecCtl_Monthly_SpnDayMnthCnt"));
+
+				var repeatNWeeksOfMonthRadioButton = ASPxClientRadioButton.Cast(controls.GetByName(baseName + "_AptRecCtl_Monthly_RbWeekDays"));
+				var repeatNWeekDayNumberOfMonthComboBox = ASPxClientComboBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Monthly_WmeWeekOfMnth"));
+				var repeatNWeekDayOfMonthComboBox = ASPxClientComboBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Monthly_WdeWeekDays"));
+				var repeatNMonthsForWeekSpinEdit = ASPxClientSpinEdit.Cast(controls.GetByName(baseName + "_AptRecCtl_Monthly_SpinWeekDaysMnthCnt"));
+				var repeatNWeekDayNumberOfMonth = repeatNWeekDayNumberOfMonthComboBox.GetValue();
+				var repeatNWeekDayOfMonth = repeatNWeekDayOfMonthComboBox.GetValue();
+				var repeatNMonthsForWeek = repeatNMonthsForWeekSpinEdit.GetValue();
+				if (repeatNDayOfMonthRadioButton.GetChecked()) {
+					result = "{0} {1} 1/{2} ? *".format(time, repeatNDayOfMonthSpinEdit.GetValue(), repeatNMonthsForDaySpinEdit.GetValue());
+				} else {
+					result = "{0} ? 1/{1} {2}#{3} *".format(time, repeatNMonthsForWeek,
+						translateWeekDayCodeToWeekDays(repeatNWeekDayOfMonth),
+						(repeatNWeekDayNumberOfMonth == 5 ? 4 : repeatNWeekDayNumberOfMonth));
+				}
+				break;
+			case 3:
+				var repeatNDayOfMonthByYearRadioButton = ASPxClientRadioButton.Cast(controls.GetByName(baseName + "_AptRecCtl_Yearly_RbDay"));
+				var repeatNMonthByYearComboBox = ASPxClientComboBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Yearly_MeDayMnth"));
+				var repeatNDayOfMonthByYearSpinEdit = ASPxClientSpinEdit.Cast(controls.GetByName(baseName + "_AptRecCtl_Yearly_SpnDayNo"));
+
+				var repeatNWeekDayOfMonthByYearRadioButton = ASPxClientRadioButton.Cast(controls.GetByName(baseName + "_AptRecCtl_Yearly_RbWeekOfMnth"));
+				var repeatNWeekDayNumberOfMonthByYearComboBox = ASPxClientComboBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Yearly_WmeWeekOfMnth"));
+				var repeatNWeekDayOfMonthByYearComboBox = ASPxClientComboBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Yearly_WdeWeekDays"));
+				var repeatNMonthOfYearComboBox = ASPxClientComboBox.Cast(controls.GetByName(baseName + "_AptRecCtl_Yearly_MeWeekDaysMnth"));
+				var repeatNWeekDayNumberOfMonthByYear = repeatNWeekDayNumberOfMonthByYearComboBox.GetValue();
+				var repeatNWeekDayOfMonthByYear = repeatNWeekDayOfMonthByYearComboBox.GetValue();
+				if (repeatNDayOfMonthByYearRadioButton.GetChecked()) {
+					result = "{0} {1} {2} ? *".format(time, repeatNDayOfMonthByYearSpinEdit.GetValue(), repeatNMonthByYearComboBox.GetValue());
+				} else {
+					result = "{0} ? {1} {2}#{3} *".format(time, repeatNMonthOfYearComboBox.GetValue(),
+						translateWeekDayCodeToWeekDays(repeatNWeekDayOfMonthByYear),
+						(repeatNWeekDayNumberOfMonthByYear == 5 ? 4 : repeatNWeekDayNumberOfMonthByYear))
+				}
+				break;
+		}
+		return result;
+	}
+
+</script>
+
+<style>
+	.recurrenceRange {
+		display: none !important;
+	}
+</style>
+
+@Html.DevExpress().TimeEdit(t =>
+{
+	t.Name = "devTimeEditCron";
+	t.DateTime = new DateTime(2000, 1, 1, 6, 0, 0);
+	t.Properties.DisplayFormatString = "HH:mm \"Uhr\"";
+}).GetHtml()
+
+@Html.DevExpress().AppointmentRecurrenceForm(r =>
+{
+	r.Name = "devRecurrenceFormCron";
+	r.IsRecurring = true;
+	r.PreRender = (sender, e) =>
+	{
+		var control = sender as DevExpress.Web.ASPxScheduler.Controls.AppointmentRecurrenceForm;
+		var controls = GreenTree.Nachtragsmanagement.Web.Extensions.ControlHelper.GetAllSubControlsOfTypes(
+			control,
+			typeof(ASPxCheckBox),
+			typeof(DevExpress.Web.ASPxScheduler.Controls.RecurrenceRangeControl));
+
+		foreach (var subControl in controls)
+		{
+			if (subControl.ID == "ChkRecurrence")
+				((ASPxEdit)subControl).ClientVisible = false;
+
+			if (subControl.ID == "RangeCtl")
+				((DevExpress.Web.ASPxScheduler.Controls.RecurrenceRangeControl)subControl).MainDiv.CssClass = "recurrenceRange";
+		}
+	};
+}).GetHtml()

+ 13 - 16
GreenTree.Nachtragsmanagement.Web/Views/Misc/_MailNotificationEditPartial.cshtml

@@ -27,11 +27,12 @@
 			}
 		}
 
-		cronEditor = $("#cronExpressionEditor").cron({
-			onChange: function () {
-				$("#CronExpression").val($(this).cron("value"));
-			}
-		});
+		//cronEditor = $("#cronExpressionEditor").cron({
+		//	onChange: function () {
+		//		$("#CronExpression").val($(this).cron("value"));
+		//		$("#cronExpressionDisplay").text($(this).cron("value"));
+		//	}
+		//});
 
 		function changeElementText(selector, textArray) {
 			for (var i = 0; i < textArray.length; i++) {
@@ -41,7 +42,7 @@
 			}
 		}
 
-		$(document).ready(function () {
+		@*$(document).ready(function () {
 			@if (String.IsNullOrEmpty(Model.CronExpression))
 			{
 				ViewContext.Writer.WriteLine("cronEditor.cron('value', '0 6 * * 1');");
@@ -84,9 +85,10 @@
 			for (var i = 1; i <= 31; i++) {
 				$('select[name="cron-dom"] > option[value="' + i + '"]').text(i + ".");
 			}
-		});
+		});*@
 
 		function saveMailNotification() {
+			$("#CronExpression").val(generateCronExpression("devRecurrenceFormCron"));
 			var form = $("#mailNotificationEditForm");
 			$(form).submit(function (e) {
 				$.ajax({
@@ -194,7 +196,7 @@
 		s.HeaderText = "\"" + Model.NotificationPluginSystemNameDescription + "\" bearbeiten";
 
 	s.Modal = true;
-	s.Width = new Unit(700, UnitType.Pixel);
+	s.Width = new Unit(800, UnitType.Pixel);
 	s.CloseAction = CloseAction.CloseButton;
 	s.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
 	s.PopupVerticalAlign = PopupVerticalAlign.TopSides;
@@ -331,14 +333,9 @@
 				{
 					ViewContext.Writer.Write(Html.CustomLabelFor(m => m.CronExpression, "Interval:"));
 					ViewContext.Writer.Write(Html.ValidationMessageFor(m => m.CronExpression).ToHtmlString());
-					ViewContext.Writer.Write("<div id=\"cronExpressionEditor\"></div>");
-					//Html.DevExpress().AppointmentRecurrenceForm(t =>
-					//{
-					//	t.Name = "devRecurrenceFormCronExpresseion";
-					//	t.Width = new Unit(100, UnitType.Percentage);
-					//	t.IsRecurring = true;
-
-					//}).Render();
+					//ViewContext.Writer.Write("<div id=\"cronExpressionEditor\"></div>");
+					//ViewContext.Writer.Write("<div id=\"cronExpressionDisplay\"></div>");
+					ViewContext.Writer.Write(Html.Partial("~/Views/Misc/_MailNotificationCronPartial.cshtml").ToHtmlString());
 				}
 				ViewContext.Writer.Write("</div>");
 			}