//更新状态
 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);
     }
 }
Beispiel #2
0
        public static Maticsoft.Model.SMT_CONTROLLER_INFO AddController(Controller ctrlr)
        {
            Maticsoft.Model.SMT_CONTROLLER_INFO info = UpdateDBControllerIp(ctrlr);//如果存在则更新
            if (info != null)
            {
                info.DOOR_INFOS = DoorDataHelper.GetDoors();
                return(info);
            }
            info = ToInfo(ctrlr);
            Maticsoft.BLL.SMT_CONTROLLER_INFO bll = new Maticsoft.BLL.SMT_CONTROLLER_INFO();
            decimal ctrlId = bll.Add(info);

            info.ID = ctrlId;
            int count = 1;
            int dir   = 1;

            switch (ctrlr.doorType)
            {
            case ControllerDoorType.OneDoorTwoDirections:
                count = 1;
                dir   = 2;
                break;

            case ControllerDoorType.TwoDoorsTwoDirections:
                count = 2;
                dir   = 2;
                break;

            case ControllerDoorType.FourDoorsOneDirection:
                count = 4;
                dir   = 1;
                break;

            default:
                break;
            }
            Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
            info.DOOR_INFOS = new List <Maticsoft.Model.SMT_DOOR_INFO>();
            for (int i = 0; i < count; i++)
            {
                Maticsoft.Model.SMT_DOOR_INFO doorInfo = new Maticsoft.Model.SMT_DOOR_INFO();
                doorInfo.CTRL_DELAY_TIME = 3;
                doorInfo.CTRL_DOOR_INDEX = i + 1;
                doorInfo.CTRL_ID         = ctrlId;
                doorInfo.CTRL_STYLE      = 0;
                doorInfo.DOOR_NAME       = "门_" + ctrlId + "_" + (i + 1);
                doorInfo.DOOR_DESC       = doorInfo.DOOR_NAME;
                doorInfo.AREA_ID         = -1;
                doorInfo.AREA_NAME       = "";
                doorInfo.ID             = -1;
                doorInfo.IS_ATTENDANCE1 = false;
                doorInfo.IS_ATTENDANCE2 = false;
                doorInfo.IS_ENABLE      = true;
                doorInfo.IS_ENTER1      = true;
                doorInfo.IS_ENTER2      = dir == 1;
                doorInfo.ID             = doorBll.Add(doorInfo);
                info.DOOR_INFOS.Add(doorInfo);
            }
            return(info);
        }
Beispiel #3
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);
        }
Beispiel #4
0
 public static void UpdateDoorSync(Maticsoft.Model.SMT_DOOR_INFO door)
 {
     if (door != null)
     {
         ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
         {
             try
             {
                 Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
                 doorBll.Update(door);
             }
             catch (Exception ex)
             {
                 log.Error("更新门禁异常:", ex);
             }
         }));
     }
 }
Beispiel #5
0
 public static List <Maticsoft.Model.SMT_DOOR_INFO> GetDoors()
 {
     Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
     if (UserInfoHelper.UserInfo.USER_NAME == "admin" ||
         PrivateMgr.FUN_POINTS.Contains(SYS_FUN_POINT.USER_PRIVATE_CONFIG))
     {
         LastDoors = doorBll.GetModelListWithArea("");
         return(LastDoors);
     }
     else
     {
         if (UserInfoHelper.UserInfo.ROLE_ID == null)
         {
             return(new List <Maticsoft.Model.SMT_DOOR_INFO>());
         }
         string strWhere = "ID IN (SELECT FUN_ID FROM SMT_ROLE_FUN WHERE ROLE_TYPE=3 and ROLE_ID=" + UserInfoHelper.UserInfo.ROLE_ID + ")";
         LastDoors = doorBll.GetModelListWithArea(strWhere);
         return(LastDoors);
     }
 }
Beispiel #6
0
 private void dgvData_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
     {
         if (dgvData.Columns[e.ColumnIndex].Name == "Col_Delete")
         {
             if (MessageBox.Show(this, "确定删除该梯门?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
             {
                 return;
             }
             if (dgvData.Rows.Count == 0)
             {
                 return;
             }
             DataGridViewRow row     = dgvData.Rows[e.RowIndex];
             var             door    = (Maticsoft.Model.SMT_DOOR_INFO)row.Tag;
             CtrlWaiting     waiting = new CtrlWaiting(() =>
             {
                 try
                 {
                     Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
                     doorBll.Delete(door.ID);
                     this.Invoke(new Action(() =>
                     {
                         dgvData.Rows.Remove(row);
                         cbCtrler_SelectedIndexChanged(null, null);
                     }));
                     WinInfoHelper.ShowInfoWindow(this, "删除梯门成功!");
                 }
                 catch (Exception ex)
                 {
                     log.Error("删除梯门失败:", ex);
                     WinInfoHelper.ShowInfoWindow(this, "删除梯门失败:" + ex.Message);
                 }
             });
             waiting.Show(this);
         }
     }
 }
Beispiel #7
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));
 }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
