- 중간 커밋
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@ bin/
|
||||
obj/
|
||||
log/
|
||||
publish/
|
||||
.vs/
|
||||
|
||||
@@ -501,6 +501,9 @@ namespace NewsCrawler
|
||||
|
||||
public void ReadDartAPI(bool bInitial = false)
|
||||
{
|
||||
if (Util.IsDebugging() == true)
|
||||
return;
|
||||
|
||||
if(m_iDartAPIRetry <= 0)
|
||||
return;
|
||||
|
||||
|
||||
212
ExcelHandler.cs
212
ExcelHandler.cs
@@ -1,119 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Excel = Microsoft.Office.Interop.Excel;
|
||||
using System.Reflection;
|
||||
namespace NewsCrawler
|
||||
{
|
||||
public class ExcelHandler
|
||||
{
|
||||
bool m_bAvailable = true;
|
||||
string m_strFileName = "";
|
||||
string m_strToday = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
//using System.Linq;
|
||||
//using System.Runtime.InteropServices;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
//using Excel = Microsoft.Office.Interop.Excel;
|
||||
//using System.Reflection;
|
||||
//namespace NewsCrawler
|
||||
//{
|
||||
// public class ExcelHandler
|
||||
// {
|
||||
// bool m_bAvailable = true;
|
||||
// string m_strFileName = "";
|
||||
// string m_strToday = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
|
||||
public ExcelHandler(string strFileName)
|
||||
{
|
||||
m_strFileName = strFileName;
|
||||
}
|
||||
// public ExcelHandler(string strFileName)
|
||||
// {
|
||||
// m_strFileName = strFileName;
|
||||
// }
|
||||
|
||||
public bool IsAvailable()
|
||||
{
|
||||
return m_bAvailable;
|
||||
}
|
||||
// public bool IsAvailable()
|
||||
// {
|
||||
// return m_bAvailable;
|
||||
// }
|
||||
|
||||
private void Create()
|
||||
{
|
||||
try
|
||||
{
|
||||
Excel.Application App = new Excel.Application();
|
||||
if(App == null)
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "엑셀이 설치되지 않음");
|
||||
m_bAvailable = false;
|
||||
return;
|
||||
}
|
||||
// private void Create()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Excel.Application App = new Excel.Application();
|
||||
// if(App == null)
|
||||
// {
|
||||
// Util.Log(Util.LOG_TYPE.ERROR, "엑셀이 설치되지 않음");
|
||||
// m_bAvailable = false;
|
||||
// return;
|
||||
// }
|
||||
|
||||
Excel._Workbook Workbook = App.Workbooks.Add(Missing.Value);
|
||||
Excel._Worksheet Worksheet = Workbook.ActiveSheet;
|
||||
// Excel._Workbook Workbook = App.Workbooks.Add(Missing.Value);
|
||||
// Excel._Worksheet Worksheet = Workbook.ActiveSheet;
|
||||
|
||||
Worksheet.Cells[1, 1] = "날짜";
|
||||
Worksheet.Cells[1, 2] = "기사 시간";
|
||||
Worksheet.Cells[1, 3] = "받은 시간";
|
||||
Worksheet.Cells[1, 4] = "출처";
|
||||
Worksheet.Cells[1, 5] = "제목";
|
||||
Worksheet.Cells[1, 6] = "요청 시간";
|
||||
Worksheet.Cells[1, 7] = "시가";
|
||||
Worksheet.Cells[1, 8] = "저가";
|
||||
Worksheet.Cells[1, 9] = "대비";
|
||||
Worksheet.Cells[1, 10] = "고가";
|
||||
Worksheet.Cells[1, 11] = "대비";
|
||||
Worksheet.Cells[1, 12] = "링크";
|
||||
// Worksheet.Cells[1, 1] = "날짜";
|
||||
// Worksheet.Cells[1, 2] = "기사 시간";
|
||||
// Worksheet.Cells[1, 3] = "받은 시간";
|
||||
// Worksheet.Cells[1, 4] = "출처";
|
||||
// Worksheet.Cells[1, 5] = "제목";
|
||||
// Worksheet.Cells[1, 6] = "요청 시간";
|
||||
// Worksheet.Cells[1, 7] = "시가";
|
||||
// Worksheet.Cells[1, 8] = "저가";
|
||||
// Worksheet.Cells[1, 9] = "대비";
|
||||
// Worksheet.Cells[1, 10] = "고가";
|
||||
// Worksheet.Cells[1, 11] = "대비";
|
||||
// Worksheet.Cells[1, 12] = "링크";
|
||||
|
||||
Workbook.SaveAs(m_strFileName, Excel.XlFileFormat.xlOpenXMLWorkbook, Missing.Value,
|
||||
Missing.Value, false, false, Excel.XlSaveAsAccessMode.xlNoChange,
|
||||
Excel.XlSaveConflictResolution.xlUserResolution, true,
|
||||
Missing.Value, Missing.Value, Missing.Value);
|
||||
Workbook.Close();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
// Workbook.SaveAs(m_strFileName, Excel.XlFileFormat.xlOpenXMLWorkbook, Missing.Value,
|
||||
// Missing.Value, false, false, Excel.XlSaveAsAccessMode.xlNoChange,
|
||||
// Excel.XlSaveConflictResolution.xlUserResolution, true,
|
||||
// Missing.Value, Missing.Value, Missing.Value);
|
||||
// Workbook.Close();
|
||||
// }
|
||||
// catch(Exception ex)
|
||||
// {
|
||||
// Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
// }
|
||||
// }
|
||||
|
||||
public bool AddRow(string strNewsTime, string strResTime, string strRef, string strTitle, float fReqTime, int iPriceS, int iPriceLow, float fPriceLowP, int iPriceHigh, float fPriceHighP, string strLink)
|
||||
{
|
||||
lock(this)
|
||||
{
|
||||
if(m_bAvailable == false)
|
||||
return false;
|
||||
// public bool AddRow(string strNewsTime, string strResTime, string strRef, string strTitle, float fReqTime, int iPriceS, int iPriceLow, float fPriceLowP, int iPriceHigh, float fPriceHighP, string strLink)
|
||||
// {
|
||||
// lock(this)
|
||||
// {
|
||||
// if(m_bAvailable == false)
|
||||
// return false;
|
||||
|
||||
if(File.Exists(m_strFileName) == false)
|
||||
Create();
|
||||
// if(File.Exists(m_strFileName) == false)
|
||||
// Create();
|
||||
|
||||
try
|
||||
{
|
||||
Excel.Application App = new Excel.Application();
|
||||
if(App == null)
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.ERROR, "엑셀이 설치되지 않음");
|
||||
m_bAvailable = false;
|
||||
return false;
|
||||
}
|
||||
App.DisplayAlerts = false;
|
||||
// try
|
||||
// {
|
||||
// Excel.Application App = new Excel.Application();
|
||||
// if(App == null)
|
||||
// {
|
||||
// Util.Log(Util.LOG_TYPE.ERROR, "엑셀이 설치되지 않음");
|
||||
// m_bAvailable = false;
|
||||
// return false;
|
||||
// }
|
||||
// App.DisplayAlerts = false;
|
||||
|
||||
Excel._Workbook Workbook = App.Workbooks.Open(m_strFileName);
|
||||
Excel._Worksheet Worksheet = Workbook.ActiveSheet;
|
||||
// Excel._Workbook Workbook = App.Workbooks.Open(m_strFileName);
|
||||
// Excel._Worksheet Worksheet = Workbook.ActiveSheet;
|
||||
|
||||
int iRow = Worksheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing).Row+1;
|
||||
Worksheet.Cells[iRow, 1] = m_strToday;
|
||||
Worksheet.Cells[iRow, 2] = strNewsTime;
|
||||
Worksheet.Cells[iRow, 3] = strResTime;
|
||||
Worksheet.Cells[iRow, 4] = strRef;
|
||||
Worksheet.Cells[iRow, 5] = strTitle;
|
||||
Worksheet.Cells[iRow, 6] = fReqTime;
|
||||
Worksheet.Cells[iRow, 7] = iPriceS;
|
||||
Worksheet.Cells[iRow, 8] = iPriceLow;
|
||||
Worksheet.Cells[iRow, 9] = fPriceLowP;
|
||||
Worksheet.Cells[iRow, 10] = iPriceHigh;
|
||||
Worksheet.Cells[iRow, 11] = fPriceHighP;
|
||||
Worksheet.Cells[iRow, 12] = strLink;
|
||||
// int iRow = Worksheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing).Row+1;
|
||||
// Worksheet.Cells[iRow, 1] = m_strToday;
|
||||
// Worksheet.Cells[iRow, 2] = strNewsTime;
|
||||
// Worksheet.Cells[iRow, 3] = strResTime;
|
||||
// Worksheet.Cells[iRow, 4] = strRef;
|
||||
// Worksheet.Cells[iRow, 5] = strTitle;
|
||||
// Worksheet.Cells[iRow, 6] = fReqTime;
|
||||
// Worksheet.Cells[iRow, 7] = iPriceS;
|
||||
// Worksheet.Cells[iRow, 8] = iPriceLow;
|
||||
// Worksheet.Cells[iRow, 9] = fPriceLowP;
|
||||
// Worksheet.Cells[iRow, 10] = iPriceHigh;
|
||||
// Worksheet.Cells[iRow, 11] = fPriceHighP;
|
||||
// Worksheet.Cells[iRow, 12] = strLink;
|
||||
|
||||
Workbook.Save();
|
||||
Workbook.Close();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Workbook.Save();
|
||||
// Workbook.Close();
|
||||
// }
|
||||
// catch(Exception ex)
|
||||
// {
|
||||
// Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
BIN
ExcelLibrary.dll
Normal file
BIN
ExcelLibrary.dll
Normal file
Binary file not shown.
26
ListViewNF.cs
Normal file
26
ListViewNF.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NewsCrawler
|
||||
{
|
||||
class ListViewNF : System.Windows.Forms.ListView
|
||||
{
|
||||
public ListViewNF()
|
||||
{
|
||||
//Activate double buffering
|
||||
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
||||
//Enable the OnNotifyMessage event so we get a chance to filter out
|
||||
// Windows messages before they get to the form's WndProc
|
||||
this.SetStyle(ControlStyles.EnableNotifyMessage, true);
|
||||
}
|
||||
|
||||
protected override void OnNotifyMessage(Message m)
|
||||
{
|
||||
//Filter out the WM_ERASEBKGND message
|
||||
if (m.Msg != 0x14)
|
||||
{
|
||||
base.OnNotifyMessage(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -89,6 +90,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ListViewNF.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CodeList.cs" />
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="ConfigForm.cs">
|
||||
@@ -213,33 +217,6 @@
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
<COMReference Include="Microsoft.Office.Core">
|
||||
<Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
|
||||
<VersionMajor>2</VersionMajor>
|
||||
<VersionMinor>4</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>primary</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
<COMReference Include="Microsoft.Office.Interop.Excel">
|
||||
<Guid>{00020813-0000-0000-C000-000000000046}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>6</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>primary</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
<COMReference Include="VBIDE">
|
||||
<Guid>{0002E157-0000-0000-C000-000000000046}</Guid>
|
||||
<VersionMajor>5</VersionMajor>
|
||||
<VersionMinor>3</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>primary</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
||||
|
||||
6
NewsForm.Designer.cs
generated
6
NewsForm.Designer.cs
generated
@@ -28,7 +28,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lvList = new System.Windows.Forms.ListView();
|
||||
this.lvList = new NewsCrawler.ListViewNF();
|
||||
this.chId = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chResT = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
@@ -279,7 +279,7 @@
|
||||
//
|
||||
this.chBuy.Appearance = System.Windows.Forms.Appearance.Button;
|
||||
this.chBuy.AutoSize = true;
|
||||
this.chBuy.Location = new System.Drawing.Point(356, 1);
|
||||
this.chBuy.Location = new System.Drawing.Point(359, 1);
|
||||
this.chBuy.Name = "chBuy";
|
||||
this.chBuy.Size = new System.Drawing.Size(39, 22);
|
||||
this.chBuy.TabIndex = 9;
|
||||
@@ -329,7 +329,7 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListView lvList;
|
||||
private ListViewNF lvList;
|
||||
private System.Windows.Forms.ColumnHeader chTime;
|
||||
private System.Windows.Forms.ColumnHeader chTitle;
|
||||
private System.Windows.Forms.ColumnHeader chReference;
|
||||
|
||||
33
NewsForm.cs
33
NewsForm.cs
@@ -86,7 +86,7 @@ namespace NewsCrawler
|
||||
|
||||
Crawler m_Crawler = null;
|
||||
|
||||
ExcelHandler m_Excel = null;
|
||||
//ExcelHandler m_Excel = null;
|
||||
|
||||
float m_fSupplyContractRate;
|
||||
|
||||
@@ -148,13 +148,13 @@ namespace NewsCrawler
|
||||
lvList.SelectedItems[0].EnsureVisible();
|
||||
}
|
||||
|
||||
foreach(ColumnHeader col in lvList.Columns)
|
||||
{
|
||||
if(!(col == chPriceS || col == chPriceLow || col == chPriceHigh))
|
||||
col.Width = -2;
|
||||
}
|
||||
//foreach(ColumnHeader col in lvList.Columns)
|
||||
//{
|
||||
// if(!(col == chPriceS || col == chPriceLow || col == chPriceHigh))
|
||||
// col.Width = -2;
|
||||
//}
|
||||
|
||||
m_Excel = new ExcelHandler(Util.GetLogPath()+"/PriceCheck"+DateTime.Now.ToString("yyyy-MM-dd")+".xlsx");
|
||||
//m_Excel = new ExcelHandler(Util.GetLogPath()+"/PriceCheck"+DateTime.Now.ToString("yyyy-MM-dd")+".xlsx");
|
||||
|
||||
m_CrawlTimer.Elapsed+=CrawlTimer_Tick;
|
||||
m_CrawlTimer.Interval = m_iCrawlInterval;
|
||||
@@ -387,6 +387,15 @@ namespace NewsCrawler
|
||||
"",
|
||||
strURL }));
|
||||
|
||||
if(lvList.Items.Count == 0)
|
||||
{
|
||||
foreach (ColumnHeader col in lvList.Columns)
|
||||
{
|
||||
if (!(col == chPriceS || col == chPriceLow || col == chPriceHigh))
|
||||
col.Width = -2;
|
||||
}
|
||||
}
|
||||
|
||||
lock(m_URLs)
|
||||
m_URLs.Add(strURL);
|
||||
|
||||
@@ -548,11 +557,11 @@ namespace NewsCrawler
|
||||
|
||||
if(Data.m_bLog == false)
|
||||
{
|
||||
Data.m_bLog = m_Excel.AddRow(Data.m_NewsItem.m_NewsTime.ToString("HH:mm:ss:fff"), Data.m_NewsItem.m_ResTime.ToString("HH:mm:ss:fff"), Data.m_NewsItem.m_strRef, Data.m_NewsItem.m_strTitle, Data.m_NewsItem.m_fElapseT,
|
||||
Data.m_iPriceStart,
|
||||
Data.m_iPriceLow, (Data.m_iPriceLow-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart,
|
||||
Data.m_iPriceHigh, (Data.m_iPriceHigh-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart,
|
||||
Data.m_NewsItem.m_strURL);
|
||||
//Data.m_bLog = m_Excel.AddRow(Data.m_NewsItem.m_NewsTime.ToString("HH:mm:ss:fff"), Data.m_NewsItem.m_ResTime.ToString("HH:mm:ss:fff"), Data.m_NewsItem.m_strRef, Data.m_NewsItem.m_strTitle, Data.m_NewsItem.m_fElapseT,
|
||||
// Data.m_iPriceStart,
|
||||
// Data.m_iPriceLow, (Data.m_iPriceLow-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart,
|
||||
// Data.m_iPriceHigh, (Data.m_iPriceHigh-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart,
|
||||
// Data.m_NewsItem.m_strURL);
|
||||
}
|
||||
|
||||
if(Data.m_bLog == false)
|
||||
|
||||
4
Util.cs
4
Util.cs
@@ -113,7 +113,11 @@ namespace NewsCrawler
|
||||
|
||||
public static bool IsDebugging()
|
||||
{
|
||||
#if DEBUG
|
||||
return Debugger.IsAttached;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string GetConfigPath()
|
||||
|
||||
@@ -76,3 +76,5 @@ KODEX 단기채권
|
||||
강스템바이오텍
|
||||
금호타이어
|
||||
아이진
|
||||
바른전자
|
||||
솔고바이오
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1000" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
|
||||
</packages>
|
||||
Binary file not shown.
BIN
packages/Microsoft.Office.Interop.Excel.15.0.4795.1000/lib/net20/Microsoft.Office.Interop.Excel.dll
vendored
Normal file
BIN
packages/Microsoft.Office.Interop.Excel.15.0.4795.1000/lib/net20/Microsoft.Office.Interop.Excel.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.9.0.1/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.9.0.1/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.9.0.1/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.9.0.1/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.9.0.1/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.9.0.1/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.9.0.1/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.9.0.1/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.9.0.1/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.9.0.1/lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user