コード例 #1
0
 public IActionResult Add([FromBody] AlarmSetting alarmSetting)
 {
     if (alarmSetting == null)
     {
         return(BadRequest());
     }
     using (var db = new AllInOneContext.AllInOneContext())
     {
         try
         {
             _logger.LogInformation("开始添加报警设置....");
             //if (db.AlarmSetting.Where(s => s.AlarmSettingId.Equals(alarmSetting.AlarmSettingId)).Count() > 0)
             //    return BadRequest("alarmSetting id is been used!");
             db.AlarmSetting.Add(alarmSetting);
             db.SaveChanges();
             _logger.LogInformation("完成添加报警设置......");
         }
         catch (Exception ex)
         {
             _logger.LogError("添加报警设置异常,Message:{0}\r\n StackTrace:{1}", ex.Message, ex.StackTrace);
             return(BadRequest(ex.Message));
         }
     }
     return(CreatedAtAction("", alarmSetting));
 }
コード例 #2
0
    // Update is called once per frame
    //void Update()
    //{
    //    if (Input.GetKeyDown(KeyCode.P))
    //    {
    //        Screen.fullScreen = !Screen.fullScreen;
    //    }
    //}

    /// <summary>
    /// 获取系统设置
    /// </summary>
    public static void GetSystemSetting()
    {
        string path = Application.dataPath + ConfigPath;

        if (!File.Exists(path))
        {
            CreateSystemSettingXml();
        }
        else
        {
            systemSetting = SerializeHelper.DeserializeFromFile <SystemSetting>(path);
        }
        Log.Error("SystemSettingHelper.GetSystemSetting" + systemSetting.IsShowLeftTopo);
        resolutionSetting    = systemSetting.ResolutionSetting;
        cinemachineSetting   = systemSetting.CinemachineSetting;
        communicationSetting = systemSetting.CommunicationSetting;
        versionSetting       = systemSetting.VersionSetting;
        refreshSetting       = systemSetting.RefreshSetting;
        assetLoadSetting     = systemSetting.AssetLoadSetting;
        honeyWellSetting     = systemSetting.HoneyWellSetting;
        deviceSetting        = systemSetting.DeviceSetting;
        historyPathSetting   = systemSetting.HistoryPathSetting;
        alarmSetting         = systemSetting.AlarmSetting;
        ///如果版本号不一致,自动更新
        if (versionSetting.VersionNumber != SystemSettingHelper.instance.versionNum)
        {
            versionSetting.VersionNumber = SystemSettingHelper.instance.versionNum;
            SaveSystemSetting();
        }

        locationSetting = systemSetting.LocationSetting;

        debugSetting = systemSetting.DebugSetting;
    }
コード例 #3
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            AlarmSetting item = new AlarmSetting();

            item.AlarmSettingId          = willUpdateItem.AlarmSettingId;
            item.DistanceValue           = Convert.ToDouble(txtDistance.Text);
            GlobalSettings.distanceValue = item.DistanceValue;
            item.FirstPersonName         = txtFirstPersonName.Text;
            item.FirstPersonNumber       = txtFirstPersonNumber.Text;
            item.SecondPersonName        = txtSecondPersonName.Text;
            item.SecondPersonNumber      = txtSecondPersonNumber.Text;
            item.IsActive = chkIsActive.Checked;
            item.IsActiveDistanceAlarm = string.IsNullOrEmpty(txtDistance.Text) ? false : true;
            item.IsCallAlarmActive     = chkAlarmWithCall.Checked;
            item.IsPoliceAlarmActive   = chkAlarmWithPolice.Checked;
            item.IsSmsAlarmActive      = chkAlarmWithSms.Checked;

            item.Save();

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

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

            StartActivity(intent);
        }
コード例 #4
0
        /// <summary>
        /// 获取设备报警配置
        /// </summary>
        /// <param name="db"></param>
        /// <param name="alarmLog"></param>
        /// <returns></returns>
        private AlarmSetting GetAlarmSetting(AllInOneContext.AllInOneContext db, AlarmLog alarmLog)
        {
            AlarmSetting setting = db.AlarmSetting.Include(t => t.Schedule).ThenInclude(t => t.ScheduleCycle).ThenInclude(t => t.DayPeriods).ThenInclude(t => t.TimePeriods).
                                   Include(t => t.Schedule).ThenInclude(t => t.ScheduleCycle).ThenInclude(t => t.CycleType).
                                   Include(t => t.AlarmSource).ThenInclude(t => t.Organization).Include(t => t.AlarmType).
                                   FirstOrDefault(p => p.AlarmSourceId.Equals(alarmLog.AlarmSourceId) &&
                                                  p.AlarmTypeId.Equals(alarmLog.AlarmTypeId));

            return(setting);
        }
