Exemple #1
0
        // POST: odata/Quakes
        public async Task <IHttpActionResult> Post(Quake quake)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Quakes.Add(quake);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (QuakeExists(quake.Event_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(quake));
        }
Exemple #2
0
        void Shell_onCollided(IGameObj Sender, CollisionResult result, GameObjInfo objB)
        {
            if (objB.ObjClass == "WarShip")
            {
                if (PurviewMgr.IsMainHost)
                {
                    WarShipShell shell = Sender as WarShipShell;
                    WarShip      firer = shell.Firer as WarShip;
                    if (objB.Script != firer.ObjInfo.Script)
                    {
                        (shell.Firer as WarShip).Score += SpaceWarConfig.ScoreByHit;
                        SyncShipScoreHp(shell.Firer as WarShip, true);
                    }
                }

                sceneMgr.DelGameObj("shell", Sender.Name);
                new ShellExplodeBeta(Sender.Pos, ((ShellNormal)Sender).Azi);

                Quake.BeginQuake(10, 50);
                Sound.PlayCue("EXPLO1");
            }
            else
            {
                WarShipShell shell = (WarShipShell)Sender;
                shell.MirrorPath(result);

                //
                //BroadcastObjPhiStatus(shell, true);
            }
        }
Exemple #3
0
        public void QuakeDataSourceNewQuake(Quake quake)
        {
            var quakeIntent = new Intent(NewQuakeDetectedAction);

            quakeIntent.PutExtra("quake", quake.toJson());

            SendOrderedBroadcast(quakeIntent, null);
        }
Exemple #4
0
        void shell_onCollided(IGameObj Sender, CollisionResult result, GameObjInfo objB)
        {
            sceneMgr.DelGameObj("shell", Sender.Name);
            new ShellExplodeBeta(Sender.Pos, ((ShellNormal)Sender).Azi);

            Quake.BeginQuake(10, 50);
            Sound.PlayCue("EXPLO1");
        }
        public IActionResult Details(LatLng latLng)
        {
            var allQuakes = Quake.GetQuakes(latLng.UserLat, latLng.UserLng);

            ViewBag.Possibility      = Metrics.PossibilityOfQuake(allQuakes);
            ViewBag.AverageMagnitude = Metrics.StrengthOfQuake(allQuakes);
            ViewBag.QuakeCount       = allQuakes.Count;
            ViewBag.MaxMag           = Metrics.MaxMagnitude(allQuakes);
            ViewBag.UserData         = latLng;

            return(View(allQuakes));
        }
Exemple #6
0
 public override string this[int position]
 {
     get
     {
         QuakeDataSource ds = getDataSource();
         if (ds != null)
         {
             Quake quake = ds.getQuake(position);
             return(quake.Place);
         }
         return("");
     }
 }
Exemple #7
0
        // DELETE: odata/Quakes(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] string key)
        {
            Quake quake = await db.Quakes.FindAsync(key);

            if (quake == null)
            {
                return(NotFound());
            }

            db.Quakes.Remove(quake);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            //RequestWindowFeature(WindowFeatures.NoTitle);

            base.OnCreate(savedInstanceState);

            try
            {
                Log.Info(TAG, "Hello world");

                Intent serviceToStart = new Intent(this, typeof(QuakeService));

                StartService(serviceToStart);

                //quakeServiceIntent = new Intent("uk.co.fixsolutions.QuakeService");
                quakeServiceIntent = new Intent(this, typeof(QuakeService));

                quakeReceiver = new QuakeReceiver(this);

                // Set our view from the "main" layout resource
                SetContentView(Resource.Layout.Main);

                lv            = FindViewById <ListView>(Resource.Id.listView1);
                listAdapter   = new AndroidQuakeAdapter(this);
                lv.Adapter    = listAdapter;
                lv.ItemClick += (sender, e) => {
                    int    pos = e.Position;
                    string msg = "item=" + pos;
                    Android.Widget.Toast.MakeText(this, msg, Android.Widget.ToastLength.Short).Show();

                    Quake quake = getQuakeDataSource().getQuake(pos);

                    //var url = "geo:" + quake.Coordinates.Latitude + "," + quake.Coordinates.Longitude + "?z=10";
                    //var geoUri = Android.Net.Uri.Parse (url);
                    //var mapIntent = new Intent (Intent.ActionView, geoUri);
                    //StartActivity (mapIntent);

                    var intent = new Intent(this, typeof(QuakeDetailActivity));
                    intent.PutExtra("quake", quake.toJson());

                    StartActivity(intent);
                };
            }
            catch (Exception e)
            {
                Log.Error(TAG, "Error: " + e.ToString());
            }
        }
