Exemple #1
0
        public DistinctProductList <Motherboard> GetMotherboardData()
        {
            MySqlCommand command =
                new MySqlCommand(
                    "SELECT Product.ProductID, Product.name, Motherboard.formFactor, Motherboard.cpuType, " +
                    "Motherboard.cpuCount, Motherboard.socket, Motherboard.netcard, Motherboard.soundCard, " +
                    "Motherboard.multiGpu, Motherboard.crossfire, Motherboard.sli, Motherboard.maxMem, " +
                    "Motherboard.memSlots, Motherboard.memType, Motherboard.graphicsCard, Motherboard.chipset " +
                    "FROM Product, Motherboard " +
                    "WHERE Product.ProductID = Motherboard.ProductID", connection);

            DistinctProductList <Motherboard> result = new DistinctProductList <Motherboard>();
            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                object[] tempResult = new object[reader.FieldCount];
                reader.GetValues(tempResult);

                Motherboard row = new Motherboard("Motherboard", (int)tempResult[0], (string)tempResult[1],
                                                  (string)tempResult[2], (string)tempResult[3],
                                                  (int)tempResult[4], (string)tempResult[5], reader.GetBoolean(6), reader.GetBoolean(7),
                                                  reader.GetBoolean(8), reader.GetBoolean(9), reader.GetBoolean(10), (int)tempResult[11],
                                                  (int)tempResult[12], (string)tempResult[13], reader.GetBoolean(14), (string)tempResult[15]);

                result.Add(row);
            }


            reader.Close();

            return(result);
        }
Exemple #2
0
        public DistinctProductList <HardDrive> GetHardDriveData()
        {
            MySqlCommand command =
                new MySqlCommand(
                    "SELECT Product.ProductID, Product.name, HardDrive.isInternal, HardDrive.type, HardDrive.formFactor, " +
                    "HardDrive.capacity, HardDrive.cacheSize, HardDrive.transferRate, HardDrive.brand, HardDrive.sata, " +
                    "HardDrive.height, HardDrive.depth, HardDrive.width " +
                    "FROM Product, HardDrive " +
                    "WHERE Product.ProductID = HardDrive.ProductID", connection);

            DistinctProductList <HardDrive> result = new DistinctProductList <HardDrive>();
            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                object[] tempResult = new object[reader.FieldCount];
                reader.GetValues(tempResult);

                HardDrive row = new HardDrive("HardDrive", (int)tempResult[0], (string)tempResult[1],
                                              reader.GetBoolean(2), (string)tempResult[3],
                                              (string)tempResult[4], (string)tempResult[5], (string)tempResult[6], (string)tempResult[7],
                                              (string)tempResult[8], (string)tempResult[9], (string)tempResult[10], (string)tempResult[11],
                                              (string)tempResult[12]);

                result.Add(row);
            }


            reader.Close();

            return(result);
        }
Exemple #3
0
        public DistinctProductList <PSU> GetPsuData()
        {
            MySqlCommand command =
                new MySqlCommand("SELECT Product.ProductID, Product.name, PSU.power, PSU.formFactor, PSU.modular, " +
                                 "PSU.width, PSU.depth, PSU.height, PSU.weight, PSU.brand " +
                                 "FROM Product, PSU " +
                                 "WHERE Product.ProductID = PSU.ProductID", connection);

            DistinctProductList <PSU> result = new DistinctProductList <PSU>();
            MySqlDataReader           reader = command.ExecuteReader();

            while (reader.Read())
            {
                object[] tempResult = new object[reader.FieldCount];
                reader.GetValues(tempResult);

                PSU row = new PSU("PSU", (int)tempResult[0], (string)tempResult[1], (string)tempResult[2],
                                  (string)tempResult[3], reader.GetBoolean(4),
                                  (string)tempResult[5], (string)tempResult[6], (string)tempResult[7], (string)tempResult[8],
                                  (string)tempResult[9]);

                result.Add(row);
            }

            reader.Close();

            return(result);
        }
Exemple #4
0
        public DistinctProductList <RAM> GetRamData()
        {
            MySqlCommand command =
                new MySqlCommand("SELECT Product.ProductID, Product.name, RAM.type, RAM.capacity, RAM.speed, " +
                                 "RAM.technology, RAM.formFactor, RAM.casLatens " +
                                 "FROM Product, RAM " +
                                 "WHERE Product.ProductID = RAM.ProductID", connection);

            DistinctProductList <RAM> result = new DistinctProductList <RAM>();
            MySqlDataReader           reader = command.ExecuteReader();

            while (reader.Read())
            {
                object[] tempResult = new object[reader.FieldCount];
                reader.GetValues(tempResult);

                RAM row = new RAM("RAM", (int)tempResult[0], (string)tempResult[1], (string)tempResult[2],
                                  (string)tempResult[3],
                                  (string)tempResult[4], (string)tempResult[5], (string)tempResult[6], (string)tempResult[7]);

                result.Add(row);
            }

            reader.Close();

            return(result);
        }
