Exemplo n.º 1
0
		protected override async void OnHandleIntent (Intent intent)
		{
			var download = new DbDownloadHelper ();
			var upload = new DbUploadHelper ();
			var newEntries = TimeManager.GetUnSynchedTimeeEntries ();
			var newLocations = GpsLocationManager.GetUnSynchedGpsLocations ();
			//getting jobs, codes and version
			await download.GetData();
			await upload.UploadAll (newEntries, newLocations);

			//wait until is over
			var success = !download.DownloadFailed () && !upload.UploadFailed ();
			if (download.bCodes.Any () && download.nbCodes.Any () && download.jobs.Any ()) {
				var update = new DbUpdateHelper ();
				update.UpdateAll (download.jobs, download.bCodes, download.nbCodes, newEntries, newLocations);
			}

			string resultString = success ? "Synch Successfull" : "Synch Unsuccessfull";
			string textString = download.message + " " + upload.message;

			var ic = success ? Resource.Drawable.sync : Resource.Drawable.unsynch;

			var pendingIntent = PendingIntent.GetActivity (this, 0, new Intent (this, typeof(MainActivity)), 0);

			var builder = new NotificationCompat.Builder (this)
				.SetAutoCancel (true)
				.SetContentIntent (pendingIntent)
				.SetContentTitle (resultString)
				.SetSmallIcon (ic)
				.SetContentInfo ("ETC Sync Notification")
				.SetContentText (textString);

			// Finally publish the notification
			var notificationManager = (NotificationManager)GetSystemService (NotificationService);
			notificationManager.Notify (0, builder.Build ());
			Intent applicationIntent = new Intent (Forms.Context, typeof(MainActivity));
			applicationIntent.AddFlags (ActivityFlags.NewTask);
			//Forms.Context.StartActivity (applicationIntent);
		}
Exemplo n.º 2
0
 void Consolidate()
 {
     var update = new DbUpdateHelper ();
     update.ConsolidateEntries ();
 }