Example #1
0
 //更新状态
 public void SaveState(decimal ctrlrId, ControllerState state)
 {
     try
     {
         Maticsoft.BLL.SMT_DOOR_INFO          doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
         List <Maticsoft.Model.SMT_DOOR_INFO> doors   = doorBll.GetModelList("CTRL_ID=" + ctrlrId);
         foreach (var item in doors)
         {
             if (item.CTRL_DOOR_INDEX == null)
             {
                 continue;
             }
             if (state == null)
             {
                 item.OPEN_STATE = 2;
             }
             else
             {
                 item.OPEN_STATE = state.relayState[((int)item.CTRL_DOOR_INDEX - 1)] ? 1 : 0;
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("保存状态失败:CTRLID=" + ctrlrId, ex);
     }
 }
Example #2
0
        private void Init()
        {
            this.dgvData.Rows.Clear();
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_CTRLR_TASK tsBll = new Maticsoft.BLL.SMT_CTRLR_TASK();
                    var models = tsBll.GetModelList("");
                    Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
                    foreach (var item in models)
                    {
                        if (item.DOOR_ID == "-1")
                        {
                            item.DOOR_NAMES = "所有门禁";
                        }
                        else
                        {
                            try
                            {
                                var doors = doorBll.GetModelList("ID in (" + item.DOOR_ID + ")");
                                foreach (var d in doors)
                                {
                                    item.DOOR_NAMES += d.DOOR_NAME + ";";
                                }
                            }
                            catch (Exception ex)
                            {
                                log.Error("出现异常:", ex);
                                item.DOOR_NAMES = item.DOOR_ID;
                            }
                        }
                        this.Invoke(new Action(() =>
                        {
                            AddData(item);
                        }));
                    }
                }
                catch (Exception ex)
                {
                    log.Error("加载列表异常:" + ex.Message);
                    WinInfoHelper.ShowInfoWindow(this, "加载列表异常:" + ex.Message);
                }
            });

            waiting.Show(this, 300);
        }
Example #3
0
 public static List <Maticsoft.Model.SMT_DOOR_INFO> GetDoors(string ctrlId)
 {
     Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
     return(doorBll.GetModelList("CTRL_ID=" + ctrlId));
 }
Example #4
0
        private void LoadDatas()
        {
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                List <decimal> ids = new List <decimal>();
                List <Maticsoft.Model.SMT_CONTROLLER_INFO> ctrlModels = null;
                try
                {
                    Maticsoft.BLL.SMT_CONTROLLER_INFO ctrlBll = new Maticsoft.BLL.SMT_CONTROLLER_INFO();
                    ctrlModels = ctrlBll.GetModelList("CTRLR_TYPE=" + (int)ControllerDoorType.Elevator);
                    this.Invoke(new Action(() =>
                    {
                        foreach (var item in ctrlModels)
                        {
                            ComboBoxItem cbi = new ComboBoxItem(item.NAME, item.NAME);
                            cbi.Tag          = item;
                            cbCtrler.Items.Add(cbi);
                            ids.Add(item.ID);
                        }
                        if (ctrlModels.Count > 0)
                        {
                            cbCtrler.SelectedIndex = 0;
                        }
                    }));
                }
                catch (System.Exception ex)
                {
                    log.Error("加载电梯控制器错误!", ex);
                    WinInfoHelper.ShowInfoWindow(this, "加载电梯控制器错误:" + ex.Message);
                }
                if (ids.Count == 0)
                {
                    return;
                }
                try
                {
                    Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
                    var doors = doorBll.GetModelList("CTRL_ID in (" + string.Join(",", ids.ToArray()) + ")");
                    this.Invoke(new Action(() =>
                    {
                        foreach (var item in doors)
                        {
                            var ctrl            = ctrlModels.Find(m => m.ID == item.CTRL_ID);
                            DataGridViewRow row = new DataGridViewRow();
                            row.CreateCells(dgvData,
                                            ctrl.ID,
                                            ctrl.NAME,
                                            (int)item.CTRL_DOOR_INDEX,
                                            item.DOOR_NAME,
                                            "删除"
                                            );
                            row.Tag = item;
                            dgvData.Rows.Add(row);
                        }
                    }));
                }
                catch (Exception ex)
                {
                    log.Error("加载电梯控制器门错误!", ex);
                    WinInfoHelper.ShowInfoWindow(this, "加载电梯控制器门错误:" + ex.Message);
                }
            });

            waiting.Show(this);
        }
