Пример #1
0
 // Serialize into XML
 internal void Serialization(object _readData, int _dataSet)
 {
     Console.WriteLine(_readData + " - " + _dataSet.ToString());
     // Customers
     if (_dataSet == 0)
     {
         // Setup
         XmlSerializer            _encrypt       = new XmlSerializer(typeof(CustomerLibrary.Routines));
         TextWriter               _output        = new StreamWriter(@"./EncryptedCustomer.XML");
         CustomerLibrary.Routines _instantiation = new CustomerLibrary.Routines();
         // Send to File
         _encrypt.Serialize(_output, _instantiation);
         _output.Close();
     }
     // Locations
     if (_dataSet == 1)
     {
         // Setup
         XmlSerializer            _encrypt       = new XmlSerializer(typeof(LocationLibrary.Routines));
         TextWriter               _output        = new StreamWriter(@"./EncryptedLocation.XML");
         LocationLibrary.Routines _instantiation = new LocationLibrary.Routines();
         // Send to File
         _encrypt.Serialize(_output, _instantiation);
         _output.Close();
     }
     // Products
     if (_dataSet == 2)
     {
         // Setup
         XmlSerializer           _encrypt       = new XmlSerializer(typeof(ProductLibrary.Routines));
         TextWriter              _output        = new StreamWriter(@"./EncryptedProduct.XML");
         ProductLibrary.Routines _instantiation = new ProductLibrary.Routines();
         // Send to File
         _encrypt.Serialize(_output, _instantiation);
         _output.Close();
     }
     // Orders
     if (_dataSet == 3)
     {
         // Setup
         XmlSerializer         _encrypt       = new XmlSerializer(typeof(OrderLibrary.Routines));
         TextWriter            _output        = new StreamWriter(@"./EncryptedOrder.XML");
         OrderLibrary.Routines _instantiation = new OrderLibrary.Routines();
         // Send to File
         _encrypt.Serialize(_output, _instantiation);
         _output.Close();
     }
 }
        // System.Data.SQLclient
        internal async void DBprocess(string _query, int _length, string[] _key, int _dataSet)
        {
            // _dataSet Selection to Inform
            if (_dataSet == 0)
            {
                Console.WriteLine("Processing Query for Customers" + (char)13 + (char)10);
            }
            if (_dataSet == 1)
            {
                Console.WriteLine("Processing Query for Locations" + (char)13 + (char)10);
            }
            if (_dataSet == 3)
            {
                Console.WriteLine("Processing Query for Products" + (char)13 + (char)10);
            }
            if (_dataSet == 4)
            {
                Console.WriteLine("Processing Query for Orders" + (char)13 + (char)10);
            }

            // Connection Information
            string _pointer = File.ReadAllText("./Database.Connection");

            //
            // Console.WriteLine(Pointer); // Test
            //

            // Establish DB
            try
            {
                using (SqlConnection _connectDB = new SqlConnection(_pointer))
                {
                    // Open ResourceDB
                    _connectDB.Open();
                    // Send Instruction
                    using (SqlCommand _instructionDB = new SqlCommand(_query, _connectDB))
                    {
                        // Read Instruction
                        SqlDataReader _readData = _instructionDB.ExecuteReader();
                        // Display Data while TRUE
                        // await attempt
                        while (_readData.Read())
                        {
                            // Await Activity
                            //await Task.Run(
                            for (int _index = 0; _index < _length; _index++)
                            {
                                Console.WriteLine(_key[_index] + ": " + _readData[_index]);
                            }
                            //);
                            // Store SQLdata
                            FileIOlayer.Routines _logicIO = new FileIOlayer.Routines();
                            // Serialize Data for Transport
                            // await
                            _logicIO.Serialization(_readData, _dataSet);
                            // Business Logic
                            if (_dataSet == 0)
                            {
                                // Instantiation
                                CustomerLibrary.Routines _instanceCL = new CustomerLibrary.Routines();
                                _instanceCL.BusinessLogic(true, "", _length, _key, _dataSet, _query);
                            }
                            if (_dataSet == 1)
                            {
                                // Instantiation
                                LocationLibrary.Routines _instanceLL = new LocationLibrary.Routines();
                                _instanceLL.BusinessLogic(true, "", _length, _key, _dataSet, _query);
                            }
                            if (_dataSet == 2)
                            {
                                // Instantiation
                                ProductLibrary.Routines _instancePL = new ProductLibrary.Routines();
                                _instancePL.BusinessLogic(true, "", _length, _key, _dataSet, _query);
                            }
                            if (_dataSet == 3)
                            {
                                // Instantiation
                                OrderLibrary.Routines _instanceOL = new OrderLibrary.Routines();
                                _instanceOL.BusinessLogic(true, "", _length, _key, _dataSet, _query);
                            }
                            // New Line
                            Console.WriteLine();
                        }
                        // Close DataReader
                        _readData.Close();
                    }
                    // New Line
                    Console.WriteLine();
                    // Close Connection
                    _connectDB.Close();
                }
            }
            // Exception Handling
            catch
            {
                // New Line
                Console.WriteLine(" ");
                // Message for User
                Console.WriteLine("Recovered...");
            }
            // Continue
            finally
            {
                // New Line
                Console.WriteLine(" ");
                // Message For User
                Console.WriteLine("Menu Option?" + (char)13 + (char)10);
            }
        }
