Fetching "Stocks per group and person" implemented , Portfolioowner on Stockpage
This commit is contained in:
@ -12,5 +12,6 @@ namespace DataDomain
|
||||
public int PersonId { get; set; }
|
||||
public int StockId { get; set; }
|
||||
public string Comment { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
15
DataDomain/StockGrpPers.cs
Normal file
15
DataDomain/StockGrpPers.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataDomain
|
||||
{
|
||||
public class StockGrpPers
|
||||
{
|
||||
public string StockId { get; set; }
|
||||
public string StockGroup { get; set;}
|
||||
public int PersId { get; set;}
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using StockDAL.Interface;
|
||||
|
||||
namespace StockDal
|
||||
{
|
||||
@ -24,10 +25,14 @@ namespace StockDal
|
||||
public bool ViewBrowser { get; set; }
|
||||
|
||||
public IWebDriver driver;
|
||||
private readonly IStockPersonConnect _stockPersonConnect;
|
||||
private readonly IStockRepository _stockRepository;
|
||||
|
||||
public StockMarketRepository()
|
||||
public StockMarketRepository(IStockPersonConnect stockPersonConnect, IStockRepository stockRepository )
|
||||
{
|
||||
ViewBrowser = false;
|
||||
_stockPersonConnect = stockPersonConnect;
|
||||
_stockRepository = stockRepository;
|
||||
}
|
||||
|
||||
private void Find_Data()
|
||||
@ -201,16 +206,23 @@ namespace StockDal
|
||||
|
||||
}
|
||||
|
||||
public void LoadStockMarketList()
|
||||
public void LoadStockMarketList(int persId)
|
||||
{
|
||||
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
DumpObjects = new List<DiTraderStockRow>();
|
||||
OpenBrowser(null);
|
||||
Find_Data();
|
||||
OpenBrowser();
|
||||
Find_Data();
|
||||
OpenBrowser(true);
|
||||
Find_Data();
|
||||
|
||||
//var connStocks = _stockPersonConnect.GetAllConnectionsByPersId(persId);
|
||||
var groupedStocks = _stockRepository.GetStocksGroupedPerPerson(persId);
|
||||
|
||||
|
||||
//OpenBrowser(null);
|
||||
//Find_Data();
|
||||
//OpenBrowser();
|
||||
//Find_Data();
|
||||
//OpenBrowser(true);
|
||||
//Find_Data();
|
||||
|
||||
|
||||
if (DumpObjects.Any())
|
||||
{
|
||||
SaveLogging();
|
||||
@ -218,7 +230,7 @@ namespace StockDal
|
||||
}
|
||||
|
||||
|
||||
public void LoadStockMarketList(bool viewBrowser)
|
||||
public void LoadStockMarketList(int persId, bool viewBrowser)
|
||||
{
|
||||
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
ViewBrowser = viewBrowser;
|
||||
@ -226,7 +238,7 @@ namespace StockDal
|
||||
Find_Data();
|
||||
}
|
||||
|
||||
public void RefreshMarketList()
|
||||
public void RefreshMarketList(int persId)
|
||||
{
|
||||
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
driver.Navigate().Refresh();
|
||||
|
||||
@ -104,6 +104,23 @@ namespace StockDAL
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public IEnumerable<StockGrpPers> GetStocksGroupedPerPerson(int persId)
|
||||
{
|
||||
using var context = new StockContext();
|
||||
var result = (from prs in context.PersonStocks
|
||||
join stk in context.Stocks on prs.StockId equals stk.Id
|
||||
join grp in context.StockGroups on stk.StockId equals grp.StockName
|
||||
where prs.PersonId == persId
|
||||
orderby grp.GroupName, grp.StockName
|
||||
select new StockGrpPers
|
||||
{
|
||||
PersId = persId,
|
||||
StockId = stk.StockId,
|
||||
StockGroup = grp.GroupName
|
||||
}).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void RestoreStockMembers(List<StockMember> stockMembers)
|
||||
{
|
||||
using var context = new StockContext();
|
||||
|
||||
@ -13,8 +13,8 @@ namespace StockDal.Interface
|
||||
bool ViewBrowser { get; set; }
|
||||
|
||||
void Clean();
|
||||
void LoadStockMarketList();
|
||||
void LoadStockMarketList(bool viewBrowser);
|
||||
void RefreshMarketList();
|
||||
void LoadStockMarketList(int persId);
|
||||
void LoadStockMarketList(int persId, bool viewBrowser);
|
||||
void RefreshMarketList(int persId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,5 +19,6 @@ namespace StockDAL.Interface
|
||||
void SaveStockMember(StockMember stockMember);
|
||||
void UpdateActualForSell(int id, int sellAmount, decimal sellPrice, DateTime sellDate);
|
||||
void UpdateActualPrice(int id, decimal price);
|
||||
IEnumerable<StockGrpPers> GetStocksGroupedPerPerson(int persId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,20 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
<None Remove="Stocks.db" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Stocks.db">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.6">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
@ -33,11 +47,5 @@
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Stocks.db">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,4 +1,5 @@
|
||||
using BrowserHelper.Driver;
|
||||
using BrowserHelper.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqliteBackups;
|
||||
using SqliteBackups.Interfaces;
|
||||
@ -20,6 +21,7 @@ namespace StockInfoCore
|
||||
{
|
||||
public static IServiceCollection AddDIInfo(this IServiceCollection services)
|
||||
{
|
||||
services.UseWebDriverInitializer();
|
||||
services.AddTransient<IBackupRepository, BackupRepository>();
|
||||
services.AddTransient<IBackupRoutines, BackupRoutines>();
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
StockInfoCore/appsettings.json
Normal file
8
StockInfoCore/appsettings.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"BrowserType": "chrome",
|
||||
"Headless" : true,
|
||||
"ApplicationUrl": "https://finansportalen.millistream.com/shares.php",
|
||||
"TimeoutInterval": 30,
|
||||
"StockWishes": [ "Arion Bank SDB", "Boliden", "Ericsson A", "Getinge B", "Investor A", "SAS", "Securitas B", "SSAB A", "Handelsbanken A", "Swedbank A" ],
|
||||
"StocWishCols": ["Aktie","Senast","Tid"]
|
||||
}
|
||||
@ -105,7 +105,7 @@ namespace StockInfoCore
|
||||
|
||||
private void btnTestScrapFunction_Click(object sender, EventArgs e)
|
||||
{
|
||||
_stockMarketRepository.LoadStockMarketList(chbShowBrowser.Checked);
|
||||
_stockMarketRepository.LoadStockMarketList(SelectedPersonId, chbShowBrowser.Checked);
|
||||
var stocklist = _stockMarketRepository.StockMarketList;
|
||||
lblStockRows.Text = stocklist.Count().ToString();
|
||||
btnReloadShares.Enabled = true;
|
||||
@ -121,7 +121,7 @@ namespace StockInfoCore
|
||||
private void Button1reload()
|
||||
{
|
||||
lblStockRows.Text = "";
|
||||
_stockMarketRepository.RefreshMarketList();
|
||||
_stockMarketRepository.RefreshMarketList(SelectedPersonId);
|
||||
var stocklist = _stockMarketRepository.StockMarketList;
|
||||
lblStockRows.Text = stocklist.Count().ToString();
|
||||
}
|
||||
@ -129,7 +129,7 @@ namespace StockInfoCore
|
||||
private void btnStockReg_Click(object sender, EventArgs e)
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
_stockMarketRepository.LoadStockMarketList();
|
||||
_stockMarketRepository.LoadStockMarketList(SelectedPersonId);
|
||||
_regWindow.Stocks = _stockMarketRepository.StockMarketList;
|
||||
Cursor.Current = DefaultCursor;
|
||||
_regWindow.ShowDialog();
|
||||
@ -149,9 +149,11 @@ namespace StockInfoCore
|
||||
{
|
||||
var person = _personRepository.GetPersonById(SelectedPersonId);
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
_stockMarketRepository.LoadStockMarketList();
|
||||
|
||||
_stockMarketRepository.LoadStockMarketList(SelectedPersonId);
|
||||
_stockWindow.ConnectedPerson = person;
|
||||
_stockWindow.Stocks = _stockMarketRepository.StockMarketList;
|
||||
|
||||
Cursor.Current = DefaultCursor;
|
||||
_stockWindow.ShowDialog();
|
||||
}
|
||||
|
||||
13
StockInfoCore/frmMyStocks.Designer.cs
generated
13
StockInfoCore/frmMyStocks.Designer.cs
generated
@ -58,6 +58,7 @@ namespace StockInfoCore
|
||||
this.txtTotalMinus = new System.Windows.Forms.TextBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.txtTotalPlus = new System.Windows.Forms.TextBox();
|
||||
this.lblOwnerName = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -80,7 +81,6 @@ namespace StockInfoCore
|
||||
this.columnHeader9,
|
||||
this.columnHeader10});
|
||||
this.lvMyStocks.GridLines = true;
|
||||
this.lvMyStocks.HideSelection = false;
|
||||
this.lvMyStocks.Location = new System.Drawing.Point(14, 43);
|
||||
this.lvMyStocks.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.lvMyStocks.Name = "lvMyStocks";
|
||||
@ -323,11 +323,21 @@ namespace StockInfoCore
|
||||
this.txtTotalPlus.Size = new System.Drawing.Size(114, 33);
|
||||
this.txtTotalPlus.TabIndex = 14;
|
||||
//
|
||||
// lblOwnerName
|
||||
//
|
||||
this.lblOwnerName.AutoSize = true;
|
||||
this.lblOwnerName.Location = new System.Drawing.Point(424, 10);
|
||||
this.lblOwnerName.Name = "lblOwnerName";
|
||||
this.lblOwnerName.Size = new System.Drawing.Size(145, 20);
|
||||
this.lblOwnerName.TabIndex = 16;
|
||||
this.lblOwnerName.Text = "Portfölj Ägare Namn";
|
||||
//
|
||||
// frmMyStocks
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1217, 651);
|
||||
this.Controls.Add(this.lblOwnerName);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.txtTotalPlus);
|
||||
this.Controls.Add(this.label6);
|
||||
@ -385,5 +395,6 @@ namespace StockInfoCore
|
||||
private System.Windows.Forms.TextBox txtTotalMinus;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.TextBox txtTotalPlus;
|
||||
private Label lblOwnerName;
|
||||
}
|
||||
}
|
||||
@ -71,6 +71,7 @@ namespace StockInfoCore
|
||||
AddItemToListView(stk);
|
||||
}
|
||||
|
||||
lblOwnerName.Text = $"* {ConnectedPerson.FirstName} {ConnectedPerson.LastName} *";
|
||||
txtBuyTotal.Text = BoughtSum.ToString();
|
||||
txtBuyTotal.Refresh();
|
||||
txtCurrValue.Text = CurrentSum.ToString();
|
||||
@ -96,7 +97,7 @@ namespace StockInfoCore
|
||||
|
||||
private void TotalReload()
|
||||
{
|
||||
_stockMarketRepository.LoadStockMarketList();
|
||||
_stockMarketRepository.LoadStockMarketList(ConnectedPerson.Id);
|
||||
Stocks = _stockMarketRepository.StockMarketList;
|
||||
ReloadData();
|
||||
// lbUpdateTimes.Items.Add($"{DateTime.Now.ToLongTimeString()} - {txtTotDiff.Text.Substring(0, txtTotDiff.Text.Length-2)}");
|
||||
|
||||
@ -57,4 +57,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user