Example #1
0
 public int Update(ComputerList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Update(entityToInsert));
     }
 }
Example #2
0
        static void TestWriteComputerList(string path)
        {
            var list  = new ComputerList();
            var comp1 = new Computer()
            {
                Id = Guid.NewGuid(), Price = 1
            };
            var comp2 = new Computer()
            {
                Id = Guid.NewGuid(), Price = 2
            };
            var comp3 = new Computer()
            {
                Id = Guid.NewGuid(), Price = 3
            };
            var comp4 = new Computer()
            {
                Id = Guid.NewGuid(), Price = 4
            };

            list.Push(comp1);
            list.Push(comp2);
            list.Push(comp3);
            list.Push(comp4);

            FileHelper.CreateComputerList(path, list);
        }
Example #3
0
 public Guid Insert(ComputerList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Insert <Guid>(entityToInsert));
     }
 }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter your name: ");
            string name = Console.ReadLine();

            Console.WriteLine("Hello " + name + "!");
            Console.ReadLine();

            ComputerList computerList = new ComputerList();

            computerList.Seed();


            /*
             * foreach (Computer comp in computerList)
             * {
             *  Console.WriteLine(comp.Manufacturer + ":" + comp.Model);
             * }
             */


            //Do same code as above with lambda expression
            computerList.ForEach(c => Console.WriteLine(c.Manufacturer + ":" + c.Model));

            Console.ReadLine();
        }
Example #5
0
        public static ComputerList ReadComputerList(string path)
        {
            var list     = new ComputerList();
            var allFiles = Directory.GetFiles(path);

            if (allFiles.Length == 0)
            {
                return(list);
            }

            var serializer = new XmlSerializer(typeof(ComputerXmlModel));
            var filePath   = allFiles.First();

            var isLoop = false;

            while (!isLoop)
            {
                using (var reader = new StreamReader(filePath))
                {
                    var xmlModel = (ComputerXmlModel)serializer.Deserialize(reader);
                    var computer = new Computer()
                    {
                        Id = xmlModel.Id, Price = xmlModel.Price
                    };
                    list.Push(computer);
                    filePath = $@"{path}\{xmlModel.Next.ToString()}.xml";
                    if (xmlModel.Next == list.Head.Id)
                    {
                        isLoop = true;
                    }
                }
            }
            return(list);
        }
Example #6
0
        public void AddOrUpdateComputer(ClientConnection connection)
        {
            var onlineComputer = ComputerList.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x.MACAddress) && x.MACAddress == connection.MACAddress);

            if (onlineComputer != null)
            {
                onlineComputer.IsOnline = true;
            }
            else
            {
                onlineComputer = new HubComputer()
                {
                    IsOnline = true
                };
                MainWindow.Current.Dispatcher.Invoke(() =>
                {
                    ComputerList.Add(onlineComputer);
                });
            }
            onlineComputer.ID             = connection.ID;
            onlineComputer.SessionID      = connection.SessionID;
            onlineComputer.ConnectionType = connection.ConnectionType;
            onlineComputer.IsOnline       = true;
            onlineComputer.CurrentUser    = connection.CurrentUser;
            onlineComputer.ComputerName   = connection.ComputerName;
            onlineComputer.LastOnline     = DateTime.Now;
            onlineComputer.LastReboot     = connection.LastReboot;
            onlineComputer.MACAddress     = connection.MACAddress;
        }
Example #7
0
 public int Delete(ComputerList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Delete(entityToInsert));
     }
 }
Example #8
0
        static void TestCreateNotEmptyRoom(string path)
        {
            var list  = new ComputerList();
            var comp1 = new Computer()
            {
                Id = Guid.NewGuid(), Price = 1
            };
            var comp2 = new Computer()
            {
                Id = Guid.NewGuid(), Price = 2
            };
            var comp3 = new Computer()
            {
                Id = Guid.NewGuid(), Price = 3
            };
            var comp4 = new Computer()
            {
                Id = Guid.NewGuid(), Price = 4
            };

            list.Push(comp1);
            list.Push(comp2);
            list.Push(comp3);
            list.Push(comp4);

            var room = new Room()
            {
                Num       = "a5",
                Computers = list
            };

            FileHelper.CreateRoom(path, room);
        }
Example #9
0
        static void Main(string[] args)
        {
            ComputerList task = new ComputerList();

            task.AddRandomComputors();
            task.BestPC(1500, 10, 10);
            Console.ReadKey();
        }