Exemple #9
0
        private async Task <Quake[]> GetQuakesDataFromServiceAsync()
        {
            var quakes = new Quake[0];

            using (var client = new HttpClient()) {
                var url = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.geojson";

                var values = await client.GetStringAsync(url);

                var data = JsonSerializer.Deserialize <QuakeData>(values);

                quakes = data.features;
            }

            return(quakes);
        }
Exemple #10
0
        // PUT: odata/Quakes(5)
        public async Task <IHttpActionResult> Put([FromODataUri] string key, Delta <Quake> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Quake quake = await db.Quakes.FindAsync(key);

            if (quake == null)
            {
                return(NotFound());
            }

            patch.Put(quake);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuakeExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(quake));
        }
Exemple #11
0
        public override void OnReceive(Context context, Intent intent)
        {
            if (intent.Action.Equals(QuakeService.NewQuakeDetectedAction))
            {
                var   json  = intent.GetStringExtra("quake");
                Quake quake = new Quake(json);

                var nMgr         = (NotificationManager)context.GetSystemService(Context.NotificationService);
                var detailIntent = new Intent(context, typeof(QuakeDetailActivity));
                detailIntent.PutExtra("quake", quake.toJson());
                var pendingIntent = PendingIntent.GetActivity(context, 0, detailIntent, 0);

                Android.App.Notification.Builder builder = new Notification.Builder(context);

                builder.SetContentTitle("New Earthquake");
                builder.SetContentText(quake.ToString());
                builder.SetContentIntent(pendingIntent);
                builder.SetSmallIcon(Resource.Drawable.Icon);
                builder.SetAutoCancel(true);                    // This means it will cancel when user clicks on it.

                var notification = builder.Build();
                nMgr.Notify(0, notification);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.QuakeDetailView);

            this.ActionBar.SetDisplayHomeAsUpEnabled(true);
            this.ActionBar.SetHomeButtonEnabled(true);

            //var quake = JsonConvert.DeserializeObject<Quake>(Intent.GetStringExtra("quake"));
            var   json  = Intent.GetStringExtra("quake");
            Quake quake = new Quake(json);

            DateTime utcTime   = quake.getUTCTime();
            DateTime localTime = quake.getLocalTime();

            //			DateTime dtim = new DateTime (1970, 1, 1, 0, 0, 0).AddSeconds (Convert.ToDouble (quake.Time / 1000));	// We need time in seconds.

            FindViewById <TextView>(Resource.Id.detailPlace).Text     = quake.Place;
            FindViewById <TextView>(Resource.Id.detailWhen).Text      = utcTime.ToString("HH:mm:ss dd-MMM-yyyy UTC");
            FindViewById <TextView>(Resource.Id.detailWhenLocal).Text = localTime.ToString("HH:mm:ss dd-MMM-yyyy (Local)");
            FindViewById <TextView>(Resource.Id.detailDistance).Text  = ((int)(quake.DistanceAway / 1000)) + "km away";
            FindViewById <TextView>(Resource.Id.detailMagnitude).Text = "Mag:" + quake.Mag + " (" + quake.getQuakeClassAsString() + ")";
            //FindViewById<TextView>(Resource.Id.detailMagnitude).SetTextColor(new Android.Graphics.Color(quake.getQuakeColor().ToArgb()));
            FindViewById <TextView>(Resource.Id.detailWhere).Text = quake.Coordinates.Latitude + "/" + quake.Coordinates.Longitude + " (latitude/longitude)";
            FindViewById <TextView>(Resource.Id.detailDepth).Text = quake.Coordinates.Depth + " km deep";

            wv = FindViewById <WebView>(Resource.Id.quakeMap);
            if (wv != null)
            {
                wv.Settings.JavaScriptEnabled = true;
                wv.SetWebViewClient(new MyWebViewClient());
                wv.LoadUrl("http://www.bing.com/mapspreview?cp=" + quake.Coordinates.Latitude + "~" + quake.Coordinates.Longitude + "&style=a");
            }
        }
        public IActionResult History()
        {
            var allQuakes = Quake.GetWorstQuakes();

            return(View(allQuakes));
        }