Cleaned code , removed commented code
This commit is contained in:
2
PP.cmd
2
PP.cmd
@ -4,7 +4,7 @@ cd \Aktier\net6.0-windows
|
||||
echo *** på plats \Aktier\net6.0-windows ***
|
||||
copy Stocks* ..\backup\cpyback
|
||||
echo *** databas backupad ***
|
||||
copy D:\TommyCsharp\StockInfoCoreApp\StockInfoCore\bin\Debug\net6.0-windows\*.* .\
|
||||
copy D:\TommyCsharp\StockInfoCoreApp\StockInfoCore\bin\Release\net6.0-windows\*.* .\
|
||||
echo *** ny prodversion flyttad ***
|
||||
copy ..\backup\cpyback\Stocks* .\
|
||||
echo ************************************
|
||||
|
||||
@ -28,7 +28,7 @@ namespace StockDal
|
||||
public StringBuilder TextResults { get; set; }
|
||||
//public bool ViewBrowser { get; set; }
|
||||
|
||||
public IWebDriver driver;
|
||||
// public IWebDriver driver;
|
||||
private readonly IStockPersonConnect _stockPersonConnect;
|
||||
private readonly IStockRepository _stockRepository;
|
||||
private readonly TestSettings _testSettings;
|
||||
@ -47,46 +47,6 @@ namespace StockDal
|
||||
_scrapePage = scrapePage;
|
||||
}
|
||||
|
||||
//private void Find_Data()
|
||||
//{
|
||||
// TextResults = new StringBuilder();
|
||||
// IList<IWebElement> searchElements = driver.FindElements(By.TagName("tbody"));
|
||||
// foreach (IWebElement i in searchElements)
|
||||
// {
|
||||
|
||||
// HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
|
||||
// var text = i.GetAttribute("innerHTML");
|
||||
// htmlDocument.LoadHtml(text);
|
||||
// var inputs = htmlDocument.DocumentNode.Descendants("tr").ToList();
|
||||
// foreach (var items in inputs)
|
||||
// {
|
||||
// HtmlAgilityPack.HtmlDocument htmlDocument1 = new HtmlAgilityPack.HtmlDocument();
|
||||
// htmlDocument1.LoadHtml(items.InnerHtml);
|
||||
// var tds = htmlDocument1.DocumentNode.Descendants("td").ToList();
|
||||
// var appendText = "";
|
||||
// var fNr = 0;
|
||||
// foreach (var item in tds)
|
||||
// {
|
||||
// var intext = item.InnerText.Replace("\r\n", "");
|
||||
// appendText += appendText.Length == 0 ? intext : " " + intext;
|
||||
// if (tds.Count == 10)
|
||||
// {
|
||||
// AddValueToListRow(fNr++, intext);
|
||||
// }
|
||||
// }
|
||||
// if (!string.IsNullOrEmpty(appendText))
|
||||
// {
|
||||
// TextResults.Append(appendText + "\r\n");
|
||||
// }
|
||||
// htmlDocument1 = null;
|
||||
// }
|
||||
// htmlDocument = null;
|
||||
|
||||
// TextResults.Append("\r\n");
|
||||
// }
|
||||
|
||||
// // var oxe = StockMarketList;
|
||||
//}
|
||||
|
||||
private void SaveLogging()
|
||||
{
|
||||
@ -101,122 +61,7 @@ namespace StockDal
|
||||
File.WriteAllText($"{programPath}\\Loggings\\Log{DateTime.Now.ToShortDateString()}.txt", output);
|
||||
}
|
||||
|
||||
//private void AddValueToListRow(int pos, string value)
|
||||
//{
|
||||
// switch (pos)
|
||||
// {
|
||||
// case 0:
|
||||
// {
|
||||
// SaveRow = new DiTraderStockRow();
|
||||
// SaveRow.StockName = value;
|
||||
// break;
|
||||
// }
|
||||
// case 1:
|
||||
// {
|
||||
// SaveRow.ProcChange = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||
// break;
|
||||
// }
|
||||
// case 2:
|
||||
// {
|
||||
// SaveRow.RealChange = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||
// break;
|
||||
// }
|
||||
// case 3:
|
||||
// {
|
||||
// SaveRow.BuyPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||
// break;
|
||||
// }
|
||||
// case 4:
|
||||
// {
|
||||
// SaveRow.SellPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||
// break;
|
||||
// }
|
||||
// case 5:
|
||||
// {
|
||||
// SaveRow.LatestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||
// break;
|
||||
// }
|
||||
// case 6:
|
||||
// {
|
||||
// SaveRow.HighestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||
// break;
|
||||
// }
|
||||
// case 7:
|
||||
// {
|
||||
// SaveRow.LowestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||
// break;
|
||||
// }
|
||||
// case 8:
|
||||
// {
|
||||
|
||||
// SaveRow.Volume = string.IsNullOrWhiteSpace(value) ? 0 : long.Parse(value.Replace(" ", ""));
|
||||
// break;
|
||||
// }
|
||||
// case 9:
|
||||
// {
|
||||
// SaveRow.TimeOfDay = value == "" ? TimeSpan.Parse("00:01") : TimeSpan.Parse(value);
|
||||
// //StockMarketList.Add(SaveRow.StockName, SaveRow);
|
||||
// try
|
||||
// {
|
||||
// StockMarketList.Add(SaveRow.StockName, SaveRow);
|
||||
// }
|
||||
// catch (ArgumentException)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// StockMarketList.Add(SaveRow.StockName + "-2", SaveRow);
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// DumpObjects.Add(SaveRow);
|
||||
// }
|
||||
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void OpenBrowser(bool? burl2 = false)
|
||||
//{
|
||||
// var driverService = ChromeDriverService.CreateDefaultService();
|
||||
// driverService.HideCommandPromptWindow = true;
|
||||
|
||||
// if (ViewBrowser)
|
||||
// {
|
||||
// if (driver == null)
|
||||
// {
|
||||
// driver = new ChromeDriver(driverService);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (driver == null)
|
||||
// {
|
||||
// var options = new ChromeOptions();
|
||||
// options.AddArgument("headless");
|
||||
// driver = new ChromeDriver(driverService, options);
|
||||
// }
|
||||
// }
|
||||
|
||||
// try
|
||||
// {
|
||||
// //var url0 = "https://money.cnn.com/data/hotstocks/index.html";
|
||||
// var url = "https://trader.di.se/index.php/stocklist/index/2055?list=7126";
|
||||
// var url2 = "https://trader.di.se/index.php/stocklist/index/2055?list=7116";
|
||||
// var url3 = "https://trader.di.se/index.php/stocklist/index/2055?list=7127";
|
||||
// //var url1 = "https://www.finansportalen.se/aktiekurser/";
|
||||
// driver.Navigate().GoToUrl(burl2.HasValue ? (burl2.Value ? url2 : url) : url3);
|
||||
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// throw;
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
private void saveStockData(List<DiTraderStockRow> saveRow)
|
||||
{
|
||||
@ -302,8 +147,6 @@ namespace StockDal
|
||||
|
||||
public DiTraderStockRow LoadStockMarketStockData(string searchedStock)
|
||||
{
|
||||
//StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
//DumpObjects = new List<DiTraderStockRow>();
|
||||
var groupedStocks = _stockRepository.GetGroupedStock(searchedStock);
|
||||
var lastGroup = string.Empty;
|
||||
var stockList = new List<string>();
|
||||
@ -354,33 +197,8 @@ namespace StockDal
|
||||
|
||||
return output[0];
|
||||
|
||||
//if (DumpObjects.Any())
|
||||
//{
|
||||
// SaveLogging();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
//public void LoadStockMarketList(int persId)
|
||||
//{
|
||||
// LoadStockMarketList(persId);
|
||||
// //StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
// //ViewBrowser = viewBrowser;
|
||||
// //OpenBrowser();
|
||||
// //Find_Data();
|
||||
//}
|
||||
|
||||
public void RefreshMarketList(int persId)
|
||||
{
|
||||
//StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
//driver.Navigate().Refresh();
|
||||
//Find_Data();
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
driver?.Quit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,10 +14,8 @@ namespace StockDal.Interface
|
||||
Dictionary<string, DiTraderStockRow> StockMarketList { get; set; }
|
||||
StringBuilder TextResults { get; set; }
|
||||
|
||||
void Clean();
|
||||
void LoadStockMarketList(int persId);
|
||||
//void LoadStockMarketList(int persId, bool viewBrowser);
|
||||
void RefreshMarketList(int persId);
|
||||
DiTraderStockRow LoadStockMarketStockData(string searchedStock);
|
||||
}
|
||||
}
|
||||
|
||||
43
StockInfoCore/frmInitial.Designer.cs
generated
43
StockInfoCore/frmInitial.Designer.cs
generated
@ -37,9 +37,6 @@ namespace StockInfoCore
|
||||
this.btnRestoreShares = new System.Windows.Forms.Button();
|
||||
this.btnBackupShares = new System.Windows.Forms.Button();
|
||||
this.btnReload = new System.Windows.Forms.Button();
|
||||
this.btnTestScrapFunction = new System.Windows.Forms.Button();
|
||||
this.btnReloadShares = new System.Windows.Forms.Button();
|
||||
this.chbShowBrowser = new System.Windows.Forms.CheckBox();
|
||||
this.gbStockMgmnt = new System.Windows.Forms.GroupBox();
|
||||
this.btnStockSale = new System.Windows.Forms.Button();
|
||||
this.btnValueView = new System.Windows.Forms.Button();
|
||||
@ -148,40 +145,6 @@ namespace StockInfoCore
|
||||
this.btnReload.UseVisualStyleBackColor = true;
|
||||
this.btnReload.Click += new System.EventHandler(this.btnReload_Click);
|
||||
//
|
||||
// btnTestScrapFunction
|
||||
//
|
||||
this.btnTestScrapFunction.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnTestScrapFunction.Location = new System.Drawing.Point(12, 467);
|
||||
this.btnTestScrapFunction.Name = "btnTestScrapFunction";
|
||||
this.btnTestScrapFunction.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnTestScrapFunction.TabIndex = 4;
|
||||
this.btnTestScrapFunction.Text = "LoadScrap";
|
||||
this.btnTestScrapFunction.UseVisualStyleBackColor = true;
|
||||
this.btnTestScrapFunction.Click += new System.EventHandler(this.btnTestScrapFunction_Click);
|
||||
//
|
||||
// btnReloadShares
|
||||
//
|
||||
this.btnReloadShares.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnReloadShares.Location = new System.Drawing.Point(12, 417);
|
||||
this.btnReloadShares.Name = "btnReloadShares";
|
||||
this.btnReloadShares.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnReloadShares.TabIndex = 6;
|
||||
this.btnReloadShares.Text = "ReLoad";
|
||||
this.btnReloadShares.UseVisualStyleBackColor = true;
|
||||
this.btnReloadShares.Click += new System.EventHandler(this.btnReloadShares_Click);
|
||||
//
|
||||
// chbShowBrowser
|
||||
//
|
||||
this.chbShowBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.chbShowBrowser.AutoSize = true;
|
||||
this.chbShowBrowser.Location = new System.Drawing.Point(12, 497);
|
||||
this.chbShowBrowser.Name = "chbShowBrowser";
|
||||
this.chbShowBrowser.Size = new System.Drawing.Size(100, 22);
|
||||
this.chbShowBrowser.TabIndex = 7;
|
||||
this.chbShowBrowser.Text = "Show Browser";
|
||||
this.chbShowBrowser.UseCompatibleTextRendering = true;
|
||||
this.chbShowBrowser.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// gbStockMgmnt
|
||||
//
|
||||
this.gbStockMgmnt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
@ -292,9 +255,6 @@ namespace StockInfoCore
|
||||
this.Controls.Add(this.gpOwners);
|
||||
this.Controls.Add(this.lblStockRows);
|
||||
this.Controls.Add(this.gbStockMgmnt);
|
||||
this.Controls.Add(this.chbShowBrowser);
|
||||
this.Controls.Add(this.btnReloadShares);
|
||||
this.Controls.Add(this.btnTestScrapFunction);
|
||||
this.Controls.Add(this.gB1);
|
||||
this.Controls.Add(this.lblTotalRecords);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
@ -321,9 +281,6 @@ namespace StockInfoCore
|
||||
private System.Windows.Forms.Label lblTotalRecords;
|
||||
private System.Windows.Forms.GroupBox gB1;
|
||||
private System.Windows.Forms.Button btnReload;
|
||||
private System.Windows.Forms.Button btnTestScrapFunction;
|
||||
private System.Windows.Forms.Button btnReloadShares;
|
||||
private System.Windows.Forms.CheckBox chbShowBrowser;
|
||||
private System.Windows.Forms.GroupBox gbStockMgmnt;
|
||||
private System.Windows.Forms.Button btnStockReg;
|
||||
private System.Windows.Forms.Button btnValueView;
|
||||
|
||||
@ -36,12 +36,7 @@ namespace StockInfoCore
|
||||
private readonly frmBackup _backupWindow;
|
||||
private readonly frmEditStock _editStock;
|
||||
bool loading = false;
|
||||
//private frmRegisterStock regWindow;
|
||||
//private frmMyStocks stockWindow;
|
||||
//private frmSelling sellWindow;
|
||||
//private frmPerson personWindow;
|
||||
//private frmPersonShareConnect personShareConnect;
|
||||
//private frmBackup backupWindow;
|
||||
|
||||
public int SelectedPersonId { get; set; } = 0;
|
||||
|
||||
public frmInitial(
|
||||
@ -85,7 +80,6 @@ namespace StockInfoCore
|
||||
ReloadData();
|
||||
btnRestoreShares.Enabled = false;
|
||||
btnBackupShares.Enabled = false;
|
||||
btnReloadShares.Enabled = false;
|
||||
btnBackupAll.Enabled = false;
|
||||
}
|
||||
|
||||
@ -119,30 +113,14 @@ namespace StockInfoCore
|
||||
|
||||
private void btnReload_Click(object sender, EventArgs e)
|
||||
{
|
||||
Cursor = Cursors.WaitCursor;
|
||||
ReloadData(true);
|
||||
Cursor=Cursors.Default;
|
||||
}
|
||||
|
||||
private void btnTestScrapFunction_Click(object sender, EventArgs e)
|
||||
private void frmInitial_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
//_stockMarketRepository.LoadStockMarketList(SelectedPersonId, chbShowBrowser.Checked);
|
||||
//var stocklist = _stockMarketRepository.StockMarketList;
|
||||
//lblStockRows.Text = stocklist.Count().ToString();
|
||||
//btnReloadShares.Enabled = true;
|
||||
}
|
||||
|
||||
private void frmInitial_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
_stockMarketRepository.Clean();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Button1reload()
|
||||
{
|
||||
lblStockRows.Text = "";
|
||||
_stockMarketRepository.RefreshMarketList(SelectedPersonId);
|
||||
var stocklist = _stockMarketRepository.StockMarketList;
|
||||
lblStockRows.Text = stocklist.Count().ToString();
|
||||
MessageBox.Show("B y e B y e !!");
|
||||
}
|
||||
|
||||
private void btnStockReg_Click(object sender, EventArgs e)
|
||||
@ -232,10 +210,6 @@ namespace StockInfoCore
|
||||
};
|
||||
}
|
||||
|
||||
private void btnReloadShares_Click(object sender, EventArgs e)
|
||||
{
|
||||
Button1reload();
|
||||
}
|
||||
|
||||
private void btnStockSale_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -301,7 +275,6 @@ namespace StockInfoCore
|
||||
{
|
||||
if (!loading)
|
||||
{
|
||||
//MessageBox.Show($"{((DataGridView)sender).SelectedRows.ToString()} eventargs = {e.ToString()}" );
|
||||
int id = Convert.ToInt32(dataGridView.Rows[dataGridView.CurrentRow.Index].Cells[0].Value);
|
||||
if (DialogResult.OK == MessageBox.Show($"Vald rads id = {id}{Environment.NewLine}Ändra ?", "Fråga", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
|
||||
{
|
||||
|
||||
@ -57,7 +57,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
|
||||
<metadata name="sfdSaver.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="ofdOpener.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>114, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>27</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user