private async Task ResolveCalendarQuery(CalendarSave c) { var query = new CalendarSave { ActiveDays = c.ActiveDays, Enabled = c.Enabled, Date = c.Date }; var response = await server.Value.SaveCalendar(query); switch (response.Result) { case OkStatus.Ok: lock (locker) { server_data.ActiveDays = data.ActiveDays = c.ActiveDays; server_data.CalEnabled = data.CalEnabled = c.Enabled; server_data.CalDate = data.CalDate = c.Date; } break; case OkStatus.Error: //something wrong break; case OkStatus.NoPermission: //you dint have permission break; } }
public async Task ResolveQuery() { Dictionary <int, int> P; Dictionary <DayOfWeek, List <CalendarTask> > T; CalendarSave C = null; Dictionary <int, ModesStatus> M; List <Task> waitfor = new List <Task>(); await _semaphoreSlim.WaitAsync(); lock (locker) { P = data.DiffParameters(server_data); T = data.DiffTask(server_data); if (data.ActiveDays != server_data.ActiveDays || data.CalEnabled != server_data.CalEnabled || data.CalDate != server_data.CalDate) { C = new CalendarSave { ActiveDays = data.ActiveDays, Enabled = data.CalEnabled }; if (data.CalDate != server_data.CalDate) { C.Date = data.CalDate; } else { C.Date = new DateTime(); } } M = data.DiffModes(server_data); } try { if (P.Count != 0) { waitfor.Add(ResolveParametersQuery(P)); } if (T.Count != 0) { waitfor.Add(ResolveTaskQuery(T)); } if (C != null) { waitfor.Add(ResolveCalendarQuery(C)); } if (M.Count != 0) { waitfor.Add(ResolveMod(M)); } } finally { _semaphoreSlim.Release(); } await Task.WhenAll(waitfor.ToArray()); }
public ActionResult Save([FromBody] CalendarSave query) { _logger.LogInformation("Saving Calendar {0} {1} {2}", query.ActiveDays, query.Enabled, query.Date.ToString()); var result = new OkErrorResponce { Result = OkStatus.Ok }; return(Ok(result)); }
public async Task <OkErrorResponce> SaveCalendar(CalendarSave calendar) { NotifyFunctionCalled(); await Task.Delay(100); var result = new OkErrorResponce(); result.Result = OkStatus.Ok; return(result); }
public Task <OkErrorResponce> SaveCalendar(CalendarSave calendar) { return(SendJsonQuery <OkErrorResponce, CalendarSave>(calendar, calendarSaveSite)); }