127 lines
3.9 KiB
C#
127 lines
3.9 KiB
C#
using EgwCoreLib.Razor.Data;
|
|
|
|
namespace EgwCoreLib.BlazorTest.Pages
|
|
{
|
|
public partial class TestCalendario
|
|
{
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
dtCurr = DateTime.Today;
|
|
await Task.Delay(1);
|
|
setupMonthSim();
|
|
|
|
// preparo calendario settimanale...
|
|
setupWeekSim();
|
|
}
|
|
|
|
private void setupMonthSim()
|
|
{
|
|
DateCheck = new Dictionary<DateTime, string>();
|
|
// random colorate...
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
DateTime newDate = dtCurr.AddDays(rnd.Next(-5, 10)).Date;
|
|
if (!DateCheck.ContainsKey(newDate))
|
|
{
|
|
DateCheck.Add(newDate, "bg-danger text-light rounded-circle p-2");
|
|
}
|
|
else
|
|
{
|
|
DateCheck[newDate] = "bg-warning text-light rounded-circle p-2";
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Forza ricaricamento week
|
|
/// </summary>
|
|
protected void ForceReloadWeek()
|
|
{
|
|
// preparo calendario settimanale...
|
|
setupWeekSim();
|
|
}
|
|
|
|
protected void SetDayDetail(DateTime selDate)
|
|
{
|
|
|
|
var tmpDays = ListDate.Where(x => x.Equals(selDate)).ToList();
|
|
var tmpEv = EventListWeek.Where(x => x.Inizio.Date.Equals(selDate)).ToList();
|
|
// salvo valori simulati
|
|
ListDate = tmpDays;
|
|
EventListWeek = tmpEv;
|
|
}
|
|
|
|
protected Random rnd = new Random();
|
|
private void setupWeekSim()
|
|
{
|
|
DateTime oggi = DateTime.Today;
|
|
var tmpDays = new List<DateTime>();
|
|
var tmpEv = new List<CalendarEvent>();
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
tmpDays.Add(oggi.AddDays(i));
|
|
// genero qualche evento da 0 a 6...
|
|
int numEv = rnd.Next(0, 8);
|
|
if (numEv > 0)
|
|
{
|
|
for (int e = 0; e < numEv; e++)
|
|
{
|
|
int inizio = rnd.Next(8, 12);
|
|
int fine = inizio + rnd.Next(2,8);
|
|
CalendarEvent newEv = new CalendarEvent()
|
|
{
|
|
CssClass = "bg-success opacity-25",
|
|
Description = $"Permesso #{e}, testo molto lungo per provare andata a capo con o senza un segnaposto",
|
|
Type = "PERM",
|
|
Inizio = oggi.AddDays(i).AddHours(inizio),
|
|
Fine = oggi.AddDays(i).AddHours(fine),
|
|
Title = "O.S.",
|
|
ToolTip = $"O.S. {oggi.AddDays(i).AddHours(inizio)} - {oggi.AddDays(i).AddHours(fine)}"
|
|
};
|
|
tmpEv.Add(newEv);
|
|
}
|
|
}
|
|
}
|
|
// salvo valori simulati
|
|
ListDate = tmpDays;
|
|
EventListWeek = tmpEv;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private Dictionary<DateTime, string> DateCheck = new Dictionary<DateTime, string>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private DateTime dtCurr { get; set; } = DateTime.Today;
|
|
|
|
private List<DateTime> ListDate { get; set; } = new List<DateTime>();
|
|
private List<CalendarEvent> EventListWeek { get; set; } = new List<CalendarEvent>();
|
|
|
|
private bool singleWeek = false;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void DisplayDate(DateTime dtSel)
|
|
{
|
|
dtCurr = dtSel;
|
|
singleWeek = true;
|
|
}
|
|
|
|
private async Task resetCal()
|
|
{
|
|
singleWeek = false;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |