예제 #1
0
        private void thBinanceWallet(object obj)
        {
            clsItem citem = obj as clsItem;

            if (citem == null)
            {
                return;
            }

            try
            {
                string html = json_get(citem.Url);

                ArrayList alst = fnc.SymbolGet(html, "assetCode");

                if (alst.Count < 100)
                {
                    throw new Exception(string.Format("조회된건수가 100건이 안됨.총 {0}건", alst.Count));
                }

                string h = "";
                //string name;
                int cnt = NewListCompByArray(citem, alst, h, 10);

                //          foreach (object n in alst)
                //          {
                //              bool isNew = db.isNewList(citem.Name, n.ToString());

                //              if (isNew)
                //              {
                //NewSymbol_Changed(citem, n.ToString(), cnSymbol_Ch_Type.Add);
                //              }

                //              cnt++;

                //          }

                citem.iRunCnt = 1;

                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, cnt.ToString());
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.White);
            }
            catch (Exception ex)
            {
                ProcException(ex, "thBinanceWallet", false);

                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, "0");
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.Red);
            }
        }
예제 #2
0
        private void thBinance(object obj)
        {
            clsItem citem = obj as clsItem;

            if (citem == null)
            {
                return;
            }

            try
            {
                string html = json_get(citem.Url);

                html = html.Replace("[", "");
                html = html.Replace("]", "");

                TreeNode node = Function.json.jsonParse.String2TreeNode(html);

                int cnt = NewListCompByTreeNode(citem, node, "symbol", enTN_Symbol.Text, "", 30);

                //         foreach (TreeNode n in node.Nodes)
                //         {
                //             if (n.Name == "symbol")
                //             {
                //                 bool isNew = db.isNewList(citem.Name, n.Text);

                //                 if (isNew)
                //                 {

                //NewSymbol_Changed(citem, n.Text, enSymbol_Ch_Type.Add);
                //                 }

                //                 cnt++;
                //             }
                //         }

                citem.iRunCnt = 1;

                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, cnt.ToString());
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.White);
            }
            catch (Exception ex)
            {
                ProcException(ex, "thBinance", false);

                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, "0");
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.Red);
            }
        }
예제 #3
0
        /// <summary>
        /// 업빗 가격
        /// </summary>
        /// <param name="obj"></param>
        private void thUpbit(object obj)
        {
            clsItem citem = obj as clsItem;

            if (citem == null)
            {
                return;
            }

            try
            {
                string html = json_get(citem.Url);

                ArrayList alst = fnc.SymbolGet(html, "\"code\"");

                if (alst.Count < 100)
                {
                    throw new Exception(string.Format("조회된건수가 100건이 안됨.총 {0}건", alst.Count));
                }

                string h = "CRIX.UPBIT.";
                //string name;
                int cnt = NewListCompByArray(citem, alst, h, 19);

                citem.iRunCnt = 1;

                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, cnt.ToString());
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.White);

                citem.iErrCnt = 0;
            }
            catch (Exception ex)
            {
                citem.iErrCnt++;

                //업빗은 자주에러가 발생 함으로 3회 이상 일시만 문자 발송
                if (citem.iErrCnt > 3)
                {
                    ProcException(ex, "thUpbit", false);
                    citem.iErrCnt = 0;
                }

                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, "0");
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.Red);
            }
        }
예제 #4
0
        private void NewSymbol_Changed(clsItem item, string symbolname, enSymbol_Ch_Type chType)
        {
            string log;
            string mtype;

            if (item.iRunCnt == 0)
            {
                log   = "[첫실행후바로]";
                mtype = "Admin";
            }
            else
            {
                log   = "";
                mtype = "NewLists";
            }

            switch (item.Idx)
            {
            case 0:                         //심볼 추가확인
            case 1:
            case 2:
            case 3:
            case 4:
                if (chType == enSymbol_Ch_Type.Add)
                {
                    log += string.Format("[{0}]{1} 심볼 추가 확인", item.Name, symbolname);
                }
                else
                {
                    log += string.Format("[{0}]{1} 심볼이 삭제 되었습니다.", item.Name, symbolname);
                }
                break;


            default:
                throw new Exception(string.Format("신규 심볼 처리 미등록 [{0}]{1}", item.Name, symbolname));
                break;
            }

            TelegramMsgSend(mtype, log);
            log_add(log);
        }
