-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
38,120 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,3 +355,4 @@ MigrationBackup/ | |
/RecurrenceRuleUIWebApp.1 | ||
/RecurrenceRuleUIWebApp22 | ||
/TestResults | ||
/ActiveButtonGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"dotnet-ef": { | ||
"version": "3.1.8", | ||
"commands": [ | ||
"dotnet-ef" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Ical.Net; | ||
using Ical.Net.DataTypes; | ||
using IcgSoftware.RecurrenceRuleToText; | ||
using Microsoft.AspNetCore.Mvc; | ||
using RecurrenceRuleWebAppVue.Models; | ||
|
||
namespace RecurrenceRuleWebAppVue.Controllers | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
|
||
private readonly int maxOccurences = 50; | ||
private readonly int maxYears = 20; | ||
|
||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
public IActionResult Privacy() | ||
{ | ||
return View(); | ||
} | ||
|
||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
public IActionResult Error() | ||
{ | ||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); | ||
} | ||
|
||
[HttpPost] | ||
//VUE erstmal ohne [ValidateAntiForgeryToken] | ||
[ValidateAntiForgeryToken] | ||
public IActionResult CreateRRule([FromBody] RRuleWrapper RRuleWrapper) | ||
{ | ||
if (RRuleWrapper == null) | ||
{ | ||
var rRuleResultE = new RRuleResult() { ErrorText = "invalid data" }; | ||
return new JsonResult(rRuleResultE); | ||
}; | ||
|
||
var recurrencePattern = new RecurrencePattern(RRuleWrapper.GetFrequencyType(), RRuleWrapper.Interval); | ||
switch (recurrencePattern.Frequency) | ||
{ | ||
case FrequencyType.None: | ||
case FrequencyType.Secondly: | ||
case FrequencyType.Minutely: | ||
case FrequencyType.Hourly: | ||
case FrequencyType.Daily: | ||
break; | ||
case FrequencyType.Weekly: | ||
recurrencePattern.ByDay = RRuleWrapper.GetByDayList(); | ||
break; | ||
case FrequencyType.Monthly: | ||
recurrencePattern.ByDay = RRuleWrapper.GetByDayList(); | ||
recurrencePattern.ByMonthDay = RRuleWrapper.ByMonthDay; | ||
recurrencePattern.BySetPosition = RRuleWrapper.BySetPosition; | ||
break; | ||
case FrequencyType.Yearly: | ||
recurrencePattern.ByDay = RRuleWrapper.GetByDayList(); | ||
recurrencePattern.ByMonth = RRuleWrapper.ByMonth; | ||
recurrencePattern.ByMonthDay = RRuleWrapper.ByMonthDay; | ||
recurrencePattern.BySetPosition = RRuleWrapper.BySetPosition; | ||
break; | ||
default: | ||
break; | ||
} | ||
if (RRuleWrapper.Count > 0) | ||
recurrencePattern.Count = RRuleWrapper.Count; | ||
if (RRuleWrapper.Until.HasValue) | ||
recurrencePattern.Until = RRuleWrapper.Until.Value; | ||
|
||
//var rRuleResult = new RRuleResult() { RecurrencePatternString = recurrencePattern.ToString(), RecurrencePatternText = recurrencePattern.ToText() }; | ||
var browserLang = Request.Headers["Accept-Language"].ToString().Split(";").FirstOrDefault()?.Split(",").FirstOrDefault(); | ||
var rRuleResult = new RRuleResult() { RecurrencePatternString = recurrencePattern.ToString(), RecurrencePatternText = recurrencePattern.ToText(new CultureInfo(browserLang)) }; | ||
var startTime = RRuleWrapper.StartDate != null ? RRuleWrapper.StartDate : DateTime.Now; | ||
rRuleResult.RecurrencePatternList = RecurringRuleProcessor.GetAppointments(startTime, startTime.AddYears(maxYears), recurrencePattern.ToString()).Take(maxOccurences + 1).ToList(); | ||
if (rRuleResult.RecurrencePatternList.Count > maxOccurences) | ||
{ | ||
rRuleResult.RecurrencePatternList.RemoveAt(maxOccurences); | ||
rRuleResult.HintText = $"there are more occurences, only first {maxOccurences} occurences in the next {maxYears} years at most are listed"; | ||
} | ||
|
||
return new JsonResult(rRuleResult); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace RecurrenceRuleWebAppVue.Models | ||
{ | ||
public class ErrorViewModel | ||
{ | ||
public string RequestId { get; set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace RecurrenceRuleWebAppVue.Models | ||
{ | ||
public class FormViewModel | ||
{ | ||
public FormFields Fields { get; set; } | ||
} | ||
|
||
public class FormFields | ||
{ | ||
public string FullName { get; set; } | ||
public string Email { get; set; } | ||
public string Comments { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace RecurrenceRuleWebAppVue.Models | ||
{ | ||
public class RRuleResult | ||
{ | ||
public string ErrorText { get; set; } = ""; | ||
public string RecurrencePatternString { get; set; } = ""; | ||
public string RecurrencePatternText { get; set; } = ""; | ||
public List<DateTime> RecurrencePatternList { get; set; } = new List<DateTime>(); | ||
public string HintText { get; set; } = ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using Ical.Net; | ||
using Ical.Net.DataTypes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace RecurrenceRuleWebAppVue.Models | ||
{ | ||
public class RRuleWrapper | ||
{ | ||
public string Guid { get; set; } | ||
public DateTime StartDate { get; set; } | ||
public string Frequency { get; set; } | ||
public string event_recurring { get; set; } | ||
public int Interval { get; set; } | ||
public List<string> ByDayValue { get; set; } | ||
public int Count { get; set; } | ||
public List<int> ByMonth { get; set; } | ||
public List<int> ByMonthDay { get; set; } | ||
public List<int> BySetPosition { get; set; } | ||
public DateTime? Until { get; set; } | ||
|
||
public List<WeekDay> GetByDayList() | ||
{ | ||
var result = new List<WeekDay>(); | ||
foreach (var d in ByDayValue) | ||
{ | ||
switch (d) | ||
{ | ||
case "MO": | ||
result.Add(new WeekDay(DayOfWeek.Monday)); | ||
break; | ||
case "TU": | ||
result.Add(new WeekDay(DayOfWeek.Tuesday)); | ||
break; | ||
case "WE": | ||
result.Add(new WeekDay(DayOfWeek.Wednesday)); | ||
break; | ||
case "TH": | ||
result.Add(new WeekDay(DayOfWeek.Thursday)); | ||
break; | ||
case "FR": | ||
result.Add(new WeekDay(DayOfWeek.Friday)); | ||
break; | ||
case "SA": | ||
result.Add(new WeekDay(DayOfWeek.Saturday)); | ||
break; | ||
case "SU": | ||
result.Add(new WeekDay(DayOfWeek.Sunday)); | ||
break; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public FrequencyType GetFrequencyType() | ||
{ | ||
|
||
switch (Frequency) | ||
{ | ||
case "daily": | ||
return FrequencyType.Daily; | ||
case "weekly": | ||
return FrequencyType.Weekly; | ||
case "monthly": | ||
return FrequencyType.Monthly; | ||
case "yearly": | ||
return FrequencyType.Yearly; | ||
default: | ||
return FrequencyType.None; | ||
} | ||
|
||
/* | ||
public enum FrequencyType | ||
{ | ||
None = 0, | ||
Secondly = 1, | ||
Minutely = 2, | ||
Hourly = 3, | ||
Daily = 4, | ||
Weekly = 5, | ||
Monthly = 6, | ||
Yearly = 7 | ||
} | ||
*/ | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.