コード例 #5
0
        private void System_set(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeViewItem power          = ((sender as TreeView).SelectedItem as TreeViewItem);
            string       systemTypeName = power.Uid.ToString();

            if (systemTypeName == null || "".Equals(systemTypeName))
            {
                return;
            }
            if (systemGrid.Children != null)
            {
                systemGrid.Children.Clear();
            }
            if (systemTypeName.Equals("sys"))
            {
                SystemSetting devicePower = SystemManagerFactory.SystemSetting;
                systemGrid.Children.Add(devicePower);
                devicePower.SetValue(Grid.RowProperty, 0);
                devicePower.SetValue(Grid.ColumnProperty, 0);
            }
            else if (systemTypeName.Equals("setting"))
            {
                AlarmSetting alarmSetting = SystemManagerFactory.AlarmSetting;
                systemGrid.Children.Add(alarmSetting);
                alarmSetting.SetValue(Grid.RowProperty, 0);
                alarmSetting.SetValue(Grid.ColumnProperty, 0);
            }
            else if (systemTypeName.Equals("userLog"))
            {
                AllUserLog userLog = SystemManagerFactory.UserLog;
                Users      user    = new Users();
                DataSet    set     = user.getUserLoginLog();
                userLog.page.ShowPages(userLog.logGrid, set, BaseRequest.PAGE_SIZE);
                systemGrid.Children.Add(userLog);
                userLog.SetValue(Grid.RowProperty, 0);
                userLog.SetValue(Grid.ColumnProperty, 0);
            }
            else if (systemTypeName.Equals("movedLog"))
            {
                MovedDevicesLog movedDevicesLog = SystemManagerFactory.MovedDevicesLog;
                SystemManager   sm  = new SystemManager();
                DataSet         set = sm.getEquipmentOperation();
                movedDevicesLog.page.ShowPages(movedDevicesLog.EquiplogGrid, set, BaseRequest.PAGE_SIZE);
                systemGrid.Children.Add(movedDevicesLog);
                movedDevicesLog.SetValue(Grid.RowProperty, 0);
                movedDevicesLog.SetValue(Grid.ColumnProperty, 0);
            }
            else if (systemTypeName.Equals("cycleSetting"))
            {
                BackupCycleSetting backupCycleSetting = new BackupCycleSetting();
                systemGrid.Children.Add(backupCycleSetting);
                backupCycleSetting.SetValue(Grid.RowProperty, 0);
                backupCycleSetting.SetValue(Grid.ColumnProperty, 0);
            }
        }
コード例 #6
0
 public IActionResult GetById(Guid id)
 {
     using (var db = new AllInOneContext.AllInOneContext())
     {
         AlarmSetting setting = db.AlarmSetting.Include(t => t.EmergencyPlan).
                                Include(t => t.BeforePlan).
                                FirstOrDefault(t => t.AlarmSettingId.Equals(id));
         if (setting == null || setting.AlarmSettingId.Equals(Guid.Empty))
         {
             return(NotFound());
         }
         return(new OkObjectResult(setting));
     }
 }
コード例 #7
0
 private void StopPlan(AlarmSetting setting)
 {
     Task.Run(new Action(() =>
     {
         if (setting.BeforePlanId != null)
         {
             StopPlan(setting.BeforePlanId.Value);
         }
         if (setting.EmergencyPlanId != null)
         {
             StopPlan(setting.EmergencyPlanId.Value);
         }
     }));
 }
コード例 #8
0
 public SystemSetting()
 {
     ResolutionSetting    = new ResolutionSetting();
     CinemachineSetting   = new CinemachineSetting();
     CommunicationSetting = new CommunicationSetting();
     VersionSetting       = new VersionSetting();
     RefreshSetting       = new RefreshSetting();
     AssetLoadSetting     = new AssetLoadSetting();
     HoneyWellSetting     = new HoneyWellSetting();
     DeviceSetting        = new DeviceSetting();
     HistoryPathSetting   = new HistoryPathSetting();
     LocationSetting      = new LocationSetting();
     DebugSetting         = new DebugSetting();
     AlarmSetting         = new AlarmSetting();
 }
