public string ParseJson(string json, int mode)
        {
            try
            {
                FileInfo fi = GetNowJsonFile();
                File.WriteAllText(fi.FullName, json);

                var info = CameraAlarmInfo.Parse(json);
                CameraAlarmHub.SendInfo(info);//发送告警给客户端

                Bll bll = Bll.NewBllNoRelation();

                string base64 = info.pic_data;
                info.pic_data = "";                                   //图片分开存

                string jsonNoPic = JsonConvert.SerializeObject(info); //新的没有图片的json
                Log.Info(LogTags.ExtremeVision, jsonNoPic);
                string alarmType = "";
                if (info.AlarmType == 1)
                {
                    alarmType = "安全帽告警";
                }
                else if (info.AlarmType == 2)
                {
                    alarmType = "火焰告警";
                }
                else if (info.AlarmType == 3)
                {
                    alarmType = "烟雾告警";
                }
                else
                {
                    alarmType = "其他告警:" + info.AlarmType;
                }

                Log.Info(LogTags.ExtremeVision, "告警类型:" + alarmType);

                bool result = SaveToCameraAlarmJson(jsonNoPic);

                var picName = info.pic_name;

                SavePicture(bll, mode, base64, picName);
                return(info.ToString());
            }
            catch (Exception ex)
            {
                Log.Error(LogTags.ExtremeVision, "Error:" + ex);
                return("Error:" + ex.Message);
            }
        }
Example #2
0
        private void MenuSendAlarm_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("该告警将发送给所有客户端,是否继续?", "告警测试", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (result == MessageBoxResult.OK)
            {
                foreach (var item in DataGrid1.SelectedItems)
                {
                    CameraAlarmInfo info = item as CameraAlarmInfo;
                    if (info == null)
                    {
                        continue;
                    }
                    CameraAlarmHub.SendInfo(info);
                }
            }
        }
Example #3
0
        public string Callback(CameraAlarmInfo info)
        {
            try
            {
                string json = JsonConvert.SerializeObject(info);

                Log.Info(LogTags.ExtremeVision, string.Format("ExtremeVisionController.Callback({0})", Request.GetClientIpAddress()));
                Log.Info(LogTags.ExtremeVision, json);
                FileInfo fi = CameraAlarmService.GetNowJsonFile();
                File.WriteAllText(fi.FullName, json);

                CameraAlarmHub.SendInfo(info);
                return(info + "");
            }
            catch (Exception ex)
            {
                Log.Error(LogTags.ExtremeVision, "ExtremeVisionController.Callback:" + ex.Message);
                return("error:" + ex);
            }
        }