예제 #5
0
        private void Notice_Add(clsItem item, string url, string title)
        {
            string log;
            string mtype;

            if (item.iRunCnt == 0)
            {
                log   = "[첫실행후바로]";
                mtype = "Admin";
            }
            else
            {
                log   = "";
                mtype = "NewNotice";
            }

            switch (item.Idx)
            {
            case 5:                         //업빗
                log += string.Format("[신규{0}]{1} \r\nhttps://upbit.com/service_center/notice?id={2}", item.Name, title, url);
                break;

            case 7:                             //후오비
                log += string.Format("[신규{0}]{1} \r\nhttps://www.huobi.co.kr/ko-KR/notices/{2}", item.Name, title, url);
                break;

            case 6:
                log += string.Format("[신규{0}]{1} \r\n{2}", item.Name, title, url);
                break;

            default:
                throw new Exception(string.Format("신규 공지 처리 미등록 [{0}]{1} \r\n", item.Name, title, url));
                break;
            }

            TelegramMsgSend(mtype, log);
            log_add(log);
        }
예제 #6
0
        private int NewListCompByTreeNode(clsItem citem, TreeNode tn, string node_name, enTN_Symbol tn_symbol, string header, int iDelRowCountMax)
        {
            DataTable dt = db.NewList_Get(citem.Name);

            string name;
            int    cnt = 0;

            DataRow[] rows;

            foreach (TreeNode n in tn.Nodes)
            {
                //노드 이름 체크
                if (node_name != string.Empty && node_name != n.Name)
                {
                    continue;
                }

                if (tn_symbol == enTN_Symbol.Name)
                {
                    name = n.Name;
                }
                else
                {
                    name = n.Text;
                }

                //헤더가 같아야 심볼
                if (header == string.Empty || n.ToString().StartsWith(header))
                {
                    if (header != string.Empty)
                    {
                        name = name.Substring(header.Length);
                    }

                    //테스트용 처리 예외
                    //if (name.StartsWith("Z")) continue;

                    rows = dt.Select(string.Format("I_Name = '{0}'", name));

                    if (rows.Length < 1)
                    {                       //신규 심볼
                        //db에 저장
                        db.NewList_Add(citem.Name, name);
                        //로그 및 메시지
                        NewSymbol_Changed(citem, name, enSymbol_Ch_Type.Add);
                    }
                    else if (rows.Length > 0)
                    {
                        //확인 여부 체크
                        rows[0]["IsChk"] = 1;
                    }

                    cnt++;
                }
            }

            //삭제 여부 확인
            rows = dt.Select("IsChk = 0");

            string log = "";

            foreach (DataRow r in rows)
            {
                name = Fnc.obj2String(r["i_name"]);

                if (rows.Length > iDelRowCountMax)
                {                   //한번에 지정 건수이상 삭제되는 경우는 에러로 처리 한다.
                    log = Fnc.StringAdd(log, name, ",");
                }
                else
                {
                    //db에서 삭제
                    db.NewList_Del(citem.Name, name);
                    //로그 및 메시지
                    NewSymbol_Changed(citem, name, enSymbol_Ch_Type.Del);
                }
            }

            if (rows.Length > iDelRowCountMax)
            {
                string l = string.Format("삭제처리1회 최대치 초과[Site]{0}[삭제처리 {1}건]/[Max {2}건]", citem.Name, rows.Length, iDelRowCountMax);
                TelegramMsgSend("Error", l);
                log_add(l);
                clsLog.WLog("[Site]{0}[삭제처리1회 최대치 초과 {1}건/Max {3}건]{2}", citem.Name, rows.Length, log, iDelRowCountMax);
            }


            return(cnt);
        }
