public async Task <bool> DoneTransInfo(TransportInformation trans, string userId) { _context.TransportInformations.Attach(trans); trans.IsCompleted = true; DateTime localTimeUTC7 = SystemUtilites.ConvertToTimeZone(DateTime.UtcNow, "SE Asia Standard Time"); trans.DateCompletedLocal = SystemUtilites.ConvertToTimeStamp(localTimeUTC7); trans.DateCompletedUTC = SystemUtilites.ConvertToTimeStamp(DateTime.UtcNow); try { EditTransportInformation newEdit = new EditTransportInformation() { DateEditLocal = SystemUtilites.ConvertToTimeStamp(localTimeUTC7), DateEditUTC = SystemUtilites.ConvertToTimeStamp(DateTime.UtcNow), EditContent = "Kết thúc chuyến vận chuyển", EditId = Guid.NewGuid().ToString(), TimeZone = "SE Asia Standard Time", TransportId = trans.TransportId, UserEditId = userId }; _context.EditTransportInformations.Add(newEdit); var result = await _context.SaveChangesAsync(); return(result > 0); } catch (Exception) { return(false); } }
public double GetTotalPrice(TransportInformation transport, Cargo cargo) { var transportCoeficient = (int)transport.TypeOfTransportation.GetTypeCode(); var totalCoefiscient = cargo.VolumeInCubicMilimeters * cargo.WeightInGrams * transportCoeficient; return(transport.Price + totalCoefiscient); }
protected string GetBaseFormText(Cargo cargo, TransportInformation transport) { return($"\n transport caracteristics: " + $"\n Type Of Transportation: {transport.TypeOfTransportation.ToString()} " + $"\n Price: {_totalPrice} $" + $"\n cargos caracteristics: " + $"\n Weight: {cargo.WeightInGrams} Grams" + $"\n Volume: {cargo.VolumeInCubicMilimeters} cubic Mls"); }
public SenderChannelAdapter(IChannel channel) { _channel = channel; Transport = new TransportInformation( _channel.Transport.Compression, _channel.Transport.Encryption, _channel.Transport.IsConnected, _channel.Transport.LocalEndPoint, _channel.Transport.RemoteEndPoint, _channel.Transport.Options); }
public async Task <bool> DeleteTransInfo(TransportInformation transDel) { try { _context.TransportInformations.Remove(transDel); var result = await _context.SaveChangesAsync(); return(result > 0); } catch (Exception) { return(false); } }
public async Task <bool> CreateNewTransInfo(TransportInformation newTransInfo) { try { _context.TransportInformations.Add(newTransInfo); var result = await _context.SaveChangesAsync(); return(result > 0); } catch (Exception) { return(false); } }
public async Task <IHttpActionResult> GetTransportInformation(string key) { TransportInformation transportInformation = await db.boxes.Where(x => x.pack_number == key).Select(x => new TransportInformation() { Name = x.check_points.name, Latitude = x.check_points.latitude, Longitude = x.check_points.longitude, Delivery_status = x.delivery_status }).FirstOrDefaultAsync(); if (transportInformation == null) { return(NotFound()); } Logger.CreateLog(HttpContext.Current.Request.Url.PathAndQuery, HttpMethod.Get.Method, null); return(Ok(transportInformation)); }
public HttpContextChannel(HttpContext context, Node localNode, Node remoteNode, IEnvelopeSerializer envelopeSerializer) { _envelopeSerializer = envelopeSerializer; _context = context; LocalNode = localNode; RemoteNode = remoteNode; SessionId = context.Connection.Id; State = SessionState.Established; Transport = new TransportInformation( SessionCompression.None, context.Request.IsHttps ? SessionEncryption.TLS : SessionEncryption.None, true, $"{context.Connection.LocalIpAddress}:{context.Connection.LocalPort}", $"{context.Connection.RemoteIpAddress}:{context.Connection.RemotePort}", new Dictionary <string, object> { { nameof(HttpContext), context } }); _sendSemaphore = new SemaphoreSlim(1); }
public DeliveryViaTrainForm(Cargo cargo, TransportInformation transport, double totalPrice) { _cargo = cargo; _transport = transport; _totalPrice = totalPrice; }
public async Task <IActionResult> Create(CreateTransInfoViewModel model) { //get local time at Timezone UTC 7 DateTime localTimeUTC7 = SystemUtilites.ConvertToTimeZone(DateTime.UtcNow, "SE Asia Standard Time"); //get timestamp of day at 0 AM double TStodayUTC7At0Am = SystemUtilites.ConvertToTimeStamp(localTimeUTC7.Date); //get timestamp now at utc double TSUTCNow = SystemUtilites.ConvertToTimeStamp(DateTime.UtcNow); //get data for select elements model.Drivers = _userServices.GetDriverUsers().ToList(); model.Routes = _routeServices.GetAllRoutes().ToList(); model.Vehicles = (await _vehicleServices.GetAllNotDeletedAndAvailableVehicles()).ToList(); string message = String.Empty; if (ModelState.IsValid) { //check the vehicle is used string driverIdUseVehicle = await _vehicleServices.IsVehicleInUsedByAnotherDriver(model.DriverId, model.VehicleId); if (!String.IsNullOrEmpty(driverIdUseVehicle)) { var driverUseVehicle = _userServices.GetUser(driverIdUseVehicle); message = $"Xe đang được sử dụng bởi {driverUseVehicle.FullName}"; TempData["UserMessage"] = SystemUtilites.SendSystemNotification(NotificationType.Error, message); return(View(model)); } //create new TransportInformation var user = await _userManager.GetUserAsync(User); TransportInformation newTrans = new TransportInformation() { TransportId = Guid.NewGuid().ToString(), AdvanceMoney = model.AdvanceMoney, DateStartUTC = TSUTCNow, DateStartLocal = SystemUtilites.ConvertToTimeStamp(localTimeUTC7), TimeZone = "SE Asia Standard Time", CargoTypes = model.CargoTypes, Note = model.Note, VehicleId = model.VehicleId, RouteId = model.RouteId, UserCreateId = user.Id }; //get or create if not dayjob has date match today timeStamp DayJob driverDayJob = _dayJobServices.GetDayJob(model.DriverId, TStodayUTC7At0Am); if (driverDayJob == null) { driverDayJob = new DayJob() { DayJobId = Guid.NewGuid().ToString(), DriverId = model.DriverId, Date = TStodayUTC7At0Am }; if (!(await _dayJobServices.Create(driverDayJob))) { message = "Lỗi không xác định, xin mời thao tác lại"; TempData["UserMessage"] = SystemUtilites.SendSystemNotification(NotificationType.Error, message); return(View(model)); } } newTrans.DayJobId = driverDayJob.DayJobId; //create new TransInfo in SQL if (await _transInfoServices.CreateNewTransInfo(newTrans)) { var vehicle = await _vehicleServices.GetVehicle(newTrans.VehicleId); if (vehicle != null) { if (!vehicle.IsInUse) { await _vehicleServices.MakeVehicleInUsed(vehicle); } } var driver = await _userManager.FindByIdAsync(model.DriverId); if (driver != null) { if (driver.IsAvailable) { await _userServices.MakeDriverIsBusy(driver); } } message = "Chuyến vận chuyển đã được tạo"; TempData["UserMessage"] = SystemUtilites.SendSystemNotification(NotificationType.Success, message); return(RedirectToAction(actionName: "Manage")); } } message = "Lỗi không xác định, xin mời thao tác lại"; TempData["UserMessage"] = SystemUtilites.SendSystemNotification(NotificationType.Error, message); return(View(model)); }