コード例 #9
0
 public AlarmSetting Post([FromBody] AlarmSetting alarmSetting)
 {
     if (alarmSetting.AlarmSettingId == 0)
     {
         alarmSetting.InsertDB();
         alarmSetting.AlarmSettingId = alarmSetting.GetLastId();
         alarmSetting.UpdateUser(alarmSetting.UserId, alarmSetting.AlarmSettingId);
         return(alarmSetting);
     }
     else
     {
         alarmSetting.Update();
         return(alarmSetting);
     }
 }
コード例 #10
0
        public IActionResult Remove(Guid id)
        {
            using (var db = new AllInOneContext.AllInOneContext())
            {
                _logger.LogInformation("开始删除报警设置{0}", id);
                try
                {
                    AlarmSetting delObj = db.AlarmSetting.FirstOrDefault(s => s.AlarmSettingId.Equals(id));
                    if (delObj == null || delObj.AlarmSettingId.Equals(Guid.Empty))
                    {
                        return(NotFound());
                    }
                    List <Guid> removePlanIds     = new List <Guid>();
                    List <Guid> removeScheduleIds = new List <Guid>();
                    if (delObj.BeforePlanId != null)
                    {
                        removePlanIds.Add(delObj.BeforePlanId.Value);
                    }
                    if (delObj.EmergencyPlanId != null)
                    {
                        removePlanIds.Add(delObj.EmergencyPlanId.Value);
                    }
                    removeScheduleIds.Add(delObj.ScheduleId);
                    db.AlarmSetting.Remove(delObj);
                    RemoveAlarmSettingPlan(db, removePlanIds);
                    RemoveAlarmSettingSchedule(db, removeScheduleIds);

                    db.SaveChanges();
                    _logger.LogInformation("完成删除报警设置{0}", id);
                    return(NoContent());
                }
                catch (Exception ex)
                {
                    _logger.LogError("删除报警设置异常,Message:{0}\r\nStackTrace:{1}", ex.Message, ex.StackTrace);
                    return(BadRequest(ex));
                }
            }
        }
コード例 #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.alarm_options);

            willUpdateItem = new AlarmSetting();
            willUpdateItem.AlarmSettingId = GlobalSettings.alarmSettingId;

            Button btnSave = FindViewById <Button>(Resource.Id.btnSaveAlarmOptions);

            btnSave.Click += BtnSave_Click;

            txtDistance           = FindViewById <EditText>(Resource.Id.txtDistanceAlarmOptions);
            txtFirstPersonName    = FindViewById <EditText>(Resource.Id.txtFirsPersonNameAlarmOptions);
            txtFirstPersonNumber  = FindViewById <EditText>(Resource.Id.txtFirstPersonNumberAlarmOptions);
            txtSecondPersonName   = FindViewById <EditText>(Resource.Id.txtSecondPersonNameAlarmOptions);
            txtSecondPersonNumber = FindViewById <EditText>(Resource.Id.txtSecondPersonNumberAlarmOptions);
            chkAlarmWithCall      = FindViewById <CheckBox>(Resource.Id.chkAlarmWithCallAlarmOptions);
            chkAlarmWithSms       = FindViewById <CheckBox>(Resource.Id.chkAlarmWithSmsAlarmOptions);
            chkAlarmWithPolice    = FindViewById <CheckBox>(Resource.Id.chkAlarmWithPoliceAlarmOptions);
            chkIsActive           = FindViewById <CheckBox>(Resource.Id.chkIsActiveAlarmOptions);

            // Create your application here
        }
コード例 #12
0
        public IActionResult Update([FromBody] AlarmSetting alarmSetting)
        {
            if (alarmSetting == null)
            {
                return(BadRequest());
            }

            using (var db = new AllInOneContext.AllInOneContext())
            {
                try
                {
                    _logger.LogInformation("开始更新报警设置....");
                    db.AlarmSetting.Update(alarmSetting);
                    db.SaveChanges();
                    _logger.LogInformation("完成更新报警设置....");
                }
                catch (Exception ex)
                {
                    _logger.LogError("更新报警设置异常,Message:{0}\r\n{StackTrace{1}}", ex.Message, ex.StackTrace);
                    return(BadRequest(ex.Message));
                }
            }
            return(NoContent());
        }
