示例#1
0
 /// <summary>
 /// 更新车辆位置信息
 /// </summary>
 /// <param name="tid">车辆id</param>
 /// <param name="para">参数:location, speed, dir, mileage, unit, position, path</param>
 public async Task UpdateTruckState(Guid tid, string[] para)
 {
     using (TruckTraceService truckTraceService = new TruckTraceService())
     {
         var truckTrace = new TruckTrace()
         {
             truckId   = tid,
             Location  = para[0],
             Speed     = para[1],
             Direction = para[2],
             Mileage   = para[3],
             Unit      = para[4],
             Position  = para[5],
             Path      = para[6],
         };
         try
         {
             await truckTraceService.CreateAsync(truckTrace);
         }
         catch (Exception err)
         {
             throw err;
         }
     }
 }
示例#2
0
        public async Task <ActionResult> FillLocation(TruckTrace trace)
        {
            if (ModelState.IsValid)
            {
                using (TruckTraceService truckTraceService = new TruckTraceService())
                {
                    var turck = new TruckTrace()
                    {
                        truckId   = trace.truckId,
                        Location  = trace.Location,
                        Mileage   = trace.Mileage,
                        Path      = trace.Path,
                        Position  = trace.Position,
                        Speed     = trace.Speed,
                        Direction = trace.Direction,
                        Type      = true,
                        Unit      = trace.Unit
                    };
                    try
                    {
                        await truckTraceService.CreateAsync(turck);
                    }
                    catch (Exception err)
                    {
                        throw err;
                    }
                }
            }
            else
            {
            }

            return(Json(new { mess = "ok" }));
        }