예제 #7
0
        private void thCoinnestNotice(object obj)
        {
            clsItem citem = obj as clsItem;

            if (citem == null)
            {
                return;
            }

            try
            {
                string html = json_get(citem.Url);

                int    cnt   = 0;
                int    idx   = 0;
                int    idx2  = 0;
                string smark = "<div class=\"entry-thumb\">";
                string url;
                string notice;
                bool   isNew;

                while (true)
                {
                    idx = html.IndexOf(smark, idx);

                    if (idx < 0)
                    {
                        break;
                    }

                    //공지 주소 조회
                    idx  = html.IndexOf("<a href=\"", idx + smark.Length);
                    idx2 = html.IndexOf("\">", idx + 1);

                    url = html.Substring(idx + 9, idx2 - idx - 9);

                    //제목 찾기
                    idx  = idx2;
                    idx  = html.IndexOf(url + "\">", idx);
                    idx += 2;
                    idx2 = html.IndexOf("</a>", idx);

                    notice = html.Substring(idx + url.Length, idx2 - idx - url.Length);

                    idx = idx2;

                    isNew = db.isNewNotice(citem.Name, url, notice);

                    if (isNew)
                    {                       //신규 항목임
                        Thread.Sleep(200);

                        Notice_Add(citem, url, notice);
                    }


                    cnt++;

                    //Console.WriteLine("[{0}]{1}  / {2}",cnt, url, notice);
                }

                citem.iRunCnt = 1;

                if (cnt != 9)
                {
                    TelegramMsgSend("Error", string.Format("빗썸공지가 9건이 아닙니다. {0}건", cnt));
                }


                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, cnt.ToString());
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.White);

                citem.iErrCnt = 0;
            }
            catch (Exception ex)
            {
                if (citem.iErrCnt > 3)
                {
                    ProcException(ex, "thBithumbNotice", false);
                    citem.iErrCnt = 0;
                }
                else
                {
                    citem.iErrCnt++;
                }

                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, "0");
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.Red);
            }
        }
예제 #8
0
        private void thHoubiNotice(object obj)
        {
            clsItem citem = obj as clsItem;

            if (citem == null)
            {
                return;
            }

            try
            {
                string html = json_get(citem.Url);



                int    cnt    = 0;
                int    idx    = 0;
                int    idx2   = 0;
                string smark  = "\"id\":";
                string smark2 = "\"title\":\"";
                string key;
                string notice;
                bool   isNew;

                while (true)
                {
                    idx = html.IndexOf(smark, idx);

                    if (idx < 0)
                    {
                        break;
                    }

                    //id 숫자 찾기
                    idx  = idx + smark.Length;
                    idx2 = html.IndexOf(",", idx + 1);

                    key = html.Substring(idx, idx2 - idx);

                    //제목 찾기
                    idx  = idx2;
                    idx  = html.IndexOf(smark2, idx);
                    idx += smark2.Length;
                    idx2 = html.IndexOf("\",", idx);

                    notice = html.Substring(idx, idx2 - idx);

                    idx = idx2;

                    isNew = db.isNewNotice(citem.Name, key, notice);

                    if (isNew)
                    {                       //신규 항목임
                        Thread.Sleep(200);

                        Notice_Add(citem, key, notice);
                    }


                    cnt++;

                    //Console.WriteLine("[{0}]{1}  / {2}",cnt, url, notice);
                }

                citem.iRunCnt = 1;

                if (cnt != 5)
                {
                    TelegramMsgSend("Error", string.Format("후오비 공지가 5건이 아닙니다. {0}건", cnt));
                }

                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, cnt.ToString());
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.White);

                citem.iErrCnt = 0;
            }
            catch (Exception ex)
            {
                if (citem.iErrCnt > 3)
                {
                    ProcException(ex, "thHoubiNotice", false);
                    citem.iErrCnt = 0;
                }
                else
                {
                    citem.iErrCnt++;
                }


                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 2, "0");
                Function.form.control.Invoke_ListView_SubItem_Text(lstNew, citem.lstItem, 3, DateTime.Now.ToString());
                Function.form.control.Invoke_ListView_SubItem_Color(lstNew, citem.lstItem, Color.Red);
            }
        }
