Esempio n. 1
0
 private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
     {
         if (dgvData.Columns[e.ColumnIndex].Name == "ColDelete")
         {
             Maticsoft.Model.SMT_WEEKEX_INFO info = (Maticsoft.Model.SMT_WEEKEX_INFO)dgvData.Rows[e.RowIndex].Tag;
             if (MessageBox.Show("确定删除该假期约束?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
             {
                 CtrlWaiting waiting = new CtrlWaiting(() =>
                 {
                     try
                     {
                         Maticsoft.BLL.SMT_WEEKEX_INFO wbll = new Maticsoft.BLL.SMT_WEEKEX_INFO();
                         wbll.Delete(info.ID);
                         SmtLog.InfoFormat("设置", "删除假期约束:{0},开始时间:{1},结束时间:{2},描述:{3}", info.WEEKEX_ON_DUTY ? "上班[允许开门]" : "假期[不能开门]", info.WEEKEX_START_DATE, info.WEEKEX_END_DATE, info.WEEKEX_DESC);
                         this.Invoke(new Action(() =>
                         {
                             dgvData.Rows.Remove(dgvData.Rows[e.RowIndex]);
                         }));
                     }
                     catch (System.Exception ex)
                     {
                         WinInfoHelper.ShowInfoWindow(this, "删除假期约束异常:" + ex.Message);
                         log.Error("删除假期约束异常:", ex);
                     }
                 });
                 waiting.Show(this);
             }
         }
     }
 }
Esempio n. 2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            int port = cboPort.SelectedIndex + 1;

            if (port <= 0)
            {
                WinInfoHelper.ShowInfoWindow(this, "端口不能为空!");
                cboPort.Focus();
                return;
            }
            if (cboModel.SelectedItem == null)
            {
                WinInfoHelper.ShowInfoWindow(this, "型号不能为空!");
                cboModel.Focus();
                return;
            }
            if (cboBaud.SelectedItem == null)
            {
                WinInfoHelper.ShowInfoWindow(this, "波特率不能为空!");
                cboBaud.Focus();
                return;
            }
            CardIssueConfig config = new CardIssueConfig();

            config.comPort        = port;
            config.cardIssueModel = (CardIssueModel)((ComboItem)cboModel.SelectedItem).Tag;
            config.comBuad        = (ComBuad)((ComboItem)cboBaud.SelectedItem).Tag;
            SysConfig.SetCardIssueConfig(config);
            SmtLog.Info("配置", "修改读卡器端口");
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (tbRoleName.Text.Trim() == "")
            {
                WinInfoHelper.ShowInfoWindow(this, "角色名称不能为空!");
                return;
            }
            Maticsoft.Model.SMT_ROLE_INFO role = new Maticsoft.Model.SMT_ROLE_INFO();
            role.ROLE_NAME = tbRoleName.Text.Trim();
            role.ROLE_DESC = tbRoleName.Text.Trim();
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO();
                    role.ID = roleBll.Add(role);
                    SmtLog.InfoFormat("用户", "添加角色:ID={0},名称={1}", role.ID, role.ROLE_NAME);
                    this.Invoke(new Action(() =>
                    {
                        AddModel(role);
                    }));
                }
                catch (Exception ex)
                {
                    log.Error("添加角色异常:", ex);
                    WinInfoHelper.ShowInfoWindow(this, "添加角色异常:" + ex.Message);
                }
            });

            waiting.Show(this);
        }
Esempio n. 4
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (tbRoleName.Text.Trim() == "")
     {
         WinInfoHelper.ShowInfoWindow(this, "角色名称不能为空!");
         return;
     }
     if (_selectRow != null && dgvData.Rows.Contains(_selectRow))
     {
         Maticsoft.Model.SMT_ROLE_INFO role = (Maticsoft.Model.SMT_ROLE_INFO)_selectRow.Tag;
         role.ROLE_NAME = tbRoleName.Text.Trim();
         role.ROLE_DESC = tbRoleDesc.Text.Trim();
         CtrlWaiting waiting = new CtrlWaiting(() =>
         {
             try
             {
                 Maticsoft.BLL.SMT_ROLE_INFO roleBll = new Maticsoft.BLL.SMT_ROLE_INFO();
                 roleBll.Update(role);
                 SmtLog.InfoFormat("用户", "更新角色:ID={0},名称={1}", role.ID, role.ROLE_NAME);
                 this.Invoke(new Action(() =>
                 {
                     _selectRow.Cells[0].Value = role.ROLE_NAME;
                     _selectRow.Cells[1].Value = role.ROLE_DESC;
                 }));
             }
             catch (Exception ex)
             {
                 log.Error("更新角色异常:", ex);
                 WinInfoHelper.ShowInfoWindow(this, "更新角色异常:" + ex.Message);
             }
         });
         waiting.Show(this);
     }
 }
