private TrackingData GeneratePayload(string asset, string[] fields) { TrackingData result = new TrackingData(); result.Asset = asset; result.fields = new Dictionary<string, Field>(); foreach (string field in fields) { result.fields.Add(field, new Field()); } result.location = new double[2]; return result; }
private void UpdateCache(TrackingData history, string field, ITracking data) { if (!history.fields.ContainsKey(field)) history.fields.Add(field, ((TrackingData)data).fields[field]); else history.fields[field] = ((TrackingData)data).fields[field]; }
private void FillTrackingDataUserChoice(ITracking data, TrackingData history, bool updateCache = true) { bool fixMovementValue = false; foreach (string field in _fieldsUse) { /* Fix Movement before to update data cache */ if (field == MD.CloudConnect.FieldDefinition.MVT_STATE.Key && _fixMoving) { fixMovementValue = IsInMovement(data, history); if (data.ContainsField(MD.CloudConnect.FieldDefinition.MVT_STATE.Key)) data.IsMoving = fixMovementValue; else if (history.ContainsField(MD.CloudConnect.FieldDefinition.MVT_STATE.Key)) history.IsMoving = fixMovementValue; } /* End Fix Movement*/ if (data.ContainsField(field)) { if (updateCache) { UpdateCache(history, field, data); } } else { if (history.fields.ContainsKey(field)) ((TrackingData)data).fields.Add(field, history.fields[field]); else ((TrackingData)data).fields.Add(field, new Field()); } } if (((TrackingData)data).location == null) { ((TrackingData)data).location = (double[])history.location.Clone(); } else { history.location[0] = data.Longitude; history.location[1] = data.Latitude; } }