Esempio n. 1
0
        public static void CallAPI()
        {
            string  SqlStr = string.Empty;
            DataSet dSet   = new DataSet();
            Double  cnt    = 0;

            try
            {
                SqlStr = "SELECT Id,WalletId,WalletTypeId,TrnID,CoinName,BitgoWalletId,CoinSpecific FROM TradeBitGoDelayAddressess WHERE Status=1 AND GenerateBit=0";
                dSet   = (new DataCommon()).OpenDataSet("TradeBitGoDelayAddressess", SqlStr, dSet, 30);
                if (dSet.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dRow in dSet.Tables[0].Rows)
                    {
                        cnt++;
                        // Need common row object for each SMScode
                        walletServiceData walletServiceDataObj = new walletServiceData();
                        walletServiceDataObj.AppType       = Convert.ToInt16(1);
                        walletServiceDataObj.WalletID      = Convert.ToInt32(dRow["WalletID"]);
                        walletServiceDataObj.WalletTypeID  = Convert.ToInt32(dRow["WalletTypeId"]);
                        walletServiceDataObj.TrnID         = dRow["TrnID"].ToString();
                        walletServiceDataObj.CoinName      = dRow["CoinName"].ToString();
                        walletServiceDataObj.SMSCode       = dRow["CoinName"].ToString();
                        walletServiceDataObj.BitgoWalletID = dRow["BitgoWalletId"].ToString();
                        walletServiceDataObj.CoinSpecific  = dRow["CoinSpecific"].ToString();

                        Console.Title = walletServiceDataObj.SMSCode + " ETH Status Check App ";

                        WriteRequestLog("New Timer Call For Id: " + dRow["Id"].ToString(), "CallAPI", walletServiceDataObj.SMSCode);
                        lock (walletServiceDataObj)
                        {
                            if (IsProcessing == false)
                            {
                                Console.WriteLine("New Timer Call : " + cnt);
                                WaitCallback callBack;
                                callBack = new WaitCallback(CallAPISingle); // create thread for each SMSCode
                                ThreadPool.QueueUserWorkItem(callBack, walletServiceDataObj);
                            }
                            else
                            {
                                WriteRequestLog("IsProcessing = true so return ", "CallAPI", walletServiceDataObj.SMSCode, Action: 2);
                            }
                            //Thread.Sleep(100);
                            //}
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //ex = null;
                WriteErrorLog(ex, "Program", "CallAPI");
            }
            finally
            {
                TransactionTick.Start();
            }
        }
Esempio n. 2
0
        private static void CallAPISingle(object RefObj)
        {
            string  TempUrl;
            DataSet DSet    = null;
            string  smscode = "eth";/*string trnID= "ddaa745649f8f09564daa1aaa51716ef49175b328c8d87aba4b207b3f178d620"; string Authorization = "Bearer v2x5e587227b1085bdcd4d5bd3421f0a702fff86d2137af0cf3a8624655d4e42f71"; string enterprise = "5a79359692f6f738073dffcbbb0c22df";*/

            try
            {
                BitGoResponses    response             = new BitGoResponses();
                walletServiceData walletServiceDataObj = (walletServiceData)RefObj;
                CommonMethods     CommonMethod         = new CommonMethods();
                CommonMethod.Transfers = new List <RespTransfers>(); // Need object of RespTransfers  for Thirdparty ApI response
                //CommonMethod.RespLocalCoins = new List<RespLocalCoin>(); // Need object of RespLocalCoins  for Thirdparty ApI response
                CommonMethod.SMSCode = walletServiceDataObj.SMSCode;
                smscode = CommonMethod.SMSCode;
                ReadMasterFile(walletServiceDataObj.SMSCode, ref CommonMethod); // Read  Master File
                if (!string.IsNullOrEmpty(CommonMethod.Path_AddressGenerate))
                {
                    ReadTransactionalFileETH(CommonMethod.Path_StatusCheck, ref CommonMethod); // Read Transaction file for specific coin
                    if (!string.IsNullOrEmpty(CommonMethod.Path_StatusCheck) && !string.IsNullOrEmpty(CommonMethod.Str_RequestType) && !string.IsNullOrEmpty(CommonMethod.ContentType))
                    {
                        switch (walletServiceDataObj.AppType)
                        {
                        case (int)EnAppType.BitGoAPI:
                            if (!TakePendingAddress_ETH(ref DSet))
                            {
                                WriteRequestLog("Transaction Detail not found", "CallAPISingle", CommonMethod.SMSCode, Action: 2);
                                return;
                            }
                            foreach (DataRow drow in DSet.Tables[0].Rows)
                            {
                                TempUrl = CommonMethod.Str_URL;    //every time assign fresh url for replacement
                                TempUrl = TempUrl.Replace("#TrnID#", drow["TrnID"].ToString());
                                string RequestType = CommonMethod.RequestType;
                                string Resp        = CallToThirdPartyAPIMethodV1(TempUrl, RequestType);

                                //Resp = "{\"id\":\"5ad5d23d623b768f1c8d49acc0c04135\",\"address\":\"\",\"chain\":10,\"index\":2,\"coin\":\"btc\",\"wallet\":\"5a969f95528688e03d1625503b286a81\",\"coinSpecific\":{\"redeemScript\":\"00206bbe938e84f03d763e955a2a9e806a55dbb0f803b9c67c8ea641c96ba4c87915\",\"witnessScript\":\"522102f949636c9bfc1ec2411907cf1b50082e9c53cbe51343ff8b88562bfbbb03a57e21039b8691fe6c084c3af2211dd73afc1a3c55392019675618ddee88dbd12fd0687a210240e277667a571e061b64e000f36aadfad97bb6f302dfc4206ebeb5f0b6906fa653ae\"}}";

                                if (!string.IsNullOrEmpty(Resp))
                                {
                                    CommonMethod.MatchRegex2 = ParseResponse(Resp, CommonMethod.Address1, CommonMethod.Address2);
                                    response.address         = CommonMethod.MatchRegex2;

                                    CommonMethod.MatchRegex2 = ParseResponse(Resp, CommonMethod.TrnID1, CommonMethod.TrnID2);
                                    response.txid            = CommonMethod.MatchRegex2;

                                    CommonMethod.MatchRegex2 = ParseResponse(Resp, CommonMethod.coinSpecific1, CommonMethod.coinSpecific2);
                                    response.coinSpecific    = CommonMethod.MatchRegex2;

                                    CommonMethod.MatchRegex2 = ParseResponse(Resp, CommonMethod.Wallet1, CommonMethod.Wallet2);
                                    response.wallet          = CommonMethod.MatchRegex2;

                                    if (!string.IsNullOrEmpty(response.address))
                                    {
                                        bool SuccessBit;
                                        if (!String.IsNullOrEmpty(response.txid) && response.txid == drow["TrnId"].ToString())
                                        {
                                            //Insert Generated Address
                                            SuccessBit = UpdateAddress_ETH(Convert.ToInt64(drow["Id"]), drow["TrnID"].ToString(), response.address, response.coinSpecific);
                                        }
                                        else
                                        {
                                            WriteRequestLog("Transaction Id Not Match", "CallAPISingle", CommonMethod.SMSCode, Action: 2);
                                        }
                                        WriteRequestLog("Address Not Found", "CallAPISingle", CommonMethod.SMSCode, Action: 2);
                                    }
                                }
                            }
                            break;

                        case (int)EnAppType.CryptoAPI:
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        WriteRequestLog("Transaction Detail not found", "CallAPISingle", CommonMethod.SMSCode, Action: 2);
                    }
                }
                else
                {
                    WriteRequestLog("Master File Detail not found", "CallAPISingle", CommonMethod.SMSCode, Action: 2);
                }
            }
            catch (Exception ex)
            {
                //ex = null;
                WriteErrorLog(ex, "Program", "CallAPISingle");
            }
            finally
            {
                IsProcessing = false;
                WriteRequestLog("IsProcessing = false ", "CallAPISingle", smscode, Action: 2);
            }
        }