Пример #3
0
        static void Main()
        {
            // Temporary Set for Initial Process of Business Logic as Disabled or NULL in Functioning
            // SqlDataReader _classTemporary = new SqlDataReader();
            string[] _temporaryArray = { "1", "2", "3" };
            // SI - TDD : BusinessLogic(false, String.Empty, -1, [1,2,3], -1, "") => Prevent From Command Execution at Start of Run-Time
            //                                                                       ^- for Structural Integrity Test
            CustomerLibrary.Routines _logicCL = new CustomerLibrary.Routines(); _logicCL.BusinessLogic(false, "", -1, _temporaryArray, -1, "");
            ProductLibrary.Routines  _logicPL = new ProductLibrary.Routines(); _logicPL.BusinessLogic(false, "", -1, _temporaryArray, -1, "");
            LocationLibrary.Routines _logicLL = new LocationLibrary.Routines(); _logicLL.BusinessLogic(false, "", -1, _temporaryArray, -1, "");
            OrderLibrary.Routines    _logicOL = new OrderLibrary.Routines(); _logicOL.BusinessLogic(false, "", -1, _temporaryArray, -1, "");
            // Register to End Program
            bool _complete = false;

            // Title
            Console.WriteLine(" " + (char)13 + (char)10 + " ");
            string _data = "Welcome to the Market Locations Inventory Management Application";

            Console.WriteLine(_data + (char)13 + (char)10);
            // Display Menu
            DisplayMenu(_data);
            // Toggle Mode
            bool _entityMode = false;

            // Main Iteration of User Interface
            do
            {
                // check for Key Pressed as ASCII
                int _key = Console.Read();
                // Flow-Chart Pointers
                if (_key == 48)
                {
                    _complete = true;
                }
                // ----------
                if (_key == 49)
                {
                    // Find Items
                    string[] _send = { "Reference #", "At Location Identifier", "Name", "Description", "Price", "Quantity In Location" };
                    // DataBase Routines
                    //DBlayer.Start _logicDB = new DBlayer.Start(); string _result = _logicDB.DBprocess("SELECT (ProductID, LocationID, Description, Price, Quantity) WHERE ProductID=20 AND QUANTITY=10", 6, _send, 2);
                    // Place Order -> Taking note of Product ID and Quantity with Location ID to make an order transaction for Customer ID
                    //string[] _send = {"Reference #", "At Location Identifier", "Name", "Description", "Price", "Quantity In Location"};
                    // DataBase Routines
                    //DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("INSERT INTO Products () WHERE ProductID=20 AND QUANTITY=10", 6, _send, 2);
                    // Map Order in System
                    //string[] _send = {"Reference #", "Customer Reference #", "Location Reference #", "Product Reference #", "Record Date", "Percentage Off", "Reduced Amount"};
                    // DataBase Routines
                    //DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Orders", 6, _send, 3);
                }
                // ----------
                if (_key == 50)
                {
                    // Request Data
                    string[] _send = { "Reference #", "Name", "Address", "Phone Number", "eMail Address", "Home Store Preference" };
                    // DataBase Routines
                    DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Customers WHERE LastName='" + Console.ReadLine() + "'", 6, _send, 0);
                }
                // ----------
                if (_key == 52)
                {
                    // Request Data
                    string[] _send = { "Reference #", "Customer Reference #", "Location Reference #", "Product Reference #", "Record Date", "Percentage Off", "Reduced Amount" };
                    // DataBase Routines
                    DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Orders Where LocationID='" + Console.ReadLine() + "' JOIN LocationID IS NOT NULL", 6, _send, 3);
                    // Request Data
                    //string[] _send = {"Reference #", "Customer Reference #", "Location Reference #", "Product Reference #", "Record Date", "Percentage Off", "Reduced Amount"};
                    // DataBase Routines
                    //DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Orders Where ProductID='" + Console.ReadLine() + "' JOIN ProductID IS NOT NULL", 6, _send, 3);
                }
                // ----------
                if (_key == 52)
                {
                    // Request Data
                    string[] _send = { "Reference #", "Customer Reference #", "Location Reference #", "Product Reference #", "Record Date", "Percentage Off", "Reduced Amount" };
                    // DataBase Routines
                    DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Orders Where OrderID='" + Console.ReadLine() + "' JOIN CustomerID IS NOT NULL", 6, _send, 3);
                }
                if (_key == 53)
                {
                    // Request Data
                    string[] _send = { "Reference #", "Customer Reference #", "Location Reference #", "Product Reference #", "Record Date", "Percentage Off", "Reduced Amount" };
                    // DataBase Routines
                    DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Orders Where CustomerID='" + Console.ReadLine() + "' JOIN ProductID IS NOT NULL", 6, _send, 3);
                }
                // ----------
                if (_key == 55)
                {
                    _entityMode = true; Console.WriteLine("Linq - Entity Frame-work Core Mode");
                }
                if (_key == 56)
                {
                    _entityMode = false; Console.WriteLine("System.Data.SQLclient Mode");
                }
                if (_key == 57)
                {
                    DisplayMenu(_data);
                }
                // ----- A /a ------ Encrypt : Serialization -> Binary
                if (_key == 65 || _key == 97)
                {
                    // Request Data
                    string[] _send = { "Reference #", "Name", "Address", "Phone Number", "eMail Address", "Home Store Preference" };
                    // DataBase Routines
                    DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Customers", 6, _send, 0);
                }
                // ----- B / b ----- Decypher : Deserialization <- From Binary
                //if (_key == 66 || _key == 98){ DeSerialization(object _readData, int _dataSet) }
                // ----- U / u ----- Customer Functions
                if (_key == 85 || _key == 117)
                {
                    if (_entityMode)
                    {
                    }
                    else
                    {
                        // Request Data
                        string[] _send = { "Reference #", "Name", "Address", "Phone Number", "eMail Address", "Home Store Preference" };
                        // DataBase Routines
                        DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Customers", 6, _send, 0);
                    }
                }
                // ----- I / i----- Location Functions
                if (_key == 73 || _key == 105)
                {
                    if (_entityMode)
                    {
                    }
                    else
                    {
                        // Request Data
                        string[] _send = { "Reference #", "Name", "Address", "Phone Number", "eMail Address" };
                        // DataBase Routines
                        DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Locations", 5, _send, 1);
                    }
                }
                // ----- I / i ----- Product Functions
                if (_key == 79 || _key == 111)
                {
                    if (_entityMode)
                    {
                    }
                    else
                    {
                        // Request Data
                        string[] _send = { "Reference #", "At Location Identifier", "Name", "Description", "Price", "Quantity In Location" };
                        // DataBase Routines
                        DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Products", 6, _send, 2);
                    }
                }
                // ----- I / i ----- Order Functions
                if (_key == 80 || _key == 112)
                {
                    if (_entityMode)
                    {
                    }
                    else
                    {
                        // Request Data
                        string[] _send = { "Reference #", "Customer Reference #", "Location Reference #", "Product Reference #", "Record Date", "Percentage Off", "Reduced Amount" };
                        // DataBase Routines
                        DBlayer.Start _logicDB = new DBlayer.Start(); _logicDB.DBprocess("SELECT * FROM Orders", 6, _send, 3);
                    }
                }
            }while (!_complete);
        }