void Button1_Click(object sender, EventArgs e) { try { int.Parse(textBox1.Text); } catch (Exception) { MessageBox.Show("Cannot parse Text! Please try again"); return; } result = new ScheduledSync(device, int.Parse(textBox1.Text)); Close(); }
public async Task <IActionResult> Add([FromBody] ScheduledSync scheduledSync) { try { await this.scheduledSyncRepo.AddAsync(scheduledSync); return(StatusCode(200)); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public override async void OnStart (Intent intent, int startId) { ((AndroidApp)Application).InitializeComponents (); try { var extras = intent.Extras; var entryId = Convert.ToInt64 (extras.GetString ("task_id", String.Empty)); // updated_at is null (usually) when the time entry was just created, in that // case we assign modifiedAt the default DateTime value (start of time) var modifiedAt = ParseDate (extras.GetString ("updated_at", String.Empty)); var dataStore = ServiceContainer.Resolve<IDataStore> (); var rows = await dataStore.Table<TimeEntryData> () .QueryAsync (r => r.RemoteId == entryId); var entry = rows.FirstOrDefault (); if (entry != null && modifiedAt <= entry.ModifiedAt) { // We already have the latest data, can skip this: GcmBroadcastReceiver.CompleteWakefulIntent (intent); StopSelf (startId); return; } // Purge finished syncs: schedule.RemoveAll ((s) => s.IsFinished); // See if we can add this task to running sync: var running = schedule.FirstOrDefault ((s) => s.IsRunning); if (running != null && running.StartTime >= modifiedAt) { running.AddCommand (intent, startId); return; } // Finally add it to the new sync: var upcoming = schedule.FirstOrDefault ((s) => !s.IsCancelled && !s.IsRunning && !s.IsFinished); if (upcoming == null) { upcoming = new ScheduledSync (this); schedule.Add (upcoming); } upcoming.AddCommand (intent, startId); } catch (Exception exc) { // Something went wrong, recover gracefully GcmBroadcastReceiver.CompleteWakefulIntent (intent); StopSelf (startId); // Log errors var log = ServiceContainer.Resolve<Logger> (); log.Error (Tag, exc, "Failed to process pushed message."); } }
public override void OnStart(Intent intent, int startId) { ((AndroidApp)Application).InitializeComponents(); try { var extras = intent.Extras; var entryId = Convert.ToInt64(extras.GetString("task_id", String.Empty)); // updated_at is null (usually) when the time entry was just created, in that // case we assign modifiedAt the default DateTime value (start of time) var modifiedAt = ParseDate(extras.GetString("updated_at", String.Empty)); var entry = Model.ByRemoteId <TimeEntryModel> (entryId); if (entry != null && modifiedAt <= entry.ModifiedAt) { // We already have the latest data, can skip this: GcmBroadcastReceiver.CompleteWakefulIntent(intent); StopSelf(startId); return; } // Purge finished syncs: schedule.RemoveAll((s) => s.IsFinished); // See if we can add this task to running sync: var running = schedule.FirstOrDefault((s) => s.IsRunning); if (running != null && running.StartTime >= modifiedAt) { running.AddCommand(intent, startId); return; } // Finally add it to the new sync: var upcoming = schedule.FirstOrDefault((s) => !s.IsCancelled && !s.IsRunning && !s.IsFinished); if (upcoming == null) { upcoming = new ScheduledSync(this); schedule.Add(upcoming); } upcoming.AddCommand(intent, startId); } catch (Exception exc) { // Something went wrong, recover gracefully GcmBroadcastReceiver.CompleteWakefulIntent(intent); StopSelf(startId); // Log errors var log = ServiceContainer.Resolve <Logger> (); log.Error(Tag, exc, "Failed to process pushed message."); } }