- 이데일리, 머니투데이, 파이낸셜뉴스 추가
- 리스트창에 종목명, 종목코드 삭제 - NewtonSoft.Json 추가
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,5 @@
|
|||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
|
log/
|
||||||
|
configure/
|
||||||
|
publish/
|
||||||
|
|||||||
@@ -70,6 +70,10 @@
|
|||||||
<Reference Include="HtmlAgilityPack">
|
<Reference Include="HtmlAgilityPack">
|
||||||
<HintPath>HtmlAgility\HtmlAgilityPack.dll</HintPath>
|
<HintPath>HtmlAgility\HtmlAgilityPack.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@@ -120,6 +124,7 @@
|
|||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<None Include="app.manifest" />
|
<None Include="app.manifest" />
|
||||||
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
|||||||
14
NewsForm.Designer.cs
generated
14
NewsForm.Designer.cs
generated
@@ -31,8 +31,6 @@
|
|||||||
this.lvList = new System.Windows.Forms.ListView();
|
this.lvList = new System.Windows.Forms.ListView();
|
||||||
this.chTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.chTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.chTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.chTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.chCodeName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
|
||||||
this.chCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
|
||||||
this.chReference = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.chReference = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.chLink = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.chLink = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.wbView = new System.Windows.Forms.WebBrowser();
|
this.wbView = new System.Windows.Forms.WebBrowser();
|
||||||
@@ -59,8 +57,6 @@
|
|||||||
this.lvList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
this.lvList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||||
this.chTime,
|
this.chTime,
|
||||||
this.chTitle,
|
this.chTitle,
|
||||||
this.chCodeName,
|
|
||||||
this.chCode,
|
|
||||||
this.chReference,
|
this.chReference,
|
||||||
this.chLink});
|
this.chLink});
|
||||||
this.lvList.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.lvList.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
@@ -86,14 +82,6 @@
|
|||||||
this.chTitle.Text = "제목";
|
this.chTitle.Text = "제목";
|
||||||
this.chTitle.Width = 366;
|
this.chTitle.Width = 366;
|
||||||
//
|
//
|
||||||
// chCodeName
|
|
||||||
//
|
|
||||||
this.chCodeName.Text = "종목명";
|
|
||||||
//
|
|
||||||
// chCode
|
|
||||||
//
|
|
||||||
this.chCode.Text = "종목코드";
|
|
||||||
//
|
|
||||||
// chReference
|
// chReference
|
||||||
//
|
//
|
||||||
this.chReference.Text = "출처";
|
this.chReference.Text = "출처";
|
||||||
@@ -249,8 +237,6 @@
|
|||||||
private System.Windows.Forms.ListView lvList;
|
private System.Windows.Forms.ListView lvList;
|
||||||
private System.Windows.Forms.ColumnHeader chTime;
|
private System.Windows.Forms.ColumnHeader chTime;
|
||||||
private System.Windows.Forms.ColumnHeader chTitle;
|
private System.Windows.Forms.ColumnHeader chTitle;
|
||||||
private System.Windows.Forms.ColumnHeader chCodeName;
|
|
||||||
private System.Windows.Forms.ColumnHeader chCode;
|
|
||||||
private System.Windows.Forms.ColumnHeader chReference;
|
private System.Windows.Forms.ColumnHeader chReference;
|
||||||
private System.Windows.Forms.ColumnHeader chLink;
|
private System.Windows.Forms.ColumnHeader chLink;
|
||||||
private System.Windows.Forms.WebBrowser wbView;
|
private System.Windows.Forms.WebBrowser wbView;
|
||||||
|
|||||||
174
NewsForm.cs
174
NewsForm.cs
@@ -46,6 +46,9 @@ namespace NewsCrawler
|
|||||||
ReadDart(true);
|
ReadDart(true);
|
||||||
ReadEtoday(true);
|
ReadEtoday(true);
|
||||||
ReadAsiaE(true);
|
ReadAsiaE(true);
|
||||||
|
ReadEdaily(true);
|
||||||
|
ReadMoneyToday(true);
|
||||||
|
ReadFinacialNews(true);
|
||||||
|
|
||||||
|
|
||||||
lvList.ListViewItemSorter = new ListViewItemComparer(0, SortOrder.Ascending);
|
lvList.ListViewItemSorter = new ListViewItemComparer(0, SortOrder.Ascending);
|
||||||
@@ -72,9 +75,9 @@ namespace NewsCrawler
|
|||||||
if(Util.IsDebugging() == false)
|
if(Util.IsDebugging() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InsertItem("덕산하이메탈, 덕산네오룩스 66만여주 취득14:38", new DateTime(2016, 11, 30, 14, 38, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914371817318", "asiae", false);
|
InsertItem("[test] 덕산하이메탈, 덕산네오룩스 66만여주 취득14:38", new DateTime(2016, 11, 30, 14, 38, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914371817318", "asiae", false);
|
||||||
InsertItem("자연과환경, 12월15일~22일 주주명부폐쇄14:19", new DateTime(2016, 11, 30, 14, 19, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914193170301", "asiae", false);
|
InsertItem("[test] 자연과환경, 12월15일~22일 주주명부폐쇄14:19", new DateTime(2016, 11, 30, 14, 19, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914193170301", "asiae", false);
|
||||||
InsertItem("이엠코리아, 한국항공우주산업과 3억원 규모 공급계약14:06", new DateTime(2016, 11, 30, 14, 06, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914055964082", "asiae", false);
|
InsertItem("[test] 이엠코리아, 한국항공우주산업과 3억원 규모 공급계약14:06", new DateTime(2016, 11, 30, 14, 06, 00), "http://www.asiae.co.kr/news/sokbo/sokbo_view.htm?idxno=2016112914055964082", "asiae", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +131,7 @@ namespace NewsCrawler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lvList.Items.Add(new ListViewItem(new string[] { time.ToString("HH:mm:ss"), strTitle, "", "", strRef, strURL }));
|
lvList.Items.Add(new ListViewItem(new string[] { time.ToString("HH:mm:ss"), strTitle, strRef, strURL }));
|
||||||
|
|
||||||
|
|
||||||
if(chAutoSelect.Checked == true)
|
if(chAutoSelect.Checked == true)
|
||||||
@@ -376,6 +379,166 @@ namespace NewsCrawler
|
|||||||
return bHasNew;
|
return bHasNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReadEdaily(bool bInitial = false)
|
||||||
|
{
|
||||||
|
bool bHasNew = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strServerURL = "http://www.edaily.co.kr/news/realtime/realtime_NewsRead.asp";
|
||||||
|
WebRequest request = WebRequest.Create("http://www.edaily.co.kr/news/realtime/realtime_NewsList_1.asp");
|
||||||
|
request.Credentials=CredentialCache.DefaultCredentials;
|
||||||
|
request.Timeout=2000;
|
||||||
|
|
||||||
|
DateTime PrevTime = DateTime.Now;
|
||||||
|
|
||||||
|
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||||
|
{
|
||||||
|
using(Stream dataStream = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
using(StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("EUC-KR")))
|
||||||
|
{
|
||||||
|
string responseFromServer = WebUtility.HtmlDecode(reader.ReadToEnd());
|
||||||
|
|
||||||
|
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
|
||||||
|
doc.LoadHtml(responseFromServer);
|
||||||
|
string strXPath = "//li[contains(@id, 'NewsIcon')]";
|
||||||
|
var lists = doc.DocumentNode.SelectNodes(strXPath);
|
||||||
|
foreach(var item in lists)
|
||||||
|
{
|
||||||
|
string strTitle = item.SelectSingleNode(".//a").GetAttributeValue("title", "");
|
||||||
|
string strTime = item.SelectSingleNode(".//span").InnerText;
|
||||||
|
|
||||||
|
string strID = item.GetAttributeValue("id", "");
|
||||||
|
strID = strID.Substring("NewsIcon_".Length);
|
||||||
|
string strURL = strServerURL+"?newsid="+strID;
|
||||||
|
|
||||||
|
DateTime Time;
|
||||||
|
DateTime.TryParseExact(strTime, "HH:mm", CultureInfo.CurrentCulture, DateTimeStyles.None, out Time);
|
||||||
|
if(Time > PrevTime)
|
||||||
|
break;
|
||||||
|
PrevTime = Time;
|
||||||
|
|
||||||
|
InsertItem(strTitle, Time, strURL, "이데일리", bInitial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return bHasNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadMoneyToday(bool bInitial = false)
|
||||||
|
{
|
||||||
|
bool bHasNew = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strServerURL = "http://news.mt.co.kr/mtview.php?no=";
|
||||||
|
WebRequest request = WebRequest.Create("http://news.mt.co.kr/newsflash/newsflash.html");
|
||||||
|
request.Credentials=CredentialCache.DefaultCredentials;
|
||||||
|
request.Timeout=2000;
|
||||||
|
|
||||||
|
DateTime PrevTime = DateTime.Now;
|
||||||
|
|
||||||
|
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||||
|
{
|
||||||
|
using(Stream dataStream = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
using(StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("EUC-KR")))
|
||||||
|
{
|
||||||
|
string responseFromServer = WebUtility.HtmlDecode(reader.ReadToEnd());
|
||||||
|
|
||||||
|
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
|
||||||
|
doc.LoadHtml(responseFromServer);
|
||||||
|
string strXPath = "//div[@id='articleList']//li[@class='bundle']";
|
||||||
|
|
||||||
|
var lists = doc.DocumentNode.SelectNodes(strXPath);
|
||||||
|
foreach(var item in lists)
|
||||||
|
{
|
||||||
|
string strTitle = item.SelectSingleNode(".//a").InnerText;
|
||||||
|
string strTime = item.SelectSingleNode(".//span").InnerText;
|
||||||
|
|
||||||
|
string strID = item.SelectSingleNode(".//a").GetAttributeValue("href", "");
|
||||||
|
int iStart = strID.IndexOf('\'', 0);
|
||||||
|
iStart = strID.IndexOf('\'', iStart+1);
|
||||||
|
iStart = strID.IndexOf('\'', iStart+1);
|
||||||
|
int iEnd = strID.IndexOf('\'', iStart+1);
|
||||||
|
strID = strID.Substring(iStart+1, iEnd-iStart+1);
|
||||||
|
string strURL = strServerURL+strID;
|
||||||
|
|
||||||
|
DateTime Time;
|
||||||
|
DateTime.TryParseExact(strTime, "HH:mm", CultureInfo.CurrentCulture, DateTimeStyles.None, out Time);
|
||||||
|
if(Time > PrevTime)
|
||||||
|
break;
|
||||||
|
PrevTime = Time;
|
||||||
|
|
||||||
|
InsertItem(strTitle, Time, strURL, "머니투데이", bInitial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return bHasNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadFinacialNews(bool bInitial = false)
|
||||||
|
{
|
||||||
|
bool bHasNew = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strServerURL = "http://www.fnnews.com/news/";
|
||||||
|
WebRequest request = WebRequest.Create("http://www.fnnews.com/newsflash/today/data?type=json");
|
||||||
|
request.Credentials=CredentialCache.DefaultCredentials;
|
||||||
|
request.Timeout=2000;
|
||||||
|
|
||||||
|
DateTime Today = DateTime.Now;
|
||||||
|
|
||||||
|
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||||
|
{
|
||||||
|
using(Stream dataStream = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
using(StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("UTF-8")))
|
||||||
|
{
|
||||||
|
string responseFromServer = WebUtility.HtmlDecode(reader.ReadToEnd());
|
||||||
|
|
||||||
|
dynamic jObj = Newtonsoft.Json.JsonConvert.DeserializeObject(responseFromServer);
|
||||||
|
foreach(var data in jObj)
|
||||||
|
{
|
||||||
|
string strTitle = data["title"];
|
||||||
|
string strTime = data["date"];
|
||||||
|
DateTime Time;
|
||||||
|
DateTime.TryParseExact(strTime, "yyyy.MM.dd HH:mm", CultureInfo.CurrentCulture, DateTimeStyles.None, out Time);
|
||||||
|
|
||||||
|
string strCode = data["code"];
|
||||||
|
string strURL = strServerURL+strCode;
|
||||||
|
|
||||||
|
if(Time.DayOfYear == Today.DayOfYear)
|
||||||
|
InsertItem(strTitle, Time, strURL, "파이낸셜뉴스", bInitial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return bHasNew;
|
||||||
|
}
|
||||||
|
|
||||||
private void CrawlTimer_Tick(object sender, EventArgs e)
|
private void CrawlTimer_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
m_CrawlTimer.Enabled = false;
|
m_CrawlTimer.Enabled = false;
|
||||||
@@ -386,6 +549,9 @@ namespace NewsCrawler
|
|||||||
ReadDart();
|
ReadDart();
|
||||||
ReadAsiaE();
|
ReadAsiaE();
|
||||||
ReadEtoday();
|
ReadEtoday();
|
||||||
|
ReadEdaily();
|
||||||
|
ReadMoneyToday();
|
||||||
|
ReadFinacialNews();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_CrawlTimer.Interval = m_iCrawlInterval;
|
m_CrawlTimer.Interval = m_iCrawlInterval;
|
||||||
|
|||||||
4
packages.config
Normal file
4
packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
|
||||||
|
</packages>
|
||||||
BIN
packages/Newtonsoft.Json.9.0.1/Newtonsoft.Json.9.0.1.nupkg
vendored
Normal file
BIN
packages/Newtonsoft.Json.9.0.1/Newtonsoft.Json.9.0.1.nupkg
vendored
Normal file
Binary file not shown.
9793
packages/Newtonsoft.Json.9.0.1/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
9793
packages/Newtonsoft.Json.9.0.1/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8922
packages/Newtonsoft.Json.9.0.1/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
8922
packages/Newtonsoft.Json.9.0.1/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9229
packages/Newtonsoft.Json.9.0.1/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
9229
packages/Newtonsoft.Json.9.0.1/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9229
packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
9229
packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8756
packages/Newtonsoft.Json.9.0.1/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
8756
packages/Newtonsoft.Json.9.0.1/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8409
packages/Newtonsoft.Json.9.0.1/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
8409
packages/Newtonsoft.Json.9.0.1/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8756
packages/Newtonsoft.Json.9.0.1/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
8756
packages/Newtonsoft.Json.9.0.1/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
116
packages/Newtonsoft.Json.9.0.1/tools/install.ps1
vendored
Normal file
116
packages/Newtonsoft.Json.9.0.1/tools/install.ps1
vendored
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
param($installPath, $toolsPath, $package, $project)
|
||||||
|
|
||||||
|
# open json.net splash page on package install
|
||||||
|
# don't open if json.net is installed as a dependency
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$url = "http://www.newtonsoft.com/json/install?version=" + $package.Version
|
||||||
|
$dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
|
||||||
|
|
||||||
|
if ($dte2.ActiveWindow.Caption -eq "Package Manager Console")
|
||||||
|
{
|
||||||
|
# user is installing from VS NuGet console
|
||||||
|
# get reference to the window, the console host and the input history
|
||||||
|
# show webpage if "install-package newtonsoft.json" was last input
|
||||||
|
|
||||||
|
$consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow])
|
||||||
|
|
||||||
|
$props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor `
|
||||||
|
[System.Reflection.BindingFlags]::NonPublic)
|
||||||
|
|
||||||
|
$prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1
|
||||||
|
if ($prop -eq $null) { return }
|
||||||
|
|
||||||
|
$hostInfo = $prop.GetValue($consoleWindow)
|
||||||
|
if ($hostInfo -eq $null) { return }
|
||||||
|
|
||||||
|
$history = $hostInfo.WpfConsole.InputHistory.History
|
||||||
|
|
||||||
|
$lastCommand = $history | select -last 1
|
||||||
|
|
||||||
|
if ($lastCommand)
|
||||||
|
{
|
||||||
|
$lastCommand = $lastCommand.Trim().ToLower()
|
||||||
|
if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json"))
|
||||||
|
{
|
||||||
|
$dte2.ItemOperations.Navigate($url) | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# user is installing from VS NuGet dialog
|
||||||
|
# get reference to the window, then smart output console provider
|
||||||
|
# show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation
|
||||||
|
|
||||||
|
$instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor `
|
||||||
|
[System.Reflection.BindingFlags]::NonPublic)
|
||||||
|
|
||||||
|
$consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor `
|
||||||
|
[System.Reflection.BindingFlags]::NonPublic)
|
||||||
|
|
||||||
|
if ($instanceField -eq $null -or $consoleField -eq $null) { return }
|
||||||
|
|
||||||
|
$instance = $instanceField.GetValue($null)
|
||||||
|
|
||||||
|
if ($instance -eq $null) { return }
|
||||||
|
|
||||||
|
$consoleProvider = $consoleField.GetValue($instance)
|
||||||
|
if ($consoleProvider -eq $null) { return }
|
||||||
|
|
||||||
|
$console = $consoleProvider.CreateOutputConsole($false)
|
||||||
|
|
||||||
|
$messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor `
|
||||||
|
[System.Reflection.BindingFlags]::NonPublic)
|
||||||
|
if ($messagesField -eq $null) { return }
|
||||||
|
|
||||||
|
$messages = $messagesField.GetValue($console)
|
||||||
|
if ($messages -eq $null) { return }
|
||||||
|
|
||||||
|
$operations = $messages -split "=============================="
|
||||||
|
|
||||||
|
$lastOperation = $operations | select -last 1
|
||||||
|
|
||||||
|
if ($lastOperation)
|
||||||
|
{
|
||||||
|
$lastOperation = $lastOperation.ToLower()
|
||||||
|
|
||||||
|
$lines = $lastOperation -split "`r`n"
|
||||||
|
|
||||||
|
$installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1
|
||||||
|
|
||||||
|
if ($installMatch)
|
||||||
|
{
|
||||||
|
$dte2.ItemOperations.Navigate($url) | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$pmPane = $dte2.ToolWindows.OutputWindow.OutputWindowPanes.Item("Package Manager")
|
||||||
|
|
||||||
|
$selection = $pmPane.TextDocument.Selection
|
||||||
|
$selection.StartOfDocument($false)
|
||||||
|
$selection.EndOfDocument($true)
|
||||||
|
|
||||||
|
if ($selection.Text.StartsWith("Attempting to gather dependencies information for package 'Newtonsoft.Json." + $package.Version + "'"))
|
||||||
|
{
|
||||||
|
# don't show on upgrade
|
||||||
|
if (!$selection.Text.Contains("Removed package"))
|
||||||
|
{
|
||||||
|
$dte2.ItemOperations.Navigate($url) | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
# stop potential errors from bubbling up
|
||||||
|
# worst case the splash page won't open
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# still yolo
|
||||||
Reference in New Issue
Block a user