//private void DBTableWatcher_VehicleChange(object sender, EventArgs e)
        //{
        //    ObjCacheManager.updateVehicle();
        //}

        private void ProcCurrentAlarm(object sender, StanMsgHandlerArgs handler)
        {
            //List<sc.ALARM> alarms = getCurrentAlarmFromRedis();
            List <sc.ALARM> alarms = AlarmBLL.loadSetAlarm();

            ObjCacheManager.updateAlarm(alarms);
            CurrentAlarmChange?.Invoke(this, alarms);
        }
Example #2
0
        private void LoadData()
        {
            var recordCount = 0;
            var stTime      = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
            var endTime     = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
            var data        = AlarmBLL.GetList("", -1, stTime, endTime, 1, 20, out recordCount);

            ViewBag.Grid1RecordCount = recordCount;
            ViewBag.Grid1DataSource  = data;
        }
        public AlarmObjToShow(ALARM _alarm, AlarmBLL _alarmBLL)
        {
            alarm    = _alarm;
            alarmBLL = _alarmBLL;
            AlarmMap alarmMap = alarmBLL.cache.getSuggestion("VH_LINE", ALAM_CODE);

            if (alarmMap != null)
            {
                SUGGESTION      = alarmMap.SUGGESTION;
                POSSIBLE_CAUSES = alarmMap.POSSIBLE_CAUSES;
            }
        }
Example #4
0
        public ActionResult btnSearch_Click(JArray AlarmInfoGrid_fields, string objectName, int alarmType, DateTime startTime, DateTime endTime, int AlarmInfoGrid_pageIndex, int AlarmInfoGrid_pageSize)
        {
            var grid1       = UIHelper.Grid("AlarmInfoGrid");
            var recordCount = 0;
            var stTime      = DateTime.Parse(startTime.ToString("yyyy-MM-dd") + " 00:00:00");
            var edTime      = DateTime.Parse(endTime.ToString("yyyy-MM-dd") + " 23:59:59");
            var data        = AlarmBLL.GetList(objectName, alarmType, stTime, edTime, AlarmInfoGrid_pageIndex + 1, AlarmInfoGrid_pageSize, out recordCount);

            grid1.RecordCount(recordCount);
            grid1.DataSource(data, AlarmInfoGrid_fields);

            return(UIHelper.Result());
        }
Example #5
0
 /// <summary>
 /// 保存报警记录
 /// </summary>
 /// <param name="equipment"></param>
 /// <param name="terminal"></param>
 /// <param name="posId"></param>
 /// <param name="alarm"></param>
 private void SaveAlarm(TB_Equipment equipment, string terminal_id, long posId, string alarm)
 {
     using (var bll = new AlarmBLL())
     {
         var obj = bll.GetObject();
         obj.Code       = alarm;
         obj.Equipment  = null == equipment ? (int?)null : equipment.id;
         obj.Position   = (0 >= posId ? (long?)null : posId);
         obj.StoreTimes = null == equipment ? 0 : equipment.StoreTimes;
         obj.Terminal   = terminal_id;
         bll.Add(obj);
     }
 }
        private int PageChange(int pageIndex, int pageSize)
        {
            _firstIndex = (pageIndex - 1) * pageSize + 1;
            int totalCount;

            var result = new AlarmBLL().GetAllAlarm(out totalCount, "", pageIndex, pageSize, _currentOrderBy, _ascding, null, null);

            if (result.Code > 0)
            {
                DlgHelper.ShowAlertMsgBox(result.Msg);
            }

            dgvAlarmList.DataSource = result.Data;

            return(totalCount);
        }
Example #7
0
        /// <summary>
        /// 新增报警信息
        /// </summary>
        /// <returns></returns>
        public ActionResult AddAlarmInfo(string info, string alarmAddress, string alarmObjectName, string alarmType, string alarmTime, string objectName)
        {
            INFO_ALARMINFO alarmInfo = new INFO_ALARMINFO();

            alarmInfo.ALARMINFO       = info;
            alarmInfo.ALARMADDRESS    = alarmAddress;
            alarmInfo.ALARMOBJECTNAME = alarmObjectName;
            alarmInfo.ALARMTYPE       = Convert.ToInt32(alarmType);
            alarmInfo.ALARMTIME       = DateTime.Parse(alarmTime);
            var isSuccess = AlarmBLL.Add(alarmInfo);

            MapBLL.UpdateGpsInfo(objectName);
            return(new JsonResult
            {
                Data = isSuccess
            });
        }
Example #8
0
        public AlarmForm(string alarmContent, AlarmType alarmType)
        {
            InitializeComponent();

            richTextBoxAlarmContent.Text = alarmContent;
            var alarm = new WebAlarm()
            {
                AlarmContent = alarmContent,
                AlarmTypeInt = (int)alarmType,
                Operator     = MainForm.CurrentUserName,
            };
            var result = new AlarmBLL().AddAlarm(alarm);

            if (result.Code > 0)
            {
                DlgHelper.ShowAlertMsgBox(result.Msg);
            }
        }
