public static List <ReporteBean> getReporteTrackingBean(String fecha, String coordinador, String jefeventa, String supervisor, String grupo, String vendedor, String tipo) { DataTable dt = TrackingModel.ReporteTracking(fecha, coordinador, jefeventa, supervisor, grupo, vendedor, tipo); var lst = new List <ReporteBean>(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { var reporte = new ReporteBean(); reporte.tipo = row["tipo"].ToString(); reporte.codigo = row["CODIGO"].ToString(); reporte.codigoVendedor = row["CODIGOVENDEDOR"].ToString(); reporte.vendedor = row["VENDEDOR"].ToString(); reporte.codigoCliente = row["CODIGOCLIENTE"].ToString(); reporte.cliente = row["CLIENTE"].ToString(); reporte.montoTotal = row["MONTO_TOTAL"].ToString(); reporte.motivo = row["MOTIVO"].ToString(); reporte.latitud = row["LATITUD"].ToString(); reporte.longitud = row["LONGITUD"].ToString(); lst.Add(reporte); } } return(lst); }
public async Task <ActionResult> Update(TrackingModel model) { var actualDay = DateTime.Now; //var currentUser = await _userService.GetUserByUsernameAsync(""); //Khang comment var currentUser = await _userService.GetUserByUsernameAsync(User.Identity.GetUsername()); if (_workContext.CurrentUser == null) { return(Content("User is Invalid")); } var currentUser = _workContext.CurrentUser; var tracking = await _trackingService.GetTrackingById(model.Id); if (tracking != null) { tracking.CreatedDate = actualDay; tracking.UpdatedDate = actualDay; //tracking.CreatedUser = currentUser; tracking.UserCreated = currentUser.Id; tracking.LineCode = model.LineCode; tracking.FGCode = model.FGCode; tracking.Variant = model.Variant; tracking.Cause = model.Cause; tracking.Lot = model.Lot; tracking.Quantity = model.Quantity; tracking.Size = model.Size; tracking.Where = model.Where; await _trackingService.UpdateAsync(tracking); } return(new NullJsonResult()); }
/// <summary> /// Post location and other information for tracking a user. /// </summary> /// <param name="tracking">Contains location and other information to track a user.</param> /// <returns>Relevant information about the user route.</returns> public TrackingResponseModel Post([FromBody] TrackingModel tracking) { /* * var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); * return epoch.AddSeconds(unixTime); */ var response = new TrackingResponseModel(); ZoneResponse zoneResponse = _zoneService.GetZone(11, 11); if (zoneResponse.HasError) { response.HasError = true; response.Error = zoneResponse.Error; } else { response.Zones.Add(new ZoneModel() { Name = zoneResponse.Name, Number = zoneResponse.Number }); } return(response); }
public async Task <ActionResult> Create(TrackingModel model) { var actualDay = DateTime.Now; //var currentUser = await _userService.GetUserByUsernameAsync(""); //Khang comment var currentUser = await _userService.GetUserByUsernameAsync(User.Identity.GetUsername()); if (_workContext.CurrentUser == null) { return(Content("User is Invalid")); } var currentUser = _workContext.CurrentUser; var newIssue = new Tracking() { CreatedDate = actualDay, UpdatedDate = actualDay, UserCreated = currentUser.Id, LineCode = model.LineCode, FGCode = model.FGCode, Variant = model.Variant, Cause = model.Cause, Lot = model.Lot, Quantity = model.Quantity, Size = model.Size, Where = model.Where }; await _trackingService.CreateAsync(newIssue); return(new NullJsonResult()); }
public async Task Handle(BMIUpdated message, IMessageHandlerContext context) { TrackingsUpdated trackingsUpdated = new TrackingsUpdated(); TrackingModel trackingModel = new TrackingModel() { BMI = message.BMI, Weight = message.Weight, trend = (int)(message.Weight - message.BMI), Comments = "you are great!", CardId = message.CardId }; var isTrackingAdded = await _trackingService.AddTracikngAsync(trackingModel); if (isTrackingAdded) { trackingsUpdated.MeasureId = message.MeasureId; trackingsUpdated.succeeded = true; } else { trackingsUpdated.MeasureId = message.MeasureId; trackingsUpdated.succeeded = false; } await context.Publish(trackingsUpdated) .ConfigureAwait(false); }
public ActionResult TrackingStores(TrackingModel model) { TrackingDataSet tls = new EnterpriseGateway().TrackCartonsForStoreSummary(model.ClientID, model.Store, model.From, model.To, model.By); TrackingStoreSummary summary = new TrackingStoreSummary(model, tls); return(View(summary)); }
private AirXRTrackingModel createTrackingModelObject(TrackingModel model) { return(model == TrackingModel.InterpupillaryDistanceOnly ? new AirXRIPDOnlyTrackingModel(this, leftEyeAnchor, centerEyeAnchor, rightEyeAnchor) : model == TrackingModel.ExternalTracker ? new AirXRExternalTrackerTrackingModel(this, leftEyeAnchor, centerEyeAnchor, rightEyeAnchor, _externalTrackingOrigin, _externalTracker) : model == TrackingModel.NoPositionTracking ? new AirXRNoPotisionTrackingModel(this, leftEyeAnchor, centerEyeAnchor, rightEyeAnchor) : new AirXRHeadTrackingModel(this, leftEyeAnchor, centerEyeAnchor, rightEyeAnchor) as AirXRTrackingModel); }
public void Track(TrackingModel model) { var json = JsonConvert.SerializeObject(model); var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json"); var client = new HttpClient(); client.PostAsync(uri_trackPage, stringContent); }
public async Task <bool> AddTrackingAsync(TrackingModel trackingModel) { TrackingEntity trackingEntity = _mapper.Map <TrackingEntity>(trackingModel); //TrackingEntity tracking = await _trackingContext.Trackings // .LastOrDefaultAsync(t => t.CardId == trackingEntity.CardId); await _trackingContext.Trackings.AddAsync(trackingEntity); await _trackingContext.SaveChangesAsync(); return(true); }
public ActionResult Tracking(TrackingModel model) { if (ModelState.IsValid) { foreach (Client client in TrackingModel.Clients) { if (client.ClientID == model.ClientID) { model.ClientName = client.CompanyName; } } return(RedirectToAction("TrackingStores", "Tracking", model)); } return(View(model)); }
public void Save(TrackingModel model) { vmsServerLinqDataContext datacontext = new vmsServerLinqDataContext(); Tracking objTracking = new Tracking(); objTracking.TrackingID = GetLongID(); objTracking.ModuleID = model.ModuleNumber; objTracking.Longtitude = model.Longtitude; objTracking.Latitude = model.Latitude; objTracking.Speed = model.Speed; objTracking.FuelLevel = model.FuelLevel; objTracking.Time = DateTime.Now; datacontext.Trackings.InsertOnSubmit(objTracking); datacontext.SubmitChanges(); }
public async Task SetProperties(TrackingModel Model) { RestRequest elm = CreateRequest <TrackingModel>("Track/Properties", Method.POST, Model); IRestResponse resp = await Client.ExecuteTaskAsync(elm); if (resp.StatusCode == HttpStatusCode.Unauthorized) { throw new UnauthorizedException(); } else if (resp.StatusCode != HttpStatusCode.OK && resp.StatusCode != HttpStatusCode.NoContent) { throw new eDockAPIException(); } return; }
public FileResult CsvExport(string asset = "", int dateKey = 20130228) { MemoryStream memStream = new MemoryStream(); StreamWriter writer = new StreamWriter(memStream); if (!String.IsNullOrEmpty(asset)) { DeviceModel device = RepositoryFactory.Instance.DeviceDb.GetDevice(asset); if (device != null) { List <string> keys = device.GetOrderFieldName(); WriteCsvCell(writer, "Date"); WriteCsvCell(writer, "Recorded_at"); WriteCsvCell(writer, "Longitude"); WriteCsvCell(writer, "Latitude"); foreach (string key in keys) { WriteCsvCell(writer, key); } DateTime date = DateTime.ParseExact(dateKey.ToString(), "yyyyMMdd", null); List <TrackingModel> tracks = RepositoryFactory.Instance.DataTrackingDB.GetData(device, date).OrderByDescending(x => x.Data.Recorded_at).ToList(); writer.WriteLine(); for (int i = 0; i < tracks.Count; i++) { TrackingModel t = tracks[i]; WriteCsvCell(writer, t.Data.Recorded_at.ToString("yyyy/MM/dd")); WriteCsvCell(writer, t.Data.Recorded_at.ToString("HH:mm:ss")); WriteCsvCell(writer, t.Data.Longitude.ToString(System.Globalization.CultureInfo.InvariantCulture)); WriteCsvCell(writer, t.Data.Latitude.ToString(System.Globalization.CultureInfo.InvariantCulture)); foreach (string key in keys) { WriteCsvCell(writer, t.GetDisplayDataFor(key, (i < tracks.Count - 1 ? tracks[i + 1].Data.fields : null))); } writer.WriteLine(); } } } writer.Flush(); memStream.Seek(0, SeekOrigin.Begin); FileStreamResult file = new FileStreamResult(memStream, "text/csv"); file.FileDownloadName = String.Format("export_tracking_{0}_{1}.csv", asset, dateKey); return(file); }
public async Task Track(string EventId, TrackingModel Model = null) { RestRequest elm = CreateRequest <TrackingModel>("Track/Event/{EventId}", Method.POST, Model); elm.AddParameter("EventId", EventId, ParameterType.UrlSegment); IRestResponse resp = await Client.ExecuteTaskAsync(elm); if (resp.StatusCode == HttpStatusCode.Unauthorized) { throw new UnauthorizedException(); } else if (resp.StatusCode != HttpStatusCode.OK && resp.StatusCode != HttpStatusCode.NoContent) { throw new eDockAPIException(); } return; }
private void DataReceived(string sData) { try { log4net.Info("Save Data:" + sData); if (checkDataCorrectFormat(sData)) { string moduleNumber = sData.Substring(0, 11); double longtitude = Convert.ToDouble(sData.Substring(11, LongLength)); double latitude = Convert.ToDouble(sData.Substring(11 + LongLength, LatLength)); double speed = Convert.ToDouble(sData.Substring(11 + LongLength + LatLength, SpeedLength)); double fuel = Convert.ToDouble(sData.Substring(11 + LongLength + LatLength + SpeedLength, FuelLength)); ModuleModel module = moduleAccess.GetModule(moduleNumber); if (module == null) { module.ModuleNumber = moduleNumber; module.ModuleType = "Module Sensor"; module.IsActive = true; moduleAccess.Save(module); } TrackingModel track = new TrackingModel(); track.ModuleNumber = module.ModuleNumber; track.Longtitude = longtitude; track.Latitude = latitude; track.Speed = speed; track.FuelLevel = fuel; track.Time = DateTime.Now; trackingAccess.Save(track); log4net.Info("Save Data Completed"); } else { log4net.Error("string received incorrect format"); } } catch (Exception ex) { log4net.Error("Cannot save data. Reason:" + ex.Message); } }
public TrackingModel ShipmentFilter(string FrayteNumber) { TrackingModel TGS = new TrackingModel(); if (!string.IsNullOrEmpty(FrayteNumber)) { if (FrayteNumber.ToUpper().Contains("TL")) { TGS.ModuleType = FrayteShipmentServiceType.TradeLaneBooking; TGS.TrackingType = "FrayteNumber"; } else if (!FrayteNumber.ToUpper().Contains("TL") && FrayteNumber.Length == 8) { TGS.ModuleType = FrayteShipmentServiceType.TradeLaneBooking; TGS.TrackingType = "MAWB"; } else if (!FrayteNumber.ToUpper().Contains("TL") && FrayteNumber.Length > 10) { var MawbRes = new TradelaneShipmentRepository().GetMawbStr(FrayteNumber); if (MawbRes != null && !string.IsNullOrEmpty(MawbRes.Item2)) { TGS.ModuleType = FrayteShipmentServiceType.TradeLaneBooking; TGS.TrackingType = "MAWB"; } else { TGS.ModuleType = FrayteShipmentServiceType.DirectBooking; TGS.TrackingType = ""; } } else { TGS.ModuleType = FrayteShipmentServiceType.DirectBooking; TGS.TrackingType = ""; } } return(TGS); }
public Task StartAsync(string BatchName, Guid sessionId) { return(Task.Run(() => { try { TrackingModel model = new TrackingModel() { BatchName = BatchName, MachineName = System.Environment.MachineName, SessionId = sessionId, StartDate = DateTime.Now, State = StatusEnum.Running.ToString() }; _trackingContext.Trackings.Add(model); _trackingContext.SaveChanges(); }catch (Exception ex) { _logger.LogError(ex, "StartAsync error:"); } })); }
public TrackingModel GetModule(long id) { vmsServerLinqDataContext datacontext = new vmsServerLinqDataContext(); var query = (from t in datacontext.Trackings where t.TrackingID == id select t).SingleOrDefault(); TrackingModel model = new TrackingModel(); try { model.TrackingID = query.TrackingID; model.ModuleNumber = query.ModuleID; model.Longtitude = Convert.ToDouble(query.Longtitude); model.Latitude = Convert.ToDouble(query.Latitude); model.Speed = Convert.ToDouble(query.Speed); model.FuelLevel = Convert.ToDouble(query.FuelLevel); model.Time = Convert.ToDateTime(query.Time); return(model); } catch { return(null); } }
public TrackingModel GetShipmentDetail(string ModuleType, string TrackingType, string FrayteNumber) { TrackingModel TGS = new TrackingModel(); TradelaneShipment Shipment; if (!string.IsNullOrEmpty(FrayteNumber) && ModuleType == FrayteShipmentServiceType.TradeLaneBooking) { if (TrackingType == "FrayteNumber") { Shipment = dbContext.TradelaneShipments.Where(x => x.FrayteNumber == FrayteNumber).FirstOrDefault(); if (Shipment != null && Shipment.TradelaneShipmentId > 0) { TGS.ModuleType = FrayteShipmentServiceType.TradeLaneBooking; TGS.ShipmentId = Shipment.TradelaneShipmentId; TGS.TrackingType = "frn"; goto End; } } if (TrackingType == "MAWB") { var MawbRes = new TradelaneShipmentRepository().GetMawbStr(FrayteNumber); if (!string.IsNullOrEmpty(MawbRes.Item1) && !string.IsNullOrEmpty(MawbRes.Item2)) { var Airline = dbContext.Airlines.Where(a => a.AirlineCode == MawbRes.Item2).FirstOrDefault(); Shipment = dbContext.TradelaneShipments.Where(x => x.MAWB == MawbRes.Item1 && x.AirlineId == Airline.AirlineId).FirstOrDefault(); if (Shipment != null) { TGS.ModuleType = FrayteShipmentServiceType.TradeLaneBooking; TGS.ShipmentId = Shipment.TradelaneShipmentId; TGS.TrackingType = "mawb"; goto End; } } else { Shipment = dbContext.TradelaneShipments.Where(x => x.MAWB == MawbRes.Item1).FirstOrDefault(); if (Shipment != null) { TGS.ModuleType = FrayteShipmentServiceType.TradeLaneBooking; TGS.ShipmentId = Shipment.TradelaneShipmentId; TGS.TrackingType = "mawb"; goto End; } } } var shipment = (from TSD in dbContext.TradelaneShipmentDetails join TS in dbContext.TradelaneShipments on TSD.TradelaneShipmentId equals TS.TradelaneShipmentId where TSD.HAWB == FrayteNumber select new { TS.TradelaneShipmentId }).FirstOrDefault(); if (shipment != null && shipment.TradelaneShipmentId > 0) { TGS.ModuleType = FrayteShipmentServiceType.TradeLaneBooking; TGS.ShipmentId = shipment.TradelaneShipmentId; TGS.TrackingType = "hawb"; } } if (!string.IsNullOrEmpty(FrayteNumber) && string.IsNullOrEmpty(TGS.ModuleType) && string.IsNullOrEmpty(TGS.TrackingType)) { var shipment = (from DSPD in dbContext.PackageTrackingDetails join DSD in dbContext.DirectShipmentDetails on DSPD.DirectShipmentDetailId equals DSD.DirectShipmentDetailId join DS in dbContext.DirectShipments on DSD.DirectShipmentId equals DS.DirectShipmentId where DSPD.TrackingNo == FrayteNumber || DS.TrackingDetail.Contains(FrayteNumber) select new { DS.TrackingDetail, DS.LogisticServiceType }).FirstOrDefault(); if (shipment != null && !string.IsNullOrEmpty(shipment.TrackingDetail)) { TGS.ModuleType = FrayteShipmentServiceType.DirectBooking; TGS.TrackingType = "TrackingNo"; TGS.CarrierType = shipment.LogisticServiceType; TGS.Number = shipment.TrackingDetail.Replace("Order_", ""); goto End; } var Result1 = dbContext.DirectShipments.Where(a => a.FrayteNumber == FrayteNumber).FirstOrDefault(); if (Result1 != null) { TGS.ModuleType = FrayteShipmentServiceType.DirectBooking; TGS.TrackingType = "FrayteNumber"; TGS.CarrierType = Result1.LogisticServiceType; TGS.Number = Result1.TrackingDetail.Replace("Order_", ""); goto End; } } End: return(TGS); }
public ContentResult LoadData(string asset, int year, int month, int day) { List <JsonTrackingModel> result = new List <JsonTrackingModel>(); if (!String.IsNullOrEmpty(asset)) { DateTime date = new DateTime(year, month, day); DeviceModel device = RepositoryFactory.Instance.DeviceDb.GetDevice(asset); if (device != null) { ViewBag.Imei = device.Imei; List <TrackingModel> tracks = RepositoryFactory.Instance.DataTrackingDB.GetData(device, date).OrderBy(x => x.Data.Recorded_at).ToList(); List <string> keys = device.GetOrderFieldName(); JsonTrackingModel jtrack = null; //for (int i = 0; i < tracks.Count; i++) //{ // TrackingModel t = tracks[i]; // WriteCsvCell(writer, t.Data.Recorded_at.ToString("HH:mm:ss")); // WriteCsvCell(writer, t.Data.Longitude.ToString(System.Globalization.CultureInfo.InvariantCulture)); // WriteCsvCell(writer, t.Data.Latitude.ToString(System.Globalization.CultureInfo.InvariantCulture)); // foreach (string key in keys) // { // WriteCsvCell(writer, t.GetDisplayDataFor(key, (i < tracks.Count - 1 ? tracks[i + 1].Data.fields : null))); // } // writer.WriteLine(); //} for (int i = 0; i < tracks.Count; i++) { TrackingModel t = tracks[i]; jtrack = new JsonTrackingModel() { Id = i, Latitude = t.Data.Latitude, Longitude = t.Data.Longitude, Recorded_at = t.Data.Recorded_at.ToString("HH:mm:ss.fff"), Received_at = t.Data.Received_at.ToString("dd/MM/yyyy HH:mm:ss"), Fields = new List <JsonFieldModel>() }; foreach (string key in keys) { jtrack.Fields.Add(new JsonFieldModel() { Key = key, DisplayName = t.GetDisplayNameField(key), Value = t.GetDisplayDataFor(key, (i > 0 ? tracks[i - 1].Data.fields : null)) }); } result.Add(jtrack); } } } return(new ContentResult() { Content = JsonConvert.SerializeObject(result, Formatting.None), ContentType = "application/json" }); }
public override void OnReceiveLocation(BDLocation lct) { if (lct == null) { return; } try { var asyncTasker = new AsyncTasker(async() => { try { if (lct != null) { //var msg = $"OnReceiveLocation:{lct.Latitude} Latitude:{lct.Longitude} Address:{lct.Country}{lct.Province}{lct.City}{lct.Address?.Street}"; //Android.Util.Log.Info("获取位置:", msg); var _conn = App.Resolve <ILiteDbService <TrackingModel> >(); if (_conn != null) { var tracking = new TrackingModel() { StoreId = Settings.StoreId, BusinessUserId = Settings.UserId, BusinessUserName = Settings.UserRealName, Latitude = lct.Latitude, Longitude = lct.Longitude, CreateDateTime = DateTime.Now, Province = lct.Province, County = lct.Country, City = lct.City, Address = $"{lct.Country}{lct.Province}{lct.City}{lct.Address?.Street}" }; //存储本地 if (!string.IsNullOrWhiteSpace(tracking.Address)) { var exits = await _conn.Table.CountAsync(s => s.Latitude == lct.Latitude && s.Longitude == lct.Longitude && s.Address == tracking.Address); if (exits == 0) { await _conn.InsertAsync(tracking); } } } } } catch (Exception ex) { Crashes.TrackError(ex); } }); asyncTasker?.Execute(); } catch (Exception ex) { Crashes.TrackError(ex); } }
public override void OnReceiveLocation(BDLocation lct) { if (lct == null) { return; } try { var msg = $"OnReceiveLocation:{lct.Latitude} Latitude:{lct.Longitude} Address:{lct.Country}{lct.Province}{lct.City}{lct.Address?.Street}"; Android.Util.Log.Info("位置:", msg); //ToastUtils.ShowSingleToast(msg); GlobalSettings.Latitude = lct.Latitude; GlobalSettings.Longitude = lct.Longitude; new Thread(async() => { if (lct != null && !GlobalSettings.IsNotConnected) { var _conn = App.Resolve <LocalDatabase>(); var tracking = new TrackingModel() { StoreId = Settings.StoreId, BusinessUserId = Settings.UserId, BusinessUserName = Settings.UserRealName, Latitude = lct.Latitude, Longitude = lct.Longitude, CreateDateTime = DateTime.Now, Province = lct.Province, County = lct.Country, City = lct.City, //Town = lct.Town, Address = lct.Address?.Street }; var gpsEvent = new GpsEvent() { Latitude = lct.Latitude, Longitude = lct.Longitude, CreateTime = DateTime.Now, Address = $"{lct.Country}{lct.Province}{lct.City}{lct.Address?.Street}" }; var cg = await _conn.GpsEvents.CountAsync(); var lg = await _conn.LocationSyncEvents.CountAsync(); if (cg > 50) { await _conn.ResetGpsEvents(); } if (lg > 50) { await _conn.ResetLocationSyncEvents(); } //存储本地 if (!string.IsNullOrWhiteSpace(gpsEvent.Address)) { await _conn.InsertAsync(gpsEvent); } if (!string.IsNullOrWhiteSpace(tracking.Address)) { await _conn.InsertAsync(tracking); } } }).Start(); } catch (Java.Lang.Exception ex) { Android.Util.Log.Error("上报", ex.Message); } }
public async Task <bool> AddTracikngAsync(TrackingModel trackingModel) { trackingModel.Date = DateTime.Now; return(await _trackingRepository.AddTrackingAsync(trackingModel)); }
public static Tracking ToTracking(this TrackingModel model) { return(model.MapTo <TrackingModel, Tracking>()); }
public static DataTable getReporteTrackingDataTable(String fecha, String coordinador, String jefeventa, String supervisor, String grupo, String vendedor, String tipo) { return(TrackingModel.ReporteTracking(fecha, coordinador, jefeventa, supervisor, grupo, vendedor, tipo)); }
public TrackingModel GetShipmentDetail(string FrayteNumber) { TrackingModel TGS = new TrackingModel(); var Result = dbContext.TrackingNumberRoutes.Where(a => a.Number == FrayteNumber).FirstOrDefault(); if (Result != null) { TGS.Number = Result.Number; TGS.ModuleType = Result.ModuleType; TGS.ShipmentId = Result.ShipmentId; //Tradelane Shipment if (Result.IsTradelaneRefNumber == true) { TGS.TrackingType = "tlfrn"; goto End; } if (Result.IsMAWB == true) { TGS.TrackingType = "mawb"; goto End; } if (Result.IsHAWB == true) { TGS.TrackingType = "hawb"; goto End; } //Express Shipment if (Result.IsAWB == true) { TGS.TrackingType = "awb"; goto End; } if (Result.IsBag == true) { TGS.TrackingType = "bag"; goto End; } if (Result.IsExpressManifestNumber == true) { TGS.TrackingType = "expmn"; goto End; } if (Result.IsTrackingNumber == true) { TGS.TrackingType = "exptn"; goto End; } //DirectBooking Shipment if (Result.IsTrackingNumber == true) { TGS.TrackingType = "dbtn"; goto End; } if (Result.IsFrayteNumber == true) { TGS.TrackingType = "dbfn"; goto End; } if (Result.IsPiecesTrackingNo == true) { TGS.TrackingType = "dbIspcs"; goto End; } } else { goto End; } End: return(TGS); }