static void part2() { car car1 = new car { Price = 2, Weight = 3 }; car car2 = new car { Price = 3, Weight = 4 }; car car3 = car1 + car2;//Operator Overloading of + operator car3.WriteLine(); var vrCar1 = globalMethods.MultiplyCar(car1, car2); var vrCar2 = globalMethods.MultiplyCar(new List <car> { vrCar1, vrCar1, vrCar1 }); Console.WriteLine(""); vrCar1.WriteLine("vrCar1: "); vrCar2.WriteLine("vrCar2: "); Console.WriteLine("\ncar class print"); vrCar2.printCar(); trucks t = new trucks(vrCar2); Console.WriteLine("\ntruck class print"); t.printCar(); }
public TruckData(trucks trk) { Command = trk.command; RequestId = NewGuid(trk.requestId); ManifestId = trk.ManifestId; DriverId = trk.DriverId; FirstName = trk.FirstName; LastName = trk.LastName; TRK_CDE = trk.TruckCode; SHIP_DTE = trk.ShipDate; NOTES = trk.Notes; Desc = trk.Description; IsClosed = trk.IsClosed; }
public static isaCommand MyQueryReader_Trucks(SqlDataReader reader, Func <byte[], Task> cb) { trucks trk = new trucks(); try { trk.ManifestId = reader.GetInt64(reader.GetOrdinal("ManifestId")); trk.DriverId = reader.GetInt32(reader.GetOrdinal("DriverId")); trk.FirstName = reader.GetString(reader.GetOrdinal("Firstname")); trk.LastName = reader.GetString(reader.GetOrdinal("Lastname")); trk.TruckCode = reader.GetString(reader.GetOrdinal("TRK_CDE")); trk.ShipDate = reader.GetDateTime(reader.GetOrdinal("SHP_DTE")).ToBinary(); trk.Description = reader.GetString(reader.GetOrdinal("DESC$")); trk.Notes = reader.GetString(reader.GetOrdinal("NOTES")); } catch (Exception ex) { } return(trk); }
public IMDMMessage QueryData(Func <byte[], Task> cb, isaCommand dat) { IMDMMessage retVal = null; SPCmds SP; manifestRequest req; // (manifestRequest)dat; switch (dat.command) { case eCommand.Drivers: SP = SPCmds.GETAVAILABLEDRIVERS; break; case eCommand.Manifest: SP = SPCmds.GETDRIVERMANIFEST; break; case eCommand.Trucks: SP = SPCmds.GETTRUCKS; break; case eCommand.Stops: SP = SPCmds.GETSTOPS; break; case eCommand.Orders: case eCommand.OrdersLoad: SP = SPCmds.GETORDERS; break; case eCommand.GenerateManifest: SP = SPCmds.GETMANIFEST; break; default: throw new Exception("Not handled"); } using (SqlConnection cnn = new SqlConnection(UMDDB.connectionString)) { using (var adapter = new SqlDataAdapter()) { using (var command = new SqlCommand(SP.ToString(), cnn)) { command.CommandType = CommandType.StoredProcedure; switch (dat.command) { case eCommand.Drivers: req = (manifestRequest)dat; command.Parameters.AddWithValue("@SHP_DTE", SqlDbType.Date).Value = DateTime.Parse(req.date).Date.ToString("yyyy-MM-dd"); dat.command = eCommand.DriversLoadComplete; retVal = new DriverData() { RequestId = new Guid(req.requestId) }; Logger.Info($"QueryData Drivers. Cmd:{retVal.Command.ToString()} reqId: {retVal.RequestId.ToString()} SHP_DTE: {DateTime.Parse(req.date).Date.ToString("yyyy-MM-dd")}"); break; case eCommand.Manifest: req = (manifestRequest)dat; command.Parameters.AddWithValue("@DriverId", SqlDbType.Int).Value = req.id; retVal = new ManifestMasterData() { RequestId = new Guid(req.requestId) }; Logger.Info($"QueryData Manifest. Cmd:{retVal.Command.ToString()} reqId: {retVal.RequestId.ToString()} DriverId: {req.id} "); dat.command = eCommand.ManifestLoadComplete; break; case eCommand.Trucks: req = (manifestRequest)dat; command.Parameters.AddWithValue("@SHP_DTE", SqlDbType.Date).Value = DateTime.Parse(req.date).Date.ToString("yyyy-MM-dd"); dat.command = eCommand.TrucksLoadComplete; Logger.Info($"QueryData Trucks. Cmd:{req.command.ToString()} reqId: {new Guid(req.requestId).ToString()} SHP_DTE: {DateTime.Parse(req.date).Date.ToString("yyyy-MM-dd")}"); retVal = new TruckData() { RequestId = new Guid(req.requestId) }; break; case eCommand.Stops: req = (manifestRequest)dat; command.Parameters.AddWithValue("@ManifestId", SqlDbType.Int).Value = req.id; dat.command = eCommand.StopsLoadComplete; Logger.Info($"QueryData Stops. Cmd:{req.command.ToString()} reqId: {new Guid(req.requestId).ToString()} manId: {req.id}"); retVal = new StopData() { RequestId = new Guid(req.requestId) }; break; case eCommand.Orders: case eCommand.OrdersLoad: req = (manifestRequest)dat; command.Parameters.AddWithValue("@ManifestId", SqlDbType.Int).Value = req.id; dat.command = eCommand.OrdersLoadComplete; command.Parameters.AddWithValue("@Stop", SqlDbType.Int).Value = req.Stop; Logger.Info($"QueryData Orders. Cmd:{req.command.ToString()} reqId: {new Guid(req.requestId).ToString()} stop: {req.Stop.ToString()}"); retVal = new OrderMasterData() { RequestId = new Guid(req.requestId) }; break; case eCommand.GenerateManifest: // req = (manifestRequest)dat; command.Parameters.AddWithValue("@Link", SqlDbType.BigInt).Value = ((manifestMaster)dat).LINK; dat.command = eCommand.ManifestLoadComplete; Logger.Info($"QueryData GenerateManifest. " + $"Cmd:{dat.command.ToString()} " + $"reqId: {new Guid(dat.requestId).ToString()}" + $"link: { ((manifestMaster)dat).LINK}"); retVal = new ManifestMasterData() { LINK = ((manifestMaster)dat).LINK, RequestId = new Guid(dat.requestId) }; break; default: { Logger.Error($"QueryData Unkonwn Command. " + $"Cmd:{retVal.Command.ToString()} " + $"reqId: {retVal.RequestId.ToString()}"); throw new Exception("Not handled"); } } adapter.SelectCommand = command; SqlDataReader reader = null; try { cnn.Open(); reader = adapter.SelectCommand.ExecuteReader(); } catch (Exception ex) { } while (reader.Read()) { switch (retVal.Command) { case eCommand.Drivers: drivers drv = (drivers)MyQueryReader_Driver(reader, cb); drv.requestId = dat.requestId; drv.command = eCommand.Drivers; Logger.Info($"QueryData Manifest. Cmd:{drv.command.ToString()} reqId: {new Guid(drv.requestId).ToString()} Link: {drv.DriverId} manId: {drv.LastName}, {drv.FirstName} "); cb(drv.ToArray()); break; case eCommand.Manifest: case eCommand.GenerateManifest: manifestMaster micmd = (manifestMaster)myQueryData_GetManifest(reader, cb); micmd.requestId = dat.requestId; micmd.command = eCommand.Manifest; Logger.Info($"QueryData Manifest. Cmd:{micmd.command.ToString()} reqId: {new Guid(micmd.requestId).ToString()} Link: {micmd.LINK} manId: {micmd.id} "); cb(micmd.ToArray()); break; case eCommand.Trucks: trucks tcmd = (trucks)MyQueryReader_Trucks(reader, cb); tcmd.requestId = dat.requestId; tcmd.command = eCommand.Trucks; Logger.Info($"QueryData Trucks. Cmd:{tcmd.command.ToString()} reqId: {new Guid(tcmd.requestId).ToString()} TRK_CDE: {tcmd.TruckCode} ManId: {tcmd.ManifestId}"); cb(tcmd.ToArray()); break; case eCommand.Stops: stops scmd = (stops)MyQueryReader_Stops(reader, cb); scmd.requestId = dat.requestId; scmd.command = eCommand.Stops; Logger.Info($"QueryData Stops. Cmd:{scmd.command.ToString()} reqId: {new Guid(scmd.requestId).ToString()} manId: {scmd.ManifestId}"); cb(scmd.ToArray()); break; case eCommand.Orders: case eCommand.OrdersLoad: var ocmd = (orders)MyQueryReader_Orders(reader, cb); ocmd.requestId = dat.requestId; ocmd.command = eCommand.OrdersLoad; Logger.Info($"QueryData Orders. Cmd:{ocmd.command.ToString()} reqId: {new Guid(ocmd.requestId).ToString()}"); cb(ocmd.ToArray()); break; default: throw new Exception("Not handled"); } } Logger.Info($"QueryData Completed. Cmd:{dat.command.ToString()} reqId: {new Guid(dat.requestId).ToString()}"); cb(dat.ToArray()); } } } return(retVal); }
static Dictionary <short, Dictionary <byte, List <long> > > dTruckCodeToDealerNumbers = new Dictionary <short, Dictionary <byte, List <long> > >(); //TruckCode -> <Seq, List<Orders>> public static isaCommand CommandFactory(byte[] cmdBytes) { isaCommand cmd = new Command().FromArray(cmdBytes); switch (cmd.command) { case eCommand.Broadcast: //Broadcast cmdType = Broadcast.FromArray(cmdBytes); break; case eCommand.DeliveryComplete: //Broadcast cmdType = Broadcast.FromArray(cmdBytes); break; case eCommand.CheckManifest: case eCommand.CheckManifestComplete: manifestMaster mamr = new manifestMaster(); cmd = mamr.FromArray(cmdBytes); break; case eCommand.GenerateManifest: manifestRequest mr = new manifestRequest(); cmd = mr.FromArray(cmdBytes); if (cmd == null) { manifestMaster mmr = new manifestMaster(); cmd = mmr.FromArray(cmdBytes); } //Call ApplicationServer to return the data requested. //UMDManifest. break; case eCommand.OrdersLoad: //orders ords = new orders(); //cmd = ords.FromArray(cmdBytes); orderMaster orm = new orderMaster(); cmd = orm.FromArray(cmdBytes); break; case eCommand.Trucks: trucks trks = new trucks(); cmd = trks.FromArray(cmdBytes); break; case eCommand.Stops: stops stps = new stops(); cmd = stps.FromArray(cmdBytes); break; case eCommand.OrderDetails: orderDetails cmdType = new orderDetails(); cmd = cmdType.FromArray(cmdBytes); break; case eCommand.Manifest: manifestMaster mm = new manifestMaster(); cmd = mm.FromArray(cmdBytes); break; case eCommand.ManifestDetails: manifestDetails md = new manifestDetails(); cmd = md.FromArray(cmdBytes); break; case eCommand.OrdersUpload: orderMaster om = new orderMaster(); cmd = om.FromArray(cmdBytes); OrderMasterData omd = new OrderMasterData(om); if (!dStopOrders.ContainsKey(omd.DLR_NO)) { dStopOrders.Add(omd.DLR_NO, new List <long>() { omd.ORD_NO }); } break; case eCommand.ScanFile: scanFile sc = new scanFile(); cmd = sc.FromArray(cmdBytes); ScanFileData scd = new ScanFileData(sc); break; case eCommand.OrderOptions: orderOptions oo = new orderOptions(); cmd = oo.FromArray(cmdBytes); //OrderOptionsData ood = new OrderOptionsData(oo); break; case eCommand.AccountReceivable: accountReceivable ar = new accountReceivable(); cmd = ar.FromArray(cmdBytes); // AccountsReceivableData acr = new AccountsReceivableData((accountReceivable)cmd); break; case eCommand.ManifestLoadComplete: case eCommand.TrucksLoadComplete: case eCommand.StopsLoadComplete: case eCommand.OrdersLoadComplete: case eCommand.OrderUpdatesComplete: case eCommand.OrderDetailsComplete: case eCommand.OrderOptionsComplete: case eCommand.ManifestDetailsComplete: case eCommand.UploadManifestComplete: case eCommand.LoadFilesComplete: Logger.Info($"CommandFactory: {Enum.GetName(typeof(eCommand), cmd.command) + Environment.NewLine}"); manifestRequest req = new manifestRequest(); Logger.Info($"CommandFactory: {req.ToString()}"); cmd = req.FromArray(cmdBytes); break; case eCommand.Ping: //Broadcast cmdType = Broadcast.FromArray(cmdBytes); //cmd = SendPong(); break; case eCommand.Pong: //Broadcast cmdType = Broadcast.FromArray(cmdBytes); //Broadcast cmdType = Broadcast.FromArray(cmdBytes); break; case eCommand.RunQuery: //Broadcast cmdType = Broadcast.FromArray(cmdBytes); break; default: break; } return(cmd); }
private void metroTile7_Click(object sender, EventArgs e) { trucks t = new trucks(); t.Show(); }