Esempio n. 5
0
        private void DoSave()
        {
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                decimal?old = _userInfo.ROLE_ID;
                try
                {
                    _userInfo.ROLE_ID = SELECT_ROLE.ID;
                    Maticsoft.BLL.SMT_USER_INFO userBll = new Maticsoft.BLL.SMT_USER_INFO();
                    userBll.Update(_userInfo);
                    SmtLog.InfoFormat("用户", "修改用户:{0},角色:{1}成功.", _userInfo.USER_NAME, _userInfo.ROLE_ID + ":" + SELECT_ROLE.ROLE_NAME);
                    this.Invoke(new Action(() =>
                    {
                        _userInfo.ROLE_NAME = SELECT_ROLE.ROLE_NAME + "(点击修改)";
                        this.DialogResult   = DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    _userInfo.ROLE_ID = old;
                    WinInfoHelper.ShowInfoWindow(this, "保存失败:" + ex.Message);
                    log.Error("保存授权角色失败:", ex);
                }
            });

            waiting.Show(this);
        }
Esempio n. 6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string pwd = this.tbPassword.Text.Trim();

            if (pwd == "")
            {
                WinInfoHelper.ShowInfoWindow(this, "密码为空!");
                return;
            }
            var doors = doorTree.Tree.GetNodeList(true, typeof(Maticsoft.Model.SMT_DOOR_INFO));

            if (doors.Count == 0)
            {
                WinInfoHelper.ShowInfoWindow(this, "未选择任何门禁!");
                return;
            }
            List <decimal> doorIds = new List <decimal>();

            foreach (var item in doors)
            {
                doorIds.Add(((Maticsoft.Model.SMT_DOOR_INFO)item.Tag).ID);
            }
            CtrlWaiting ctrlWaiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_SUPER_PWD pwdBll             = new Maticsoft.BLL.SMT_SUPER_PWD();
                    List <Maticsoft.Model.SMT_SUPER_PWD> models    = pwdBll.GetModelList("SUPER_PWD='" + pwd + "'");
                    List <Maticsoft.Model.SMT_SUPER_PWD> addmodels = new List <Maticsoft.Model.SMT_SUPER_PWD>();
                    foreach (var item in doorIds)
                    {
                        if (!models.Exists(m => m.DOOR_ID == item))
                        {
                            Maticsoft.Model.SMT_SUPER_PWD model = new Maticsoft.Model.SMT_SUPER_PWD()
                            {
                                DOOR_ID   = item,
                                SUPER_PWD = pwd
                            };
                            model.ID = pwdBll.Add(model);
                            addmodels.Add(model);
                            SmtLog.InfoFormat("配置", "添加超级通行密码:门禁Id={0}", item);
                        }
                    }
                    if (addmodels.Count > 0)
                    {
                        RefreshDatas();
                    }
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "添加超级通行密码异常!" + ex.Message);
                    log.Error("添加超级通行密码异常:", ex);
                }
            });

            ctrlWaiting.Show(this);
        }
Esempio n. 7
0
        public FrmMain()
        {
            InitializeComponent();
            Instance = this;
            CreateStyleItems();
            SmtLog.Info("系统", "进入系统");

            LoadSys();
        }
Esempio n. 8
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(tbAreaName.Text))
     {
         MessageBox.Show("区域名称不能为空!");
         tbAreaName.Focus();
         return;
     }
     try
     {
         if (Area == null)
         {
             Area             = new Maticsoft.Model.SMT_CONTROLLER_ZONE();
             Area.ID          = -1;
             Area.PAR_ID      = ParentAreaID == null ? 0 : (decimal)ParentAreaID;
             Area.ORDER_VALUE = 100;
         }
         Area.ZONE_NAME = tbAreaName.Text.Trim();
         Area.ZONE_DESC = tbAreaDesc.Text.Trim();
         CtrlWaiting waiting = new CtrlWaiting(() =>
         {
             try
             {
                 if (Area.ID == -1)
                 {
                     Area.ID = AreaDataHelper.AddArea(Area);
                     SmtLog.Info("区域", "添加区域:" + Area.ZONE_NAME);
                 }
                 else
                 {
                     AreaDataHelper.UpdateArea(Area);
                     SmtLog.Info("区域", "更新区域:" + Area.ZONE_NAME);
                 }
                 this.BeginInvoke(new Action(() =>
                 {
                     this.DialogResult = DialogResult.OK;
                     this.Close();
                 }));
             }
             catch (Exception ex)
             {
                 WinInfoHelper.ShowInfoWindow(this, "保存区域异常:" + ex.Message);
                 log.Error("保存区域异常:", ex);
             }
         });
         waiting.Show(this);
     }
     catch (Exception ex)
     {
         WinInfoHelper.ShowInfoWindow(this, "保存区域异常:" + ex.Message);
         log.Error("保存区域异常:", ex);
     }
 }
Esempio n. 9
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (tbIp.Text.Trim() == "")
            {
                WinInfoHelper.ShowInfoWindow(this, "IP不能为空!");
                return;
            }
            if (CAMERA == null)
            {
                CAMERA    = new Maticsoft.Model.SMT_CAMERA_INFO();
                CAMERA.ID = -1;
            }
            CAMERA.CAMERA_NAME     = tbCameraName.Text.Trim();
            CAMERA.CAMERA_IP       = tbIp.Text.Trim();
            CAMERA.CAMERA_PORT     = iiPort.Value;
            CAMERA.CAMERA_USER     = tbUser.Text.Trim();
            CAMERA.CAMERA_PWD      = tbPwd.Text;
            CAMERA.CAMERA_MODEL    = (string)cbModel.SelectedItem;
            CAMERA.CAMERA_CAP_TYPE = (string)cbCapType.SelectedItem;
            CAMERA.CAMERA_CAP_PORT = iiCapPort.Value;

            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_CAMERA_INFO cameraBll = new Maticsoft.BLL.SMT_CAMERA_INFO();
                    if (CAMERA.ID == -1)
                    {
                        CAMERA.ID = cameraBll.Add(CAMERA);
                    }
                    else
                    {
                        cameraBll.Update(CAMERA);
                    }

                    SmtLog.Info("配置", "配置摄像头:" + CAMERA.CAMERA_NAME + ",IP=" + CAMERA.CAMERA_IP);
                    this.BeginInvoke(new Action(() =>
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    log.Error("添加摄像头失败:", ex);
                    WinInfoHelper.ShowInfoWindow(this, "添加相机失败!" + ex.Message);
                }
            });

            waiting.Show(this);
        }