コード例 #13
0
        private void btnGiris_Click(object sender, EventArgs e)
        {
            AccessToken.GetAuthorizationAccessToken(txtUsername.Text, txtPassword.Text);

            // User class'ı içerisindeki GetUser metoduna kullanıcının girmiş olduğunu kullanıcı adı ve şifre gönderilir.
            //GetUser metodu Web API ye giderek bu bilgilere sahip bir kullanıcı var mı diye sorgular
            User loggedOnUser = User.GetUser(txtUsername.Text, txtPassword.Text);

            //bu bilgilere ait bir kullanıcı var ise Sisteme giriş yapılır
            if (loggedOnUser != null)
            {
                //kullanıcının bilgileri GlobalSettings classındaki değişkenlerde tutulur.Böylelikle başka yerlerde de ihtiyacmımız olduğunda GlobalSettings.userId vs diyerek ulaşabiliriz bu bilgilere.
                GlobalSettings.userId         = loggedOnUser.UserId;
                GlobalSettings.username       = loggedOnUser.Username;
                GlobalSettings.panicSettingId = loggedOnUser.PanicSettingId;
                GlobalSettings.alarmSettingId = loggedOnUser.AlarmSettingId;
                GlobalSettings.email          = loggedOnUser.Email;

                if (loggedOnUser.AlarmSettingId != 0)
                {
                    AlarmSetting setting = AlarmSetting.GetAlarmSetting(loggedOnUser.AlarmSettingId);
                    GlobalSettings.distanceValue = setting.DistanceValue;
                }


                IsPlayServicesAvailable();
                //İkinci sayfaya geçilir(MenuActivity sayfasına)
                Intent intent = new Intent(this, typeof(MenuActivity));
                StartActivity(intent);
            }
            //Bu bilgilere ait kullanıcı yok ise hata mesajı gösterilir.
            else
            {
                Toast.MakeText(this, "Bilgiler Hatalı", ToastLength.Short).Show();
            }
        }
コード例 #14
0
 public AlarmSetting Get(int alarmSettingId)
 {
     return(AlarmSetting.GetObjects().FirstOrDefault(x => x.AlarmSettingId == alarmSettingId));
 }
コード例 #15
0
        private void button_AlarmSetting_Click(object sender, EventArgs e)
        {
            AlarmSetting alarmsetting = new AlarmSetting();

            alarmsetting.Show();
        }
コード例 #16
0
        /// <summary>
        /// 获取报警推送到哨位中心的状态
        /// </summary>
        /// <param name="db"></param>
        /// <param name="setting"></param>
        /// <param name="alarmStatus"></param>
        /// <returns></returns>
        private DeviceAlarmStatus GetDeviceAlarmStatus(AllInOneContext.AllInOneContext db, AlarmSetting setting, bool alarmStatus)
        {
            DeviceAlarmStatus status = null;
            var deviceType           = db.SystemOption.FirstOrDefault(t => t.SystemOptionId.Equals(setting.AlarmSource.DeviceTypeId));

            if (deviceType != null)
            {
                if (deviceType.ParentSystemOptionId.Equals(Guid.Parse("A0002016-E009-B019-E001-ABCD11000004")))
                {
                    var sentinel = db.Sentinel.Include(t => t.DeviceInfo).FirstOrDefault(t => t.DeviceInfoId.Equals(setting.AlarmSource.IPDeviceInfoId));
                    status = new DeviceAlarmStatus()
                    {
                        DeviceCode   = sentinel.DeviceInfo.IPDeviceCode,
                        SentinelCode = sentinel.DeviceInfo.IPDeviceCode,
                        //DeviceCode = Int32.Parse(sentinel.DeviceInfo.Organization.OrganizationCode),
                        //SentinelCode = Int32.Parse(sentinel.DeviceInfo.Organization.OrganizationCode),
                        AlarmType   = setting.AlarmTypeId,
                        AlarmStatus = alarmStatus
                    };
                }
                else if (deviceType.ParentSystemOptionId.Equals(Guid.Parse("A0002016-E009-B019-E001-ABCDEF000110")))
                {
                    //获取防区设备关联的哨位台
                    var defenceDevice = db.DefenseDevice.Include(t => t.Sentinel).ThenInclude(t => t.DeviceInfo).ThenInclude(t => t.Organization)
                                        .Include(t => t.DeviceInfo)
                                        .First(t => t.DeviceInfoId.Equals(setting.AlarmSource.IPDeviceInfoId));
                    status = new DeviceAlarmStatus()
                    {
                        DeviceCode = defenceDevice.DeviceInfo.IPDeviceCode,
                        // SentinelCode = defenceDevice.Sentinel.DeviceInfo.IPDeviceCode,
                        SentinelCode = Int32.Parse(defenceDevice.Sentinel.DeviceInfo.Organization.OrganizationCode),
                        AlarmType    = setting.AlarmTypeId,
                        AlarmStatus  = alarmStatus
                    };
                }
            }
            return(status);
        }
コード例 #17
0
        //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();
                        }
                    }
                }
            }
        }