static void Main(string[] args) { Console.WriteLine(@"|============================================|"); Console.WriteLine(@"| |"); Console.WriteLine(@"| ***Petrole Pump*** |"); Console.WriteLine(@"| |"); Console.WriteLine(@"|============================================|"); Console.WriteLine("\n***Welcome To Petrole Pump***"); Console.WriteLine("Please enter login details to continue!"); Console.Write("Username: "******"Password: "******"admin" && password != "1234") //if username and password did not matched { Console.WriteLine("Username or Password is incorrect!"); return; } Console.WriteLine("Loading..."); VehicleContainer vc = new VehicleContainer(); //calculate vehicle container Station station = new Station(3.5f); //calculate station IO.init(vc, station); //init input and output while (true) { int input = IO.getInput(); //get the input if (input == 0) //if inout is 0 means it is logout { break; //get out of loop } if (input != -1 && (input > 0 && input < 10)) //if the user input correct number { Vehicle v = vc.getVehicleToServed(); //get the vehicle to serve station.serveVehicle(v, input); //serve the vehicle to pump } } Console.WriteLine("Thank you for working on Petrole Pump!"); Console.WriteLine("Todays total earning: ", station.Commission, "£"); //get total comissioned }
public void RemoveVehicle(int vehicleId) { VehicleContainer.RemoveVehicle(vehicleId); }
public IEnumerable <Vehicle> GetStoreVehicles(int storeId) { return(VehicleContainer.GetStoreVehicles(storeId)); }
public Vehicle ModifyVehicle(Vehicle vehicle) { return(VehicleContainer.UpdateVehicle(vehicle)); }
public IEnumerable <Vehicle> GetAll() { return(VehicleContainer.GetAll()); }
public Vehicle GetById(int vehicleId) { return(VehicleContainer.GetById(vehicleId)); }
public void setVehicle(VehicleContainer s) { vehicle = s.transferVehicle(); }
public Vehicle AddVehicle(Vehicle vehicle) { return(VehicleContainer.AddVehicle(vehicle)); }
private static bool updating; //lock to check the console update process is started or not, if started then lock it else update the console public static void init(VehicleContainer _vc, Station _station) //initialize the class { vc = _vc; station = _station; updating = false; }
/// <summary> /// HACK: For the Stockholm case. /// </summary> public void trackVehicleScore(VehicleContainer element, ScoreContainer scoreContainer) { vehicleScores.Add(new Tuple <VehicleContainer, ScoreContainer>(element, scoreContainer)); }
public bool CheckRequestData(VehicleContainer inputModel) { ///////////////////////// процедура приема (сначала пишется файл - 7 строк, затем обработка для распихивания по таблицам) ConnectStr conStrKl1 = new ConnectStr(); conStrKl1.ConStr(1); cstrU1 = conStrKl1.StP; if (inputModel.ID < 2832035 || inputModel.ID >= 2832037) { using (MySqlConnection sqlConnectionT1 = new MySqlConnection(cstrU1)) { long IP = Convert.ToInt64(inputModel.ID); sqlConnectionT1.Open(); MySqlTransaction transaction = sqlConnectionT1.BeginTransaction(); string NamF = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmss") + "_" + inputModel.CreatedBy.PlatformId + "_" + inputModel.ID; ////string NamF = DateTime.Now + "_" + inputModel.ID; //using (FileStream stream = new FileStream(@"C:\Users\cherednikov\Desktop\АКТЫ\" + NamF.ToString() + ".xml", FileMode.CreateNew)) using (FileStream stream = new FileStream(@"F:\archiv\XML\" + NamF.ToString() + ".xml", FileMode.CreateNew)) { XmlSerializer serializer = new XmlSerializer(typeof(VehicleContainer)); serializer.Serialize(stream, inputModel); stream.Flush(); //stream.Close(); } //string aaa = @"C:\Users\cherednikov\Desktop\АКТЫ\" + DateTime.Now.AddDays(-1).ToString("yyyyMMdd"); string aaa = @"F:\archiv\XML\" + DateTime.Now.AddDays(-1).ToString("yyyyMMdd"); //CopyFolderYesterdayFiles(@"C:\Users\cherednikov\Desktop\АКТЫ", aaa); CopyFolderYesterdayFiles(@"F:\archiv\XML", aaa); KlSch = new string[4]; int j = 0; //////////////////////////////////// класс-схема и индекс ////////////////////////////////////// foreach (Classification Cl in inputModel.Classification) { KlSch[j] = Cl.Index.ToString(); j = j + 1; KlSch[j] = Cl.Schema.ToString(); j = j + 1; } //////////////////////////////////////////////////////////////////////////////////////// using (MySql.Data.MySqlClient.MySqlCommand cmd1 = new MySql.Data.MySqlClient.MySqlCommand(St1(inputModel), sqlConnectionT1)) { if (sqlConnectionT1.State == System.Data.ConnectionState.Closed) { sqlConnectionT1.Open(); } cmd1.ExecuteNonQuery(); } PDK = new string[inputModel.AxleCount, 30]; foreach (AxleContainer a in inputModel.Axles) { using (MySql.Data.MySqlClient.MySqlCommand cmd1 = new MySql.Data.MySqlClient.MySqlCommand(StrAxel(a, IP), sqlConnectionT1)) { if (sqlConnectionT1.State == System.Data.ConnectionState.Closed) { sqlConnectionT1.Open(); } cmd1.ExecuteNonQuery(); } } Im = new string[15]; co = 0; foreach (BinaryContainer b in inputModel.Binaries) { string BS = @"F:\\archivACT\\Photo\\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\\" + IP.ToString() + "_" + b.CreatedBy.PlatformId.ToString() + "_" + b.Created.ToString("yyyyMMdd_HHmmss") + "_" + co.ToString(); if (b.Name != "Video") { if (b == null) { continue; } Im[co] = b.ID.ToString(); co = co + 1; CO = CO + 1; //b.CreatedBy.PlatformId // b.Data; //if (!System.IO.Directory.Exists(@"C:\Users\cherednikov\Desktop\АКТЫ\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\")) if (!System.IO.Directory.Exists(@"F:\archivACT\Photo\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\")) { //System.IO.Directory.CreateDirectory(@"C:\Users\cherednikov\Desktop\АКТЫ\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\"); System.IO.Directory.CreateDirectory(@"F:\archivACT\Photo\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\"); } // System.DrawingCore.Image imgg = byteArrayToImage(b.Data); //string BS = @"C:\Users\cherednikov\Desktop\АКТЫ\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\"+IP.ToString()+"_"+b.CreatedBy.PlatformId.ToString()+"_"+b.Created.ToString("yyyyMMdd_HHmmss") + "_" + co.ToString(); BS = @"F:\\archivACT\\Photo\\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\\" + IP.ToString() + "_" + b.Name.ToString() + "_" + b.CreatedBy.PlatformId.ToString() + "_" + b.Created.ToString("yyyyMMdd_HHmmss") + "_" + CO.ToString(); //Bitmap aa = byteArrayToImage(b.Data); //aa.Save(@"C:\Users\cherednikov\Desktop\АКТЫ\123.png", System.DrawingCore.Imaging.ImageFormat.Png); File.WriteAllBytes(BS + ".png", b.Data); //aa.Save(BS + ".png", System.DrawingCore.Imaging.ImageFormat.Png); ////imgg.Save(BS + "_" + co + ".Jpeg", System.DrawingCore.Imaging.ImageFormat.Jpeg); //BinStr = @BS.ToString(); using (MySql.Data.MySqlClient.MySqlCommand cmd1 = new MySql.Data.MySqlClient.MySqlCommand(StrBinryN(b, IP, BS + ".png"), sqlConnectionT1)) { if (sqlConnectionT1.State == System.Data.ConnectionState.Closed) { sqlConnectionT1.Open(); } cmd1.ExecuteNonQuery(); } //using (MySql.Data.MySqlClient.MySqlCommand cmd1 = new MySql.Data.MySqlClient.MySqlCommand(StrBinry(b, IP), sqlConnectionT1)) //{ // if (sqlConnectionT1.State == System.Data.ConnectionState.Closed) // { sqlConnectionT1.Open(); } // cmd1.ExecuteNonQuery(); //} } else { Im[co] = b.ID.ToString(); co = co + 1; CO = CO + 1; File.WriteAllBytes(@"F:\\archivACT\\Photo\\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\\" + IP.ToString() + "_" + b.CreatedBy.PlatformId.ToString() + "_" + b.Created.ToString("yyyyMMdd_HHmmss") + "_" + co.ToString() + ".avi", b.Data); using (MySql.Data.MySqlClient.MySqlCommand cmd1 = new MySql.Data.MySqlClient.MySqlCommand(StrBinryN(b, IP, @"F:\\archivACT\\Photo\\" + DateTime.Now.ToString("dd_MM_yyyy") + @"\\" + IP.ToString() + "_" + b.CreatedBy.PlatformId.ToString() + "_" + b.Created.ToString("yyyyMMdd_HHmmss") + "_" + CO.ToString() + ".avi"), sqlConnectionT1)) { if (sqlConnectionT1.State == System.Data.ConnectionState.Closed) { sqlConnectionT1.Open(); } cmd1.ExecuteNonQuery(); } //using (MySql.Data.MySqlClient.MySqlCommand cmd1 = new MySql.Data.MySqlClient.MySqlCommand(StrBinry(b, IP), sqlConnectionT1)) //{ // if (sqlConnectionT1.State == System.Data.ConnectionState.Closed) // { sqlConnectionT1.Open(); } // cmd1.ExecuteNonQuery(); //} } } using (MySql.Data.MySqlClient.MySqlCommand cmd1 = new MySql.Data.MySqlClient.MySqlCommand(StrPROEZD(inputModel, IP), sqlConnectionT1)) { if (sqlConnectionT1.State == System.Data.ConnectionState.Closed) { sqlConnectionT1.Open(); } cmd1.ExecuteNonQuery(); } //////////////////////////////////////////////////////////////////////////////////////////// transaction.Commit(); sqlConnectionT1.Close(); } } return(true); }
private string StrPROEZD(VehicleContainer inputModel, long IP) { double Ll = 0; double LL = 0; double LA = 0; if (inputModel.LocationLatitude != "NaN") { Ll = Convert.ToDouble(inputModel.LocationLatitude); } else { Ll = 0; } if (inputModel.LocationLongitude != "NaN") { LL = Convert.ToDouble(inputModel.LocationLongitude); } else { LL = 0; } if (inputModel.LocationAltitude != "NaN") { LA = Convert.ToDouble(inputModel.LocationAltitude); } else { LA = 0; } //if ( inputModel.LocationLatitude. != null) // //"" + inputModel.LocationLongitude + ", " + // //"" + inputModel.LocationAltitude + ", " +) //{ } return("INSERT INTO vehiclecontainer_r (" + "ParentType, " + " ParentID, " + " PlatformId, " + " ComponentId, " + " Created, " + " Checksum, " + " Captions, " + " Credence, " + " CredenceExceeded, " + " Lane, " + " Direction, " + " Speed, " + " SpeedDifference, " + " Length, " + " Width, " + " Height, " + " PositionLeft, " + " PositionRight, " + " ClassScheme, " + " Class, " + " ClassScheme2, " + " Class2, " + " ClassScheme3, " + " Class3, " + " Units, " + " WheelBase, " + " Weight, " + " WeightLimit, " + " Overweight, " + " AxleCount, " + " Plate, " + " PlateConfidence, " + " PlateValid, " + " PlateRear, " + " PlateRearConfidence, " + " Country, " + " CountryConfidence, " + " AdrFrontEmpty, " + " AdrFrontKemler, " + " AdrFrontUn, " + " AdrFrontConfidence, " + " AdrRearEmpty, " + " AdrRearKemler, " + " AdrRearUn, " + " AdrRearConfidence, " + " IsOverweightGross, " + " IsOverweightPartial, " + " IsExceededLength, " + " IsExceededWidth, " + " IsExceededHeight, " + " IsOverspeed, " + " IsWrongDirection, " + " IsNonStandard, " + " OperatingRangeExceededSpeed, " + " OperatingRangeExceededWeight, " + " Divert, " + " Diverted, " + " ID_wim, " + " VehicleTypeName, " + " IDVStup, " + " LocationLatitude, " + " LocationLongitude, " + " LocationAltitude, " + "IsOverweightGroup )" + " VALUES(" + "" + Convert.ToInt32(inputModel.CreatedBy.BGuidType) + ", " + "" + Convert.ToInt32(inputModel.CreatedBy.KeyMark) + ", " + "" + Convert.ToInt64(inputModel.CreatedBy.PlatformId) + ", " + "" + Convert.ToInt64(inputModel.CreatedBy.ID) + ", " + "REPLACE(REPLACE(REPLACE(REPLACE('" + inputModel.Created.ToString("u") + "','-',''),' ',''),':',''),'Z',''), " + "'" + bit(Convert.ToString(inputModel.Checksum), 10, 16) + "', " + "'" + inputModel.Captions[0] + "', " + "" + inputModel.Credence + ", " + "" + inputModel.CodeInt + ", " + //CredenceExceeded "" + inputModel.LaneNumber + ", " + "" + Convert.ToInt16(inputModel.Direction) + ", " + "" + inputModel.Speed + ", " + "" + inputModel.SpeedDifference + ", " + "" + inputModel.Length + ", " + "" + inputModel.Width + ", " + "" + inputModel.Height + ", " + "" + inputModel.PositionLeft + ", " + "" + inputModel.PositionRight + ", " + "'" + KlSch[1] + "', " + //inputModel.Classification.Where(s=>s.Schema=="EUR13").FirstOrDefault()?.Schema ?? "No" "" + Convert.ToInt32(KlSch[0]) + ", " + "'" + KlSch[3] + "', " + //inputModel.Classification.Where(s=>s.Schema=="EUR13").FirstOrDefault()?.Schema ?? "No" "" + Convert.ToInt32(KlSch[2]) + ", " + "" + co + ", " + "(SELECT MAX(binarycontainer_n.id) AS expr1 FROM binarycontainer_n WHERE binarycontainer_n.ID_PR = " + IP + " GROUP BY binarycontainer_n.ID_PR), " + //"'" + KlSch[3] ??"" + "', " + //"" + Convert.ToInt32(KlSch[2]) ?? 0 + ", " + "" + inputModel.Units + ", " + "" + inputModel.WheelBase + ", " + "" + inputModel.Weight + ", " + "" + inputModel.WeightLimit + ", " + "" + inputModel.Overweight + ", " + "" + inputModel.AxleCount + ", " + "'" + inputModel.Plate + "', " + "" + inputModel.PlateConfidence + ", " + "'" + inputModel.PlateValid.ToString() + "', " + "'" + inputModel.PlateRear + "', " + "" + inputModel.PlateRearConfidence + ", " + "'" + inputModel.CountryCode + "', " + "" + inputModel.CountryConfidence + ", " + "" + inputModel.AdrFrontEmpty + ", " + "'" + inputModel.AdrFrontKemler + "', " + "'" + inputModel.AdrFrontUn + "', " + "" + inputModel.AdrFrontConfidence + ", " + "" + inputModel.AdrRearEmpty + ", " + "'" + inputModel.AdrRearKemler + "', " + "'" + inputModel.AdrRearUn + "', " + "" + inputModel.AdrRearConfidence + ", " + "" + inputModel.IsOverweightGross + ", " + "" + inputModel.IsOverweightPartial + ", " + //"" + inputModel.Overweight + ", " + "" + inputModel.IsExceededLength + ", " + "" + inputModel.IsExceededWidth + ", " + "" + inputModel.IsExceededHeight + ", " + "" + inputModel.IsOverspeed + ", " + "" + inputModel.IsWrongDirection + ", " + "" + inputModel.IsNonStandard + ", " + "" + inputModel.OperatingRangeExceededSpeed + ", " + "" + inputModel.OperatingRangeExceededWeight + ", " + "" + inputModel.Divert + ", " + "" + inputModel.Diverted + ", " + "" + IP + ", " + "'" + inputModel.VehicleTypeName + "', " + "" + 0 + ", " + "" + Ll + ", " + "" + LL + ", " + "" + LA + ", " + "" + inputModel.IsOverweightPartialGroup + "); "); }
private string St1(VehicleContainer inputModel) { return("INSERT INTO vehiclecontainer (ID, " + " PlatformId, " + " ComponentId, " + " SoftwareVersion, " + " CreatedBy, " + " Created, " + " Credence, " + " CredenceExceeded, " + " Lane, " + " Direction, " + " Speed, " + " SpeedDifference, " + " Length, " + " Width, " + " Height, " + " PositionLeft, " + " PositionRight, " + " Units, " + " WheelBase, " + " Weight, " + " WeightLimit, " + " Overweight, " + " AxleCount, " + " Plate, " + " PlateConfidence, " + " PlateValid, " + " PlateRearConfidence, " + " PlateRearValid, " + " Country, " //+ " CountrySubdivision, " + " CountryConfidence, " + " AdrFrontEmpty, " + " AdrFrontKemler, " + " AdrFrontUn, " + " AdrFrontConfidence, " + " AdrRearEmpty, " + " AdrRearKemler, " + " AdrRearUn, " + " AdrRearConfidence, " + " IsOverweightGross, " + " IsOverweightPartial, " + " IsExceededLength, " + " IsExceededWidth, " + " IsExceededHeight, " + " IsOverspeed, " + " IsWrongDirection, " + " IsNonStandard, " + " OperatingRangeExceededSpeed, " + " OperatingRangeExceededWeight, " + " Divert, " + " Diverted ) " + " VALUES( " + "" + inputModel.ID + ", " + "'" + inputModel.CreatedBy.PlatformId + "', " + "'" + inputModel.CreatedBy.BGuidType + "'," + "'" + inputModel.CreatedBy.KeyMark + "'," + "'" + inputModel.CreatedBy.ID + "'," + "'" + inputModel.Created + "'," + "'" + inputModel.Credence + "'," + "'" + inputModel.CodeInt + "', " +//CredenceExceeded + "'," + "'" + inputModel.LaneNumber + "'," + "'" + inputModel.Direction + "'," + "'" + inputModel.Speed + "'," + "'" + inputModel.SpeedDifference + "'," + "'" + inputModel.Length + "'," + "'" + inputModel.Width + "'," + "'" + inputModel.Height + "'," + "'" + inputModel.PositionLeft + "'," + "'" + inputModel.PositionRight + "'," + "'" + inputModel.Units + "'," + "'" + inputModel.WheelBase + "'," + "'" + inputModel.Weight + "'," + "'" + inputModel.WeightLimit + "'," + "'" + inputModel.Overweight + "'," + "'" + inputModel.AxleCount + "'," + "'" + inputModel.Plate + "'," + "'" + inputModel.PlateConfidence + "'," + "'" + inputModel.PlateValid + "'," + "'" + inputModel.PlateRearConfidence + "'," + "'" + inputModel.PlateRearValid + "'," + "'" + inputModel.CountryCode + "'," + //"'" + inputModel.CountrySubdivisionCode + "'," + "'" + inputModel.CountryConfidence + "'," + "'" + inputModel.AdrFrontEmpty + "'," + "'" + inputModel.AdrFrontKemler + "'," + "'" + inputModel.AdrFrontUn + "'," + "'" + inputModel.AdrFrontConfidence + "'," + "'" + inputModel.AdrRearEmpty + "'," + "'" + inputModel.AdrRearKemler + "'," + "'" + inputModel.AdrRearUn + "'," + "'" + inputModel.AdrRearConfidence + "'," + "'" + inputModel.IsOverweightGross + "'," + "'" + inputModel.IsOverweightPartial + "'," + "'" + inputModel.IsExceededLength + "'," + "'" + inputModel.IsExceededWidth + "'," + "'" + inputModel.IsExceededHeight + "'," + "'" + inputModel.IsOverspeed + "'," + "'" + inputModel.IsWrongDirection + "'," + "'" + inputModel.IsNonStandard + "'," + "'" + inputModel.OperatingRangeExceededSpeed + "'," + "'" + inputModel.OperatingRangeExceededWeight + "'," + "'" + inputModel.Divert + "'," + "'" + inputModel.Diverted + "');"); }