Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.SMT_ALARM_INFO model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SMT_ALARM_INFO set ");
            strSql.Append("ALARM_TYPE=@ALARM_TYPE,");
            strSql.Append("ALARM_NAME=@ALARM_NAME,");
            strSql.Append("ALARM_CONTENT=@ALARM_CONTENT,");
            strSql.Append("ALARM_TIME=@ALARM_TIME,");
            strSql.Append("RECORD_ID=@RECORD_ID,");
            strSql.Append("CARD_NO=@CARD_NO,");
            strSql.Append("CTRLR_DOOR_INDEX=@CTRLR_DOOR_INDEX,");
            strSql.Append("CTRLR_ID=@CTRLR_ID,");
            strSql.Append("DOOR_ID=@DOOR_ID,");
            strSql.Append("STAFF_ID=@STAFF_ID");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ALARM_TYPE",       SqlDbType.TinyInt,     1),
                new SqlParameter("@ALARM_NAME",       SqlDbType.NVarChar,   50),
                new SqlParameter("@ALARM_CONTENT",    SqlDbType.NVarChar,  200),
                new SqlParameter("@ALARM_TIME",       SqlDbType.DateTime),
                new SqlParameter("@RECORD_ID",        SqlDbType.Decimal,     9),
                new SqlParameter("@CARD_NO",          SqlDbType.VarChar,   100),
                new SqlParameter("@CTRLR_DOOR_INDEX", SqlDbType.TinyInt,     1),
                new SqlParameter("@CTRLR_ID",         SqlDbType.Decimal,     9),
                new SqlParameter("@DOOR_ID",          SqlDbType.Decimal,     9),
                new SqlParameter("@STAFF_ID",         SqlDbType.Decimal,     9),
                new SqlParameter("@ID",               SqlDbType.Decimal, 9)
            };
            parameters[0].Value  = model.ALARM_TYPE;
            parameters[1].Value  = model.ALARM_NAME;
            parameters[2].Value  = model.ALARM_CONTENT;
            parameters[3].Value  = model.ALARM_TIME;
            parameters[4].Value  = model.RECORD_ID;
            parameters[5].Value  = model.CARD_NO;
            parameters[6].Value  = model.CTRLR_DOOR_INDEX;
            parameters[7].Value  = model.CTRLR_ID;
            parameters[8].Value  = model.DOOR_ID;
            parameters[9].Value  = model.STAFF_ID;
            parameters[10].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.SMT_ALARM_INFO DataRowToModel(DataRow row)
 {
     Maticsoft.Model.SMT_ALARM_INFO model = new Maticsoft.Model.SMT_ALARM_INFO();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = decimal.Parse(row["ID"].ToString());
         }
         if (row["ALARM_TYPE"] != null && row["ALARM_TYPE"].ToString() != "")
         {
             model.ALARM_TYPE = int.Parse(row["ALARM_TYPE"].ToString());
         }
         if (row["ALARM_NAME"] != null)
         {
             model.ALARM_NAME = row["ALARM_NAME"].ToString();
         }
         if (row["ALARM_CONTENT"] != null)
         {
             model.ALARM_CONTENT = row["ALARM_CONTENT"].ToString();
         }
         if (row["ALARM_TIME"] != null && row["ALARM_TIME"].ToString() != "")
         {
             model.ALARM_TIME = DateTime.Parse(row["ALARM_TIME"].ToString());
         }
         if (row["RECORD_ID"] != null && row["RECORD_ID"].ToString() != "")
         {
             model.RECORD_ID = decimal.Parse(row["RECORD_ID"].ToString());
         }
         if (row["CARD_NO"] != null)
         {
             model.CARD_NO = row["CARD_NO"].ToString();
         }
         if (row["CTRLR_DOOR_INDEX"] != null && row["CTRLR_DOOR_INDEX"].ToString() != "")
         {
             model.CTRLR_DOOR_INDEX = int.Parse(row["CTRLR_DOOR_INDEX"].ToString());
         }
         if (row["CTRLR_ID"] != null && row["CTRLR_ID"].ToString() != "")
         {
             model.CTRLR_ID = decimal.Parse(row["CTRLR_ID"].ToString());
         }
         if (row["DOOR_ID"] != null && row["DOOR_ID"].ToString() != "")
         {
             model.DOOR_ID = decimal.Parse(row["DOOR_ID"].ToString());
         }
         if (row["STAFF_ID"] != null && row["STAFF_ID"].ToString() != "")
         {
             model.STAFF_ID = decimal.Parse(row["STAFF_ID"].ToString());
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(Maticsoft.Model.SMT_ALARM_INFO model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SMT_ALARM_INFO(");
            strSql.Append("ALARM_TYPE,ALARM_NAME,ALARM_CONTENT,ALARM_TIME,RECORD_ID,CARD_NO,CTRLR_DOOR_INDEX,CTRLR_ID,DOOR_ID,STAFF_ID)");
            strSql.Append(" values (");
            strSql.Append("@ALARM_TYPE,@ALARM_NAME,@ALARM_CONTENT,@ALARM_TIME,@RECORD_ID,@CARD_NO,@CTRLR_DOOR_INDEX,@CTRLR_ID,@DOOR_ID,@STAFF_ID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ALARM_TYPE",       SqlDbType.TinyInt,     1),
                new SqlParameter("@ALARM_NAME",       SqlDbType.NVarChar,   50),
                new SqlParameter("@ALARM_CONTENT",    SqlDbType.NVarChar,  200),
                new SqlParameter("@ALARM_TIME",       SqlDbType.DateTime),
                new SqlParameter("@RECORD_ID",        SqlDbType.Decimal,     9),
                new SqlParameter("@CARD_NO",          SqlDbType.VarChar,   100),
                new SqlParameter("@CTRLR_DOOR_INDEX", SqlDbType.TinyInt,     1),
                new SqlParameter("@CTRLR_ID",         SqlDbType.Decimal,     9),
                new SqlParameter("@DOOR_ID",          SqlDbType.Decimal,     9),
                new SqlParameter("@STAFF_ID",         SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.ALARM_TYPE;
            parameters[1].Value = model.ALARM_NAME;
            parameters[2].Value = model.ALARM_CONTENT;
            parameters[3].Value = model.ALARM_TIME;
            parameters[4].Value = model.RECORD_ID;
            parameters[5].Value = model.CARD_NO;
            parameters[6].Value = model.CTRLR_DOOR_INDEX;
            parameters[7].Value = model.CTRLR_ID;
            parameters[8].Value = model.DOOR_ID;
            parameters[9].Value = model.STAFF_ID;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToDecimal(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.SMT_ALARM_INFO GetModel(decimal ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,ALARM_TYPE,ALARM_NAME,ALARM_CONTENT,ALARM_TIME,RECORD_ID,CARD_NO,CTRLR_DOOR_INDEX,CTRLR_ID,DOOR_ID,STAFF_ID from SMT_ALARM_INFO ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Decimal)
            };
            parameters[0].Value = ID;

            Maticsoft.Model.SMT_ALARM_INFO model = new Maticsoft.Model.SMT_ALARM_INFO();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
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;
            }
        }