public bool Contains(StockWrapper item) { #if DEBUG Debug.Assert(_list.Contains(item) == _itemKeyDic[item.Item.ID].Contains(item)); #endif return _list.Contains(item); }
public void TestWrapperEventHandler() { StockWrapper.m_wrapperFired = false; StockWrapper wrapper = new StockWrapper(m_stock); wrapper.PriceChanged += StockWrapper.WrapperEvtHandler; wrapper.Price = m_newPrice; CheckAfterPriceChanged(); Assert.IsTrue(StockWrapper.m_wrapperFired); }
/// <summary> /// 기존의 InOutStock 데이터를 수정할 때 쓰이는 생성자입니다. /// </summary> /// <param name="viewModel"></param> /// <param name="ioStockWrapper"></param> public StockWrapperEditorViewModel(StockWrapperViewModel viewModel, StockWrapper ioStockWrapper) : base(ioStockWrapper) { if (ioStockWrapper == null) throw new ArgumentNullException(); _target = ioStockWrapper; Initialize(viewModel); //수정할 데이터를 변경할 수 없도록 고정 ItemList = new ItemWrapper[] { _target.Item }; SpecificationList = new SpecificationWrapper[] { _target.Specification }; WarehouseList = new Observable<Warehouse>[] { _target.Warehouse }; Item = ItemList.First(); Specification = SpecificationList.First(); Warehouse = WarehouseList.First(); }
/// <summary> /// 수정 또는 새로 추가할 데이터를 데이터베이스와 ViewModel의 Items 속성에 각각 추가 및 적용한다. /// </summary> /// <returns></returns> public StockWrapper Update() { //추가 및 적용의 최소 조건들 if (Item == null) throw new Exception("리스트박스에서 품목을 선택하세요."); if (Specification == null) throw new Exception("리스트박스에서 규격을 선택하세요."); InventoryWrapperDirector iwd = InventoryWrapperDirector.GetInstance(); InventoryWrapper invenw = iwd.SearchAsSpecificationKey(Specification.ID); StockWrapper stockw = null; if (invenw != null) { //재고의 개수를 수정 invenw.Quantity = InventoryQuantity; } else { //새로운 재고를 등록 Inventory inven = new Inventory(); inven.ItemID = this.Item.ID; inven.SpecificationID = this.Specification.ID; inven.Quantity = this.InventoryQuantity; inven.WarehouseID = this.Warehouse != null ? this.Warehouse.ID : null; invenw = new InventoryWrapper(inven); CollectionViewModelObserverSubject.GetInstance().NotifyNewItemAdded(invenw); //순서의 주의 iwd.Add(invenw); //순서의 주의 } if (_target != null) //InOutStock 데이터의 수정 코드 { _target.Product = InOutStock; stockw = _target; } else //새로운 InOutStock 데이터의 추가 코드 { InOutStock.InventoryID = invenw.ID; stockw = new StockWrapper(InOutStock); _viewModel.Add(stockw); } stockw.Product.Save<InOutStock>(); return stockw; }
public void Remove(StockWrapper item) { if (Contains(item)) { _list.Remove(item); _itemKeyDic.Remove(item.Item.ID, item); _invenKeyDic.Remove(item.Inventory.ID, item); } }
public void Add(StockWrapper item) { if (!Contains(item)) { _list.Add(item); _itemKeyDic.Add(item.Item.ID, item); _invenKeyDic.Add(item.Inventory.ID, item); } }
public void OpenAppTest() { driver.Url = "https://finviz.com/screener.ashx?v=111&f=cap_smallover,fa_curratio_o1,fa_debteq_u0.5,fa_estltgrowth_o5,fa_pb_u2,fa_pe_u15,geo_usa&ft=2"; List <IWebElement> links = driver.FindElements(By.ClassName("screener-link-primary")).ToList(); List <StockWrapper> stocks = new List <StockWrapper>(); string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // Write the string array to a new file named "WriteLines.txt". using (StreamWriter outputFile = new StreamWriter(mydocpath + @"\WriteLines.txt")) { for (int i = 0; i < 1; i++) { StockWrapper newStock = new StockWrapper(); newStock.tickerSymbol = links[i].Text; driver2.Url = "http://www.advfn.com/stock-market/NYSE/" + links[i].Text + "/financials?btn=start_date&mode=annual_reports"; //Get date selector // select the drop down list var dateDropDown = driver.FindElement(By.Id("start_dateid")); //create select element object var selectElement = new SelectElement(dateDropDown); // select by text selectElement.SelectByText("2007/12"); Thread.Sleep(5000); //Get old book value IWebElement oldBookValueParent = driver2.FindElement(By.XPath("//td[contains(text(),'book value per share')]")); IWebElement oldBookValue = oldBookValueParent.FindElement(By.XPath("following-sibling::*")); Decimal.TryParse(oldBookValue.Text, out newStock.oldBookValue); //Get oldest date, which may not be 10 years behind the current date IWebElement oldYearEndParent = driver2.FindElement(By.XPath("//td[contains(text(),'year end date')]")); IWebElement oldYearEnd = oldYearEndParent.FindElement(By.XPath("following-sibling::*")); newStock.oldYear = oldYearEnd.Text; //Set page to latest date driver2.Url = "http://www.advfn.com/stock-market/NYSE/" + links[i].Text + "/financials?btn=start_date&mode=annual_reports"; //Get new book value IWebElement newBookValueParent = driver2.FindElement(By.XPath("//td[contains(text(),'book value per share')]")); IWebElement newBookValue = newBookValueParent.FindElements(By.XPath("following-sibling::*")).LastOrDefault(); Decimal.TryParse(newBookValue.Text, out newStock.newBookValue); //Get newest year IWebElement newYearEndParent = driver2.FindElement(By.XPath("//td[contains(text(),'year end date')]")); IWebElement newYearEnd = newYearEndParent.FindElements(By.XPath("following-sibling::*")).LastOrDefault(); newStock.newYear = newYearEnd.Text; //Get dividend IWebElement dividendParent = driver2.FindElement(By.XPath("//td[contains(text(),'Dividends Paid Per Share')]")); IWebElement dividend = dividendParent.FindElements(By.XPath("following-sibling::*")).LastOrDefault(); Decimal.TryParse(dividend.Text, out newStock.dividend); //Set page to current info driver2.Url = "http://www.advfn.com/stock-market/NYSE/" + links[i].Text + "/financials"; IWebElement priceText = driver2.FindElement(By.XPath("//span[contains(text(),'Price')]")); IWebElement priceParent = priceText.FindElement(By.XPath("../..")); IWebElement priceRow = priceParent.FindElement(By.XPath("following-sibling::*")); IWebElement price = priceRow.FindElement(By.XPath("child::*")); Decimal.TryParse(price.Text, out newStock.currentMarketValue); outputFile.WriteLine(newStock.tickerSymbol + "- Book Value in " + newStock.oldYear + ": " + newStock.oldBookValue + ", Book Value in " + newStock.newYear + ": " + newStock.newBookValue + ", Dividend: " + newStock.dividend + ", Current Value: " + newStock.currentMarketValue); } } }
public StockWrapperProperties(StockWrapper stockWrapper) : base(stockWrapper) { _target = stockWrapper; }