protected void InsertBadReCordInfo(string strAlarmType, string strCarNo, string strDecript) { if (InsertState == 0) { #region 报警实体类 CoalTraffic.Model.TT_BadRecord modelBad = new CoalTraffic.Model.TT_BadRecord(); modelBad.AlarmType = strAlarmType; modelBad.BreakDate = DateTime.Now; modelBad.CarNo = strCarNo; modelBad.CollCode = ""; modelBad.Decript = ""; modelBad.NavicertCode = strNavicertCode; modelBad.RecordID = Guid.NewGuid().ToString().Replace("-", ""); modelBad.RoomCode = strRoomCode; modelBad.FrontImage = ""; modelBad.FrontImageContent = null; modelBad.RoomImage = ""; modelBad.RoomImageContent = null; modelBad.UpImage = ""; modelBad.UpImageContent = null; modelBad.BackImage = ""; modelBad.BackImageContent = null; #endregion #region 数据同步 MSMQClient MC = new MSMQClient(); StringBuilder sbInsertBR = new StringBuilder(); sbInsertBR.Append("PT_BadRecord '" + modelBad.RecordID + "','" + modelBad.NavicertCode + "','" + modelBad.RoomCode + "','" + modelBad.CarNo + "','" + modelBad.Decript + "',"); sbInsertBR.Append("'" + modelBad.BreakDate + "','" + modelBad.AlarmType + "','" + modelBad.AlarmStatus + "','" + modelBad.CollCode + "','" + modelBad.FrontImage + "',"); sbInsertBR.Append("'" + modelBad.FrontImageContent + "','" + modelBad.BackImage + "','" + modelBad.BackImageContent + "','" + modelBad.UpImage + "',"); sbInsertBR.Append("'" + modelBad.UpImageContent + "','" + modelBad.RoomImage + "','" + modelBad.RoomImageContent + "'"); MC.AddNewSqlText(sbInsertBR.ToString()); #endregion string strRecordID = new CoalTraffic.BLL.TT_BadRecord().Add(modelBad); //添加违规记录成功,上传违规记录到服务器 if (strRecordID != "") { InsertState = 0; } else { alarmSound.Alarm("该站的数据库异常"); InsertBadReCordInfo("异常", "", ini.IniReadValue("RoomSetting", "RoomName") + "的数据库异常"); InsertState = 0; } } }
private void btnOK_Click(object sender, EventArgs e) { CoalTraffic.BLL.TT_CheckBang bllCheckBang = new CoalTraffic.BLL.TT_CheckBang(); CoalTraffic.Model.TT_CheckBang modelCheckBang = new CoalTraffic.Model.TT_CheckBang(); decimal DNetWeight = 0.00m; if (strCurrentMenu != "Person") { DNetWeight = Convert.ToDecimal(Convert.ToDecimal(lblDigital.Text.Trim()) - Convert.ToDecimal(lblEmptyWeight.Text)); } else { #region 验证数据的正确性 if (txtHandDigital.Text.Trim() != "" && CommonMethod.IsDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim()))) { if (Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) < Convert.ToDecimal(lblDigital.Text.Trim())) { alSound.Alarm("你输入的重车重量不能小于磅秤重量"); txtHandDigital.Text = ""; return; } else { DNetWeight = Convert.ToDecimal(CommonMethod.ToDBC(this.txtHandDigital.Text.Trim())) - Convert.ToDecimal(lblEmptyWeight.Text.Trim()); } } else { alSound.Alarm("你输入的重车重量格式不对"); txtHandDigital.Text = ""; return; } #endregion } if (DNetWeight > 0.00m) { modelCheckBang.RoomCode = strRoomCode; #region 散煤车验票 bool bolChecked = bllCheckBang.IsChecked(strTrafficCode, modelCheckBang.RoomCode); if (bolChecked) { modelCheckBang.CheckResult = "散煤验票不通过,该过磅单在本磅房中已检验过"; modelCheckBang.IsPassed = "0"; } else { if (this.txtRandCode.Text.Trim() != strRandomCode && iCount < iTryAgainTime) { //CommonMethod.MessageBox("您输入的验证码不正确,请重新输入,您还有" + (iTryAgainTime - iCount) + "次输入机会", MessageBoxButtons.OK, MessageBoxIcon.Error); alSound.Alarm("您输入的验证码不正确,请重新输入,您还有" + (iTryAgainTime - iCount) + "次输入机会"); txtRandCode.Text = ""; btnOK.Enabled = false; iCount++; return; } else if (this.txtRandCode.Text.Trim() != strRandomCode && iCount == iTryAgainTime) { modelCheckBang.CheckResult = "散煤验票不通过,过磅单可能造假"; //验票结果:通过 or 不通过 modelCheckBang.IsPassed = "0"; } else if (this.txtRandCode.Text.Trim() == strRandomCode) { modelCheckBang.CheckResult = "散煤验票通过"; modelCheckBang.IsPassed = "1"; } } #endregion #region 视频截图 if (StaticParameter.IsVideo == "1") { if (byteFrontImage == null && byteBackImage == null && byteUpImage == null && byteRoomImage == null) { strFrontImage = Guid.NewGuid().ToString().Replace("-", ""); strBackImage = Guid.NewGuid().ToString().Replace("-", ""); strUpImage = Guid.NewGuid().ToString().Replace("-", ""); strRoomImage = Guid.NewGuid().ToString().Replace("-", ""); byteFrontImage = this.videoFrontImage.CapturePic(); byteBackImage = this.videoBackImage.CapturePic(); byteUpImage = this.videoUpImage.CapturePic(); byteRoomImage = this.videoRoomImage.CapturePic(); } } #endregion Model.TT_LoadWeight MLW = new CoalTraffic.Model.TT_LoadWeight(); BLL.TT_LoadWeight BLW = new CoalTraffic.BLL.TT_LoadWeight(); Model.TT_BadRecord MBR = new CoalTraffic.Model.TT_BadRecord(); BLL.TT_BadRecord BBR = new CoalTraffic.BLL.TT_BadRecord(); decimal dOverWeight = 0.0m; decimal DLimitWeight = 0.0m; #region 实例化检票 modelCheckBang.CheckCode = Guid.NewGuid().ToString().Replace("-", ""); modelCheckBang.CheckTime = DateTime.Now; modelCheckBang.Operator = StaticParameter.UserName; modelCheckBang.MarkedCardCode = ""; modelCheckBang.NavicertCode = ""; modelCheckBang.NetWeight = DNetWeight; modelCheckBang.WeightCode = strTrafficCode; modelCheckBang.FrontImage = strFrontImage; modelCheckBang.BackImage = strBackImage; modelCheckBang.UpImage = strUpImage; modelCheckBang.RoomImage = strRoomImage; modelCheckBang.FrontImageContent = byteFrontImage; modelCheckBang.BackImageContent = byteBackImage; modelCheckBang.UpImageContent = byteUpImage; modelCheckBang.RoomImageContent = byteRoomImage; #endregion if (modelCheckBang.IsPassed == "0") { InsertBadReCordInfo("不通过", txtCarNo.Text.Trim(), modelCheckBang.CheckResult); } else { #region 获取最大重车重量 string strsql = "select max(LoadWeight) from TT_LoadWeight where TrafficCode ='" + strTrafficCode + "'"; object OMLoadWeight = DbHelperSQL.GetSingle(strsql); if (strCurrentMenu != "Person") { dOverWeight = decimal.Parse(lblDigital.Text.Trim()) - decimal.Parse(OMLoadWeight.ToString()); } else { dOverWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) - Convert.ToDecimal(OMLoadWeight.ToString()); } DLimitWeight = StaticParameter.WeightThreshold; #endregion if (dOverWeight >= DLimitWeight) { #region 超重时的实例化 if (dOverWeight >= DLimitWeight) { #region 实例化重车过磅 string strWeightCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss"); MLW.WeightCode = strWeightCode; MLW.TrafficCode = strTrafficCode; MLW.NavicertCode = ""; MLW.MarkedCardCode = ""; MLW.RemoteCardCode = ""; MLW.CollCode = strCollCode; MLW.CollName = strCollName; MLW.CoalKindCode = strCoalKindCode; MLW.CoalKindName = strCoalKindName; MLW.CarOwnerName = ""; MLW.CarNo = txtCarNo.Text; MLW.CarType = ""; if (strCurrentMenu != "Person") { MLW.LoadWeight = decimal.Parse(lblDigital.Text.Trim()); } else { MLW.LoadWeight = Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())); } MLW.EmptyWeight = decimal.Parse(lblEmptyWeight.Text.Trim()); MLW.NetWeight = 0.0m; MLW.OverWeight = decimal.Parse(dOverWeight.ToString()); MLW.RoomCode = strRoomCode; MLW.RoomName = strRoomName; MLW.BangType = "散煤" + strBangType + "验票"; MLW.Operator = StaticParameter.UserName; MLW.WeightTime = DateTime.Now; MLW.RandomCode = CommonMethod.getRandom(4); MLW.CustomerName = "运煤去向"; MLW.TaxType = "散煤补扣税费"; MLW.IsFirstSite = "0"; MLW.FrontImage = Guid.NewGuid().ToString().Replace("-", ""); MLW.BackImage = Guid.NewGuid().ToString().Replace("-", ""); MLW.UpImage = Guid.NewGuid().ToString().Replace("-", ""); MLW.RoomImage = Guid.NewGuid().ToString().Replace("-", ""); MLW.FrontImageContent = byteFrontImage; MLW.BackImageContent = byteBackImage; MLW.UpImageContent = byteUpImage; MLW.RoomImageContent = byteRoomImage; MLW.TaxObject = ConfigurationManager.AppSettings["TaxObject"].ToString(); MLW.EmptyCode = strEmptyCode; #endregion } #endregion } } bool ISSound = false; bool IsLoadWeight = true; string isConnection = ini.IniReadValue("Connection", "isConnection"); //MSMQClient MC = new MSMQClient(); if ((dOverWeight >= DLimitWeight) && (dOverWeight != 0.0m)) { #region 添加重车过磅记录 if (BLW.Add(MLW) != "") { ISSound = true; if (BLW.Add(MLW) != "-1") { #region 数据上传 string strSql = "PT_LoadWeight '" + MLW.WeightCode + "','" + MLW.TrafficCode + "','" + MLW.NavicertCode + "','" + MLW.MarkedCardCode + "','" + MLW.RemoteCardCode + "'," + "'" + MLW.CollCode + "','" + MLW.CollName + "','" + MLW.CoalKindCode + "','" + MLW.CoalKindName + "','" + MLW.CarOwnerName + "'," + "'" + MLW.CarNo + "','" + MLW.CarType + "','" + MLW.LoadWeight + "','" + MLW.EmptyWeight + "','" + MLW.NetWeight + "'," + "'" + MLW.OverWeight + "','" + MLW.RoomCode + "','" + MLW.RoomName + "','" + MLW.BangType + "','" + MLW.Operator + "'," + "'" + MLW.WeightTime + "','" + MLW.RandomCode + "','" + MLW.CustomerName + "','" + MLW.TaxType + "','" + MLW.TaxObject + "'," + "'" + MLW.IsFirstSite + "','" + MLW.FrontImage + "','" + MLW.BackImage + "','" + MLW.UpImage + "','" + MLW.RoomImage + "'," + "null,null,null,null,'" + MLW.EmptyCode + "'"; if (isConnection == "0") { mqServer.AddMsmq(MC.AllStation + MC.Prefix + "TT_LoadWeight" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + strSql); } else { MC.AddNewSqlText(MC.AllStation + MC.Prefix + "TT_LoadWeight" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + strSql); } //发送图片 string strIsSendPicToRoom = StaticParameter.IsSendPicToRoom; int iSend = MC.ServerStation; //是否发送磅房 if (strIsSendPicToRoom == "1") iSend = MC.CheckStation; string strPic = ""; if (MLW.FrontImageContent != null) { strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + MLW.FrontImage + ",jpg," + Convert.ToBase64String(MLW.FrontImageContent, 0, MLW.FrontImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic); } else { MC.AddNewSqlText(strPic); } } if (MLW.BackImageContent != null) { strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + MLW.BackImage + ",jpg," + Convert.ToBase64String(MLW.BackImageContent, 0, MLW.BackImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic); } else { MC.AddNewSqlText(strPic); } } if (MLW.UpImageContent != null) { strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + MLW.UpImage + ",jpg," + Convert.ToBase64String(MLW.UpImageContent, 0, MLW.UpImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic); } else { MC.AddNewSqlText(strPic); } } if (MLW.RoomImageContent != null) { strPic = iSend + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + MLW.RoomImage + ",jpg," + Convert.ToBase64String(MLW.RoomImageContent, 0, MLW.RoomImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic); } else { MC.AddNewSqlText(strPic); } } //try //{ // CoalTraffic.MessagingService.LocalWeightServiceClient Loalclient = new CoalTraffic.MessagingService.LocalWeightServiceClient(); // Loalclient.AddLoadWeight(MLW); //} //catch //{ } #endregion alSound.Alarm("散煤验票过磅通过,点击确定打印散煤验票过磅单"); CommonMethod.MessageBox("散煤过磅验票通过,点击确定打印散煤验票过磅单!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); string strFileName = ""; if (StaticParameter.ReportFile == "FuYuan.") { strFileName = "ZiChang."; } else { strFileName = StaticParameter.ReportFile; } Type type = assembly.GetType("CoalTraffic.Report." + strFileName + "CheckSpreadWeightPrint"); object obj = Activator.CreateInstance(type, MLW.WeightCode, false); Form formToShow = (Form)obj; formToShow.ShowDialog(); IsLoadWeight = true; } else { alSound.Alarm("账户余额已不足本车的扣款,请通知" + txtCollName.Text.Trim() + "速来交费"); IsLoadWeight = false; } } else { if (isConnection == "0") { //ini.IniWriteValue("Connection", "isConnection", CommonMethod.ToDBC("1")); MessageBox.Show("系统与服务器断开连接,请联系中心机房!"); Application.ExitThread(); Application.Exit(); } else { this.alSound.Alarm("该站的数据库异常"); InsertState = 0; InsertBadReCordInfo("异常", txtCarNo.Text.Trim(), strRoomName + "的数据库异常"); } } #endregion } #region 添加验票信息 if (IsLoadWeight) { if (bllCheckBang.Add(modelCheckBang) != "") { #region 数据上传 StringBuilder sbInsertCheckBang = new StringBuilder(); sbInsertCheckBang.Append("PT_CheckBang '" + modelCheckBang.CheckCode + "','" + modelCheckBang.WeightCode + "','" + modelCheckBang.NavicertCode + "',"); sbInsertCheckBang.Append("'" + modelCheckBang.MarkedCardCode + "','" + modelCheckBang.NetWeight + "','" + modelCheckBang.RoomCode + "',"); sbInsertCheckBang.Append("'" + modelCheckBang.IsPassed + "','" + modelCheckBang.CheckResult + "','" + modelCheckBang.CheckTime + "',"); sbInsertCheckBang.Append("'" + modelCheckBang.Operator + "','" + modelCheckBang.FrontImage + "',null,"); sbInsertCheckBang.Append("'" + modelCheckBang.BackImage + "',null,"); sbInsertCheckBang.Append("'" + modelCheckBang.UpImage + "',null,'" + modelCheckBang.RoomImage + "',null"); if (isConnection == "0") { mqServer.AddMsmq(MC.AllStation + MC.Prefix + "TT_CheckBang" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + sbInsertCheckBang.ToString()); } else { MC.AddNewSqlText(MC.AllStation + MC.Prefix + "TT_CheckBang" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + sbInsertCheckBang.ToString()); } //发送图片 string strIsSendPicTo = StaticParameter.IsSendPicToRoom; int iSend1 = MC.ServerStation; //是否发送磅房 if (strIsSendPicTo == "1") iSend1 = MC.AllStation; string strPic1 = ""; if (modelCheckBang.FrontImageContent != null) { strPic1 = iSend1 + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + modelCheckBang.FrontImage + ",jpg," + Convert.ToBase64String(modelCheckBang.FrontImageContent, 0, modelCheckBang.FrontImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic1); } else { MC.AddNewSqlText(strPic1); } } if (modelCheckBang.BackImageContent != null) { strPic1 = iSend1 + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + modelCheckBang.BackImage + ",jpg," + Convert.ToBase64String(modelCheckBang.BackImageContent, 0, modelCheckBang.BackImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic1); } else { MC.AddNewSqlText(strPic1); } } if (modelCheckBang.UpImageContent != null) { strPic1 = iSend1 + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + modelCheckBang.UpImage + ",jpg," + Convert.ToBase64String(modelCheckBang.UpImageContent, 0, modelCheckBang.UpImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic1); } else { MC.AddNewSqlText(strPic1); } } if (modelCheckBang.RoomImageContent != null) { strPic1 = iSend1 + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + modelCheckBang.RoomImage + ",jpg," + Convert.ToBase64String(modelCheckBang.RoomImageContent, 0, modelCheckBang.RoomImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic1); } else { MC.AddNewSqlText(strPic1); } } #endregion if (!ISSound) { alSound.Alarm(modelCheckBang.CheckResult); } } else { if (isConnection == "0") { //ini.IniWriteValue("Connection", "isConnection", CommonMethod.ToDBC("1")); //MessageBox.Show("系统与服务器断开连接,请重新登陆系统!"); MessageBox.Show("系统与服务器断开连接,请联系中心机房!"); Application.ExitThread(); Application.Exit(); } else { alSound.Alarm("该站的数据库异常"); InsertState = 0; InsertBadReCordInfo("异常", txtCarNo.Text.Trim(), strRoomName + "的数据库异常"); } } } #endregion ClearAllControl(); } else { alSound.Alarm("煤炭净重异常"); InsertState = 0; InsertBadReCordInfo("异常", txtCarNo.Text.Trim(), "车牌号为:" + txtCarNo.Text.Trim() + "车辆的煤炭净重异常"); } }
protected void InsertBadReCordInfo(string strAlarmType, string strCarNo, string strDecript) { string isConnection = ini.IniReadValue("Connection", "isConnection"); if (InsertState == 0) { #region 报警实体类 CoalTraffic.Model.TT_BadRecord modelBad = new CoalTraffic.Model.TT_BadRecord(); modelBad.AlarmType = strAlarmType; modelBad.BreakDate = DateTime.Now; modelBad.CarNo = strCarNo; modelBad.CollCode = ""; modelBad.Decript = ""; modelBad.NavicertCode = strNavicertCode; modelBad.RecordID = Guid.NewGuid().ToString().Replace("-", ""); modelBad.RoomCode = strRoomCode; if (strIsVideo == "1") { modelBad.FrontImage = Guid.NewGuid().ToString().Replace("-", ""); modelBad.FrontImageContent = ((DHVideo)Form1.PF.Controls["videoFrontImage"]).CapturePic(); modelBad.RoomImage = Guid.NewGuid().ToString().Replace("-", ""); modelBad.RoomImageContent = ((DHVideo)Form1.PF.Controls["videoRoomImage"]).CapturePic(); modelBad.UpImage = Guid.NewGuid().ToString().Replace("-", ""); modelBad.UpImageContent = ((DHVideo)Form1.PF.Controls["videoUpImage"]).CapturePic(); modelBad.BackImage = Guid.NewGuid().ToString().Replace("-", ""); modelBad.BackImageContent = ((DHVideo)Form1.PF.Controls["videoBackImage"]).CapturePic(); } else { modelBad.FrontImage = ""; modelBad.FrontImageContent = null; modelBad.RoomImage = ""; modelBad.RoomImageContent = null; modelBad.UpImage = ""; modelBad.UpImageContent = null; modelBad.BackImage = ""; modelBad.BackImageContent = null; } #endregion #region 数据同步 //MSMQClient MC = new MSMQClient(); StringBuilder sbInsertBR = new StringBuilder(); sbInsertBR.Append("PT_BadRecord '" + modelBad.RecordID + "','" + modelBad.NavicertCode + "','" + modelBad.RoomCode + "','" + modelBad.CarNo + "','" + modelBad.Decript + "',"); sbInsertBR.Append("'" + modelBad.BreakDate + "','" + modelBad.AlarmType + "','" + modelBad.AlarmStatus + "','" + modelBad.CollCode + "','" + modelBad.FrontImage + "',"); sbInsertBR.Append("'" + modelBad.FrontImageContent + "','" + modelBad.BackImage + "','" + modelBad.BackImageContent + "','" + modelBad.UpImage + "',"); sbInsertBR.Append("'" + modelBad.UpImageContent + "','" + modelBad.RoomImage + "','" + modelBad.RoomImageContent + "'"); if (isConnection == "0") { mqServer.AddMsmq(sbInsertBR.ToString()); } else { MC.AddNewSqlText(sbInsertBR.ToString()); } #endregion string strRecordID = new CoalTraffic.BLL.TT_BadRecord().Add(modelBad); //添加违规记录成功,上传违规记录到服务器 if (strRecordID != "") { InsertState = 0; } else { if (isConnection == "0") { //ini.IniWriteValue("Connection", "isConnection", CommonMethod.ToDBC("1")); //MessageBox.Show("系统与服务器断开连接,请重新登陆系统!"); MessageBox.Show("系统与服务器断开连接,请联系中心机房!"); Application.ExitThread(); Application.Exit(); } else { alSound.Alarm("该站的数据库异常"); InsertBadReCordInfo("异常", "", ini.IniReadValue("RoomSetting", "RoomName") + "的数据库异常"); InsertState = 0; } } } }
protected void InsertBadReCordInfo(string strAlarmType, string strCarNo, string strDecript) { if (InsertState == 0) { #region 报警实体类 CoalTraffic.Model.TT_BadRecord modelBad = new CoalTraffic.Model.TT_BadRecord(); modelBad.AlarmType = strAlarmType; modelBad.BreakDate = DateTime.Now; modelBad.CarNo = strCarNo; modelBad.CollCode = strCollCode; modelBad.Decript = strDecript; modelBad.NavicertCode = ""; modelBad.RecordID = Guid.NewGuid().ToString().Replace("-", ""); modelBad.RoomCode = strRoomCode; if (StaticParameter.IsVideo == "1") { if (byteFrontImage == null && byteBackImage == null && byteUpImage == null && byteRoomImage == null) { strFrontImage = Guid.NewGuid().ToString().Replace("-", ""); strBackImage = Guid.NewGuid().ToString().Replace("-", ""); strUpImage = Guid.NewGuid().ToString().Replace("-", ""); strRoomImage = Guid.NewGuid().ToString().Replace("-", ""); byteFrontImage = this.videoFrontImage.CapturePic(); byteBackImage = this.videoBackImage.CapturePic(); byteUpImage = this.videoUpImage.CapturePic(); byteRoomImage = this.videoRoomImage.CapturePic(); } modelBad.FrontImage = strFrontImage; modelBad.FrontImageContent = byteFrontImage; modelBad.RoomImage = strRoomImage; modelBad.RoomImageContent = byteRoomImage; modelBad.UpImage = strUpImage; modelBad.UpImageContent = byteUpImage; modelBad.BackImage = strBackImage; modelBad.BackImageContent = byteBackImage; } else { modelBad.FrontImage = ""; modelBad.FrontImageContent = null; modelBad.RoomImage = ""; modelBad.RoomImageContent = null; modelBad.UpImage = ""; modelBad.UpImageContent = null; modelBad.BackImage = ""; modelBad.BackImageContent = null; } #endregion #region 数据同步 //MSMQClient MC = new MSMQClient(); string isConnection = ini.IniReadValue("Connection", "isConnection"); StringBuilder sbInsertBR = new StringBuilder(); sbInsertBR.Append("PT_BadRecord '" + modelBad.RecordID + "','" + modelBad.NavicertCode + "','" + modelBad.RoomCode + "','" + modelBad.CarNo + "','" + modelBad.Decript + "',"); sbInsertBR.Append("'" + modelBad.BreakDate + "','" + modelBad.AlarmType + "','" + modelBad.AlarmStatus + "','" + modelBad.CollCode + "','" + modelBad.FrontImage + "',"); sbInsertBR.Append("null,'" + modelBad.BackImage + "',null,'" + modelBad.UpImage + "',"); sbInsertBR.Append("null,'" + modelBad.RoomImage + "',null"); if (isConnection == "0") { mqServer.AddMsmq(MC.ServerStation + MC.Prefix + "TT_BadRecord" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + sbInsertBR.ToString()); } else { MC.AddNewSqlText(MC.ServerStation + MC.Prefix + "TT_BadRecord" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + sbInsertBR.ToString()); } //发送图片 string strIsSendPicTo = StaticParameter.IsSendPicToRoom; int iSend1 = MC.ServerStation; string strPic1 = ""; if (modelBad.FrontImageContent != null) { strPic1 = iSend1 + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + modelBad.FrontImage + ",jpg," + Convert.ToBase64String(modelBad.FrontImageContent, 0, modelBad.FrontImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic1); } else { MC.AddNewSqlText(strPic1); } } if (modelBad.BackImageContent != null) { strPic1 = iSend1 + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + modelBad.BackImage + ",jpg," + Convert.ToBase64String(modelBad.BackImageContent, 0, modelBad.BackImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic1); } else { MC.AddNewSqlText(strPic1); } } if (modelBad.UpImageContent != null) { strPic1 = iSend1 + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + modelBad.UpImage + ",jpg," + Convert.ToBase64String(modelBad.UpImageContent, 0, modelBad.UpImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic1); } else { MC.AddNewSqlText(strPic1); } } if (modelBad.RoomImageContent != null) { strPic1 = iSend1 + MC.Prefix + "Sys_FileSave" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + modelBad.RoomImage + ",jpg," + Convert.ToBase64String(modelBad.RoomImageContent, 0, modelBad.RoomImageContent.Length); if (isConnection == "0") { mqServer.AddMsmq(strPic1); } else { MC.AddNewSqlText(strPic1); } } #endregion string strRecordID = new CoalTraffic.BLL.TT_BadRecord().Add(modelBad); //添加违规记录成功,上传违规记录到服务器 if (strRecordID != "") { InsertState = 0; } else { if (isConnection == "0") { //ini.IniWriteValue("Connection", "isConnection", CommonMethod.ToDBC("1")); //MessageBox.Show("系统与服务器断开连接,请重新登陆系统!"); MessageBox.Show("系统与服务器断开连接,请联系中心机房!"); Application.ExitThread(); Application.Exit(); } else { alSound.Alarm("该站的数据库异常"); InsertState = 1; InsertBadReCordInfo("异常", "", strRoomName + "的数据库异常"); } } } }
protected void InsertBadReCordInfo(string strAlarmType, string strCarNo, string strDecript) { if (InsertState == 0) { #region ����ʵ���� CoalTraffic.Model.TT_BadRecord modelBad = new CoalTraffic.Model.TT_BadRecord(); modelBad.AlarmType = strAlarmType; modelBad.BreakDate = DateTime.Now; modelBad.CarNo = strCarNo; modelBad.CollCode = strCollCode; modelBad.Decript = strDecript; modelBad.NavicertCode = strNavicertCode; modelBad.RecordID = Guid.NewGuid().ToString().Replace("-", ""); modelBad.RoomCode = strRoomCode; if (strIsVideo == "1") { modelBad.FrontImage = Guid.NewGuid().ToString().Replace("-", ""); modelBad.FrontImageContent = ((DHVideo)Form1.PF.Controls["videoFrontImage"]).CapturePic(); modelBad.RoomImage = Guid.NewGuid().ToString().Replace("-", ""); modelBad.RoomImageContent = ((DHVideo)Form1.PF.Controls["videoRoomImage"]).CapturePic(); modelBad.UpImage = Guid.NewGuid().ToString().Replace("-", ""); modelBad.UpImageContent = ((DHVideo)Form1.PF.Controls["videoUpImage"]).CapturePic(); modelBad.BackImage = Guid.NewGuid().ToString().Replace("-", ""); modelBad.BackImageContent = ((DHVideo)Form1.PF.Controls["videoBackImage"]).CapturePic(); } else { modelBad.FrontImage = ""; modelBad.FrontImageContent = null; modelBad.RoomImage = ""; modelBad.RoomImageContent = null; modelBad.UpImage = ""; modelBad.UpImageContent = null; modelBad.BackImage = ""; modelBad.BackImageContent = null; } #endregion #region ����ͬ�� //MSMQClient MC = new MSMQClient(); StringBuilder sbInsertBR = new StringBuilder(); sbInsertBR.Append("PT_BadRecord '" + modelBad.RecordID + "','" + modelBad.NavicertCode + "','" + modelBad.RoomCode + "','" + modelBad.CarNo + "','" + modelBad.Decript + "',"); sbInsertBR.Append("'" + modelBad.BreakDate + "','" + modelBad.AlarmType + "','" + modelBad.AlarmStatus + "','" + modelBad.CollCode + "','" + modelBad.FrontImage + "',"); sbInsertBR.Append("'" + modelBad.FrontImageContent + "','" + modelBad.BackImage + "','" + modelBad.BackImageContent + "','" + modelBad.UpImage + "',"); sbInsertBR.Append("'" + modelBad.UpImageContent + "','" + modelBad.RoomImage + "','" + modelBad.RoomImageContent + "'"); MC.AddNewSqlText(MC.ServerStation + MC.Prefix + "TT_BadRecord" + MC.Prefix + MC.AddFlg + MC.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + MC.Prefix + sbInsertBR.ToString()); #endregion string strRecordID = new CoalTraffic.BLL.TT_BadRecord().Add(modelBad); //���Υ���¼�ɹ����ϴ�Υ���¼�������� if (strRecordID != "") { InsertState = 0; } else { alarmSound.Alarm("��վ�����ݿ��쳣"); InsertBadReCordInfo("�쳣", "", strRoomName + "�����ݿ��쳣"); InsertState = 0; } } }