/// <summary> /// 异步处理请求 /// </summary> /// <param name="request">请求消息</param> /// <param name="processCompletion">处理完成时的回调</param> /// <returns>处理任务</returns> public Task ProcessRequestAsyn(RequestDataCalcMessage request, Action <IEnumerable <RequestScoreMessage> > processCompletion) { int structId = request.StructId; DateTime collectTime = request.DateTime; this.logger.Debug(string.Format("开始处理计算请求,结构物编号:{0},采集时间:{1}", structId, collectTime)); if (string.IsNullOrEmpty(request.FilePath)) { // 查询原始数据 DataTable source = DataAccessHelper.GetOriginalData(collectTime); // 计算任务 Task task = new Task(() => { DataProcessor dataProcessor = new DataProcessor(); dataProcessor.ProcessRequest(structId, source, null); }); return(task); } else // 处理振动数据 { // 计算任务 Task task = new Task(() => { DataProcessor dataProcessor = new DataProcessor(); dataProcessor.ProcessRequest(request.FilePath, request.SensorID, request.DateTime, null); }); return(task); } }
public static RequestDataCalcMessage MakeMsgToRequestDataCalc(int project, DateTime time) { var msg = new RequestDataCalcMessage { Id = Guid.NewGuid(), StructId = project, DateTime = time, RoundNum = string.Empty }; Task task = new Task( () => { WarningThread.GetWarningThread().SendWarningProcessMessage(msg); }); task.Start(); task.ContinueWith( t => { if (t.Exception != null) { Log.Error("发送数据计算请求失败:" + t.Exception.Message, t.Exception); } else { Log.Info("发送数据计算请求成功"); } }); return(msg); }
internal static void MakeMsgToRequestDataCalc(int sensorid, string filePath, DateTime acqTime) { var msg = new RequestDataCalcMessage { Id = Guid.NewGuid(), SensorID = sensorid, DateTime = acqTime, FilePath = filePath, RoundNum = string.Empty }; System.Threading.Tasks.Task task = new System.Threading.Tasks.Task( () => { WarningThread.GetWarningThread().SendWarningProcessMessage(msg); }); task.Start(); task.ContinueWith( t => { if (t.Exception != null) { Log.Error("发送振动计算请求失败:" + t.Exception.Message, t.Exception); } else { Log.Info("发送振动计算请求成功"); } }); }
public void SendWarningProcessMessage(RequestDataCalcMessage request) { if (!isConnect) { this.Start(); } var reqWarnMsg = mdsClient.CreateMessage(); reqWarnMsg.MessageData = GeneralHelper.SerializeObject(request); reqWarnMsg.TransmitRule = MDS.Communication.Messages.MessageTransmitRules.NonPersistent; reqWarnMsg.DestinationApplicationName = WarningAppName; reqWarnMsg.Send(); log.Info("成功发送告警"); }