0
        private void btnApplyState_Click(object sender, EventArgs e)
        {
            List <decimal> ids            = GetCtrlIds();
            bool           isAllowVisitor = cbIsAllowVisitor.Checked;
            CtrlWaiting    waiting        = new CtrlWaiting(() =>
            {
                try
                {
                    List <decimal> visitorIds = new List <decimal>();
                    foreach (var item in _doors)
                    {
                        if (item.IS_ALLOW_VISITOR != isAllowVisitor)
                        {
                            visitorIds.Add(item.ID);
                        }
                    }
                    if (visitorIds.Count > 0)
                    {
                        Maticsoft.DBUtility.DbHelperSQL.Query("update SMT_DOOR_INFO set IS_ALLOW_VISITOR=" + (isAllowVisitor ? 1 : 0) + " where ID in (" + string.Join(",", visitorIds.ToArray()) + ")");
                        WinInfoHelper.ShowInfoWindow(this.Parent, "更新访客状态正常!");
                        foreach (var item in _doors)
                        {
                            item.IS_ALLOW_VISITOR = isAllowVisitor;
                        }
                    }

                    Maticsoft.BLL.SMT_CONTROLLER_INFO ctrlBLL = new Maticsoft.BLL.SMT_CONTROLLER_INFO();
                    var ctrls = ctrlBLL.GetModelList("ID in (" + string.Join(",", ids) + ")");
                    DoorControlStyle style = DoorControlStyle.Online;
                    if (rbOnline.Checked)
                    {
                        style = DoorControlStyle.Online;
                    }
                    else if (rbAlwaysOpen.Checked)
                    {
                        style = DoorControlStyle.AlwaysOpen;
                    }
                    else if (rbAlwaysClose.Checked)
                    {
                        style = DoorControlStyle.AlwaysClose;
                    }
                    List <ManualResetEvent> resetEvents = new List <ManualResetEvent>();
                    foreach (var item in ctrls)
                    {
                        var doors = _doors.FindAll(m => m.CTRL_ID == item.ID);
                        if (doors.Count == 0)
                        {
                            continue;
                        }
                        ManualResetEvent evt = new ManualResetEvent(false);
                        resetEvents.Add(evt);
                        ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
                        {
                            try
                            {
                                var c           = ControllerHelper.ToController(item);
                                IAccessCore acc = new WGAccess();
                                foreach (var d in doors)
                                {
                                    if (d.CTRL_DOOR_INDEX == null)
                                    {
                                        continue;
                                    }
                                    string temp = "在线";
                                    switch (style)
                                    {
                                    case DoorControlStyle.Online:
                                        temp = "在线";
                                        break;

                                    case DoorControlStyle.AlwaysOpen:
                                        temp = "常开";
                                        break;

                                    case DoorControlStyle.AlwaysClose:
                                        temp = "常关";
                                        break;

                                    default:
                                        break;
                                    }
                                    bool ret = acc.SetDoorControlStyle(c, (int)d.CTRL_DOOR_INDEX, style, iDelayTime.Value);
                                    if (!ret)
                                    {
                                        this.Invoke(new Action(() =>
                                        {
                                            if (_dgvX != null)
                                            {
                                                DataGridViewRow row = new DataGridViewRow();
                                                row.CreateCells(_dgvX, DateTime.Now, d.DOOR_NAME, "设置门禁失败!控制器IP=" + item.IP + ",SN=" + item.SN_NO + ",门禁:" + d.DOOR_NAME);
                                                _dgvX.Rows.Insert(0, row);
                                                row.Selected = true;
                                            }
                                        }));
                                        WinInfoHelper.ShowInfoWindow(this.Parent, "设置门禁失败!控制器IP=" + item.IP + ",SN=" + item.SN_NO + ",门禁:" + d.DOOR_NAME);
                                        continue;
                                    }
                                    else
                                    {
                                        Maticsoft.BLL.SMT_DOOR_INFO doorBll = new Maticsoft.BLL.SMT_DOOR_INFO();
                                        d.CTRL_DELAY_TIME = iDelayTime.Value;
                                        d.CTRL_STYLE      = (int)style;
                                        doorBll.Update(d);
                                        IsChanged = true;
                                        this.Invoke(new Action(() =>
                                        {
                                            if (_dgvX != null)
                                            {
                                                DataGridViewRow row = new DataGridViewRow();
                                                row.CreateCells(_dgvX, DateTime.Now, d.DOOR_NAME, "设置门禁:" + d.DOOR_NAME + " " + temp + "状态,时间" + iDelayTime.Value + "秒成功!");
                                                _dgvX.Rows.Insert(0, row);
                                                row.Selected = true;
                                            }
                                        }));
                                        WinInfoHelper.ShowInfoWindow(this.Parent, "设置门禁:" + d.DOOR_NAME + " " + temp + "状态,时间" + iDelayTime.Value + "秒成功!");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                log.Error("设置门禁发生异常:", ex);
                                this.Invoke(new Action(() =>
                                {
                                    if (_dgvX != null)
                                    {
                                        DataGridViewRow row = new DataGridViewRow();
                                        row.CreateCells(_dgvX, DateTime.Now, "", "设置门禁发生异常!控制器IP=" + item.IP + ",SN=" + item.SN_NO + ",异常信息:" + ex.Message);
                                        _dgvX.Rows.Insert(0, row);
                                        row.Selected = true;
                                    }
                                }));
                                WinInfoHelper.ShowInfoWindow(this.Parent, "设置门禁发生异常!控制器IP=" + item.IP + ",SN=" + item.SN_NO + ",异常信息:" + ex.Message);
                            }
                            finally
                            {
                                evt.Set();
                            }
                        }));
                    }
                    foreach (var item in resetEvents)
                    {
                        item.WaitOne(15000);
                    }
                }
                catch (Exception ex)
                {
                    log.Error("设置门禁发生异常1:", ex);
                    WinInfoHelper.ShowInfoWindow(this.Parent, "设置门禁发生异常!");
                }
                finally
                {
                    this.Invoke(new Action(() =>
                    {
                        this.Close();
                    }));
                }
            });

            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);
            }
        }
Beispiel #12
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;
            }
        }