Пример #1
0
 /// <summary>
 /// 读取记录的所有值
 /// </summary>
 /// <param name="tags"></param>
 /// <param name="starttime"></param>
 /// <param name="endTime"></param>
 /// <returns></returns>
 public Dictionary <string, HisDataValueCollection> ReadAllHisValue(List <string> tags, DateTime starttime, DateTime endTime)
 {
     if (mHisDataClient != null && !string.IsNullOrEmpty(mLoginId))
     {
         Dictionary <string, HisDataValueCollection> re = new Dictionary <string, HisDataValueCollection>();
         var req = new AllHisDataRequest()
         {
             StartTime = starttime.ToBinary(), EndTime = endTime.ToBinary(), Token = mLoginId
         };
         req.Tags.AddRange(tags);
         var res = mHisDataClient.GetAllHisValue(req);
         if (res.Result)
         {
             foreach (var vv in res.Values)
             {
                 HisDataValueCollection hvd = new HisDataValueCollection()
                 {
                     ValueType = vv.ValueType
                 };
                 foreach (var vvv in vv.Values)
                 {
                     hvd.Add(new HisDataValuePoint()
                     {
                         Time = DateTime.FromBinary(vvv.Time), Value = ConvertToValue(vvv.Value, vv.ValueType)
                     });
                 }
                 re.Add(vv.Tag, hvd);
             }
         }
         return(re);
     }
     return(null);
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="request"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public override Task <HisDataCollectionReplay> GetAllHisValue(AllHisDataRequest request, ServerCallContext context)
 {
     if (SecurityManager.Manager.IsLogin(request.Token))
     {
         HisDataCollectionReplay re = new HisDataCollectionReplay()
         {
             Result = true
         };
         foreach (var vv in request.Tags)
         {
             string sname = GetGroupName(vv);
             if (SecurityManager.Manager.CheckReaderPermission(request.Token, sname))
             {
                 ReadTagAllHisValue(vv, DateTime.FromBinary(request.StartTime), DateTime.FromBinary(request.EndTime), re);
             }
         }
         return(Task.FromResult(re));
     }
     else
     {
         return(Task.FromResult(new HisDataCollectionReplay()
         {
             Result = false
         }));
     }
 }