예제 #9
0
        private void frmNewLists_Load(object sender, EventArgs e)
        {
#if (DEBUG)
            this.Text += "[DEBUG]";
#endif
            this.Text += " v." + Application.ProductVersion;

            //시작시간
            inpHeadStartTime.Value = Fnc.Date2String(DateTime.Now, Fnc.enDateType.DateTime);


            //텔레그램 전송 로그
            cTelLg = new Function.Util.Log(vari.pgm_path + "\\LOG", "TEL_SEND_LOG", 30, true);



            vari.Setting.Group_Select("PGM");
            //설정된 전화번호 가져오기
            vari.HP     = vari.Setting.Value_Get("PGM", "HP", "");
            inpHP.Value = vari.HP;

            //텔래그램 연결
            btnHPConn_Click(null, null);


            sItems = new string[] {
                "Binance"                                        //0
                , "Bithumb"                                      //1
                , "BinanceWallet"                                //2
                , "Upbit"                                        //3
                , "bittrex(미동작)"                                 //4
                , "Upbit공지"                                      //5
                , "Bithumb공지"                                    //6
                , "huobi코리아공지"                                   //7
                , "huobi프로공지"                                    //8
                , "Coinnest공지(미사용)"                              //9
            };
            sUrls = new string[]
            {
                "https://www.binance.com/api/v1/ticker/allPrices"                                                           //바이낸스 가격
                , "https://api.bithumb.com/public/ticker/all"                                                               //빗썸
                , "https://www.binance.com/assetWithdraw/getAllAsset.html"                                                  //바이낸스 지갑
                , "https://crix-api.upbit.com/v1/crix/trends/change_rate"                                                   //upbit 가격
                , "https://bittrex.com/api/v1.1/public/getmarketsummaries"                                                  //비트렉스 가격
                , "https://api-manager.upbit.com/api/v1/notices?page=1&per_page=5"                                          //업비트 공지
                , "https://bithumb.cafe/notice"                                                                             //빗썸공지
                , "https://api.huobi.co.kr/v1/notice/list?language=ko-KR&limit=5&currPage=1"                                //후오비코리아 공지
                , ""
                , "https://www.coinnest.co.kr/gonggao/"                                                                     //코인네스트 공지
            };

            cItems  = new clsItem[sItems.Length];
            tmrWork = new System.Threading.Timer[cItems.Length];

            int idx = 0;

            foreach (string item in sItems)
            {
                cItems[idx]         = new clsItem(idx, item, sUrls[idx]);
                cItems[idx].lstItem = new ListViewItem(new string[] { "", item, "0", "" });

                lstNew.Items.Add(cItems[idx].lstItem);

#if (!no_tmr)
                switch (idx)
                {
                case 0:
                    tmrWork[idx] = new System.Threading.Timer(new TimerCallback(thBinance), cItems[idx], 1000, 5000);
                    break;

                case 1:
                    tmrWork[idx] = new System.Threading.Timer(new TimerCallback(thBithumb), cItems[idx], 1000, 5000);
                    break;

                case 2:
                    tmrWork[idx] = new System.Threading.Timer(new TimerCallback(thBinanceWallet), cItems[idx], 1000, 5000);
                    break;

                case 3:
                    tmrWork[idx] = new System.Threading.Timer(new TimerCallback(thUpbit), cItems[idx], 1000, 5000);
                    break;

                case 5:
                    tmrWork[idx] = new System.Threading.Timer(new TimerCallback(thUpbitNotice), cItems[idx], 1000, 5000);
                    break;

                case 6:
                    tmrWork[idx] = new System.Threading.Timer(new TimerCallback(thBithumbNotice), cItems[idx], 1000, 5000);
                    break;

                case 7:
                    tmrWork[idx] = new System.Threading.Timer(new TimerCallback(thHoubiNotice), cItems[idx], 1000, 5000);
                    break;

                case 8:
                    //tmrWork[idx] = new System.Threading.Timer(new TimerCallback(thCoinnestNotice), cItems[idx], 1000, 5000);
                    break;
                }
#endif

                idx++;
            }


            //설정 ?분 간격으로 문자 보냄
            tmrChkAlive = new System.Threading.Timer(new TimerCallback(thChkAlive), null, 1000, 1000 * 60 * vari.ChkInterval);
        }