Beispiel #1
0
        public string GetCheckID(string Title, string SubTitle)
        {
            try
            {
                string        path = "C:/Temp/CoinBlock_HTS/";
                DirectoryInfo dir  = new DirectoryInfo(path);
                if (!dir.Exists)
                {
                    dir.Create();
                }

                path += "Login.ini";
                INIFile(path);
                string tempKey = Read(Title, SubTitle);
                string ID      = EncodingLib.Decrypt(tempKey).Replace("\0", "");

                if (!ID.Trim().Equals(string.Empty))
                {
                    return(ID);
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
            return(string.Empty);
        }
Beispiel #2
0
        /// <summary>
        /// Sync
        /// </summary>
        /// <typeparam name="Response"></typeparam>
        /// <typeparam name="Request"></typeparam>
        /// <param name="req"></param>
        /// <returns></returns>
        public static Response SyncCallEncrypt <Response, Request>(Request req) where Response : IDisposable, new()
        {
            Response    response = new Response();
            WebClientEx wc       = new WebClientEx();

            try
            {
                //해더 셋팅
                wc.Encoding = Encoding.UTF8;
                wc.Headers.Add("Accept-Language", "utf-8");
                wc.Headers.Add("Accept", "text/html, application/xhtml+xml, */*");
                wc.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");

                //파라미터 직렬화
                string sReqSerial = new JavaScriptSerializer().Serialize(req);
                //암호화
                string sEncrpt = EncodingLib.AesEncrypt(sReqSerial, RequestBaseModel.GidParam);

                NameValueCollection nvc = new NameValueCollection();
                nvc.Add("encStr", sEncrpt);
                nvc.Add("clientPe", RequestBaseModel.RsaParam);
                wc.QueryString = nvc;

                //상세 API URL 설정
                string targetUrl = "bt.arbitrage.listen.dp/proc.go";

                //API 요청
                byte[] bt = wc.UploadValues(ConfigLib.ApiUrl + targetUrl, new NameValueCollection());

                //JSON 파싱
                response = new JavaScriptSerializer().Deserialize <Response>(Encoding.UTF8.GetString(bt));

                //API 결과 코드 값
                string resultStrCode = GetPropertyValue(response, ResultStrCode);

                //API 결과 메시지
                string resultMsg = GetPropertyValue(response, ResultMsg);

                if (resultStrCode != "000")
                {
                    throw new Exception("API resultMsg : " + resultMsg);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                wc.Dispose();
                response.Dispose();
            }
            return(response);
        }
Beispiel #3
0
        public void SetCheckID(string UserName, string Title, string SubTitle)
        {
            try
            {
                string        path = "C:/Temp/CoinBlock_HTS/";
                DirectoryInfo dir  = new DirectoryInfo(path);
                if (!dir.Exists)
                {
                    dir.Create();
                }

                path += "Login.ini";
                INIFile(path);
                Write(Title, SubTitle, EncodingLib.Encrypt(UserName));
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
Beispiel #4
0
        /// <summary>
        /// ASync
        /// </summary>
        /// <returns>T</returns>
        public static async Task <Response> AsyncCallEncrypt <Response, Request>(Request req) where Response : class, IDisposable, new()
        {
            Response    response  = new Response();
            WebClientEx wc        = new WebClientEx();
            string      targetUrl = null;

            try
            {
                //해더 셋팅
                wc.Encoding = Encoding.UTF8;
                wc.Headers.Add("Accept-Language", "utf-8");
                wc.Headers.Add("Accept", "text/html, application/xhtml+xml, */*");
                wc.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");

                //파라미터 직렬화
                string sReqSerial = new JavaScriptSerializer().Serialize(req);
                //암호화
                string sEncrpt = EncodingLib.AesEncrypt(sReqSerial, RequestBaseModel.GidParam);

                NameValueCollection nvc = new NameValueCollection();
                nvc.Add("encStr", sEncrpt);
                nvc.Add("clientPe", RequestBaseModel.RsaParam);
                wc.QueryString = nvc;

                //상세 API URL 설정
                targetUrl = "bt.arbitrage.listen.dp/proc.go";

                //API 요청
                byte[] bt = await wc.UploadValuesTaskAsync(ConfigLib.ApiUrl + targetUrl, new NameValueCollection());

                var dy = new JavaScriptSerializer().Deserialize <dynamic>(Encoding.UTF8.GetString(bt));

                //API 결과 코드 값
                string resultStrCode = dy["resultStrCode"];
                //API 결과 메시지
                string resultMsg = dy["resultMsg"];

                if (resultStrCode == "000")
                {
                    response = new JavaScriptSerializer().Deserialize <Response>(Encoding.UTF8.GetString(bt));
                }
                else
                {
                    if (resultStrCode != "000")
                    {
                        //SysLog.Info("API resultMsg : " + resultMsg);
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("DP : " + targetUrl);
                throw ex;
            }
            finally
            {
                wc.Dispose();
                response.Dispose();
            }
            return(response);
        }