Example #9
0
        public void TestAlarmBLL()
        {
            AlarmBLL bll = new AlarmBLL(new AlarmDAL());

            Alarm alarm = new Alarm(2, "testAddress", "dectription33333");

            bll.Add(alarm);

            bll.Delete(alarm);

            bll.Modify(new Alarm(4), new Alarm(2, "modify address", ""));

            int   a      = 2;
            Alarm alarm2 = (Alarm)bll.GetObjById(a.ToString());

            List <object> objs1 = bll.GetAllObjs();

            List <object> objs2 = bll.GetObjsBySQL("select * from alarm", null);

            int b = bll.ExcuteSqlStr("select * from alarm where id = 1");
        }
Example #10
0
 internal ZpAlarm(int ledger, SysPro pro)
 {
     this.bll = new AlarmBLL(ledger, Config.Uid);
     this.pro = pro;
 }
        public WindownApplication()
        {
            ViewerID         = getString("Viewer_ID", "");
            webClientManager = WebClientManager.getInstance();

            ObjCacheManager = new ObjCacheManager(this);

            elasticSearchManager = new ElasticSearchManager();

            RailDao             = new RAILDao();
            AddressDao          = new ADDRESSDao();
            PortIconDao         = new PortIconDao();
            PointDao            = new POINTDao();
            GroupRailDao        = new GROUPRAILSDao();
            SegmentDao          = new SegmentDao();
            SectionDao          = new SectionDao();
            PortDao             = new PortDao();
            VehicleDao          = new VehicleDao();
            UserDao             = new UserDao();
            UserGroupDao        = new UserGroupDao();
            UserFuncDao         = new UserFuncDao();
            FunctionCodeDao     = new FunctionCodeDao();
            CMD_OHTCDao         = new CMD_OHTCDao();
            CMD_MCSDao          = new CMD_MCSDao();
            VCMD_MCSDao         = new VCMD_MCSDao();
            PortStationDao      = new PortStationDao();
            AlarmDao            = new AlarmDao();
            MapBLL              = new MapBLL(this);
            UserBLL             = new UserBLL(this);
            OperationHistoryBLL = new OperationHistoryBLL(this);
            CmdBLL              = new CmdBLL(this);
            AlarmBLL            = new AlarmBLL(this);
            PortStationBLL      = new PortStationBLL(this);
            SegmentBLL          = new SegmentBLL(this);
            ObjCacheManager.start();
            ID = ObjCacheManager.MapId;

            LineBLL             = new LineBLL(this);
            VehicleBLL          = new VehicleBLL(this);
            SysExcuteQualityBLL = new SysExcuteQualityBLL(this);

            dBTableWatcher = new EventAction.DBTableWatcher(this);
            dBTableWatcher.initStart();
            // setEFConnectionString(ObjCacheManager.EFConnectionString);



            SysExcuteQualityQueryService = new SysExcuteQualityQueryService(this);
            //initBackgroundWork();
            //  SysExcuteQualityQueryService = new SysExcuteQualityQueryService();
            switch (WindownApplication.OHxCFormMode)
            {
            case OHxCFormMode.CurrentPlayer:
                natsManager       = new NatsManager(ID, "nats-cluster", ViewerID);
                redisCacheManager = new RedisCacheManager(ID);
                SubscriberNatsEvent();
                SubscriberDBTableWatcherEvent();
                //SysExcuteQualityQueryService.start();
                break;

            case OHxCFormMode.HistoricalPlayer:
                HistoricalReplyService = new HistoricalReplyService(this);
                //HistoricalReplyService.loadVhHistoricalInfo();
                break;
            }
            //VehicleBLL.ReguestViewerUpdate();
        }
        /// <summary>
        /// 处理新版的卫星通讯协议
        /// </summary>
        /// <param name="data"></param>
        private void HandleIridiumNewProtocolPackage(IridiumData data)
        {
            if (data.Payload[0] == 0x01)
            {
                // 新版的卫星通讯协议
                uint   thisWorkTime = BitConverter.ToUInt32(data.Payload, 13);
                string locks        = CustomConvert.GetHex(data.Payload[1]);
                string alarms       = CustomConvert.IntToDigit(data.Payload[2], CustomConvert.BIN, 8) +
                                      CustomConvert.IntToDigit(data.Payload[3], CustomConvert.BIN, 8);
                IridiumLocation location = new IridiumLocation();
                location.LatLng = new byte[IridiumLocation.SIZE];
                Buffer.BlockCopy(data.Payload, 4, location.LatLng, 0, IridiumLocation.SIZE);
                location.Unpackate();

                // 通过卫星的IMEI号码查找终端
                using (var tbll = new TerminalBLL())
                {
                    using (var ebll = new EquipmentBLL())
                    {
                        var          terminal  = tbll.Find(f => f.TB_Satellite.CardNo.Equals(data.IMEI));
                        TB_Equipment equipment = null;
                        if (null != terminal)
                        {
                            // 只有第一版的终端才需要计算补偿时间
                            var compensated = terminal.Version == 1;

                            tbll.Update(f => f.id == terminal.id, act =>
                            {
                                act.OnlineStyle = (byte)LinkType.SATELLITE;
                                // 同时更新终端的最后链接时间
                                act.OnlineTime = data.Time;
                            });
                            equipment = ebll.Find(f => f.Terminal == terminal.id);
                            if (null != equipment)
                            {
                                // 旧的运转时间
                                var oldRuntime = equipment.Runtime;
                                var interval   = 0 == oldRuntime ? 0 : (thisWorkTime - oldRuntime);
                                // 粗略增加的小时数,启动时加2小时
                                var    addMin         = interval > 60 ? interval / 60 : 1 + (location.EngFlag.Equals("On") ? 1 : 0);
                                int    addHour        = (int)(interval > 60 ? interval / 60 : 1);// 显示历史记录
                                string oldCompensated = format("WorkHours {0}, UsedHours {1}, Efficiency {2}, AddHours {3}, Compensated {4}", equipment.WorkHours, equipment.UsedHours, equipment.HourWorkEfficiency, equipment.AddedHours, equipment.CompensatedHours);
                                string newCompensated = "";
                                // 更新设备的总运转时间
                                HandleEquipmentRuntime(equipment, thisWorkTime);
                                if (null != equipment)
                                {
                                    string calculated = "";
                                    ebll.Update(f => f.id == equipment.id, act =>
                                    {
                                        act.OnlineStyle = (byte)LinkType.SATELLITE;
                                        act.OnlineTime  = data.Time;
                                        // 更新设备的报警状态 2015/09/10 14:04
                                        act.Alarm = alarms;

                                        act.LastAction     = "0x1000";
                                        act.LastActionBy   = "SAT";
                                        act.LastActionTime = data.Time;
                                        // 更新定位信息 2015/09/09 23:29
                                        if (location.Available)
                                        {
                                            act.Latitude  = location.Latitude;
                                            act.Longitude = location.Longitude;
                                        }
                                        // 更新启动与否状态 2015/08/31
                                        act.Voltage = location.EngFlag.Equals("On") ? "G2400" : "G0000";

                                        // 更新总运转时间
                                        act.Runtime             = equipment.Runtime;
                                        act.AccumulativeRuntime = equipment.AccumulativeRuntime;
                                        // 更新 version 终端为1的版本的运转时间的补偿
                                        if (compensated && interval > 0)
                                        {
                                            // 实际工作小时数
                                            act.WorkHours += interval / 60.0;
                                            // 实际所用小时数
                                            act.UsedHours += addHour;
                                            // 重新计算每小时工作效率
                                            act.HourWorkEfficiency = act.WorkHours / act.UsedHours;
                                            // 补偿的小时数
                                            act.AddedHours += addMin / 60.0;
                                            // 实际补偿的小时数
                                            act.CompensatedHours = act.AddedHours * act.HourWorkEfficiency;
                                        }
                                        // 如果回来的运转时间比当前时间大则更新成为On状态  暂时  2015/09/02
                                        //if (worktime > act.Runtime)
                                        //{
                                        //    // act.Voltage = "G2400";
                                        //    act.Runtime = (int)worktime;
                                        //}
                                        //else
                                        //{
                                        //    if (worktime > 0)
                                        //    {
                                        //        // 运转时间不为零的话,更新运转时间
                                        //        act.Runtime = (int)worktime;
                                        //    }
                                        //}
                                        // 锁车状态 2015/08/14
                                        if (act.LockStatus != locks)
                                        {
                                            act.LockStatus = locks;
                                        }
                                        // 判断锁车的有效状态
                                        if (locks.Equals("40") || locks.Equals("0F") || locks.Equals("FF"))
                                        {
                                            // 锁车时还有开机状态
                                            if (location.EngFlag.Equals("On"))
                                            {
                                                // 锁车了,但未关机,还在工作中
                                                if (act.LockEffected == (byte)LockEffect.Locked)
                                                {
                                                    act.LockEffected = (byte)LockEffect.LockedAndStillWork;
                                                }
                                                else if (act.LockEffected == (byte)LockEffect.LockedAndEngineOff)
                                                {
                                                    // 锁车了且已关机了,此时再开机则需要报警(没锁住车)
                                                    act.LockEffected = (byte)LockEffect.LockedAndNoEffect;
                                                }
                                            }
                                            else
                                            {
                                                // 锁车了,且已关机了
                                                if (act.LockEffected == (byte)LockEffect.Locked)
                                                {
                                                    act.LockEffected = (byte)LockEffect.LockedAndEngineOff;
                                                }
                                            }
                                        }
                                    });
                                    if (compensated && interval > 0)
                                    {
                                        equipment      = ebll.Find(f => f.id == equipment.id);
                                        newCompensated = format("WorkHours {0}, UsedHours {1}, Efficiency {2}, AddHours {3}, Compensated {4}", equipment.WorkHours, equipment.UsedHours, equipment.HourWorkEfficiency, equipment.AddedHours, equipment.CompensatedHours);

                                        calculated = format("Compensate changed(interval: {0}){1} from {2}{3} to {4}", interval, Environment.NewLine, oldCompensated, Environment.NewLine, newCompensated);
                                    }
                                    if (!string.IsNullOrEmpty(calculated))
                                    {
                                        OnUnhandledMessage(this, new Sockets.UIEventArgs()
                                        {
                                            Message = format("{0}{1}{2}", Now, calculated, Environment.NewLine)
                                        });
                                    }
                                }
                            }
                            else
                            {
                                OnUnhandledMessage(this, new Sockets.UIEventArgs()
                                {
                                    Message = format("{0} Iridium has not bind with any equipment.", Now, Environment.NewLine)
                                });
                            }
                        }
                        else
                        {
                            OnUnhandledMessage(this, new Sockets.UIEventArgs()
                            {
                                Message = format("{0} Satellite has no terminal, data will save as terminal number: \"{1}\".{2}",
                                                 Now, data.IMEI.Substring(4), Environment.NewLine)
                            });
                        }
                        // 保存TX300历史记录
                        SaveTX300History(new TX300()
                        {
                            CommandID    = 0x1000,
                            MsgContent   = data.Payload,
                            ProtocolType = ProtocolTypes.SATELLITE,
                            // 默认装载机终端类型 2015/09/22 09:40
                            TerminalType = null == terminal ? TerminalTypes.LD : terminal.Type.Value,
                            // 没有终端时,用IMEI号码的末尾11位数字表示终端号码 2015/09/22 09:40
                            TerminalID  = null == terminal ? data.IMEI.Substring(4) : terminal.Sim,
                            TotalLength = (ushort)data.Payload.Length
                        }, data.Time, ebll.GetFullNumber(equipment));

                        try
                        {
                            long?posId = null;
                            if (location.Available)
                            {
                                using (var posbll = new PositionBLL())
                                {
                                    var pos = posbll.GetObject();
                                    pos.Latitude   = location.Latitude;
                                    pos.Longitude  = location.Longitude;
                                    pos.NS         = location.NSI;
                                    pos.EW         = location.EWI;
                                    pos.StoreTimes = null == equipment ? 0 : equipment.StoreTimes;
                                    pos.GpsTime    = data.Time;
                                    pos.Equipment  = null == equipment ? (int?)null : equipment.id;
                                    // 没有终端时,用IMEI号码的末尾11位数字表示终端号码 2015/09/22 09:40
                                    pos.Terminal = null == terminal?data.IMEI.Substring(4) : (terminal.Sim.Length < 11 ? (terminal.Sim + "000") : terminal.Sim);

                                    pos.Type = location.Report + "(Eng " + location.EngFlag + ")(SAT)";
                                    posbll.Add(pos);
                                    posId = pos.id;
                                }
                            }

                            // 处理报警信息
                            if (alarms != ALARM)
                            {
                                using (var armbll = new AlarmBLL())
                                {
                                    var arm = armbll.GetObject();
                                    arm.Code       = alarms;
                                    arm.AlarmTime  = data.Time;
                                    arm.Equipment  = null == equipment ? (int?)null : equipment.id;
                                    arm.Position   = posId;
                                    arm.StoreTimes = null == equipment ? 0 : equipment.StoreTimes;
                                    // 没有终端时,用IMEI号码的末尾11位数字表示终端号码 2015/09/22 09:40
                                    arm.Terminal = null == terminal?data.IMEI.Substring(4) : (terminal.Sim.Length < 11 ? (terminal.Sim + "000") : terminal.Sim);

                                    armbll.Add(arm);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            OnUnhandledMessage(this, new Sockets.UIEventArgs()
                            {
                                Message = format("{0}{1}{2}{3}", Now, e.Message, Environment.NewLine, e.StackTrace)
                            });
                        }
                        // 更新卫星方式的命令状态(只处理命令回复的1000,其他的命令在普通命令过程中处理)
                        if (location.ReportType == 1 && data.Payload.Length <= 17)
                        {
                            HandleIridiumCommandResponseed(data);
                        }
                        location.Dispose();
                        location = null;
                    }
                }
            }
        }