Esempio n. 10
0
        private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                DataGridViewRow row = dgvData.Rows[e.RowIndex];

                _selectRow = row;
                Maticsoft.Model.SMT_ROLE_INFO role = (Maticsoft.Model.SMT_ROLE_INFO)row.Tag;

                tbRoleName.Text = role.ROLE_NAME;
                tbRoleDesc.Text = role.ROLE_DESC;

                if (e.ColumnIndex >= 0)
                {
                    if (dgvData.Columns[e.ColumnIndex].Name == "ColPrivate")
                    {
                        DoSetPrivate();
                    }
                    else if (dgvData.Columns[e.ColumnIndex].Name == "ColDelete")
                    {
                        if (MessageBox.Show("确定删除该角色?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            CtrlWaiting waiting = new CtrlWaiting(() =>
                            {
                                try
                                {
                                    Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + role.ID);
                                    Maticsoft.BLL.SMT_ROLE_INFO roleInfo = new Maticsoft.BLL.SMT_ROLE_INFO();
                                    roleInfo.Delete(role.ID);
                                    SmtLog.InfoFormat("用户", "删除角色:ID={0},名称={1}", role.ID, role.ROLE_NAME);
                                    this.Invoke(new Action(() =>
                                    {
                                        dgvData.Rows.Remove(row);
                                        _selectRow      = null;
                                        tbRoleName.Text = "";
                                        tbRoleDesc.Text = "";
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    log.Error("删除角色异常:", ex);
                                    WinInfoHelper.ShowInfoWindow(this, "删除角色异常:" + ex.Message);
                                }
                            });
                            waiting.Show(this);
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        private bool CheckDoExitSystem()
        {
            bool ret = DevComponents.DotNetBar.TaskDialog.Show("退出系统", eTaskDialogIcon.Help, "退出", "确定退出系统?", eTaskDialogButton.Ok | eTaskDialogButton.Cancel) == eTaskDialogResult.Ok;

            if (ret)
            {
                if (consumerClient != null)
                {
                    consumerClient.Stop();
                }
                SmtLog.Info("系统", "退出系统");
            }
            return(ret);
        }
Esempio n. 12
0
 private void DoDelete(DataGridViewRow row)
 {
     if (MessageBox.Show("确定删除该控制器?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         CtrlWaiting ctrlWaiting = new CtrlWaiting("正在删除中...", () =>
         {
             try
             {
                 Maticsoft.Model.SMT_FACERECG_DEVICE dev = (Maticsoft.Model.SMT_FACERECG_DEVICE)row.Tag;
                 DialogResult dr = DialogResult.No;
                 this.Invoke(new Action(() =>
                 {
                     dr = MessageBox.Show("是否清除该人脸识别设备权限?", "提示", MessageBoxButtons.YesNo);
                 }));
                 if (dr == DialogResult.Yes)
                 {
                     ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
                     {
                         try
                         {
                             BSTFaceRecg c = FaceRecgHelper.ToFaceController(dev);
                             c.ClearFaces();
                         }
                         catch (Exception ex)
                         {
                             WinInfoHelper.ShowInfoWindow(this, "权限清除异常,可能设备离线或者不存在:" + ex.Message);
                         }
                     }));
                     Thread.Sleep(1000);
                 }
                 Maticsoft.BLL.SMT_FACERECG_DEVICE ctrlBll = new Maticsoft.BLL.SMT_FACERECG_DEVICE();
                 ctrlBll.Delete(dev.ID);
                 //置门关联控制器为空
                 Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_STAFF_FACEDEV where FACEDEV_ID=" + dev.ID);
                 SmtLog.Info("设备", "人脸识别设备删除:" + dev.FACEDEV_IP + "," + dev.FACEDEV_NAME);
                 this.Invoke(new Action(() =>
                 {
                     dgvCtrlr.Rows.Remove(row);
                 }));
             }
             catch (System.Exception ex)
             {
                 log.Error("删除人脸识别设备异常:", ex);
                 WinInfoHelper.ShowInfoWindow(this, "删除失败:" + ex.Message);
             }
         });
         ctrlWaiting.Show(this);
     }
 }
Esempio n. 13
0
 private void biDelete_Click(object sender, EventArgs e)
 {
     if (dgvData.SelectedRows.Count > 0)
     {
         if (MessageBox.Show("确定删除选择对象?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             List <Maticsoft.Model.SMT_TIMESCALE_INFO> mscs = new List <Maticsoft.Model.SMT_TIMESCALE_INFO>();
             List <DataGridViewRow> rows = new List <DataGridViewRow>();
             foreach (DataGridViewRow item in dgvData.SelectedRows)
             {
                 mscs.Add((Maticsoft.Model.SMT_TIMESCALE_INFO)item.Tag);
                 rows.Add(item);
             }
             CtrlWaiting waiting = new CtrlWaiting(() =>
             {
                 try
                 {
                     Maticsoft.BLL.SMT_TIMESCALE_INFO scBll = new Maticsoft.BLL.SMT_TIMESCALE_INFO();
                     foreach (var item in mscs)
                     {
                         scBll.Delete(item.ID);
                         SmtLog.InfoFormat("配置", "删除定时任务,编号:{0},名称:{1}", item.TIME_NO, item.TIME_NAME);
                     }
                     this.Invoke(new Action(() =>
                     {
                         foreach (var item in rows)
                         {
                             dgvData.Rows.Remove(item);
                         }
                         DoUpload();
                     }));
                 }
                 catch (Exception ex)
                 {
                     WinInfoHelper.ShowInfoWindow(this, "删除对象异常:" + ex.Message);
                     log.Error("删除对象异常:", ex);
                 }
             });
             waiting.Show(this);
         }
     }
 }
Esempio n. 14
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (tbOldPwd.Text != UserInfoHelper.OldPwd)
            {
                MessageBox.Show("原始密码输入错误!");
                tbOldPwd.Focus();
                return;
            }
            if (tbNewPwd.Text == "")
            {
                MessageBox.Show("新密码不能为空!");
                tbNewPwd.Focus();
                return;
            }
            if (tbNewPwd.Text != tbRePwd.Text)
            {
                MessageBox.Show("两次输入密码不相同!");
                tbRePwd.Focus();
                return;
            }
            //"USER_NAME='" + tbUserName.Text.Trim() + "' and IS_ENABLE=1 and IS_DELETE=0 and PASS_WORD= substring(sys.fn_sqlvarbasetostr(HashBytes('MD5','" + tbPwd.Text + "')),3,32)"
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("update SMT_USER_INFO set PASS_WORD=substring(sys.fn_sqlvarbasetostr(HashBytes('MD5','" + tbNewPwd.Text + "')),3,32) where ID='" + UserInfoHelper.UserID + "'");
                    SmtLog.InfoFormat("用户", "修改密码,用户名:{0}", UserInfoHelper.UserInfo.USER_NAME);
                    this.Invoke(new Action(() =>
                    {
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "修改用户密码失败:" + ex.Message);
                }
            });

            waiting.Show(this);
        }
Esempio n. 15
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DateTime dtStart = DateTime.Parse(dtpStartDate.Value.ToString("yyyy-MM-dd HH:mm:00"));
            DateTime dtEnd   = DateTime.Parse(dtpEndDate.Value.ToString("yyyy-MM-dd HH:mm:00"));

            if (dtStart > dtEnd)
            {
                WinInfoHelper.ShowInfoWindow(this, "开始时间大于结束时间!");
                return;
            }
            Maticsoft.Model.SMT_WEEKEX_INFO info = new Maticsoft.Model.SMT_WEEKEX_INFO();
            info.WEEKEX_ON_DUTY    = cboHolidayType.SelectedIndex == 1;
            info.WEEKEX_START_DATE = dtStart;
            info.WEEKEX_END_DATE   = dtEnd;
            info.WEEKEX_DESC       = tbDesc.Text.Trim();
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_WEEKEX_INFO wbll = new Maticsoft.BLL.SMT_WEEKEX_INFO();
                    info.ID = wbll.Add(info);
                    SmtLog.InfoFormat("设置", "添加假期约束:{0},开始时间:{1},结束时间:{2},描述:{3}", info.WEEKEX_ON_DUTY ? "上班[允许开门]" : "假期[不能开门]", info.WEEKEX_START_DATE, info.WEEKEX_END_DATE, info.WEEKEX_DESC);
                    this.Invoke(new Action(() =>
                    {
                        AddToGrid(info);
                    }));
                }
                catch (System.Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "添加假期约束异常:" + ex.Message);
                    log.Error("添加假期约束异常:", ex);
                }
            });

            waiting.Show(this);
        }