Example #10
0
    //Buy item
    private void BuyItem(GameObject item)
    {
        int      itemId   = item.GetComponent <IDScript>().id;
        int      itemType = -1;
        ShopItem shopItem = null;

        if (item.tag == "Computer")
        {
            shopItem = ComputerList.FindItem(itemId);
            itemType = 0;
        }
        else if (item.tag == "GraphicCard")
        {
            shopItem = GraphicCardList.FindItem(itemId);
            itemType = 1;
        }
        else if (item.tag == "Asic")
        {
            shopItem = AsicList.FindItem(itemId);
            itemType = 2;
        }

        if (shopItem != null)
        {
            if (gameStatManager.IsEnoughCash(shopItem.GetPrice()))
            {
                gameStatManager.DeductCash(shopItem.GetPrice());
                gameStatManager.AddSpeed(shopItem.GetSpeed());
                gameStatManager.AddWatt(shopItem.GetWatt());

                if (itemType == 0)
                {
                    gameStatManager.AddComputer(itemId);
                }
                else if (itemType == 1)
                {
                    gameStatManager.AddGrahpicCard(itemId);
                }
                else if (itemType == 2)
                {
                    gameStatManager.AddAsic(itemId);
                }
                else
                {
                    Debug.Log("Error: [ItemContainerManager][BuyItem][Cannot get itemType]");
                }

                statusText.color = Color.green;
                statusText.text  = "Model [" + shopItem.GetModel() + "] purchase successful!";
            }
            else
            {
                statusText.color = Color.red;
                statusText.text  = "Not enough cash to buy model [" + shopItem.GetModel() + "]";
            }
        }
    }
Example #11
0
    private void AddItem()
    {
        //Computer
        int id = 0;

        foreach (Computer item in ComputerList.GetList())
        {
            //Set attributes
            GameObject newItem = Instantiate(itemFrame, computerGrid.transform);
            newItem.GetComponent <IDScript>().id = id++;
            newItem.tag = "Computer";

            //Set displays
            newItem.transform.Find("Model").GetComponent <Text>().text    = item.GetModel();
            newItem.transform.Find("Image").GetComponent <Image>().sprite = item.GetImage();
            newItem.transform.Find("Value").GetComponent <Text>().text    = item.GetSpeed().ToString() + "\n" + item.GetWatt().ToString();
            newItem.transform.Find("Price").GetComponent <Text>().text    = "$" + item.GetPrice();

            //Set button events
            Button itemButton = newItem.GetComponent <Button>();
            itemButton.onClick.AddListener(() => BuyItem(newItem));
        }

        //Graphic card
        id = 0;
        foreach (GraphicCard item in GraphicCardList.GetList())
        {
            GameObject newItem = Instantiate(itemFrame, graphicCardGrid.transform);
            newItem.GetComponent <IDScript>().id = id++;
            newItem.tag = "GraphicCard";

            newItem.transform.Find("Model").GetComponent <Text>().text    = item.GetModel();
            newItem.transform.Find("Image").GetComponent <Image>().sprite = item.GetImage();
            newItem.transform.Find("Value").GetComponent <Text>().text    = item.GetSpeed().ToString() + "\n" + item.GetWatt().ToString();
            newItem.transform.Find("Price").GetComponent <Text>().text    = "$" + item.GetPrice();

            Button itemButton = newItem.GetComponent <Button>();
            itemButton.onClick.AddListener(() => BuyItem(newItem));
        }

        //Asic
        id = 0;
        foreach (Asic item in AsicList.GetList())
        {
            GameObject newItem = Instantiate(itemFrame, asicGrid.transform);
            newItem.GetComponent <IDScript>().id = id++;
            newItem.tag = "Asic";

            newItem.transform.Find("Model").GetComponent <Text>().text    = item.GetModel();
            newItem.transform.Find("Image").GetComponent <Image>().sprite = item.GetImage();
            newItem.transform.Find("Value").GetComponent <Text>().text    = item.GetSpeed().ToString() + "\n" + item.GetWatt().ToString();
            newItem.transform.Find("Price").GetComponent <Text>().text    = "$" + item.GetPrice();

            Button itemButton = newItem.GetComponent <Button>();
            itemButton.onClick.AddListener(() => BuyItem(newItem));
        }
    }
Example #12
0
        public static void CreateComputerList(string path, ComputerList list)
        {
            var formatter = new XmlSerializer(typeof(ComputerXmlModel));

            foreach (Computer comp in list)
            {
                CreateComputer(path, comp);
            }
        }
Example #13
0
 private void ComputerData(ComputerList _tmpData)
 {
     txtname.Text = _tmpData.Name;
     txtip.Text   = _tmpData.Ip;
     if (_tmpData.StationID != null)
     {
         comboBox1.SelectedValue = _tmpData.StationID;
     }
     txtdescription.Text = _tmpData.Description;
 }
        public async Task <ActionResult> Index(ComputerFilter cFilter)
        {
            var computers = await FilterAsync(cFilter);

            var model = new ComputerList {
                Computers = computers, Filter = cFilter
            };

            return(View(model));
        }
