Exemplo n.º 1
0
        //panic butonuna basıldığında buraya girer
        private void BtnPanic_Click(object sender, EventArgs e)
        {
            try
            {
                //kullanıcı giriş yaparken serverdan gelen panic ayarları parametresine bakılır.
                //Eğer herhangi bir panik ayarlaması yapılmadıysa mesaj gösterilir.
                if (GlobalSettings.panicSettingId==0)
                {
                    Toast.MakeText(this, "Panik butonunu kullanmak için panik seçeneklerinizi oluşturmalısınız", ToastLength.Long).Show();
                    return;
                }

                //panik ayarlaması yapılmış ise kayıtlı kişilere sms gönderilir


                PanicSetting panicSetting = PanicSetting.GetPanicSetting(GlobalSettings.panicSettingId);
                
                if (panicSetting.IsSmsAlarmActive)
                {
                    //kişinin enlem ve boylam bilgileri kullanılarak google api(geolocation) vasıtasyla açık adres elde edilir.
                    string adres = Utilities.AdresBul(GlobalSettings.enlem, GlobalSettings.boylam);


                    //adres bilgisi elde edildikten sonra gerekli kişilere sms atılır.
                    _smsManager = SmsManager.Default;

                    var message = "Acil Durumu\n Güvende olmadığımı düşünüyorum! Bulunduğum Adres:" + adres;
                    var piSent = PendingIntent.GetBroadcast(this, 0, new Intent("SMS_SENT"), 0);
                    var piDelivered = PendingIntent.GetBroadcast(this, 0, new Intent("SMS_DELIVERED"), 0);

                    string phone = string.Empty;

                    if (!string.IsNullOrEmpty(panicSetting.FirstPersonNumber))
                    {
                        phone = "0" + panicSetting.FirstPersonNumber;
                        _smsManager.SendTextMessage(phone, null, message, piSent, piDelivered);
                    }

                    if (!string.IsNullOrEmpty(panicSetting.SecondPersonNumber))
                    {
                        phone = "0" + panicSetting.SecondPersonNumber;

                        _smsManager.SendTextMessage(phone, null, message, piSent, piDelivered);
                    }
                }

                Toast.MakeText(this, "Panik bildiriminiz gönderilmiştir", ToastLength.Short).Show();
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Panik bildiriminiz gönderilirken hata oluşmuştur.KOŞ!!!", ToastLength.Short).Show();
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.PanicOptions);

            willUpdateItem = new PanicSetting();
            willUpdateItem.PanicSetttingId = GlobalSettings.panicSettingId;

            Button btn = FindViewById <Button>(Resource.Id.btnSavePanicOption);

            btn.Click += Btn_Click;

            txtFirstPersonName    = FindViewById <EditText>(Resource.Id.txtFirstPersonNamePanicOptions);
            txtFirstPersonNumber  = FindViewById <EditText>(Resource.Id.txtFirstPersonNumberPanicOptions);
            txtSecondPersonName   = FindViewById <EditText>(Resource.Id.txtSecondPersonNamePanicOption);
            txtSecondPersonNumber = FindViewById <EditText>(Resource.Id.txtSecondPersonNumberPanicOption);
            chkIsCallAlarmActive  = FindViewById <CheckBox>(Resource.Id.chkAlarmWithCallPanicOption);
            chkIsSmsAlarmActive   = FindViewById <CheckBox>(Resource.Id.chkAlarmWithSMSPanicOption);
        }
        private void Btn_Click(object sender, EventArgs e)
        {
            PanicSetting panicSetting = new PanicSetting();

            panicSetting.PanicSetttingId    = willUpdateItem.PanicSetttingId;
            panicSetting.FirstPersonName    = txtFirstPersonName.Text;
            panicSetting.FirstPersonNumber  = txtFirstPersonNumber.Text;
            panicSetting.IsCallAlarmActive  = chkIsCallAlarmActive.Checked;
            panicSetting.IsSmsAlarmActive   = chkIsSmsAlarmActive.Checked;
            panicSetting.SecondPersonName   = txtSecondPersonName.Text;
            panicSetting.SecondPersonNumber = txtSecondPersonNumber.Text;
            panicSetting.UserId             = GlobalSettings.userId;

            panicSetting.Save();

            Toast.MakeText(this, "Panik ayarlarınız kaydedilmiştir.", ToastLength.Short).Show();

            Intent intent = new Intent(this, typeof(MenuActivity));

            StartActivity(intent);
        }
Exemplo n.º 4
0
 public PanicSetting Post([FromBody] PanicSetting panicSetting)
 {
     try
     {
         if (panicSetting.PanicSetttingId == 0)
         {
             panicSetting.InsertDB();
             panicSetting.PanicSetttingId = panicSetting.GetLastId();
             panicSetting.UpdateUser(panicSetting.UserId, panicSetting.PanicSetttingId);
             return(panicSetting);
         }
         else
         {
             panicSetting.Update();
             return(panicSetting);
         }
     }
     catch (Exception ex)
     {
         logger.AddLog("PanicSettingController Post Hata :" + ex.Message, Logger.LogLevel.Error);
         return(new PanicSetting());
     }
 }
Exemplo n.º 5
0
 public PanicSetting Get(int panicSettingId)
 {
     return(PanicSetting.GetObjects().FirstOrDefault(x => x.PanicSetttingId == panicSettingId));
 }