Example #5
0
        private void biAdd_Click(object sender, EventArgs e)
        {
            if (cbCtrler.SelectedItem == null)
            {
                WinInfoHelper.ShowInfoWindow(this, "请选择电梯控制器!");
                return;
            }
            if (cbDoorIndex.SelectedItem == null)
            {
                WinInfoHelper.ShowInfoWindow(this, "请选择继电器序号!");
                return;
            }
            if (tbDoorName.Text.Trim() == "")
            {
                WinInfoHelper.ShowInfoWindow(this, "梯门名称不能为空!");
                return;
            }
            var info  = (Maticsoft.Model.SMT_CONTROLLER_INFO)((ComboBoxItem)cbCtrler.SelectedItem).Tag;
            int index = (int)cbDoorIndex.SelectedItem;

            Maticsoft.Model.SMT_DOOR_INFO door = new Maticsoft.Model.SMT_DOOR_INFO();
            door.CTRL_ID         = info.ID;
            door.CTRL_DOOR_INDEX = index;
            door.DOOR_NAME       = tbDoorName.Text.Trim();
            door.ID        = -1;
            door.IS_ENABLE = true;
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
                    var doors = doorBll.GetModelList("CTRL_ID=" + info.ID + " and CTRL_DOOR_INDEX=" + index);
                    if (doors.Count > 0)
                    {
                        doors[0].DOOR_NAME = door.DOOR_NAME;
                        doorBll.Update(doors[0]);
                        door.ID = doors[0].ID;
                    }
                    else
                    {
                        door.ID = doorBll.Add(door);
                    }
                    this.Invoke(new Action(() =>
                    {
                        DataGridViewRow row = null;
                        foreach (DataGridViewRow item in dgvData.Rows)
                        {
                            if ((decimal)item.Cells[0].Value == info.ID &&
                                (int)item.Cells[2].Value == index
                                )
                            {
                                row = item;

                                break;
                            }
                        }
                        if (row != null)
                        {
                            row.Cells[3].Value = door.DOOR_NAME;
                            row.Tag            = door;
                        }
                        else
                        {
                            row = new DataGridViewRow();
                            row.CreateCells(dgvData,
                                            info.ID,
                                            info.NAME,
                                            index,
                                            door.DOOR_NAME,
                                            "删除"
                                            );
                            row.Tag = door;
                            dgvData.Rows.Add(row);
                        }
                        if (cbDoorIndex.SelectedIndex < cbDoorIndex.Items.Count - 1)
                        {
                            cbDoorIndex.SelectedIndex += 1;
                        }
                    }));
                }
                catch (Exception ex)
                {
                    log.Error("添加梯控门失败:", ex);
                    WinInfoHelper.ShowInfoWindow(this, "添加梯控门失败:" + ex.Message);
                    return;
                }
            });

            waiting.Show(this);
        }
        private void DoSave(bool upload)
        {
            try
            {
                if (!CheckInput())
                {
                    return;
                }
                Maticsoft.Model.SMT_CONTROLLER_INFO ctrlInfo = new Maticsoft.Model.SMT_CONTROLLER_INFO();
                if (_ctrlr != null)
                {
                    ctrlInfo.MAC            = _ctrlr.MAC;
                    ctrlInfo.ID             = _ctrlr.ID;
                    ctrlInfo.MASK           = _ctrlr.MASK;
                    ctrlInfo.ORG_ID         = _ctrlr.ORG_ID;
                    ctrlInfo.ORDER_VALUE    = _ctrlr.ORDER_VALUE;
                    ctrlInfo.CTRLR_MODEL    = _ctrlr.CTRLR_MODEL;
                    ctrlInfo.DRIVER_DATE    = _ctrlr.DRIVER_DATE;
                    ctrlInfo.DRIVER_VERSION = _ctrlr.DRIVER_VERSION;
                    ctrlInfo.GATEWAY        = _ctrlr.GATEWAY;
                }
                else
                {
                    ctrlInfo.ID = -1;
                }
                ctrlInfo.SN_NO     = tbCtrlrSn.Text.Trim();
                ctrlInfo.IS_ENABLE = cbCtrlrEnable.Checked;
                string name = tbCtrlName.Text.Trim();
                if (name == "")
                {
                    name = ctrlInfo.SN_NO;
                }
                ctrlInfo.NAME       = name;
                ctrlInfo.IP         = ipCtrlr.Value;
                ctrlInfo.PORT       = iiPort.Value;
                ctrlInfo.CTRLR_DESC = tbDesc.Text.Trim();
                ctrlInfo.CTRLR_TYPE = (int)_lastType;
                ctrlInfo.AREA_ID    = -1;
                if (cboTreeArea.SelectedNode != null && cboTreeArea.SelectedNode.Tag is Maticsoft.Model.SMT_CONTROLLER_ZONE)
                {
                    var area = cboTreeArea.SelectedNode.Tag as Maticsoft.Model.SMT_CONTROLLER_ZONE;
                    ctrlInfo.AREA_ID   = area.ID;
                    ctrlInfo.AREA_NAME = area.ZONE_NAME;
                }

                List <DoorNameAttriData>             doorNameDatas   = doorNameAttriGroup.GetDatas();
                List <DoorReaderAttriData>           doorReaderDatas = doorReaderAttriGroup.GetDatas();
                List <Maticsoft.Model.SMT_DOOR_INFO> doors           = new List <Maticsoft.Model.SMT_DOOR_INFO>();
                foreach (var item in doorNameDatas)
                {
                    Maticsoft.Model.SMT_DOOR_INFO door = new Maticsoft.Model.SMT_DOOR_INFO();
                    door.CTRL_ID          = ctrlInfo.ID;
                    door.CTRL_DELAY_TIME  = item.doorSecond;
                    door.CTRL_DOOR_INDEX  = item.doorNo;
                    door.CTRL_STYLE       = item.doorCtrlType;
                    door.IS_ALLOW_VISITOR = item.visitor;
                    if (_ctrlr != null)
                    {
                        var old = _ctrlr.DOOR_INFOS.Find(m => m.CTRL_DOOR_INDEX == item.doorNo);
                        if (old != null)
                        {
                            door.ID        = old.ID;
                            door.DOOR_DESC = old.DOOR_DESC;
                        }
                    }
                    else
                    {
                        door.ID        = -1;
                        door.DOOR_DESC = "";
                    }
                    door.DOOR_NAME = item.doorName;
                    DoorReaderAttriData reader1 = doorReaderDatas.Find(m => m.doorNo == item.doorNo && m.isEnter1);
                    DoorReaderAttriData reader2 = doorReaderDatas.Find(m => m.doorNo == item.doorNo && !m.isEnter1);
                    door.IS_ATTENDANCE1 = reader1 == null ? false : reader1.isAttend;
                    door.IS_ATTENDANCE2 = reader2 == null ? false : reader2.isAttend;
                    door.IS_ENABLE      = item.doorEnable;
                    door.IS_ENTER1      = reader1 == null ? false : reader1.isEnter;
                    door.IS_ENTER2      = reader2 == null ? false : reader2.isEnter;
                    doors.Add(door);
                }
                CtrlWaiting ctrlWaiting = new CtrlWaiting(() =>
                {
                    try
                    {
                        Maticsoft.BLL.SMT_CONTROLLER_INFO ctrlBll = new Maticsoft.BLL.SMT_CONTROLLER_INFO();
                        var exists = ctrlBll.GetModelList("SN_NO='" + ctrlInfo.SN_NO + "'");

                        if (ctrlInfo.ID != -1)
                        {
                            if (exists.Count > 0)
                            {
                                if (exists[0].ID != ctrlInfo.ID)
                                {
                                    WinInfoHelper.ShowInfoWindow(this, "已存在控制器序列号:" + ctrlInfo.SN_NO);
                                    return;
                                }
                            }
                            ctrlBll.Update(ctrlInfo);
                            ctrlInfo.DOOR_INFOS = _ctrlr.DOOR_INFOS;
                            _ctrlr = ctrlInfo;
                        }
                        else
                        {
                            if (exists.Count > 0)
                            {
                                WinInfoHelper.ShowInfoWindow(this, "已存在控制器序列号:" + ctrlInfo.SN_NO);
                                return;
                            }
                            ctrlInfo.ID = ctrlBll.Add(ctrlInfo);
                            _ctrlr      = ctrlInfo;
                        }

                        if (_lastType != ControllerDoorType.Elevator)//非电梯控制器
                        {
                            Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();

                            foreach (var item in doors)
                            {
                                var edoors = doorBll.GetModelList("CTRL_ID=" + ctrlInfo.ID + " and " + " CTRL_DOOR_INDEX=" + item.CTRL_DOOR_INDEX);
                                if (edoors.Count > 0)
                                {
                                    item.ID = edoors[0].ID;
                                    doorBll.Update(item);
                                }
                                else
                                {
                                    item.CTRL_ID = ctrlInfo.ID;
                                    item.ID      = doorBll.Add(item);
                                }
                            }
                            _ctrlr.DOOR_INFOS = doors;

                            if (upload)
                            {
                                string errMsg = null;
                                if (UploadPrivate.UploadByCtrlr(_ctrlr, out errMsg, doors, true))
                                {
                                    if (errMsg != "")
                                    {
                                        WinInfoHelper.ShowInfoWindow(this, "设置控制器" + (_ctrlr.IS_ENABLE ? "启用" : "禁用") + "异常:" + errMsg);
                                        return;
                                    }
                                }
                                else
                                {
                                    WinInfoHelper.ShowInfoWindow(this, "设置控制器" + (_ctrlr.IS_ENABLE ? "启用" : "禁用") + "异常:" + errMsg);
                                    return;
                                }
                                Controller c = ControllerHelper.ToController(_ctrlr);
                                //设置门控制方式
                                foreach (var item in doors)
                                {
                                    using (IAccessCore access = new WGAccess())
                                    {
                                        bool ret = access.SetDoorControlStyle(c, (int)item.CTRL_DOOR_INDEX, (DoorControlStyle)item.CTRL_STYLE, item.CTRL_DELAY_TIME);
                                        if (!ret)
                                        {
                                            WinInfoHelper.ShowInfoWindow(this, "上传门控制方式失败!");
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                        this.Invoke(new Action(() =>
                        {
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }));
                    }
                    catch (Exception ex)
                    {
                        log.Error("保存异常:" + ex.Message, ex);
                        WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message);
                    }
                });
                ctrlWaiting.Show(this);
            }
            catch (Exception ex)
            {
                WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message);
                log.Error("保存异常:" + ex.Message, ex);
            }
        }
Example #7
0
        //保存记录
        public void SaveRecord(decimal ctrlrId, ControllerState record)
        {
            try
            {
                Maticsoft.Model.SMT_CARD_RECORDS modelRecord = new Maticsoft.Model.SMT_CARD_RECORDS();
                modelRecord.CARD_NO          = record.cardOrNoNumber;
                modelRecord.CTRLR_DOOR_INDEX = record.doorNum;

                modelRecord.CTRLR_ID = ctrlrId;
                modelRecord.CTRLR_SN = record.sn;

                Maticsoft.BLL.SMT_DOOR_INFO bll = new Maticsoft.BLL.SMT_DOOR_INFO();

                List <Maticsoft.Model.SMT_DOOR_INFO> doors = bll.GetModelList("CTRL_ID=" + ctrlrId + " and CTRL_DOOR_INDEX=" + record.doorNum);
                if (doors.Count > 0)
                {
                    modelRecord.DOOR_ID = doors[0].ID;
                }
                else
                {
                    modelRecord.DOOR_ID = -1;
                }
                modelRecord.IS_ALLOW      = record.isAllowValid;
                modelRecord.IS_ENTER      = record.isEnterDoor;
                modelRecord.RECORD_DATE   = record.recordTime;
                modelRecord.RECORD_DESC   = AccessHelper.GetRecordReasonString(record.reasonNo);
                modelRecord.RECORD_INDEX  = record.lastRecordIndex;
                modelRecord.RECORD_REASON = record.reasonNo.ToString();
                modelRecord.RECORD_TYPE   = record.recordType.ToString();

                Maticsoft.BLL.SMT_STAFF_CARD cardBll = new Maticsoft.BLL.SMT_STAFF_CARD();

                List <Maticsoft.Model.SMT_STAFF_CARD> staffCards = cardBll.GetModelListByWGCardNo(record.cardOrNoNumber);
                if (staffCards.Count > 0)
                {
                    modelRecord.STAFF_ID = staffCards[0].STAFF_ID;
                }
                else
                {
                    modelRecord.STAFF_ID = -1;
                }
                Maticsoft.BLL.SMT_CARD_RECORDS recordBll = new Maticsoft.BLL.SMT_CARD_RECORDS();
                modelRecord.ID = recordBll.Add(modelRecord);
                switch (record.reasonNo)
                {
                case RecordReasonNo.Swipe:
                    break;

                case RecordReasonNo.Reserved2:
                    break;

                case RecordReasonNo.Reserved3:
                    break;

                case RecordReasonNo.Reserved4:
                    break;

                case RecordReasonNo.DeniedAccessPCControl:
                case RecordReasonNo.DeniedAccessNoPRIVILEGE:
                case RecordReasonNo.DeniedAccessWrongPASSWORD:
                case RecordReasonNo.DeniedAccessAntiBack:
                case RecordReasonNo.DeniedAccessMoreCards:
                case RecordReasonNo.DeniedAccessFirstCardOpen:
                case RecordReasonNo.DeniedAccessDoorSetNC:
                case RecordReasonNo.DeniedAccessInterLock:
                case RecordReasonNo.DeniedAccessLimitedTimes:
                case RecordReasonNo.DeniedAccessInvalidTimezone:
                case RecordReasonNo.DeniedAccess:
                case RecordReasonNo.PushButtonInvalidForcedLock:
                case RecordReasonNo.PushButtonInvalidNotOnLine:
                case RecordReasonNo.PushButtonInvalidInterLock:
                case RecordReasonNo.Threat:
                case RecordReasonNo.OpenTooLong:
                case RecordReasonNo.ForcedOpen:
                case RecordReasonNo.Fire:
                case RecordReasonNo.ForcedClose:
                case RecordReasonNo.GuardAgainstTheft:
                case RecordReasonNo.H7X24HourZone:
                case RecordReasonNo.EmergencyCall:
                {
                    Maticsoft.Model.SMT_ALARM_INFO alarmInfo = new Maticsoft.Model.SMT_ALARM_INFO();
                    try
                    {
                        alarmInfo.ALARM_NAME       = AccessHelper.GetRecordReasonString(record.reasonNo);
                        alarmInfo.ALARM_CONTENT    = alarmInfo.ALARM_NAME;
                        alarmInfo.ALARM_TIME       = record.recordTime;
                        alarmInfo.ALARM_TYPE       = (int)record.reasonNo;
                        alarmInfo.CARD_NO          = record.cardOrNoNumber;
                        alarmInfo.CTRLR_DOOR_INDEX = record.doorNum;
                        alarmInfo.CTRLR_ID         = ctrlrId;
                        alarmInfo.DOOR_ID          = modelRecord.DOOR_ID;
                        alarmInfo.RECORD_ID        = modelRecord.ID;
                        alarmInfo.STAFF_ID         = modelRecord.STAFF_ID;
                        Maticsoft.BLL.SMT_ALARM_INFO alarmBll = new Maticsoft.BLL.SMT_ALARM_INFO();
                        alarmInfo.ID = alarmBll.Add(alarmInfo);
                        try
                        {
                            _alarmServer.SendMessageAsync <decimal>(alarmInfo.ID, MessageType.ALARM);
                        }
                        catch (Exception ex)
                        {
                            log.Error("转发报警消息失败:Alarm Id=" + alarmInfo.ID + ",EX=" + ex.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("报警记录保存失败:CTRLID=" + ctrlrId + ", RECORD ID=" + modelRecord.ID + ",ALARM_NAME=" + alarmInfo.ALARM_NAME, ex);
                    }
                }
                break;

                case RecordReasonNo.Reserved14:
                    break;

                case RecordReasonNo.Reserved16:
                    break;

                case RecordReasonNo.Reserved17:
                    break;

                case RecordReasonNo.Reserved19:
                    break;

                case RecordReasonNo.PushButton:
                    break;

                case RecordReasonNo.Reserved21:
                    break;

                case RecordReasonNo.Reserved22:
                    break;

                case RecordReasonNo.DoorOpen:
                    break;

                case RecordReasonNo.DoorClosed:
                    break;

                case RecordReasonNo.SuperPasswordOpenDoor:
                    break;

                case RecordReasonNo.Reserved26:
                    break;

                case RecordReasonNo.Reserved27:
                    break;

                case RecordReasonNo.ControllerPowerOn:
                    break;

                case RecordReasonNo.ControllerReset:
                    break;

                case RecordReasonNo.Reserved30:
                    break;

                case RecordReasonNo.Reserved35:
                    break;

                case RecordReasonNo.Reserved36:
                    break;

                case RecordReasonNo.RemoteOpenDoor:
                    break;

                case RecordReasonNo.RemoteOpenDoorByUSBReader:
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                log.Error("记录保存失败:CTRLID=" + ctrlrId, ex);
                throw ex;
            }
        }