Example #15
0
        public async Task <ActionResult> Index(ComputerFilter filter)
        {
            var computers = await db.GetComputers(filter.Year, filter.ComputerName);

            var model = new ComputerList {
                Computers = computers, Filter = filter
            };

            return(View(model));
        }
        private void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                lblStatus.Text      = string.Empty;
                lblStatus.ForeColor = Color.Blue;

                // Creating a new computer
                Computer computer = new Computer();

                // Set the properties from the screen.
                computer.Description = txtDescription.Text;

                computer.EquipmentType = (EquipmentType.Types)cboEquipmentType.SelectedIndex;

                computer.HardDriveSize = Convert.ToInt32(txtHardDriveSize.Text);
                computer.Manufacturer  = txtManufacturer.Text;
                computer.SerialNo      = txtSerialNo.Text;
                computer.RAM           = Convert.ToInt32(txtRAM.Text);
                computer.Model         = txtModel.Text;
                computer.Price         = Convert.ToDouble(txtPrice.Text);

                if (computerList == null)
                {
                    computerList = new ComputerList();
                    computer.Id  = 3;
                }
                else
                {
                    computer.Id = computerList.Count + 1;
                }



                computerList.Add(computer);



                Rebind();
            }
            catch (BadHardDriveException ex)
            {
                lblStatus.Text      = ex.Message;
                lblStatus.ForeColor = Color.Red;
                txtHardDriveSize.Focus();
                txtHardDriveSize.SelectAll();
                txtHardDriveSize.BackColor = Color.LightYellow;
            }

            catch (Exception ex)
            {
                lblStatus.Text      = ex.Message;
                lblStatus.ForeColor = Color.Red;
            }
        }
Example #17
0
        private void ToolStripMenuItem_add_Click(object sender, EventArgs e)
        {
            ComputerList        _tmpData = null;
            Add_Modify_Computer tmpAdd_Modify_Computer = new Add_Modify_Computer(_tmpData);

            tmpAdd_Modify_Computer.ShowDialog();
            if (tmpAdd_Modify_Computer.result == DialogResult.OK)
            {
                GetComputerList();
            }
        }
 private void AddComputer(int deck)
 {
     if (BasicData.Client == true)
     {
         return; //host does computer.
     }
     if (SaveRoot !.ComputerList.ObjectExist(deck) == false)
     {
         SimpleDominoInfo thisDomino = _model.DominosList !.GetSpecificItem(deck);
         SaveRoot.ComputerList.Add(thisDomino);
     }
 }
Example #19
0
        public void SeedTest()
        {
            ComputerList computerList = new ComputerList();

            computerList.Seed();

            //Test to see if I have two computers
            int expected = 2;
            int actual   = computerList.Count;

            Assert.AreEqual(expected, actual);
        }
 public void TakeOffComputer(int deck)
 {
     if (BasicData.Client == true)
     {
         return;
     }
     if (SaveRoot !.ComputerList.ObjectExist(deck) == false)
     {
         return;
     }
     SaveRoot.ComputerList.RemoveObjectByDeck(deck);
 }
Example #21
0
 public Add_Modify_Computer(ComputerList _tmpData)
 {
     InitializeComponent();
     if (_tmpData == null)
     {
         TypeNameDataBinding();
     }
     else if (_tmpData != null)
     {
         tmpStation = _tmpData;
         TypeNameDataBinding();
         ComputerData(tmpStation);
     }
 }
 private void AddComputer(DeckRegularDict <RegularSimpleCard> thisCol)
 {
     if (PlayerList.Any(items => items.PlayerCategory == EnumPlayerCategory.Computer) == false)
     {
         return;
     }
     thisCol.ForEach(thisCard =>
     {
         if (SaveRoot !.ComputerList.ObjectExist(thisCard.Deck) == false)
         {
             SaveRoot.ComputerList.Add(thisCard);
         }
     });
 }
 private void RemoveComputer(DeckRegularDict <RegularSimpleCard> ThisCol)
 {
     if (PlayerList.Any(items => items.PlayerCategory == EnumPlayerCategory.Computer) == false)
     {
         return;
     }
     ThisCol.ForEach(thisCard =>
     {
         if (SaveRoot !.ComputerList.ObjectExist(thisCard.Deck) == true)
         {
             SaveRoot.ComputerList.RemoveObjectByDeck(thisCard.Deck);
         }
     });
 }