Esempio n. 16
0
 private void DoDelete(DataGridViewRow row)
 {
     if (MessageBox.Show("确定删除该控制器?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         CtrlWaiting ctrlWaiting = new CtrlWaiting("正在删除中...", () =>
         {
             try
             {
                 Maticsoft.Model.SMT_CONTROLLER_INFO ctrlr = (Maticsoft.Model.SMT_CONTROLLER_INFO)row.Tag;
                 DialogResult dr = DialogResult.No;
                 this.Invoke(new Action(() =>
                 {
                     dr = MessageBox.Show("是否清除该控制器权限?", "提示", MessageBoxButtons.YesNo);
                 }));
                 if (dr == DialogResult.Yes)
                 {
                     Controller c = ControllerHelper.ToController(ctrlr);
                     using (IAccessCore ac = new WGAccess())
                     {
                         try
                         {
                             bool ret = ac.ClearAuthority(c);
                             if (!ret)
                             {
                                 this.Invoke(new Action(() =>
                                 {
                                     dr = MessageBox.Show("清除控制器权限失败(控制器可能离线),是否继续删除控制器?", "提示", MessageBoxButtons.YesNo);
                                 }));
                                 if (dr == DialogResult.No)
                                 {
                                     return;
                                 }
                             }
                         }
                         catch (Exception ex)
                         {
                             log.Error("清除控制器权限失败(控制器可能离线)(删除控制器):", ex);
                             this.Invoke(new Action(() =>
                             {
                                 dr = MessageBox.Show("清除控制器权限失败(控制器可能离线),是否继续删除控制器?", "提示", MessageBoxButtons.YesNo);
                             }));
                             if (dr == DialogResult.No)
                             {
                                 return;
                             }
                         }
                     }
                 }
                 Maticsoft.BLL.SMT_CONTROLLER_INFO ctrlBll = new Maticsoft.BLL.SMT_CONTROLLER_INFO();
                 ctrlBll.Delete(ctrlr.ID);
                 //置门关联控制器为空
                 Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("update SMT_DOOR_INFO set CTRL_ID=-1,CTRL_DOOR_INDEX=0 where CTRL_ID=" + ctrlr.ID);
                 SmtLog.Info("设备", "控制器删除:" + ctrlr.IP + "," + ctrlr.NAME);
                 this.Invoke(new Action(() =>
                 {
                     dgvCtrlr.Rows.Remove(row);
                 }));
             }
             catch (System.Exception ex)
             {
                 log.Error("删除控制器异常:", ex);
                 WinInfoHelper.ShowInfoWindow(this, "删除失败:" + ex.Message);
             }
         });
         ctrlWaiting.Show(this);
     }
 }
