public List <CargoTransferViewModel> Match(List <CargoTransfer> _cargoTransfers) { PackageNumberBL _packageNumberService = new PackageNumberBL(); ShipmentBL shipment = new ShipmentBL(); List <CargoTransferViewModel> _results = new List <CargoTransferViewModel>(); BundleBL bundleService = new BundleBL(); PackageNumber _packageNumber = new PackageNumber(); List <string> listCargo = new List <string>(); UserStore _userService = new UserStore(); foreach (CargoTransfer cargoTransfer in _cargoTransfers) { CargoTransferViewModel model = new CargoTransferViewModel(); string _airwaybill = ""; try { // _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == cargoTransfer.Cargo).Shipment.AirwayBillNo; _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == cargoTransfer.Cargo).FirstOrDefault(); if (_packageNumber == null) { CargoTransferViewModel model1 = new CargoTransferViewModel(); listCargo = bundleService.GetAll().Where(x => x.SackNo == cargoTransfer.Cargo).Select(y => y.Cargo).ToList(); if (listCargo != null && listCargo.Count != 0) { CargoTransferViewModel isExist = _results.Find(x => x.AWB == cargoTransfer.Cargo); if (isExist != null) { isExist.QTY++; model.Pieces++; } else { //List<Shipment> list = shipment.GetAll().Where(x => x.AirwayBillNo.Equals(_airwaybill)).ToList(); //model1.Origin = _airwaybill; //foreach (Shipment x in list) //{ // model1.Origin = x.OriginCity.CityName; // model1.Destination = x.DestinationCity.CityName; //} model1.Origin = "N/A"; model1.Destination = "N/A"; model1.Driver = cargoTransfer.Driver; model1.Checker = cargoTransfer.Checker; model1.Pieces = listCargo.Count; model1.PlateNo = cargoTransfer.PlateNo; model1.Batch = cargoTransfer.Batch.BatchName; model1.AWB = cargoTransfer.Cargo; model1.QTY = listCargo.Count; model1.CreatedDate = cargoTransfer.CreatedDate; model1.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName; model1.GATEWAY = cargoTransfer.RevenueUnit.RevenueUnitName; model1.SATELLITE = cargoTransfer.RevenueUnit.RevenueUnitName; //model1.ScannedBy = AppUser.User.Employee.FullName; model1.ScannedBy = "N/A"; string employee = _userService.FindById(cargoTransfer.CreatedBy).Employee.FullName; if (employee != "") { model1.ScannedBy = employee; } _results.Add(model1); } } } else { _airwaybill = _packageNumber.Shipment.AirwayBillNo; CargoTransferViewModel isExist = _results.Find(x => x.AWB == _airwaybill); if (isExist != null) { isExist.QTY++; model.Pieces++; //_results.Add(isExist); } else { List <Shipment> list = shipment.GetAll().Where(x => x.AirwayBillNo.Equals(_airwaybill)).ToList(); model.Origin = _airwaybill; foreach (Shipment x in list) { model.Origin = x.OriginCity.CityName; model.Destination = x.DestinationCity.CityName; model.BCO = x.DestinationCity.BranchCorpOffice.BranchCorpOfficeName; } model.Driver = cargoTransfer.Driver; model.Checker = cargoTransfer.Checker; model.Pieces++; model.PlateNo = cargoTransfer.PlateNo; model.Batch = cargoTransfer.Batch.BatchName; model.AWB = _airwaybill; model.QTY++; model.CreatedDate = cargoTransfer.CreatedDate; // model.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName; //model.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName; model.GATEWAY = cargoTransfer.RevenueUnit.RevenueUnitName; model.SATELLITE = cargoTransfer.RevenueUnit.RevenueUnitName; //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; string employee = _userService.FindById(cargoTransfer.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } _results.Add(model); } } } catch (Exception) { continue; } } return(_results); }
public List <GatewayOutboundViewModel> Match(List <GatewayInbound> _inbound, List <GatewayOutbound> _outbound) { PackageNumberBL _packageNumberService = new PackageNumberBL(); List <GatewayOutboundViewModel> _results = new List <GatewayOutboundViewModel>(); PackageNumber _packageNumber = new PackageNumber(); List <string> listCargo = new List <string>(); BundleBL bundleService = new BundleBL(); UserStore _userService = new UserStore(); foreach (GatewayOutbound outbound in _outbound) { GatewayOutboundViewModel model = new GatewayOutboundViewModel(); string _airwaybill = ""; try { //_airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == outbound.Cargo).Shipment.AirwayBillNo; _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == outbound.Cargo).FirstOrDefault(); if (_packageNumber == null) { GatewayOutboundViewModel model1 = new GatewayOutboundViewModel(); listCargo = bundleService.GetAll().Where(x => x.SackNo == outbound.Cargo).Select(y => y.Cargo).ToList(); if (listCargo != null && listCargo.Count != 0) { GatewayOutboundViewModel isExist = _results.Find(x => x.AirwayBillNo == outbound.Cargo); if (_inbound.Exists(x => x.Cargo == outbound.Cargo)) { if (isExist != null) { isExist.TotalRecieved++; isExist.Total = isExist.TotalRecieved; } else { model1.AirwayBillNo = outbound.Cargo; model1.Gateway = outbound.Gateway; model1.Driver = outbound.Driver; model1.PlateNo = outbound.PlateNo; model1.Batch = outbound.Batch.BatchName; model1.TotalRecieved = listCargo.Count; model1.Total = model1.TotalRecieved; model1.Branch = outbound.BranchCorpOffice.BranchCorpOfficeName; // model1.ScannedBy = AppUser.User.Employee.FullName; model1.ScannedBy = "N/A"; //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName; string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName; if (employee != "") { model1.ScannedBy = employee; } model1.CommodityTypeName = "N/A"; //model1.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName; _results.Add(model1); } } else { if (isExist != null) { isExist.TotalDiscrepency++; isExist.Total = isExist.TotalDiscrepency; } else { model1.AirwayBillNo = outbound.Cargo; model1.Gateway = outbound.Gateway; model1.Driver = outbound.Driver; model1.PlateNo = outbound.PlateNo; model1.Batch = outbound.Batch.BatchName; model1.TotalDiscrepency = listCargo.Count; model1.Total = model1.TotalDiscrepency; model1.Branch = outbound.BranchCorpOffice.BranchCorpOfficeName; //model1.ScannedBy = "N/A"; string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName; if (employee != "") { model1.ScannedBy = employee; } model1.CommodityTypeName = "N/A"; //model1.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName; _results.Add(model1); } } } } else { _airwaybill = _packageNumber.Shipment.AirwayBillNo; GatewayOutboundViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (_inbound.Exists(x => x.Cargo == outbound.Cargo)) { if (isExist != null) { isExist.TotalRecieved++; isExist.Total = isExist.TotalRecieved; //model.Total = model.TotalRecieved; //_results.Add(isExist); } else { model.AirwayBillNo = _airwaybill; model.Gateway = outbound.Gateway; model.Driver = outbound.Driver; model.PlateNo = outbound.PlateNo; model.Batch = outbound.Batch.BatchName; model.TotalRecieved++; model.Total = model.TotalRecieved; model.Branch = outbound.BranchCorpOffice.BranchCorpOfficeName; //model.ScannedBy = AppUser.User.Employee.FullName; string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } //model.CommodityTypeName = _inbound.Where(x => x.Cargo == outbound.Cargo).Select(x => x.CommodityType.CommodityTypeName).ToString(); // model.CommodityTypeName = _inbound.Find(x => x.Cargo == outbound.Cargo).CommodityType.CommodityTypeName; model.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName; _results.Add(model); } } else { if (isExist != null) { isExist.TotalDiscrepency++; isExist.Total = isExist.TotalDiscrepency; //model.Total = model.TotalDiscrepency; //_results.Add(isExist); } else { model.AirwayBillNo = _airwaybill; model.Gateway = outbound.Gateway; model.Driver = outbound.Driver; model.PlateNo = outbound.PlateNo; model.Batch = outbound.Batch.BatchName; model.TotalDiscrepency++; model.Total = model.TotalDiscrepency; model.Branch = outbound.BranchCorpOffice.BranchCorpOfficeName; string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } //model.CommodityTypeName = _inbound.Find(x => x.Cargo == outbound.Cargo).CommodityType.CommodityTypeName; // model.CommodityTypeName = _inbound.Where(x => x.Cargo == outbound.Cargo).Select(x => x.CommodityType.CommodityTypeName).ToString(); model.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName; _results.Add(model); } } } } catch (Exception) { continue; } } return(_results); }
public List <GatewayInboundViewModel> Match(List <GatewayInbound> _inbound) { PackageNumberBL _packageNumberService = new PackageNumberBL(); List <GatewayInboundViewModel> _results = new List <GatewayInboundViewModel>(); PackageNumber _packageNumber = new PackageNumber(); BundleBL bundleService = new BundleBL(); List <string> listCargo = new List <string>(); UserStore _userService = new UserStore(); foreach (GatewayInbound inbound in _inbound) { GatewayInboundViewModel model = new GatewayInboundViewModel(); string _airwaybill = ""; try { // _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == inbound.Cargo).Shipment.AirwayBillNo; _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == inbound.Cargo).FirstOrDefault(); if (_packageNumber == null) { GatewayInboundViewModel model1 = new GatewayInboundViewModel(); listCargo = bundleService.GetAll().Where(x => x.SackNo == inbound.Cargo).Select(y => y.Cargo).ToList(); if (listCargo != null && listCargo.Count != 0) { GatewayInboundViewModel isExist = _results.Find(x => x.AirwayBillNo == inbound.Cargo); if (isExist != null) { isExist.Pieces++; } else { model1.AirwayBillNo = inbound.Cargo; model1.Gateway = inbound.Gateway; model1.Origin = inbound.BranchCorpOffice.BranchCorpOfficeName; model1.Pieces = listCargo.Count; model1.MAWB = inbound.MasterAirwayBill; model1.FlightNo = inbound.FlightNumber; model1.CommodityType = inbound.CommodityType.CommodityTypeName; model1.CreatedDate = inbound.CreatedDate; //model1.ScannedBy = AppUser.User.Employee.FullName; model1.ScannedBy = "N/A"; string employee = _userService.FindById(inbound.CreatedBy).Employee.FullName; if (employee != "") { model1.ScannedBy = employee; } _results.Add(model1); } } } else { _airwaybill = _packageNumber.Shipment.AirwayBillNo; GatewayInboundViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (isExist != null) { isExist.Pieces++; } else { model.AirwayBillNo = _airwaybill; model.Gateway = inbound.Gateway; model.Origin = inbound.BranchCorpOffice.BranchCorpOfficeName; model.Pieces++; model.MAWB = inbound.MasterAirwayBill; model.FlightNo = inbound.FlightNumber; model.CommodityType = inbound.CommodityType.CommodityTypeName; model.CreatedDate = inbound.CreatedDate; //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; string employee = _userService.FindById(inbound.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } _results.Add(model); } } } catch (Exception) { continue; } } return(_results); }
public override string ToString() { StringBuilder headerTLVBuilder = new StringBuilder(); headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Header TLVs ({0}) : ", headerTLVs.Count.ToString(System.Globalization.CultureInfo.InvariantCulture))); if (headerTLVs.Count > 0) { foreach (KeyValuePair <byte, byte[]> keyvalue in headerTLVs) { headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),", keyvalue.Key.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Key)); headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),( ", keyvalue.Value.Length.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Value.Length)); foreach (byte b in keyvalue.Value) { headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "0x{0:x2} ", b)); } headerTLVBuilder.Append("); "); } } headerTLVBuilder.Append("\r\n"); StringBuilder bodyTLVBuilder = new StringBuilder(); bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, " DataPacket TLVs ({0}): ", dataPacketTLVs.Count.ToString(System.Globalization.CultureInfo.InvariantCulture))); if (dataPacketTLVs.Count > 0) { foreach (KeyValuePair <byte, byte[]> keyvalue in dataPacketTLVs) { bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),", keyvalue.Key.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Key)); bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),( ", keyvalue.Value.Length.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Value.Length)); foreach (byte b in keyvalue.Value) { bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "0x{0:x2} ", b)); } bodyTLVBuilder.Append("); "); } } bodyTLVBuilder.Append("\r\n"); int dataHeaderLen = DataPacketHeaderLength; return("[P2Pv2Header]\r\n" + String.Format(System.Globalization.CultureInfo.InvariantCulture, "HeaderLength : {1:x} ({0})\r\n", HeaderLength.ToString(System.Globalization.CultureInfo.InvariantCulture), HeaderLength) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "OperationCode : {1:x} ({0})\r\n", (byte)OperationCode, Convert.ToString(OperationCode)) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "MessageSize : {1:x} ({0})\r\n", MessageSize.ToString(System.Globalization.CultureInfo.InvariantCulture), MessageSize) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Identifier : {1:x} ({0})\r\n", Identifier.ToString(System.Globalization.CultureInfo.InvariantCulture), Identifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckIdentifier : {1:x} ({0})\r\n", AckIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture), AckIdentifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "NakIdentifier : {1:x} ({0})\r\n", NakIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture), NakIdentifier) + headerTLVBuilder.ToString() + String.Format(System.Globalization.CultureInfo.InvariantCulture, " Data HeaderLength : {1:x} ({0})\r\n", dataHeaderLen.ToString(System.Globalization.CultureInfo.InvariantCulture), dataHeaderLen) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " TFCombination : {1:x} ({0})\r\n", (byte)TFCombination, Convert.ToString(TFCombination)) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " PackageNumber : {1:x} ({0})\r\n", PackageNumber.ToString(System.Globalization.CultureInfo.InvariantCulture), PackageNumber) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " SessionId : {1:x} ({0})\r\n", SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture), SessionId) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " DataRemaining : {1:x} ({0})\r\n", DataRemaining.ToString(System.Globalization.CultureInfo.InvariantCulture), DataRemaining) + bodyTLVBuilder.ToString()); }