private void DoChat() { try { while (true) { requestCount++; //NetworkStream networkStream = clientSocket.GetStream(); //networkStream.Read(bytesFrom, 0, 10025); //dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom); Console.WriteLine("From GPS - " + clNo + " : " + dataFromClient); rCount = requestCount.ToString(); Console.WriteLine("GPS data: " + dataFromClient); var separate = dataFromClient.Split(':'); var parseData = separate.Last().Split(',').Length; if (parseData == 1) { Broadcast.BroadcastClientData("ON", clNo, false, clientsList); } if (parseData > 3 && dataFromClient.Contains("tracker")) { Dictionary <string, InsertionData> dataForInsertion = new Dictionary <string, InsertionData>(); List <string> parseGpsData = new List <string>(separate.Last().Split(',')); InsertionData insertionData = new InsertionData(); insertionData.mileage = (float.Parse(parseGpsData[5]) * 1.60934).ToString(); insertionData.latitude = CalculateData.DegreeToDecimal(Decimal.Parse(parseGpsData[7]), parseGpsData[8]).ToString(); insertionData.longitude = CalculateData.DegreeToDecimal(Decimal.Parse(parseGpsData[9]), parseGpsData[10]).ToString(); insertionData.speed = (float.Parse(parseGpsData[11]) * (float)1.852).ToString(); insertionData.bearing = float.Parse(parseGpsData[12]).ToString(); insertionData.fuelConsumption = float.Parse(parseGpsData[14]).ToString(); dataForInsertion.Add(clNo, insertionData); Tracking data = new Tracking() { imei = clNo, type = "tracker", journey_data = JsonConvert.SerializeObject(dataForInsertion.Values), timestamp = DateTime.Now }; using (VehicleContext _db = new VehicleContext()) { _db.Tracking.Add(data); _db.SaveChangesAsync(); //##,imei:359710048989827,A; : imei:359710048989827,tracker,161101201234,,F,191235.000,A,4515.6358,N,01949.5184,E,0.14,181.92,,0,,,,; } } } } catch (Exception ex) { Console.WriteLine(ex); } }
private InsertionData GetData(object dataAsAnonymousType) { var data = new InsertionData(); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(dataAsAnonymousType); foreach (PropertyDescriptor property in properties) { data.Add(new KeyValuePair<string, object>(property.Name, property.GetValue(dataAsAnonymousType))); } return data; }
public void InsertTest( [Values(2, 987, 100, 17, 3, 2, 1)] int length, [Values(1, 2, 2, 3, 3, 2, 16)] int rank, [Values(0, 0, 1, 2, 2, 1, 5)] int dim) { var idata = new InsertionData(length, rank, dim); var zeroIdx = IndexesHelper.Zero(idata.Rank); // Build O and A hypercubes lengths var alengths = IndexesHelper.Add(zeroIdx, idata.Length); var olengths = IndexesHelper.Multiply(alengths, 2); // Build O and A hypercubes var oarray = ArrayHelper.New().NewArray <object>(olengths).FillWith("O").As <Array>(); var aarray = ArrayHelper.New().NewArray <object>(alengths).FillWith("A").As <Array>(); // NOTE capacities are set to the minimum to force buffer resize var capacities = IndexesHelper.Add(IndexesHelper.Zero(idata.Rank), 1); var dynarray = new DynamicArray <string>(idata.Rank, capacities); dynarray.Insert(oarray, 0, zeroIdx); DynamicArrayAssert.Included(dynarray, oarray, IndexesHelper.Zero(idata.Rank)); DynamicArrayAssert.CountsEqual(dynarray, olengths); var pos = IndexesHelper.Add(alengths, -1); var expected = IndexesHelper.Clone(olengths); expected[idata.Dim] += alengths[idata.Dim]; dynarray.Insert(aarray, idata.Dim, pos); DynamicArrayAssert.CountsEqual(dynarray, expected); DynamicArrayAssert.Included(dynarray, aarray, pos); DynamicArrayAssert.Included( dynarray, oarray, IndexesHelper.Add(pos, alengths), idata.Rank > 1 ? IndexesHelper.Add(pos, alengths) : pos, olengths); }
public void InsertTest( [Values(2, 987, 100, 17, 3, 2, 1)]int length, [Values(1, 2, 2, 3, 3, 2, 16)] int rank, [Values(0, 0, 1, 2, 2, 1, 5)] int dim) { var idata = new InsertionData(length, rank, dim); var zeroIdx = IndexesHelper.Zero(idata.Rank); // Build O and A hypercubes lengths var alengths = IndexesHelper.Add(zeroIdx, idata.Length); var olengths = IndexesHelper.Multiply(alengths, 2); // Build O and A hypercubes var oarray = ArrayHelper.New().NewArray<object>(olengths).FillWith("O").As<Array>(); var aarray = ArrayHelper.New().NewArray<object>(alengths).FillWith("A").As<Array>(); // NOTE capacities are set to the minimum to force buffer resize var capacities = IndexesHelper.Add(IndexesHelper.Zero(idata.Rank), 1); var dynarray = new DynamicArray<string>(idata.Rank, capacities); dynarray.Insert(oarray, 0, zeroIdx); DynamicArrayAssert.Included(dynarray, oarray, IndexesHelper.Zero(idata.Rank)); DynamicArrayAssert.CountsEqual(dynarray, olengths); var pos = IndexesHelper.Add(alengths, -1); var expected = IndexesHelper.Clone(olengths); expected[idata.Dim] += alengths[idata.Dim]; dynarray.Insert(aarray, idata.Dim, pos); DynamicArrayAssert.CountsEqual(dynarray, expected); DynamicArrayAssert.Included(dynarray, aarray, pos); DynamicArrayAssert.Included( dynarray, oarray, IndexesHelper.Add(pos, alengths), idata.Rank > 1 ? IndexesHelper.Add(pos, alengths) : pos, olengths); }