Esempio n. 17
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }
            if (_timeScaleInfo == null)
            {
                _timeScaleInfo    = new Maticsoft.Model.SMT_TIMESCALE_INFO();
                _timeScaleInfo.ID = -1;
            }
            _timeScaleInfo.TIME_NAME         = tbName.Text.Trim();
            _timeScaleInfo.TIME_NO           = (int)cbTimeNo.SelectedItem;
            _timeScaleInfo.TIME_NEXT_NO      = (int)cbNextTimeNo.SelectedItem;
            _timeScaleInfo.TIME_DATE_START   = dtpStartDate.Value.Date;
            _timeScaleInfo.TIME_DATE_END     = dtpEndDate.Value.Date;
            _timeScaleInfo.TIME_WEEK_DAY1    = cbWeek1.Checked;
            _timeScaleInfo.TIME_WEEK_DAY2    = cbWeek2.Checked;
            _timeScaleInfo.TIME_WEEK_DAY3    = cbWeek3.Checked;
            _timeScaleInfo.TIME_WEEK_DAY4    = cbWeek4.Checked;
            _timeScaleInfo.TIME_WEEK_DAY5    = cbWeek5.Checked;
            _timeScaleInfo.TIME_WEEK_DAY6    = cbWeek6.Checked;
            _timeScaleInfo.TIME_WEEK_DAY7    = cbWeek7.Checked;
            _timeScaleInfo.TIME_RANGE_START1 = dtiTimeAreaStart1.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_END1   = dtiTimeAreaEnd1.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_START2 = dtiTimeAreaStart2.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_END2   = dtiTimeAreaEnd2.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_START3 = dtiTimeAreaStart3.Value.TimeOfDay;
            _timeScaleInfo.TIME_RANGE_END3   = dtiTimeAreaEnd3.Value.TimeOfDay;
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_TIMESCALE_INFO scBll = new Maticsoft.BLL.SMT_TIMESCALE_INFO();
                    if (_timeScaleInfo.ID == -1)
                    {
                        var ss = scBll.GetModelList("TIME_NO=" + _timeScaleInfo.TIME_NO);
                        if (ss.Count > 0)
                        {
                            WinInfoHelper.ShowInfoWindow(this, "已存在同一时区的规则!");
                            return;
                        }
                        _timeScaleInfo.ID = scBll.Add(_timeScaleInfo);
                        SmtLog.Info("配置", "添加时区,编号:" + _timeScaleInfo.TIME_NO + ",名称:" + _timeScaleInfo.TIME_NAME);
                    }
                    else
                    {
                        scBll.Update(_timeScaleInfo);
                        SmtLog.Info("配置", "更新时区,编号:" + _timeScaleInfo.TIME_NO + ",名称:" + _timeScaleInfo.TIME_NAME);
                    }
                    this.Invoke(new Action(() =>
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message);
                    log.Error("保存异常:", ex);
                }
            });

            waiting.Show(this);
        }
Esempio n. 18
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (setting == null)
            {
                setting           = new Maticsoft.Model.SMT_ATTEN_SETTING();
                setting.ID        = -1;
                setting.DUTY_TYPE = 0;
            }
            setting.DUTY_ON_TIME1    = dtiOnDuty.Value.TimeOfDay;
            setting.DUTY_OFF_TIME1   = dtiOffDuty.Value.TimeOfDay;
            setting.DUTY_ON_EARLIEST = dtiEarliestTime.Value.TimeOfDay;
            setting.DUTY_LATE_MIN    = iiLateMin.Value;
            setting.DUTY_LATE_MAX    = iiLateMax.Value;
            setting.DUTY_LEAVE_MIN   = iiLeaveMin.Value;
            setting.DUTY_LEAVE_MAX   = iiLeaveMax.Value;
            if (cboLatePunish.SelectedIndex == 0)
            {
                setting.DUTY_LATE_PUNISH = 0;
            }
            else if (cboLatePunish.SelectedIndex == 2)
            {
                setting.DUTY_LATE_PUNISH = 1;
            }
            else
            {
                setting.DUTY_LATE_PUNISH = 0.5M;
            }

            if (cboLeavePunish.SelectedIndex == 0)
            {
                setting.DUTY_LEAVE_PUNISH = 0;
            }
            else if (cboLeavePunish.SelectedIndex == 2)
            {
                setting.DUTY_LEAVE_PUNISH = 1;
            }
            else
            {
                setting.DUTY_LEAVE_PUNISH = 0.5M;
            }

            setting.DUTY_ONLY_ON = cbOnlyOn.Checked;


            if (cbSatSetting0.Checked)
            {
                setting.DUTY_SAT_TYPE = 0;
            }
            else if (cbSatSetting1.Checked)
            {
                setting.DUTY_SAT_TYPE = 1;
            }
            else
            {
                setting.DUTY_SAT_TYPE = 2;
            }

            if (cbSunSetting0.Checked)
            {
                setting.DUTY_SUN_TYPE = 0;
            }
            else if (cbSunSetting1.Checked)
            {
                setting.DUTY_SUN_TYPE = 1;
            }
            else
            {
                setting.DUTY_SUN_TYPE = 2;
            }
            CtrlWaiting waiting = new CtrlWaiting("正在保存...", () =>
            {
                try
                {
                    Maticsoft.BLL.SMT_ATTEN_SETTING settingBll = new Maticsoft.BLL.SMT_ATTEN_SETTING();
                    if (setting.ID == -1)
                    {
                        settingBll.Add(setting);
                        SmtLog.Info("设置", "设置考勤正常班");
                    }
                    else
                    {
                        settingBll.Update(setting);
                        SmtLog.Info("设置", "更新考勤正常班");
                    }
                    WinInfoHelper.ShowInfoWindow(this, "保存成功。");
                }
                catch (System.Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "保存设置异常!" + ex.Message);
                    log.Error("保存正常班设置异常:" + ex.Message, ex);
                }
            });

            waiting.Show(this);
        }
