Ejemplo n.º 1
0
        //Method
        public void ReturnVehicleSubMenu(bool clear = true)
        {
            if (clear)
            {
                Console.Clear();
            }

            Console.WriteLine("### Return Vehicle Submenu ###\n");
            RegoReturnValidInput();
            // Store customer ID to be returned
            int CustomerID = Fleet.ReturnVehicle(RegoToReturn);

            // Return is unsuccessful if returned customer ID is -1
            if (CustomerID == -1)
            {
                Console.WriteLine($"\nReturn Unsuccessful. Vehicle '{RegoToReturn}' is not currently being rented.");
            }
            else
            {
                // Delete Record containing rego and customer id
                CsvOperations.DeleteRecord("rentals.csv", RegoToReturn, Fleet.RentalsFile, 0);
                // Remove rego and Id from rental dictionary
                foreach (var item in Fleet.Rentals.Where(kvp => kvp.Value == CustomerID).ToList())
                {
                    Fleet.Rentals.Remove(item.Key);
                }
                Console.WriteLine($"\nSuccessfully returned the Vehicle with the registration of '{RegoToReturn}' belonging to customer '{CustomerID.ToString()}'");
            }
            LastMRRCscreen(() => SubMenu("Rentals"), () => ReturnVehicleSubMenu());
        }
Ejemplo n.º 2
0
        //Method
        public void ReturnVehicleSubMenu(bool clear = true)
        {
            if (clear)
            {
                Console.Clear();
            }

            Console.WriteLine("### Return Vehicle Submenu ###\n");
            RegoReturnValidInput();
            // Store customer ID to be returned
            int CustomerID = Fleet.ReturnVehicle(RegoToReturn);

            // Return is unsuccessful if returned customer ID is -1
            if (CustomerID == -1)
            {
                Console.WriteLine($"\nReturn Unsuccessful. Vehicle '{RegoToReturn}' is not currently being rented.");
            }
            else
            {
                // Delete Record containing rego and customer id
                CsvOperations.DeleteRecord("rentals.csv", RegoToReturn, Fleet.RentalsFile, 0);
                int position = Fleet.RentalListRego.IndexOf(RegoToReturn);
                // Remove rego, Id, time and cost from rental list
                Fleet.RentalListRego.RemoveAt(position);
                Fleet.RentalListID.RemoveAt(position);
                Fleet.DailyCost.RemoveAt(position);
                Console.WriteLine($"\nSuccessfully returned the Vehicle with the registration of '{RegoToReturn}' belonging to customer '{CustomerID.ToString()}'");
            }
            LastMRRCscreen(() => SubMenu("Rentals"), () => ReturnVehicleSubMenu());
        }
Ejemplo n.º 3
0
        // Method to perform search on the querey
        private void search(RPN rpn, Fleet fleet)
        {
            Console.WriteLine("\n--------------------------------------------- Searching available vehicles ---------------------------------------------");

            // Create new datatable for available vehicles (unrented)
            DataTable AvaiableVehicles = new DataTable();

            // Fill table for available vehicles
            CsvOperations.SearchToTable(fleet, AvaiableVehicles);
            // Show search to table datatable
            CsvOperations.ShowDataTable(AvaiableVehicles, fleet.FleetFile, "ASCII", true);

            Console.Write("\nInfix expression:    ");
            foreach (string token in rpn.InfixTokens)
            {
                Console.Write(token + " ");
            }
            Console.WriteLine();

            Console.Write("Postfix expression:  ");
            foreach (string token in rpn.PostfixTokens)
            {
                Console.Write(token + " ");
            }
            Console.WriteLine();
            Console.WriteLine();

            fleet.search(out string[] result, rpn);

            if (result.Length == 0)
            {
                throw new Exception("No match found");
            }

            List <string> results = new List <string>();

            foreach (string res in result)
            {
                // display vehicle by registration plate (rego)
                Vehicle v;
                for (int i = 0; i < fleet.vehicles.Count; i++)
                {   // go through, find the vehicle by rego
                    v = (Vehicle)fleet.vehicles[i];
                    if (v.registration == res)
                    {
                        results.Add(v.ToCSVstring());
                        break;
                    }
                }
            }

            Console.WriteLine("\n-------------------------------------------------- Query Search Output -------------------------------------------------");
            // Create new datatable for query result for searched vehicles
            DataTable resultTable = new DataTable();

            // fill query result table
            CsvOperations.SearchToTable(fleet, resultTable, results);
            // show datatable
            CsvOperations.ShowDataTable(resultTable, fleet.FleetFile, "Extended", true);
        }
