1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using GDNXFD.Data;
- using log4net;
- namespace GDNXFD.WcfService
- {
- public class DefectBillService : IDefectBillService
- {
- ILog logger = LogManager.GetLogger("AppLog");
- public bool DefectBill(FaultInfo info, string alertText, string userName)
- {
- try
- {
- //数据格式:时间(yyyy-MM-dd hh:mm:ss)|场站ID|风机ID|故障类型|报警内容|操作员|故障编码
- //string msg = "2019-06-21 12:30:00|MHS_FDC|MG01_01|FJ|故障停机|徐瑞|5001";
- if (info == null || String.IsNullOrWhiteSpace(userName))
- return false;
- logger.Info("1");
- StringBuilder sbMsg = new StringBuilder();
- sbMsg.Append(info.AlertTime.ToString("yyyy-MM-dd hh:mm:ss"));
- logger.Info("2");
- sbMsg.Append('|');
- sbMsg.Append(info.StationId);
- sbMsg.Append('|');
- sbMsg.Append(info.WindturbineId);
- sbMsg.Append('|');
- sbMsg.Append(info.Category1);
- sbMsg.Append('|');
- sbMsg.Append(alertText);
- sbMsg.Append('|');
- sbMsg.Append(userName);
- sbMsg.Append('|');
- sbMsg.Append(info.AlertValue);
- byte[] msgB = System.Text.Encoding.UTF8.GetBytes(sbMsg.ToString());
- logger.Info(DateTime.Now.ToString() + "===接收数据" + msgB);
- System.Diagnostics.Debug.WriteLine(msgB + "===接收数据");
- SocetClient.Instance.Send(msgB);
- logger.Info(DateTime.Now.ToString()+ "===发送数据完成" + msgB );
- System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString() + "===发送数据完成" + msgB);
- }
- catch (Exception ex)
- {
- logger.Info(ex.ToString());
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- return false;
- //
- }
- return true;
- }
- }
- }
|