Esempio n. 19
0
        private void biSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbMapName.Text))
            {
                WinInfoHelper.ShowInfoWindow(this, "地图名称不能为空!");
                tbMapName.Focus();
                return;
            }
            if (_mapInfo == null)
            {
                _mapInfo             = new Maticsoft.Model.SMT_MAP_INFO();
                _mapInfo.CREATE_TIME = DateTime.Now;
                _mapInfo.ID          = -1;
            }
            if (mapCtrl.MapImage != null)
            {
                MemoryStream ms = new MemoryStream();
                using (Bitmap bitmap = new Bitmap(mapCtrl.MapImage))
                {
                    bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
                _mapInfo.MAP_IMAGE = ms.GetBuffer();
                ms.Dispose();
            }
            else
            {
                _mapInfo.MAP_IMAGE = new byte[0];
            }
            _mapInfo.MAP_NAME = tbMapName.Text.Trim();
            _mapInfo.GROUP_ID = -1;
            var         doors   = mapCtrl.GetDoors();
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_MAP_INFO mapBll       = new Maticsoft.BLL.SMT_MAP_INFO();
                    Maticsoft.BLL.SMT_MAP_DOOR mdBll        = new Maticsoft.BLL.SMT_MAP_DOOR();
                    List <Maticsoft.Model.SMT_MAP_DOOR> mds = new List <Maticsoft.Model.SMT_MAP_DOOR>();
                    foreach (var item in doors)
                    {
                        Maticsoft.Model.SMT_MAP_DOOR md = new Maticsoft.Model.SMT_MAP_DOOR();
                        md.DOOR_ID    = item.Id;
                        md.MAP_ID     = _mapInfo.ID;
                        md.DOOR_TYPE  = item.DoorType;
                        md.LOCATION_X = (decimal)item.RatioX;
                        md.LOCATION_Y = (decimal)item.RatioY;
                        md.WIDTH      = (decimal)item.RatioWidth;
                        md.HEIGHT     = (decimal)item.RatioHeight;
                        mds.Add(md);
                    }
                    if (_mapInfo.ID == -1)
                    {
                        _mapInfo.ID = mapBll.Add(_mapInfo);
                        SmtLog.Info("配置", "添加地图:" + _mapInfo.MAP_NAME);
                    }
                    else
                    {
                        mapBll.Update(_mapInfo);
                        SmtLog.Info("配置", "更新地图:" + _mapInfo.MAP_NAME);
                        var olds = mdBll.GetModelList("MAP_ID=" + _mapInfo.ID);
                        foreach (var old in olds)
                        {
                            mdBll.Delete(old.MAP_ID, old.DOOR_ID, old.DOOR_TYPE);
                        }
                    }
                    foreach (var md in mds)
                    {
                        md.MAP_ID = _mapInfo.ID;
                        mdBll.Add(md);
                        _selectNodes.Find(m =>
                        {
                            if (m.Tag is Maticsoft.Model.SMT_DOOR_INFO)
                            {
                                if (((Maticsoft.Model.SMT_DOOR_INFO)m.Tag).ID == md.DOOR_ID && md.DOOR_TYPE == 1)
                                {
                                    md.DOOR = (Maticsoft.Model.SMT_DOOR_INFO)m.Tag;
                                    return(true);
                                }
                            }
                            else if (m.Tag is Maticsoft.Model.SMT_FACERECG_DEVICE)
                            {
                                if (((Maticsoft.Model.SMT_FACERECG_DEVICE)m.Tag).ID == md.DOOR_ID && md.DOOR_TYPE == 2)
                                {
                                    md.FACE = (Maticsoft.Model.SMT_FACERECG_DEVICE)m.Tag;
                                    return(true);
                                }
                            }
                            return(false);
                        });
                    }
                    _mapInfo.MAP_DOORS = mds;

                    IsChanged = true;
                    this.Invoke(new Action(() =>
                    {
                        this.Text = "修改地图:" + tbMapName.Text;
                    }));
                    WinInfoHelper.ShowInfoWindow(this, "保存地图成功!");
                }
                catch (Exception ex)
                {
                    log.Error("保存地图异常:", ex);
                    WinInfoHelper.ShowInfoWindow(this, "保存异常!" + ex.Message);
                }
            });

            waiting.Show(this);
        }
