public void ExitNotification() { ExitNotification exitNotification = new ExitNotification(); Notification_Message notificationMessage = new Notification_Message("exit", exitNotification); string json = JsonConvert.SerializeObject(notificationMessage); string headerAndJson = "Content-Length: " + (json.Length) + "\r\n\r\n" + json; tcpManager.Send(headerAndJson); }
private void CheckTollRoad() { if (!inTollRoad && !isExiting) //Toll Yolda Değilken Ve Çıkmıyor İken { //Toll Yola Girip Girmediğimizi Burdan Anlıyoruz foreach (Area tollAreaItem in tollAreaList.Where(x => x.isBooth)) { double dist = CommonMethods.GetDistance(tollAreaItem.areaLatitude, tollAreaItem.areaLongitude, currentLocation.Latitude, currentLocation.Longitude); if (dist < avgApproximity && tollAreaItem.isBooth) { tollAreaExitList = dbOperations.GetAreaPassListWithDisctance(tollAreaItem.areaID).ReturnObject.OrderBy(x => x.distance).ToList(); if (tollAreaExitList.Count != 0) { NotificationList = new List <ExitNotification>(); notificationLayout = FindViewById <LinearLayout>(Resource.Id.notificationLayout); notificationLayout.RemoveAllViews(); dialog.Dismiss(); foreach (var exitItem in tollAreaExitList) { //bu liste giris sonrasi cikan kutulari yaratiyor if (exitItem.isBooth) { //eger exitItem gise ise listeye ekle notificationLayout.AddView(RoadNotification(exitItem.areaID)); } } //yola girildi olarak kayit atiliyor inTollRoad = true; tollAreaEnter = tollAreaItem; tollAreaEnterTime = DateTime.Now; break; } } } } else //Toll yola girdikten sonra { //Yolun İçindeyken ve cikis halinde degilken if (!isExiting) { //her exit icin foreach (var tollAreaItem in tollAreaExitList.ToList()) { double dist = CommonMethods.GetDistance(tollAreaItem.areaLatitude, tollAreaItem.areaLongitude, currentLocation.Latitude, currentLocation.Longitude); ExitNotification currentNotify = NotificationList.Where(x => x.areaID == tollAreaItem.areaID).FirstOrDefault(); notificationLayout = FindViewById <LinearLayout>(Resource.Id.notificationLayout); if (tollAreaItem.isBooth) { LinearLayout Container = (LinearLayout)FindViewById(currentNotify.ContainerID); if (Container != null) { TextView LeftText = (TextView)FindViewById(currentNotify.LeftID); TextView CenterText = (TextView)FindViewById(currentNotify.CenterID); TextView RightText = (TextView)FindViewById(currentNotify.RightID); TextView UpperRight = (TextView)FindViewById(currentNotify.RightUpperID); TimeSpan TimeLeft = CommonMethods.GetMinutesLeft(tollAreaItem.distance, carMaxSpeed, tollAreaEnterTime); Container.Visibility = ViewStates.Visible; if (TimeLeft == TimeSpan.Zero) { Container.SetBackgroundColor(Color.Argb(200, 39, 174, 96)); } //kutularin icindeki verileri guncelle LeftText.Text = tollAreaItem.areaName; CenterText.Text = CommonMethods.GetExitTime(tollAreaItem.distance, carMaxSpeed, tollAreaEnterTime).ToString("HH:mm"); RightText.Text = TimeLeft != null && TimeLeft.Hours > 0 ? string.Format(timeDisplayFormatWithHour, TimeLeft.Hours, TimeLeft.Minutes, TimeLeft.Seconds) : string.Format(timeDisplayFormat, TimeLeft.Minutes, TimeLeft.Seconds); //eger cikisa gelinmis ise if (dist < avgApproximity) { //yaziyi degistir UpperRight.Text = "Çıkış Saati"; //cikis saatini goster RightText.Text = DateTime.Now.ToString("HH:mm"); //diger tum cikislari listeden cikar foreach (ExitNotification item2 in NotificationList) { if (item2.areaID != tollAreaItem.areaID) { LinearLayout delContainer = (LinearLayout)FindViewById(item2.ContainerID); notificationLayout.RemoveView(delContainer); } } //cikiliyor olarak kayit yap isExiting = true; inTollRoad = false; //cikis popup mesaji olusturm #region Popup Mesaji PopupMessage(this, TimeLeft); break; #endregion Popup Mesaji } } } else //Yon tayini ile ilgili bolumler { //gatelerden birine girmisse if (dist < avgApproximity) { //giris noktasindan yolun bitis istikametine dogru gidiyor if (tollAreaItem.areaID > tollAreaEnter.areaID) { foreach (AreaWithDistance item2 in tollAreaExitList.ToList()) { if (item2.areaID < tollAreaItem.areaID) { if (item2.isBooth) { ExitNotification delnotify = NotificationList.Where(x => x.areaID == item2.areaID).FirstOrDefault(); LinearLayout delContainer = (LinearLayout)FindViewById(delnotify.ContainerID); notificationLayout.RemoveView(delContainer); //AdMob çıkıyor ShowInterstitialAd(); } tollAreaExitList.Remove(item2); } } } else //giris noktasindan yolun baslangic istikametine dogru gidiyor { foreach (AreaWithDistance item2 in tollAreaExitList.ToList()) { if (tollAreaItem.areaID < item2.areaID) { if (item2.isBooth) { ExitNotification delnotify = NotificationList.Where(x => x.areaID == item2.areaID).FirstOrDefault(); LinearLayout delContainer = (LinearLayout)FindViewById(delnotify.ContainerID); notificationLayout.RemoveView(delContainer); //AdMob çıkıyor ShowInterstitialAd(); } tollAreaExitList.Remove(item2); } } } } } } } else //Yoldan Çıkıyorken { Boolean stillExiting = false; foreach (AreaWithDistance item in tollAreaExitList) { double dist = CommonMethods.GetDistance(item.areaLatitude, item.areaLongitude, currentLocation.Latitude, currentLocation.Longitude); if (dist < avgExitApproximity) { stillExiting = true; } } if (!stillExiting) { isExiting = stillExiting; inTollRoad = false; tollAreaEnter = null; tollAreaEnterTime = DateTime.MinValue; tollAreaExitList = null; TollWaitingPopUpShow(); } } } }