Example #24
0
        public void Save()
        {
            var di           = Directory.CreateDirectory(Utilities.DataFolder);
            var computerList = ComputerList.Where(x => !string.IsNullOrWhiteSpace(x.MACAddress)).ToList();

            for (var i = computerList.Count - 1; i >= 0; i--)
            {
                if (computerList.FindAll(x => x.MACAddress == computerList[i].MACAddress).Count > 1)
                {
                    computerList.RemoveAt(i);
                }
            }

            File.WriteAllText(Path.Combine(di.FullName, "Hub.json"), Utilities.JSON.Serialize(computerList));
        }
        private void btnLoadComputers_Click(object sender, EventArgs e)
        {
            try
            {
                computerList = new ComputerList();
                computerList.Seed();

                //bind the data to the screen
                Rebind();
            }
            catch (Exception ex)
            {
                lblStatus.Text      = ex.Message;
                lblStatus.ForeColor = Color.DarkRed;
            }
        }
Example #26
0
        public void Load()
        {
            var fi = new FileInfo(Path.Combine(Utilities.DataFolder, "Hub.json"));

            if (fi.Exists)
            {
                var savedList = Utilities.JSON.Deserialize <List <HubComputer> >(File.ReadAllText(fi.FullName)).Where(x => !string.IsNullOrWhiteSpace(x.MACAddress));
                foreach (var computer in savedList)
                {
                    if (!ComputerList.Any(x => x.MACAddress == computer.MACAddress))
                    {
                        ComputerList.Add(computer);
                    }
                }
            }
            MergeAditServerClientList();
        }
 public ComputerForm(string path, Form1 contextForm, ComputerList computerList, Computer computer = null)
 {
     InitializeComponent();
     _path         = path;
     _contextForm  = contextForm;
     _computerList = computerList;
     _computer     = computer;
     if (computer != null)
     {
         labelId.Text      = computer.Id.ToString();
         textBoxPrice.Text = computer.Price.ToString();
     }
     else
     {
         labelId.Text      = Guid.NewGuid().ToString();
         textBoxPrice.Text = 0.ToString();
     }
 }
        private void btnMakeComputer_Click(object sender, EventArgs e)
        {
            try
            {
                lblStatus.Text      = string.Empty;
                lblStatus.ForeColor = Color.Blue;

                //Create a new Computer
                Computer computer = new Computer();

                //Set the properties from the screen
                computer.Description   = txtDescription.Text;
                computer.EquipmentType = EquipmentType.Types.Desktop;
                computer.HardDriveSize = Convert.ToInt32(txtHardDriveSize.Text);
                computer.Manufacturer  = txtManufacturer.Text;
                computer.SerialNo      = txtSerialNo.Text;
                computer.RAM           = Convert.ToInt32(txtRAM.Text);
                computer.Price         = Convert.ToDouble(txtPrice.Text);
                computer.Model         = txtModel.Text;

                if (computerList == null)
                {
                    //Instantiate new computer list if not created already
                    computerList = new ComputerList();
                }

                computerList.Add(computer);

                Rebind();
            }
            catch (BadHardDriveException ex)
            {
                lblStatus.Text      = ex.Message;
                lblStatus.ForeColor = Color.Red;
                txtHardDriveSize.Focus();
                txtHardDriveSize.SelectAll();
                txtHardDriveSize.BackColor = Color.LightYellow;
            }
            catch (Exception ex)
            {
                lblStatus.Text      = ex.Message;
                lblStatus.ForeColor = Color.Red;
            }
        }
 public override async Task SetUpGameAsync(bool isBeginning)
 {
     LoadControls();
     PlayerList !.ForEach(items =>
     {
         items.NumberChosen = -1;
         items.NumberWon    = 0;
     });
     _model.DominosList !.ClearObjects();
     _model.DominosList.ShuffleObjects(); //i think.
     SaveRoot !.ComputerList.Clear();
     SaveRoot.GameStatus = EnumStatus.ChooseNumber;
     _gameBoard.ClearPieces(); //i think
     if (FinishUpAsync == null)
     {
         throw new BasicBlankException("The loader never set the finish up code.  Rethink");
     }
     await FinishUpAsync(isBeginning);
 }
Example #30
0
 public void MergeAditServerClientList()
 {
     foreach (var computer in ComputerList)
     {
         computer.IsOnline = false;
     }
     foreach (var connection in AditServer.ClientList)
     {
         AddOrUpdateComputer(connection);
     }
     for (var i = ComputerList.Count - 1; i >= 0; i--)
     {
         var computer = ComputerList[i];
         if (!computer.IsOnline && string.IsNullOrWhiteSpace(computer.MACAddress))
         {
             ComputerList.Remove(computer);
         }
     }
 }