Ejemplo n.º 4
0
        // Method to perform search on the querey
        private void search(RPN rpn, Fleet fleet)
        {
            // hardcode some vehicles and create sets of attributes.
            // a set is comprised of vehicle number plates

            Console.WriteLine("\n---------------- Searching available vehicles --------------");

            DataTable AvaiableVehicles = new DataTable();

            CsvOperations.SearchToTable(fleet, AvaiableVehicles);
            CsvOperations.ShowDataTable(AvaiableVehicles, fleet.FleetFile, "ASCII", true);

            Console.Write("\nInfix expression:    ");
            foreach (string token in rpn.InfixTokens)
            {
                Console.Write(token + " ");
            }
            Console.WriteLine();

            Console.Write("Postfix expression:  ");
            foreach (string token in rpn.PostfixTokens)
            {
                Console.Write(token + " ");
            }
            Console.WriteLine();
            Console.WriteLine();

            fleet.search(out string[] result, rpn);

            if (result.Length == 0)
            {
                throw new Exception("No match found");
            }

            List <string> results = new List <string>();

            foreach (string res in result)
            {
                // display vehicle by registration plate (rego)
                Vehicle v;
                for (int i = 0; i < fleet.vehicles.Count; i++)
                {   // go through, find the vehicle by rego
                    v = (Vehicle)fleet.vehicles[i];
                    if (v.registration == res)
                    {
                        results.Add(v.ToCSVstring());
                        break;
                    }
                }
            }

            DataTable resultTable = new DataTable();

            CsvOperations.SearchToTable(fleet, resultTable, results);
            CsvOperations.ShowDataTable(resultTable, fleet.FleetFile, "Extended", true);
        }
Ejemplo n.º 5
0
        // method to show all vehicles if query is a blank line
        private void search(Fleet fleet)
        {
            Console.WriteLine("\n-------------------------------------------- Showing all available vehicles --------------------------------------------");
            // Create new datatable for all vehicles (unrented)
            DataTable AllVehicles = new DataTable();

            // Fill table for all vehicles
            CsvOperations.SearchToTable(fleet, AllVehicles, null);
            // Show search to table datatable
            CsvOperations.ShowDataTable(AllVehicles, fleet.FleetFile, "ASCII", true);
        }
Ejemplo n.º 6
0
 private void MergeCsv(string filename)
 {
     foreach (string[] strArray in this._gameRoot == null ? CsvOperations.Read(ScriptHost.FileSystem, filename, '"', ',', 0, 2) : CsvOperations.Read(filename, '"', ',', 0, 2))
     {
         if (strArray.Length != 0)
         {
             string key = strArray[0].Trim();
             if (key.Length != 0)
             {
                 if (this.ContainsKey(key))
                 {
                     throw new InvalidDataException(string.Format("Duplicate ID '{0}' found in '{1}'.", (object)key, (object)filename));
                 }
                 string str = strArray.Length <= 1 ? string.Empty : strArray[1].Trim();
                 this[key] = str;
             }
         }
     }
 }
        // This methods displays the data table to the console, where it sources the csv files from the specified locations
        private void DisplayTable(string option)
        {
            DataTable rentals   = new DataTable();
            DataTable fleet     = new DataTable();
            DataTable customers = new DataTable();

            switch (option)
            {
            case "Customer":
                CsvOperations.ShowDataTable(customers, Crm.CrmFile, CsvOperations.borderStyle);
                break;

            case "Fleet":
                CsvOperations.ShowDataTable(fleet, Fleet.FleetFile, CsvOperations.borderStyle);
                break;

            case "Rentals":
                CsvOperations.RentalsToTable(Fleet, rentals);
                CsvOperations.ShowDataTable(rentals, Fleet.RentalsFile, CsvOperations.borderStyle, true);
                break;
            }
        }
Ejemplo n.º 8
0
 public MembeClaimController()
 {
     csvOperation = new CsvOperations();
 }
        public async Task <IActionResult> Analysis(List <IFormFile> allfiles)
        {
            //DeleteFilesIfReachMax();

            string path = "";
            string loc  = "";

            if (allfiles.Count > 0)
            {
                foreach (var files in allfiles)
                {
                    string currFilename = DateTime.Now.ToString("yyyyMMddHHmmss") + files.FileName.Replace(" ", "");
                    string Filename     = currFilename.Replace("#", "Number-");
                    path = Path.Combine(_env.WebRootPath, "Files/" + Filename);
                    loc  = "Files/" + Filename;

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        files.CopyTo(stream);
                    }
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }

            List <string> mails = CsvOperations.ReadCsv(path);

            List <string> mx = await MxOperations.SetListForSearchingAsync(mails);

            /* if (mx[0] == "Try Again")
             *   return new ContentResult{
             *   ContentType = "text/html",
             *   Content = "<h1>"+mx[1]+"</h1>"};*/

            int index = 0;

            foreach (string mail in mx.ToArray())
            {
                foreach (KeyValuePair <string, string> pair in companies)
                {
                    if (mail.Contains(pair.Key))
                    {
                        mx[index] = pair.Value;
                        break;
                    }
                    else if (mail == "" || mail == " ")
                    {
                        mx[index] = "Unknown";
                    }
                    else
                    {
                        mx[index] = "Web Mail";
                    }
                }
                index++;
            }

            CsvOperations.WriteCsv(path, mx);

            return(RedirectToAction("Result", "Home", new { path = loc }));
        }