Add project files.
This commit is contained in:
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
340
.gitignore
vendored
Normal file
340
.gitignore
vendored
Normal file
@ -0,0 +1,340 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- Backup*.rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
20
StockDal.Interface/IStockMarketRepository.cs
Normal file
20
StockDal.Interface/IStockMarketRepository.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using StockDomain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StockDal.Interface
|
||||
{
|
||||
public interface IStockMarketRepository
|
||||
{
|
||||
Dictionary<string, DiTraderStockRow> StockMarketList { get; set; }
|
||||
bool ViewBrowser { get; set; }
|
||||
|
||||
void Clean();
|
||||
void LoadStockMarketList();
|
||||
void LoadStockMarketList(bool viewBrowser);
|
||||
void RefreshMarketList();
|
||||
}
|
||||
}
|
||||
16
StockDal.Interface/IStockMemberRepository.cs
Normal file
16
StockDal.Interface/IStockMemberRepository.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using StockDomain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StockDal.Interface
|
||||
{
|
||||
public interface IStockMemberRepository
|
||||
{
|
||||
IEnumerable<StockMember> GetStocks();
|
||||
//bool Insert(StockMember stockMember);
|
||||
void UpdateActPrice(int Id, decimal price);
|
||||
bool Delete(string stockMemberId);
|
||||
void InsertMany(List<StockMember> stockMembers);
|
||||
IEnumerable<StockMember> GetAllStocks();
|
||||
}
|
||||
}
|
||||
16
StockDal.Interface/StockDal.Interface.csproj
Normal file
16
StockDal.Interface/StockDal.Interface.csproj
Normal file
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.0.78" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.29" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StockDomain\StockDomain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
15
StockDal/AppConnection.cs
Normal file
15
StockDal/AppConnection.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RepositoryPattern
|
||||
{
|
||||
|
||||
public class StockDBConnection
|
||||
{
|
||||
public static string ConnectionString => ConfigurationManager.ConnectionStrings["StockDB"].ConnectionString;
|
||||
}
|
||||
}
|
||||
19
StockDal/StockDal.csproj
Normal file
19
StockDal/StockDal.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.0.78" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.29" />
|
||||
<PackageReference Include="Selenium.WebDriverBackedSelenium" Version="3.141.0" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StockDal.Interface\StockDal.Interface.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
230
StockDal/StockMarketRepository.cs
Normal file
230
StockDal/StockMarketRepository.cs
Normal file
@ -0,0 +1,230 @@
|
||||
using Newtonsoft.Json;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Chrome;
|
||||
using StockDal.Interface;
|
||||
using StockDomain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StockDal
|
||||
{
|
||||
public class StockMarketRepository : IStockMarketRepository
|
||||
{
|
||||
public Dictionary<string, DiTraderStockRow> StockMarketList { get; set; }
|
||||
|
||||
public List<DiTraderStockRow> DumpObjects { get; set; } = new List<DiTraderStockRow>();
|
||||
public DiTraderStockRow SaveRow { get; set; }
|
||||
public StringBuilder TextResults { get; set; }
|
||||
public bool ViewBrowser { get; set; }
|
||||
|
||||
public IWebDriver driver;
|
||||
|
||||
public StockMarketRepository()
|
||||
{
|
||||
ViewBrowser = false;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
var output = JsonConvert.SerializeObject(DumpObjects, Formatting.Indented);
|
||||
File.WriteAllText($"D:\\TimCoDemos\\DemoLogs\\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 ae)
|
||||
{
|
||||
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 url1 = "https://www.finansportalen.se/aktiekurser/";
|
||||
driver.Navigate().GoToUrl(burl2 ? url2 : url);
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void LoadStockMarketList()
|
||||
{
|
||||
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
DumpObjects = new List<DiTraderStockRow>();
|
||||
OpenBrowser();
|
||||
Find_Data();
|
||||
OpenBrowser(true);
|
||||
Find_Data();
|
||||
if (DumpObjects.Any())
|
||||
{
|
||||
SaveLogging();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void LoadStockMarketList(bool viewBrowser)
|
||||
{
|
||||
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
ViewBrowser = viewBrowser;
|
||||
OpenBrowser();
|
||||
Find_Data();
|
||||
}
|
||||
|
||||
public void RefreshMarketList()
|
||||
{
|
||||
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||
driver.Navigate().Refresh();
|
||||
Find_Data();
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
driver?.Quit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
104
StockDal/StockMemberRepository.cs
Normal file
104
StockDal/StockMemberRepository.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using Dapper;
|
||||
using RepositoryPattern;
|
||||
using StockDal.Interface;
|
||||
using StockDomain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace StockDal
|
||||
{
|
||||
public class StockMemberRepository : IStockMemberRepository
|
||||
{
|
||||
public bool Delete(string stockMemberId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InsertMany(List<StockMember> stockMembers)
|
||||
{
|
||||
using IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString);
|
||||
if (db.State == ConnectionState.Closed)
|
||||
db.Open();
|
||||
db.Execute(
|
||||
@"INSERT INTO [dbo].[StockMember]
|
||||
(StockId
|
||||
,StockExtId
|
||||
,BuyValue
|
||||
,BuyDate
|
||||
,ActValue
|
||||
,ActDate
|
||||
,SoldValue
|
||||
,SoldDate
|
||||
,Comment
|
||||
,PostAmount)
|
||||
VALUES
|
||||
(@StockId
|
||||
,@StockExtId
|
||||
,@BuyValue
|
||||
,@BuyDate
|
||||
,@ActValue
|
||||
,@ActDate
|
||||
,@SoldValue
|
||||
,@SoldDate
|
||||
,@Comment
|
||||
,@PostAmount)
|
||||
", stockMembers);
|
||||
}
|
||||
|
||||
public void UpdateActPrice(int Id, decimal price)
|
||||
{
|
||||
using IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString);
|
||||
if (db.State == ConnectionState.Closed)
|
||||
db.Open();
|
||||
|
||||
db.Execute(
|
||||
@"UPDATE [dbo].[StockMember]
|
||||
SET ActValue = @val,
|
||||
ActDate = @date
|
||||
WHERE Id = @id
|
||||
", new { val = price, date = DateTime.Today, id = Id });
|
||||
}
|
||||
|
||||
public IEnumerable<StockMember> GetStocks()
|
||||
{
|
||||
using IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString);
|
||||
if (db.State == ConnectionState.Closed)
|
||||
db.Open();
|
||||
return db.Query<StockMember>(@"SELECT Id
|
||||
,StockId
|
||||
,StockExtId
|
||||
,BuyValue
|
||||
,BuyDate
|
||||
,ActValue
|
||||
,ActDate
|
||||
,SoldValue
|
||||
,SoldDate
|
||||
,Comment
|
||||
,PostAmount
|
||||
FROM dbo.StockMember
|
||||
Where SoldDate is null
|
||||
ORDER BY PostAmount * (actvalue - BuyValue) desc", commandType: CommandType.Text);
|
||||
}
|
||||
public IEnumerable<StockMember> GetAllStocks()
|
||||
{
|
||||
using IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString);
|
||||
if (db.State == ConnectionState.Closed)
|
||||
db.Open();
|
||||
return db.Query<StockMember>(@"SELECT Id
|
||||
,StockId
|
||||
,StockExtId
|
||||
,BuyValue
|
||||
,BuyDate
|
||||
,ActValue
|
||||
,ActDate
|
||||
,SoldValue
|
||||
,SoldDate
|
||||
,Comment
|
||||
,PostAmount
|
||||
FROM dbo.StockMember
|
||||
ORDER BY PostAmount * (actvalue - BuyValue) desc", commandType: CommandType.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
StockDomain/DiTraderStockRow.cs
Normal file
22
StockDomain/DiTraderStockRow.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StockDomain
|
||||
{
|
||||
public class DiTraderStockRow
|
||||
{
|
||||
public string StockName { get; set; }
|
||||
public decimal ProcChange { get; set; }
|
||||
public decimal RealChange { get; set; }
|
||||
public decimal BuyPrice { get; set; }
|
||||
public decimal SellPrice { get; set; }
|
||||
public decimal LatestPrice { get; set; }
|
||||
public decimal HighestPrice { get; set; }
|
||||
public decimal LowestPrice { get; set; }
|
||||
public long Volume { get; set; }
|
||||
public TimeSpan TimeOfDay { get; set; }
|
||||
}
|
||||
}
|
||||
7
StockDomain/StockDomain.csproj
Normal file
7
StockDomain/StockDomain.csproj
Normal file
@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
25
StockDomain/StockMember.cs
Normal file
25
StockDomain/StockMember.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace StockDomain
|
||||
{
|
||||
public class StockMember
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string StockId { get; set; }
|
||||
public string StockExtId { get; set; }
|
||||
public decimal BuyValue { get; set; }
|
||||
public DateTime BuyDate { get; set; }
|
||||
public decimal ActValue { get; set; }
|
||||
public DateTime ActDate { get; set; }
|
||||
public long ActAmount { get; set; }
|
||||
public decimal SoldValue { get; set; }
|
||||
public DateTime? SoldDate { get; set; }
|
||||
// public string PostId { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public long PostAmount { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
43
WpfStocks.sln
Normal file
43
WpfStocks.sln
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30804.86
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockDomain", "StockDomain\StockDomain.csproj", "{25899D94-D35E-44A1-BDD7-BDD5589DB2E0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockDal.Interface", "StockDal.Interface\StockDal.Interface.csproj", "{65F33E97-16CF-471A-9C59-D0D17287856C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockDal", "StockDal\StockDal.csproj", "{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfStocks", "WpfStocks\WpfStocks.csproj", "{7640245C-91FF-4530-B909-32D347EC7FEA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{25899D94-D35E-44A1-BDD7-BDD5589DB2E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{25899D94-D35E-44A1-BDD7-BDD5589DB2E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{25899D94-D35E-44A1-BDD7-BDD5589DB2E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{25899D94-D35E-44A1-BDD7-BDD5589DB2E0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{65F33E97-16CF-471A-9C59-D0D17287856C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{65F33E97-16CF-471A-9C59-D0D17287856C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{65F33E97-16CF-471A-9C59-D0D17287856C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{65F33E97-16CF-471A-9C59-D0D17287856C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7640245C-91FF-4530-B909-32D347EC7FEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7640245C-91FF-4530-B909-32D347EC7FEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7640245C-91FF-4530-B909-32D347EC7FEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7640245C-91FF-4530-B909-32D347EC7FEA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {DEA63362-5E0F-44C4-AF18-358A682FA93B}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
9
WpfStocks/App.xaml
Normal file
9
WpfStocks/App.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<Application x:Class="WpfStocks.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:WpfStocks"
|
||||
Startup="OnStartup">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
44
WpfStocks/App.xaml.cs
Normal file
44
WpfStocks/App.xaml.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using WpfStocks.Data;
|
||||
|
||||
namespace WpfStocks
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
private ServiceProvider serviceProvider;
|
||||
|
||||
public App()
|
||||
{
|
||||
ServiceCollection services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
private void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddDbContext<EmployeeDbContext>(options =>
|
||||
{
|
||||
options.UseSqlite("Data Source = Employee.db");
|
||||
});
|
||||
|
||||
services.AddSingleton<MainWindow>();
|
||||
}
|
||||
|
||||
private void OnStartup(object sender , StartupEventArgs e)
|
||||
{
|
||||
var mainWindow = serviceProvider.GetService<MainWindow>();
|
||||
mainWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
WpfStocks/AssemblyInfo.cs
Normal file
10
WpfStocks/AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
15
WpfStocks/Data/Employee.cs
Normal file
15
WpfStocks/Data/Employee.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WpfStocks.Data
|
||||
{
|
||||
public class Employee
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
}
|
||||
}
|
||||
44
WpfStocks/Data/EmployeeDbContext.cs
Normal file
44
WpfStocks/Data/EmployeeDbContext.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WpfStocks.Data
|
||||
{
|
||||
public class EmployeeDbContext : DbContext
|
||||
{
|
||||
#region Constructor
|
||||
public EmployeeDbContext(DbContextOptions<EmployeeDbContext> options) : base(options)
|
||||
{
|
||||
Database.EnsureCreated();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
public DbSet<Employee> Employee { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Overridden Method
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Employee>().HasData(GetEmployees());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Method
|
||||
private List<Employee> GetEmployees()
|
||||
{
|
||||
return new List<Employee>
|
||||
{
|
||||
new Employee {Id=100, FirstName="John",LastName="Doe"},
|
||||
new Employee {Id=101, FirstName="Nicole",LastName="Martha"},
|
||||
new Employee {Id=102, FirstName="Steve",LastName="Johnsson"},
|
||||
new Employee {Id=103, FirstName="Thomas",LastName="Bond"},
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
17
WpfStocks/Data/Product.cs
Normal file
17
WpfStocks/Data/Product.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WpfStocks.Data
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public double Price { get; set; }
|
||||
public int Unit { get; set; }
|
||||
}
|
||||
}
|
||||
18
WpfStocks/MainWindow.xaml
Normal file
18
WpfStocks/MainWindow.xaml
Normal file
@ -0,0 +1,18 @@
|
||||
<Window x:Class="WpfStocks.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:WpfStocks"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
<DataGrid x:Name="EmployeeDG" AutoGenerateColumns="False">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Id" Binding="{Binding Id}"/>
|
||||
<DataGridTextColumn Header="First Name" Binding="{Binding FirstName}"/>
|
||||
<DataGridTextColumn Header="Last Name" Binding="{Binding LastName}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Window>
|
||||
39
WpfStocks/MainWindow.xaml.cs
Normal file
39
WpfStocks/MainWindow.xaml.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using WpfStocks.Data;
|
||||
|
||||
namespace WpfStocks
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
EmployeeDbContext _dbContext;
|
||||
|
||||
public MainWindow(EmployeeDbContext dbContext)
|
||||
{
|
||||
InitializeComponent();
|
||||
_dbContext = dbContext;
|
||||
GetEmployees();
|
||||
}
|
||||
|
||||
private void GetEmployees()
|
||||
{
|
||||
var employees = _dbContext.Employee.ToList();
|
||||
EmployeeDG.ItemsSource = employees;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
WpfStocks/WpfStocks.csproj
Normal file
14
WpfStocks/WpfStocks.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user