90 lines
2.3 KiB
C#
90 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace upper_limit_crawler
|
|
{
|
|
public static class UlUtil
|
|
{
|
|
static string m_strLogServer = "http://mjjo53.us.to:8000";
|
|
|
|
static CPUTILLib.CpCybos m_Util = new CPUTILLib.CpCybos();
|
|
static TextBox m_tbLog = null;
|
|
|
|
public static void SetLogView(TextBox tbLog)
|
|
{
|
|
m_tbLog = tbLog;
|
|
}
|
|
|
|
public static string GetCurTimeString()
|
|
{
|
|
return DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
|
|
public static void WebLog(string strURL, string strMsg)
|
|
{
|
|
try
|
|
{
|
|
// 요청 String -> 요청 Byte 변환
|
|
byte[] byteDataParams = UTF8Encoding.UTF8.GetBytes(strMsg);
|
|
|
|
// HttpWebRequest 객체 생성, 설정
|
|
Uri reqURI = new Uri(strURL);
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(reqURI);
|
|
request.Method = "POST"; // 기본값 "GET"
|
|
request.ContentType = "application/x-www-form-urlencoded";
|
|
request.ContentLength = byteDataParams.Length;
|
|
|
|
// 요청 Byte -> 요청 Stream 변환
|
|
Stream stDataParams = request.GetRequestStream();
|
|
stDataParams.Write(byteDataParams, 0, byteDataParams.Length);
|
|
stDataParams.Close();
|
|
|
|
// 요청, 응답 받기
|
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
|
|
// 응답 Stream 읽기
|
|
Stream stReadData = response.GetResponseStream();
|
|
StreamReader srReadData = new StreamReader(stReadData, Encoding.Default);
|
|
|
|
// 응답 Stream -> 응답 String 변환
|
|
string strResult = srReadData.ReadToEnd();
|
|
|
|
Console.WriteLine(strResult);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
ex.ToString();
|
|
}
|
|
}
|
|
|
|
public static void Trace(string strMsg)
|
|
{
|
|
string strLog = "["+GetCurTimeString()+"] "+strMsg;
|
|
Console.WriteLine(strLog);
|
|
//m_tbLog.Text += strLog;
|
|
//WebLog(m_strLogServer, strLog);
|
|
}
|
|
|
|
public static int GetLimitRemainCountTrace()
|
|
{
|
|
return m_Util.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST);
|
|
}
|
|
|
|
public static int GetLimitRemainCountRQ()
|
|
{
|
|
return m_Util.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_NONTRADE_REQUEST);
|
|
}
|
|
|
|
public static int GetLimitRemainCountSB()
|
|
{
|
|
return m_Util.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_SUBSCRIBE);
|
|
}
|
|
}
|
|
}
|