Esempio n. 20
0
        private void DoUpload()
        {
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                var ctrls = ControllerHelper.GetList("1=1");
                if (ctrls.Count == 0)
                {
                    WinInfoHelper.ShowInfoWindow(this, "没有控制器!");
                    return;
                }
                Maticsoft.BLL.SMT_TIMESCALE_INFO tsBll = new Maticsoft.BLL.SMT_TIMESCALE_INFO();
                var models = tsBll.GetModelList("");
                models     = models.OrderBy(m => m.TIME_NO).ToList();//时段升序
                Maticsoft.BLL.SMT_WEEKEX_INFO wbll = new Maticsoft.BLL.SMT_WEEKEX_INFO();
                var weekexs = wbll.GetModelList("");

                SmtLog.Info("设置", "上传时间段设置");
                FrmDetailInfo.Show(false);
                FrmDetailInfo.AddOneMsg(string.Format("开始上传控制器时段:控制器数={0},时段数={1} ...", ctrls.Count, models.Count));
                List <ManualResetEvent> eventList = new List <ManualResetEvent>();
                foreach (var item in ctrls)
                {
                    ManualResetEvent evt = new ManualResetEvent(false);
                    eventList.Add(evt);
                    ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
                    {
                        try
                        {
                            var ctrl = ControllerHelper.ToController(item);
                            using (IAccessCore acc = new WGAccess())
                            {
                                if (acc.ClearTimeScales(ctrl))
                                {
                                    FrmDetailInfo.AddOneMsg(string.Format("清除控制器时间段成功:SN={0},IP={1},开始上传控制器时间段...", ctrl.sn, ctrl.ip));
                                    foreach (var model in models)
                                    {
                                        var m    = TimeScaleHelper.ToTimeScale(model);
                                        bool ret = acc.SetTimeScales(ctrl, m);
                                        if (!ret)
                                        {
                                            FrmDetailInfo.AddOneMsg(string.Format("上传控制器时间段失败:时段号={0},控制器IP={1}", model.TIME_NO, ctrl.ip), isRed: true);
                                        }
                                        else
                                        {
                                            FrmDetailInfo.AddOneMsg(string.Format("上传控制器时间段成功:时段号={0},控制器IP={1}", model.TIME_NO, ctrl.ip));
                                        }
                                    }
                                }
                                else
                                {
                                    FrmDetailInfo.AddOneMsg(string.Format("清除控制器时间段失败:SN={0},IP={1},结束该控制器上传...", ctrl.sn, ctrl.ip), isRed: true);
                                }

                                if (acc.SetHoliday(ctrl, new HolidayPrm()
                                {
                                    IsClear = true,
                                    startDate = DateTime.Now,
                                    endDate = DateTime.Now.AddDays(1)
                                }))
                                {
                                    FrmDetailInfo.AddOneMsg(string.Format("清除控制器假期约束成功:SN={0},IP={1},开始上传假期约束...", ctrl.sn, ctrl.ip));
                                    foreach (var w in weekexs)
                                    {
                                        bool ret = acc.SetHoliday(ctrl, new HolidayPrm()
                                        {
                                            IsClear   = false,
                                            IsOnDuty  = w.WEEKEX_ON_DUTY,
                                            startDate = w.WEEKEX_START_DATE,
                                            endDate   = w.WEEKEX_END_DATE
                                        });
                                        if (!ret)
                                        {
                                            FrmDetailInfo.AddOneMsg(string.Format("上传控制器假期约束失败:约束={0},起止时间={1}~{2},控制器IP={3}", w.WEEKEX_ON_DUTY ? "上班" : "假期", w.WEEKEX_START_DATE, w.WEEKEX_END_DATE, ctrl.ip), isRed: true);
                                        }
                                        else
                                        {
                                            FrmDetailInfo.AddOneMsg(string.Format("上传控制器假期约束成功:约束={0},起止时间={1}~{2},控制器IP={3}", w.WEEKEX_ON_DUTY ? "上班" : "假期", w.WEEKEX_START_DATE, w.WEEKEX_END_DATE, ctrl.ip));
                                        }
                                    }
                                }
                                else
                                {
                                    FrmDetailInfo.AddOneMsg(string.Format("清除控制器假期约束失败:SN={0},IP={1}", ctrl.sn, ctrl.ip), isRed: true);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            FrmDetailInfo.AddOneMsg(string.Format("上传控制器时间段失败:SN={0},IP={1},异常信息:{2},结束该控制器上传...", item.SN_NO, item.IP, ex.Message), isRed: true);
                            log.Error("上传控制器时间段失败,", ex);
                            SmtLog.ErrorFormat("设置", "上传控制器时间段失败:SN={0},IP={1},异常信息:{2},结束该控制器上传...", item.SN_NO, item.IP, ex.Message);
                        }
                        finally
                        {
                            evt.Set();
                        }
                    }));
                }
                foreach (var item in eventList)
                {
                    item.WaitOne(60000);
                }
                FrmDetailInfo.AddOneMsg("结束控制器时段上传!");
            });

            waiting.Show(this);
        }
