//命令执行前调用 public override void OnCommandExecuting(CommandExecutingContext commandContext) { try { StringRequestInfo requestInfo = (StringRequestInfo)commandContext.RequestInfo; //TODO: construct the receving casic data String deviceId = requestInfo.Parameters[3]; String pduType = requestInfo.Parameters[6]; //print the receving data String devType = new CasicCmd().getDeviceTypeByPdu(pduType); String operType = new CasicCmd().getOpeTypeByPdu(pduType); if (devType != "集中器") { Model.DeviceLogInfo1 log = new Model.DeviceLogInfo1(); log.DEVICECODE = deviceId; log.DEVTYPE = devType; log.OPERATETYPE = operType; log.LOGTIME = DateTime.Now; log.MESSAGE = operType; new BLL.DeviceLog1().insert(log); } } catch (Exception e) { ((CasicSession)commandContext.Session).Logger.Error(e.Message); } }
public void add(Model.DeviceLogInfo1 log) { try { OracleParameter[] parms = new OracleParameter[] { new OracleParameter(":DEVCODE", log.DEVICECODE), new OracleParameter(":DEVTYPE", log.DEVTYPE), new OracleParameter(":MESSAGE", log.MESSAGE), new OracleParameter(":TP", log.OPERATETYPE), new OracleParameter(":TM", log.LOGTIME) }; string SQL = "INSERT INTO ALARM_DEVICE_LOG1 (DBID,DEVICECODE,DEVICETYPE,MESSAGE,OPERATETYPE,LOGTIME) " + "VALUES" + " (SEQ_ALARM_DEVICE_LOG1_ID.NEXTVAL,:DEVCODE,:DEVTYPE,:MESSAGE,:TP,:TM)"; string strCnn = OracleHelper.ConnectionStringOrderDistributedTransaction; using (OracleConnection cnn = new OracleConnection(strCnn)) { OracleHelper.ExecuteNonQuery(cnn, CommandType.Text, SQL, parms); } } catch (Exception e) { throw e; } }
public void insert(Model.DeviceLogInfo1 log) { try { IDAL.IDeviceLog1 dal = DALFactory.DeviceLog1.Create(); dal.add(log); } catch (Exception e) { throw e; } }
protected override void OnSessionClosed(CloseReason reason) { try { Model.DeviceLogInfo1 log = new Model.DeviceLogInfo1(); log.DEVICECODE = this.hubAddr; log.DEVTYPE = "数据集中器"; log.OPERATETYPE = "下线"; log.LOGTIME = DateTime.Now; log.MESSAGE = "下线"; new BLL.DeviceLog1().insert(log); //TODO LIST:待实现 new BLL.AlarmConcentrator().setHubOffLine(this.hubAddr); } catch (Exception e) { this.Logger.Error(e.Message); } }