public static List <OnTimeEntity> GetReadDatas(int uId, List <string> stationList, string trans) { ReadDatas rDatas = new ReadDatas(); //储出返回的信息 List <OnTimeEntity> onTimeList = new List <OnTimeEntity>(); var options = new List <ChannelOption> { new ChannelOption(ChannelOptions.MaxReceiveMessageLength, int.MaxValue) }; var channel = new Channel(Conf.Config.DB_SERVER_IP, ChannelCredentials.Insecure, options); var client = new BatchService(new gRPCServices.gRPCServicesClient(channel)); rDatas = client.GetReadMsg(stationList, trans); //初始话站点信息 if (StationHelper.stationInfoList == null || StationHelper.stationInfoList.Count == 0) { StationHelper.getStationInfoList(); } for (int i = 0; i < rDatas.RData.Count; i++) { string id = rDatas.RData[i].StationId; //获取雨量精度 //double accuracy = StationHelper.stationInfoDic4[id]. double accuracy = 0.5; string state = "-"; if (rDatas.RData[i].Data != null && rDatas.RData[i].Data.Length > 0) { int rawData = int.Parse(rDatas.RData[i].Data); double totalRain = rawData * accuracy; state = totalRain.ToString(); } else { state = "获取失败"; } onTimeList.Add(new OnTimeEntity { id = id, stationId = StationHelper.stationInfoDic4[id].stationId, stationName = StationHelper.stationInfoDic4[id].stationName, state = state }); } channel.ShutdownAsync().Wait(); client.StopGrpcClient(); return(onTimeList); }
public static List <OnTimeEntity> GetTruList(int uId, List <string> stationList) { TruList tList = new TruList(); List <OnTimeEntity> onTimeList = new List <OnTimeEntity>(); var options = new List <ChannelOption> { new ChannelOption(ChannelOptions.MaxReceiveMessageLength, int.MaxValue) }; var channel = new Channel(Conf.Config.DB_SERVER_IP, ChannelCredentials.Insecure, options); var client = new BatchService(new gRPCServices.gRPCServicesClient(channel)); tList = client.GetTruMsg(stationList); if (StationHelper.stationInfoList == null || StationHelper.stationInfoList.Count == 0) { StationHelper.getStationInfoList(); } for (int i = 0; i < tList.TruData.Count; i++) { string id = tList.TruData[i].StationId; string state = "正在对时"; bool tru = false; if (tList.TruData[i].Tru == true) { tru = tList.TruData[i].Tru; } if (tru) { state = "√"; } else { state = "对时失败"; } onTimeList.Add(new OnTimeEntity { id = id, stationId = StationHelper.stationInfoDic4[id].stationId, stationName = StationHelper.stationInfoDic4[id].stationName, state = state }); } channel.ShutdownAsync().Wait(); client.StopGrpcClient(); return(onTimeList); }
//private BatchService StartClient() //{ // Channel channel = new Channel(Conf.Config.DB_SERVER_IP, ChannelCredentials.Insecure); // BatchService client = new BatchService(new gRPCServices.gRPCServicesClient(channel)); // clientExisting = true; // return client; //} public static BatchList GetBatchList(int uID, string sID, bool rtype, bool trans, string stime, string etime) { BatchList batch = new BatchList(); string gprs = StationService.GetHydroStationById(sID).Gprs; var options = new List <ChannelOption> { new ChannelOption(ChannelOptions.MaxReceiveMessageLength, int.MaxValue) }; var channel = new Channel(Conf.Config.DB_SERVER_IP, ChannelCredentials.Insecure, options); var client = new BatchService(new gRPCServices.gRPCServicesClient(channel)); batch = client.GetBatchMag(uID, sID, rtype, trans, stime, etime, gprs); channel.ShutdownAsync().Wait(); client.StopGrpcClient(); return(batch); }