public AlarmSetting Get(int alarmSettingId)
 {
     return(AlarmSetting.GetObjects().FirstOrDefault(x => x.AlarmSettingId == alarmSettingId));
 }
        //gelen resmi model ile kıyasla
        private void RecognisePicture(MemoryStream memoryStream)
        {
            Image <Gray, byte> img     = new Image <Gray, byte>(new Bitmap(Image.FromStream((Stream)memoryStream)));
            HaarCascade        haaryuz = new HaarCascade("haarcascade_frontalface_alt2.xml");

            MCvAvgComp[][] Yuzler = img.DetectHaarCascade(haaryuz, 1.2, 5, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(15, 15));

            foreach (MCvAvgComp item in Yuzler[0])
            {
                List <Classes.User> customerUsers = Classes.User.GetObjects().Where(x => x.CustomerId == GlobalSetting.CustomerId).ToList();
                var    yuz  = img.Copy(item.rect).Convert <Gray, byte>().Resize(100, 100, INTER.CV_INTER_CUBIC);
                string name = train.Recognise(yuz);
                if (string.IsNullOrEmpty(name) || name == "Tanımsız" || customerUsers.FirstOrDefault(x => x.Username == name) == null)
                {
                    AlarmSetting alarm = AlarmSetting.GetObjects().FirstOrDefault(x => x.AlarmSettingId == GlobalSetting.UserAlarmSettingId);
                    if (alarm.IsActive)
                    {
                        if (alarm.IsCallAlarmActive)
                        {
                            if (!string.IsNullOrEmpty(alarm.FirstPersonNumber))
                            {
                                if (alarm.FirstPersonNumber.Length == 10)
                                {
                                    alarm.FirstPersonNumber = "+90" + alarm.FirstPersonNumber;
                                }
                                else if (alarm.FirstPersonNumber.Length == 11)
                                {
                                    alarm.FirstPersonNumber = "+9" + alarm.FirstPersonNumber;
                                }
                                AlertRequest request = new AlertRequest();
                                request.AlarmNumber    = alarm.FirstPersonNumber;
                                request.AlarmParameter = string.Empty;
                                request.AlarmType      = "CallAlarm";
                                request.IsAlerted      = false;
                                request.Insert();
                            }

                            if (!string.IsNullOrEmpty(alarm.SecondPersonNumber))
                            {
                                if (alarm.SecondPersonNumber.Length == 10)
                                {
                                    alarm.SecondPersonNumber = "+90" + alarm.SecondPersonNumber;
                                }
                                else if (alarm.SecondPersonNumber.Length == 11)
                                {
                                    alarm.SecondPersonNumber = "+9" + alarm.SecondPersonNumber;
                                }
                                AlertRequest request = new AlertRequest();
                                request.AlarmNumber    = alarm.SecondPersonNumber;
                                request.AlarmParameter = string.Empty;
                                request.AlarmType      = "CallAlarm";
                                request.IsAlerted      = false;
                                request.Insert();
                            }
                        }
                        else if (alarm.IsPoliceAlarmActive)
                        {
                            if (alarm.SecondPersonNumber.Length == 10)
                            {
                                alarm.SecondPersonNumber = "+90" + alarm.SecondPersonNumber;
                            }
                            else if (alarm.SecondPersonNumber.Length == 11)
                            {
                                alarm.SecondPersonNumber = "+9" + alarm.SecondPersonNumber;
                            }
                            AlertRequest request = new AlertRequest();
                            request.AlarmNumber    = "911";
                            request.AlarmParameter = string.Empty;
                            request.AlarmType      = "CallAlarm";
                            request.IsAlerted      = false;
                            request.Insert();
                        }
                        else if (alarm.IsSmsAlarmActive)
                        {
                            if (alarm.SecondPersonNumber.Length == 10)
                            {
                                alarm.SecondPersonNumber = "+90" + alarm.SecondPersonNumber;
                            }
                            else if (alarm.SecondPersonNumber.Length == 11)
                            {
                                alarm.SecondPersonNumber = "+9" + alarm.SecondPersonNumber;
                            }
                            AlertRequest request = new AlertRequest();
                            request.AlarmNumber    = alarm.SecondPersonNumber;
                            request.AlarmParameter = string.Empty;
                            request.AlarmType      = "SmsAlarm";
                            request.IsAlerted      = false;
                            request.Insert();
                        }
                    }
                }
            }
        }