Exemple #5
0
        public DistinctProductList <Chassis> GetChassisData()
        {
            MySqlCommand command =
                new MySqlCommand(
                    "SELECT Product.ProductID, Product.name, Chassis.type, Chassis.atx, Chassis.miniAtx, Chassis.miniItx, " +
                    "Chassis.fans, Chassis.brand, Chassis.height, Chassis.width, Chassis.depth, Chassis.weight " +
                    "FROM Product, Chassis " +
                    "WHERE Product.ProductID = Chassis.ProductID", connection);

            DistinctProductList <Chassis> result = new DistinctProductList <Chassis>();
            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                object[] tempResult = new object[reader.FieldCount];
                reader.GetValues(tempResult);

                Chassis row = new Chassis("Chassis", (int)tempResult[0], (string)tempResult[1], (string)tempResult[2],
                                          reader.GetBoolean(3),
                                          reader.GetBoolean(4), reader.GetBoolean(5), (string)tempResult[6], (string)tempResult[7],
                                          (string)tempResult[8], (string)tempResult[9], (string)tempResult[10], (string)tempResult[11]);

                result.Add(row);
            }

            reader.Close();

            return(result);
        }
Exemple #6
0
        public DistinctProductList <CPU> GetCpuData()
        {
            MySqlCommand command =
                new MySqlCommand(
                    "SELECT Product.ProductID, Product.name, CPU.model, CPU.clock, CPU.maxTurbo, CPU.integratedGpu, " +
                    "CPU.stockCooler, CPU.manufacturer, CPU.cpuSeries, CPU.logicalCores, CPU.physicalCores, CPU.socket " +
                    "FROM Product, CPU " +
                    "WHERE Product.ProductID = CPU.ProductID AND CPU.Model != \"\" AND CPU.cpuSeries != \"\"", connection);

            DistinctProductList <CPU> result = new DistinctProductList <CPU>();
            MySqlDataReader           reader = command.ExecuteReader();

            while (reader.Read())
            {
                object[] tempResult = new object[reader.FieldCount];
                reader.GetValues(tempResult);

                CPU row = new CPU("CPU", (int)tempResult[0], (string)tempResult[1], (string)tempResult[2],
                                  (string)tempResult[3],
                                  (string)tempResult[4], (string)tempResult[5], reader.GetBoolean(6), (string)tempResult[7],
                                  (string)tempResult[8], (int)tempResult[9], (int)tempResult[10], (string)tempResult[11]);

                Match model = Regex.Match(row.Model, "\\d\\d\\d");

                if (model.Success)
                {
                    result.Add(row);
                }
            }

            reader.Close();

            return(result);
        }
Exemple #7
0
        public DistinctProductList <GPU> GetGpuData()
        {
            MySqlCommand command =
                new MySqlCommand(
                    "SELECT Product.ProductID, Product.name, GPU.processorManufacturer, GPU.chipset, GPU.graphicsProcessor, " +
                    "GPU.architecture, GPU.cooling, GPU.memSize, GPU.pciSlots, GPU.manufacturer, GPU.model, GPU.boostedClock " +
                    "FROM Product, GPU " +
                    "WHERE Product.ProductID = GPU.ProductID AND GPU.manufacturer != \"\" AND GPU.graphicsProcessor != \"\" AND GPU.model != \"\"", connection);

            DistinctProductList <GPU> result = new DistinctProductList <GPU>();
            MySqlDataReader           reader = command.ExecuteReader();

            while (reader.Read())
            {
                object[] tempResult = new object[reader.FieldCount];
                reader.GetValues(tempResult);

                GPU row = new GPU("GPU", (int)tempResult[0], (string)tempResult[1], (string)tempResult[2],
                                  (string)tempResult[3], (string)tempResult[4], (string)tempResult[5], (string)tempResult[6],
                                  (string)tempResult[7], (int)tempResult[8], (string)tempResult[9],
                                  (string)tempResult[10], //model
                                  (string)tempResult[11]  //boosted clock
                                  );

                result.Add(row);
            }


            reader.Close();

            return(result);
        }
Exemple #8
0
        //The work each thread should do (link the products delegated to this thread, with the reviews.)
        public void ThreadfunctionProduct <T>(object data) where T : Product
        {
            DistinctProductList <T>     productList = ((ThreadingData <T>)data).productList;
            DistinctReviewList <Review> reviewList  = ((ThreadingData <T>)data).reviewList;
            ReviewProductLinks          processedReviewProductLinks = ThreadingData.threadProcessedData[((ThreadingData <T>)data).id];

            foreach (var product in productList)
            {
                product.MatchReviewAndProductTokens(reviewList, productList.stopWord, ref processedReviewProductLinks); //execute linking processing
            }

            Interlocked.Decrement(ref ThreadingData.semaphore);
        }
Exemple #9
0
 //method to start all threads, with their work.
 public void StartThreads <T>(int productsPerThread, DistinctProductList <T> productList, DistinctReviewList <Review> reviewList) where T : Product
 {
     for (int i = 0; i < productList.Count; i += productsPerThread)
     {
         if (productList.Count - i > productsPerThread)                       //amount of products left to process is above that which the thread task should process
         {
             ThreadingData.threadProcessedData.Add(new ReviewProductLinks()); //this specific thread's container for processed data
             ThreadPool.QueueUserWorkItem(ThreadfunctionProduct <T>, new ThreadingData <T>(ThreadingData.semaphore, productList.GetRange(i, productsPerThread), reviewList));
             Interlocked.Increment(ref ThreadingData.semaphore);              //interlocked ensure atomic increment of semaphore
         }
         else //amount of products left to process is the last batch to process.
         {
             ThreadingData.threadProcessedData.Add(new ReviewProductLinks());
             ThreadPool.QueueUserWorkItem(ThreadfunctionProduct <T>, new ThreadingData <T>(ThreadingData.semaphore, productList.GetRange(i, productList.Count - i), reviewList));
             Interlocked.Increment(ref ThreadingData.semaphore);
             break;
         }
     }
 }