Esempio n. 21
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //读取菜单权限
            List <Maticsoft.Model.SMT_FUN_MENUPOINT> funs = GetSelectModels <Maticsoft.Model.SMT_FUN_MENUPOINT>(advPrivate, CheckState.Indeterminate, CheckState.Checked);

            //读取部门菜单
            List <Maticsoft.Model.SMT_ORG_INFO> orgs = null;

            if (deptTree.IsLoaded)
            {
                orgs = GetSelectModels <Maticsoft.Model.SMT_ORG_INFO>(deptTree.Tree, CheckState.Checked);
            }
            //读取门参数
            List <Maticsoft.Model.SMT_DOOR_INFO> doors = null;

            if (doorTree.IsLoaded)
            {
                doors = GetSelectModels <Maticsoft.Model.SMT_DOOR_INFO>(doorTree.Tree, CheckState.Checked);
            }

            //读取人脸参数
            List <Maticsoft.Model.SMT_FACERECG_DEVICE> faces = null;

            if (faceDevTree.IsLoaded)
            {
                faces = GetSelectModels <Maticsoft.Model.SMT_FACERECG_DEVICE>(faceDevTree.Tree, CheckState.Checked);
            }

            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_ROLE_FUN rolefunBll = new Maticsoft.BLL.SMT_ROLE_FUN();
                    Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and (ROLE_TYPE=1 or ROLE_TYPE is null)");

                    if (funs.Count > 0)
                    {
                        foreach (var item in funs)
                        {
                            Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN();
                            rf.ROLE_ID   = _roleInfo.ID;
                            rf.FUN_ID    = item.ID;
                            rf.ROLE_TYPE = 1;
                            rolefunBll.Add(rf);
                        }
                    }
                    SmtLog.InfoFormat("用户", "更新角色:{0}菜单权限,个数:{1}.", _roleInfo.ROLE_NAME, funs.Count);

                    if (orgs != null)
                    {
                        Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=2");
                        foreach (var item in orgs)
                        {
                            Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN();
                            rf.ROLE_ID   = _roleInfo.ID;
                            rf.FUN_ID    = item.ID;
                            rf.ROLE_TYPE = 2;
                            rolefunBll.Add(rf);
                        }
                        SmtLog.InfoFormat("用户", "更新角色:{0}部门权限,个数:{1}.", _roleInfo.ROLE_NAME, orgs.Count);
                    }


                    if (doors != null)
                    {
                        Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=3");
                        foreach (var item in doors)
                        {
                            Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN();
                            rf.ROLE_ID   = _roleInfo.ID;
                            rf.FUN_ID    = item.ID;
                            rf.ROLE_TYPE = 3;
                            rolefunBll.Add(rf);
                        }
                        SmtLog.InfoFormat("用户", "更新角色:{0}门禁权限,个数:{1}.", _roleInfo.ROLE_NAME, doors.Count);
                    }

                    if (faces != null)
                    {
                        Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=4");
                        foreach (var item in faces)
                        {
                            Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN();
                            rf.ROLE_ID   = _roleInfo.ID;
                            rf.FUN_ID    = item.ID;
                            rf.ROLE_TYPE = 4;
                            rolefunBll.Add(rf);
                        }
                        SmtLog.InfoFormat("用户", "更新角色:{0}人脸设备权限,个数:{1}.", _roleInfo.ROLE_NAME, faces.Count);
                    }

                    this.Invoke(new Action(() =>
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "更新角色权限失败:" + ex.Message);
                    log.Error("更新角色权限失败:", ex);
                }
            });

            waiting.Show(this);
        }
Esempio n. 22
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (tbUserName.Text.Trim() == "")
            {
                MessageBox.Show("用户名不能为空!");
                return;
            }
            if (_userInfo == null)
            {
                _userInfo    = new Maticsoft.Model.SMT_USER_INFO();
                _userInfo.ID = -1;
            }
            string oldUser = _userInfo.USER_NAME;

            _userInfo.USER_NAME = tbUserName.Text.Trim();
            _userInfo.PASS_WORD = tbPwd.Text;
            if (_userInfo.PASS_WORD == "123456")
            {
                _userInfo.PASS_WORD = "e10adc3949ba59abbe56e057f20f883e";
            }
            _userInfo.REAL_NAME = tbRealName.Text.Trim();
            _userInfo.IS_ENABLE = cbEnable.Checked;
            _userInfo.TELEPHONE = tbTel.Text.Trim();
            _userInfo.ADDRESS   = tbAddress.Text.Trim();
            _userInfo.EMAIL     = tbEmail.Text.Trim();
            _userInfo.QQ        = tbQQ.Text.Trim();
            _userInfo.KEY_VAL   = "";
            _userInfo.IS_DELETE = false;
            if (cboRole.SelectedItem != null)
            {
                ComboItem cboItem = (ComboItem)cboRole.SelectedItem;
                Maticsoft.Model.SMT_ROLE_INFO roleInfo = (Maticsoft.Model.SMT_ROLE_INFO)cboItem.Tag;
                _userInfo.ROLE_ID   = roleInfo.ID;
                _userInfo.ROLE_NAME = roleInfo.ROLE_NAME;
            }
            else
            {
                _userInfo.ROLE_ID = -1;
            }
            if (cbtDept.SelectedNode != null)
            {
                Maticsoft.Model.SMT_ORG_INFO orgInfo = (Maticsoft.Model.SMT_ORG_INFO)cbtDept.SelectedNode.Tag;
                _userInfo.ORG_ID    = orgInfo.ID;
                _userInfo.DEPT_NAME = orgInfo.ORG_NAME;
            }
            else
            {
                _userInfo.ORG_ID = -1;
            }
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.SMT_USER_INFO userBll = new Maticsoft.BLL.SMT_USER_INFO();
                    if (_userInfo.ID == -1)
                    {
                        userBll.Add(_userInfo);
                        SmtLog.InfoFormat("用户", "添加用户:用户名={0},状态={1}", _userInfo.USER_NAME, _userInfo.IS_ENABLE);
                    }
                    else
                    {
                        userBll.Update(_userInfo);
                        SmtLog.InfoFormat("用户", "更新用户:用户名={0},状态={1},原始用户名={2}", _userInfo.USER_NAME, _userInfo.IS_ENABLE, oldUser);
                    }
                    this.BeginInvoke(new Action(() =>
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "保存用户异常:" + ex.Message);
                    log.Error("保存用户异常:", ex);
                }
            });

            waiting.Show(this);
        }