private BatchMsg GetBatchMsg(BatchRequest request) { m_timer_1.Start(); SendBatchMsg(request); if (batchMsg.NotOL != false) { m_timer.Stop(); return(batchMsg); } while (true) { if (batchMsg.Msg != "") { break; } Thread.Sleep(1000); if (timeDown_1) { batchMsg = new BatchMsg() { TimeOut = true }; timeDown_1 = false; break; } } m_timer_1.Stop(); return(batchMsg); }
private void BatchForData_EventHandler(object sender, BatchEventArgs e) { try { batchMsg = new BatchMsg() { Msg = e.RawData }; CBatchStruct info = e.Value; if (info == null) { return; } BatchData batchInfo = new BatchData(); batchInfo.StationId = info.StationID; if (info.StationType == EStationType.ERainFall) { batchInfo.StationType = true; } else { batchInfo.StationType = false; } this.GetBatchList.Add(batchInfo); foreach (var v in info.Datas) { BatchData dataInfo = new BatchData(); dataInfo.Time = v.Time.ToString(); dataInfo.Data = v.Data; this.GetBatchList.Add(dataInfo); } BatchData endInfo = new BatchData(); endInfo.StationId = endInfo.StationId; endInfo.End = true; this.GetBatchList.Add(endInfo); } catch (Exception exp) { Debug.WriteLine("" + exp.Message); } }
private void SendBatchMsg(BatchRequest request) { this.batchMsg = null; this.batchMsg = new BatchMsg() { }; this.batchList = new List <BatchData>(); EStationType stype = request.ReportType == true ? EStationType.ERainFall : EStationType.EHydrology; ETrans trans = request.TransType == true ? ETrans.ByDay : ETrans.ByHour; DateTime st = Convert.ToDateTime(request.StartTime); DateTime et = Convert.ToDateTime(request.EndTime); DateTime beginTime; DateTime endTime; if (trans == ETrans.ByHour) { beginTime = new DateTime( year: st.Year, month: st.Month, day: st.Day, hour: st.Hour, minute: 0, second: 0 ); endTime = new DateTime( year: et.Year, month: et.Month, day: et.Day, hour: et.Hour, minute: 0, second: 0 ); } else { beginTime = new DateTime( year: st.Year, month: st.Month, day: st.Day, hour: 8, minute: 0, second: 0 ); endTime = new DateTime( year: st.Year, month: et.Month, day: et.Day, hour: 8, minute: 0, second: 0 ); } string query = string.Empty; var gprs = CPortDataMgr.Instance.FindGprsByUserid(request.Gprsid); if (gprs != null) { uint dtuID = 0; if (gprs.FindByID(request.Gprsid, out dtuID)) { query = gprs.FlashBatch.BuildQuery(request.StationId, stype, trans, beginTime, endTime, EChannelType.GPRS); gprs.SendDataTwiceForBatchTrans(dtuID, query); } } else { batchMsg = new BatchMsg() { NotOL = true }; BatchData error = new BatchData(); error.StationId = request.StationId; error.NotOL = true; this.batchList.Add(error); BatchData endInfo = new BatchData(); endInfo.StationId = endInfo.StationId; endInfo.End = true; this.batchList.Add(endInfo); } }