Пример #1
0
        public object getRes(JsonRPCrequest req, string reqAddr)
        {
            JArray result     = new JArray();
            string resultStr  = string.Empty;
            string findFliter = string.Empty;
            string sortStr    = string.Empty;

            try
            {
                point(req.method);
                switch (req.method)
                {
                // dex
                case "verifyEmail":
                    result = dexService.verifyEmail(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString());
                    break;

                case "clearEmail":
                    result = dexService.clearEmail(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "bindEmail":
                    result = dexService.bindEmail(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "getEmailState":
                    result = dexService.getEmailState(req.@params[0].ToString());
                    break;

                case "hasStarDomain":
                    result = dexService.hasStarDomain(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "getStarDomainList":
                    result = dexService.getStarDomainList(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()));
                    break;

                case "getStarDomainCount":
                    result = dexService.getStarDomainCount(req.@params[0].ToString());
                    break;

                case "starDexDomain":
                    //result = dexService.starDexDomain(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString());
                    result = dexService.starDexDomain(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), req.@params[2].ToString(), req.@params[3].ToString());
                    break;

                case "searchDexDomainLikeInfo":
                    result = dexService.searchDexDomainLikeInfo(req.@params[0].ToString(), req.@params[1].ToString(), int.Parse(req.@params[2].ToString()), int.Parse(req.@params[3].ToString()));
                    break;

                case "searchDexDomainInfo":
                    result = dexService.searchDexDomainInfo(req.@params[0].ToString());
                    break;

                case "getOrderRange":
                    result = dexService.getOrderRange(decimal.Parse(req.@params[0].ToString()));
                    break;

                case "getDexDomainList":
                    result = dexService.getDexDomainList(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString(), req.@params[3].ToString(), int.Parse(req.@params[4].ToString()), int.Parse(req.@params[5].ToString()));
                    break;

                case "getDexDomainCanUseList":
                    result = dexService.getDexDomainCanUseList(req.@params[0].ToString(), req.@params[1].ToString(), int.Parse(req.@params[2].ToString()), int.Parse(req.@params[3].ToString()));
                    break;

                case "getDexDomainInfo":
                    result = dexService.getDexDomainInfo(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "getDexDomainOrder":
                    result = dexService.getDexDomainOrder(req.@params[0].ToString(), req.@params[1].ToString(), int.Parse(req.@params[2].ToString()), int.Parse(req.@params[3].ToString()));
                    break;

                case "getDexDomainBuyOther":
                    result = dexService.getDexDomainBuyOther(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "getDexDomainBuyDetail":
                    result = dexService.getDexDomainBuyDetail(req.@params[0].ToString());
                    break;

                case "getDexDomainSellOther":
                    result = dexService.getDexDomainSellOther(req.@params[0].ToString());
                    break;

                case "getDexDomainSellDetail":
                    result = dexService.getDexDomainSellDetail(req.@params[0].ToString());
                    break;

                case "getDexDomainDealHistList":
                    result = dexService.getDexDomainDealHistList(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString(), req.@params[4].ToString());
                    break;

                case "getDexDomainBuyList":
                    result = dexService.getDexDomainBuyList(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString(), req.@params[4].ToString(), req.@params[5].ToString());
                    break;

                case "getDexDomainSellList":
                    result = dexService.getDexDomainSellList(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString(), req.@params[4].ToString(), req.@params[5].ToString());
                    break;

                case "getBalanceFromDex":
                    result = dexService.getBalanceFromDex(req.@params[0].ToString());
                    break;

                // test
                case "getnodetype":
                    result = new JArray {
                        new JObject {
                            { "nodeType", netnode }
                        }
                    };
                    break;
                }
                if (result.Count == 0)
                {
                    JsonPRCresponse_Error resE = new JsonPRCresponse_Error(req.id, -1, "No Data", "Data does not exist");
                    return(resE);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("errMsg:{0},errStack:{1}", e.Message, e.StackTrace);
                JsonPRCresponse_Error resE = new JsonPRCresponse_Error(req.id, -100, "Parameter Error", e.Message);
                return(resE);
            }

            JsonPRCresponse res = new JsonPRCresponse();

            res.jsonrpc = req.jsonrpc;
            res.id      = req.id;
            res.result  = result;

            return(res);
        }
Пример #2
0
        public object getRes(JsonRPCrequest req, string reqAddr)
        {
            JArray result     = new JArray();
            string resultStr  = string.Empty;
            string findFliter = string.Empty;
            string sortStr    = string.Empty;

            try
            {
                point(req.method);
                switch (req.method)
                {
                // dex
                case "verifyEmail":
                    result = dexService.verifyEmail(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString());
                    break;

                case "clearEmail":
                    result = dexService.clearEmail(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "bindEmail":
                    result = dexService.bindEmail(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "getEmailState":
                    result = dexService.getEmailState(req.@params[0].ToString());
                    break;

                case "hasStarDomain":
                    result = dexService.hasStarDomain(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "getStarDomainList":
                    result = dexService.getStarDomainList(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()));
                    break;

                case "getStarDomainCount":
                    result = dexService.getStarDomainCount(req.@params[0].ToString());
                    break;

                case "starDexDomain":
                    //result = dexService.starDexDomain(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString());
                    result = dexService.starDexDomain(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), req.@params[2].ToString(), req.@params[3].ToString());
                    break;

                case "searchDexDomainLikeInfo":
                    result = dexService.searchDexDomainLikeInfo(req.@params[0].ToString(), req.@params[1].ToString(), int.Parse(req.@params[2].ToString()), int.Parse(req.@params[3].ToString()));
                    break;

                case "searchDexDomainInfo":
                    result = dexService.searchDexDomainInfo(req.@params[0].ToString());
                    break;

                case "getOrderRange":
                    result = dexService.getOrderRange(decimal.Parse(req.@params[0].ToString()));
                    break;

                case "getDexDomainList":
                    result = dexService.getDexDomainList(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString(), req.@params[3].ToString(), int.Parse(req.@params[4].ToString()), int.Parse(req.@params[5].ToString()));
                    break;

                case "getDexDomainCanUseList":
                    result = dexService.getDexDomainCanUseList(req.@params[0].ToString(), req.@params[1].ToString(), int.Parse(req.@params[2].ToString()), int.Parse(req.@params[3].ToString()));
                    break;

                case "getDexDomainInfo":
                    result = dexService.getDexDomainInfo(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "getDexDomainOrder":
                    result = dexService.getDexDomainOrder(req.@params[0].ToString(), req.@params[1].ToString(), int.Parse(req.@params[2].ToString()), int.Parse(req.@params[3].ToString()));
                    break;

                case "getDexDomainBuyOther":
                    result = dexService.getDexDomainBuyOther(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                case "getDexDomainBuyDetail":
                    result = dexService.getDexDomainBuyDetail(req.@params[0].ToString());
                    break;

                case "getDexDomainSellOther":
                    result = dexService.getDexDomainSellOther(req.@params[0].ToString());
                    break;

                case "getDexDomainSellDetail":
                    result = dexService.getDexDomainSellDetail(req.@params[0].ToString());
                    break;

                case "getDexDomainDealHistList":
                    result = dexService.getDexDomainDealHistList(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString(), req.@params[4].ToString());
                    break;

                case "getDexDomainBuyList":
                    result = dexService.getDexDomainBuyList(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString(), req.@params[4].ToString(), req.@params[5].ToString());
                    break;

                case "getDexDomainSellList":
                    result = dexService.getDexDomainSellList(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString(), req.@params[4].ToString(), req.@params[5].ToString());
                    break;

                case "getBalanceFromDex":
                    result = dexService.getBalanceFromDex(req.@params[0].ToString());
                    break;

                // 移动端调用: 根据地址查询域名列表(包括已绑定和未绑定)
                case "getDomainListByAddress":
                    if ([email protected] < 3)
                    {
                        result = mobileService.getDomainListByAddress(req.@params[0].ToString());
                    }
                    else if ([email protected] < 4)
                    {
                        result = mobileService.getDomainListByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()));
                    }
                    else
                    {
                        result = mobileService.getDomainListByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString());
                    }
                    break;

                //
                case "getMappingDomain":
                    result = nnsDomainCrediteService.getMappingDomain(req.@params[0].ToString());
                    break;

                /**
                 * 获取域名状态(出售状态或竞拍状态)
                 */
                case "getdomainstate":
                    result = newAuctionService.getdomainstate(req.@params[0].ToString());
                    break;

                /**
                 * 获取域名出售或购买列表
                 */
                case "getDomainSellingListByAddress":
                    if ([email protected] < 3)
                    {
                        result = nnsFixedSellingService.getDomainSellingListByAddress(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString());
                    }
                    else
                    {
                        result = nnsFixedSellingService.getDomainSellingListByAddress(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString(), int.Parse(req.@params[3].ToString()), int.Parse(req.@params[4].ToString()));
                    }
                    break;

                /**
                 * 新增测试nnc
                 * 1. 申请nnc接口
                 * 2. 查询nnc余额接口
                 */
                case "hasClaimNNC":
                    result = claimNNCService.hasClaimNNC(req.@params[0].ToString());
                    break;

                case "claimNNC":
                    result = claimNNCService.claimNNC(req.@params[0].ToString());
                    break;

                case "getNNCfromSellingHash":
                    result = nnsFixedSellingService.getNNCfromSellingHash(req.@params[0].ToString());
                    break;

                /***
                 * 新增转让信息和出售信息
                 *
                 * 1. 首页输入框中显示"出售中"
                 * 2. 首页填写输入框后点击查询详情,显示出售信息:domain + ttl + price
                 * 3. 我的域名管理中新增是否为出售中的状态
                 * 4. 我的域名管理中新增已出售域名列表
                 * 5. 浏览器查询显示初始状态/出售中
                 * 6. 浏览器查询显示域名owner的变化:领取域名 + 转让域名 + 出售域名
                 *
                 */
                // 查询已出售列表
                case "getHasBuyListByAddress":
                    if ([email protected] < 4)
                    {
                        result = nnsFixedSellingService.getHasBuyListByAddress(req.@params[0].ToString(), req.@params[1].ToString());
                    }
                    else
                    {
                        result = nnsFixedSellingService.getHasBuyListByAddress(req.@params[0].ToString(), req.@params[1].ToString(), int.Parse(req.@params[2].ToString()), int.Parse(req.@params[3].ToString()));
                    }
                    break;

                // 查询出售信息
                case "getNNSfixedSellingInfo":
                    result = nnsFixedSellingService.getNNSfixedSellingInfo(req.@params[0].ToString());
                    break;

                // 查询域名竞拍状态+(新增是否正在出售中状态0901)
                case "getdomainauctioninfo":
                    result = newAuctionService.getdomainAuctionInfo(req.@params[0].ToString());
                    break;

                // 移动端调用:获取注册器竞拍账户余额
                case "getregisteraddressbalance":
                    result = newAuctionService.getRegisterAddressBalance(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                // 移动端调用:获取竞拍状态
                case "getauctionstate":
                    result = newAuctionService.getAuctionState(req.@params[0].ToString());
                    break;

                // 移动端调用:获取域名信息
                case "getdomaininfo":
                    result = newAuctionService.getDomainInfo(req.@params[0].ToString());
                    break;

                //
                case "getresolvedaddress":
                    result = domainService.getResolvedAddress(req.@params[0].ToString());
                    break;

                case "getavailableutxos":
                    result = utxoService.getAvailableUtxos(req.@params[0].ToString(), Convert.ToDecimal(req.@params[1]));
                    break;

                case "getCagsLockUtxo":
                    if ([email protected] > 0)
                    {
                        result = utxoService.getCagsLockUtxo(req.@params[0].ToString());
                    }
                    else
                    {
                        result = utxoService.getCagsLockUtxo();
                    }
                    break;

                case "getauctioninfocount":
                    if ([email protected] < 2)
                    {
                        result = newAuctionService.getAcutionInfoCount(req.@params[0].ToString());
                    }
                    else
                    {
                        result = newAuctionService.getAcutionInfoCount(req.@params[0].ToString(), req.@params[1].ToString());
                    }
                    break;

                case "getauctioninfobyaddress":
                    if ([email protected] < 3)
                    {
                        result = newAuctionService.getAuctionInfoByAddress(req.@params[0].ToString());
                    }
                    else if ([email protected] < 4)
                    {
                        result = newAuctionService.getAuctionInfoByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()));
                    }
                    else if ([email protected] < 5)
                    {
                        result = newAuctionService.getAuctionInfoByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString());
                    }
                    else if ([email protected] < 7)
                    {
                        result = newAuctionService.getAuctionInfoByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString(), req.@params[4].ToString());
                    }
                    else
                    {
                        result = newAuctionService.getAuctionInfoByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()), req.@params[3].ToString(), req.@params[4].ToString(), req.@params[5].ToString(), req.@params[6].ToString());
                    }
                    break;

                case "getauctioninfobyaucitonid":
                    string address       = req.@params[0].ToString(); // address
                    string auctionIdsStr = req.@params[1].ToString(); // auctionIdArr
                    result = newAuctionService.getAuctionInfoByAuctionId(JArray.Parse(auctionIdsStr), address);
                    break;

                // 查询是否可以申领Gas
                case "hasclaimgas":
                    result = claimService.hasClaimGas(req.@params[0].ToString());
                    break;

                // 申领Gas(即向客户地址转账,默认1gas
                case "claimgas":
                    if ([email protected] < 2)
                    {
                        result = claimService.claimGas(req.@params[0].ToString());
                    }
                    else
                    {
                        result = claimService.claimGas(req.@params[0].ToString(), Convert.ToDecimal(req.@params[1]));
                    }
                    break;

                // 根据txid查询交易是否成功
                case "hastx":
                    result = auctionService.hasTx(req.@params[0].ToString());
                    break;

                // 根据txid查询合约是否成功
                case "hascontract":
                    result = auctionService.hasContract(req.@params[0].ToString());
                    break;

                // 充值&转账
                case "rechargeandtransfer":
                    result = auctionService.rechargeAndTransfer(req.@params[0].ToString(), req.@params[1].ToString());
                    break;

                // 查询充值&转账交易
                case "getrechargeandtransfer":
                    result = auctionService.getRechargeAndTransfer(req.@params[0].ToString());
                    break;

                // 根据地址查询分红历史
                case "getbonushistbyaddress":
                    if ([email protected] < 3)
                    {
                        result = bonusService.getBonusHistByAddress(req.@params[0].ToString());
                    }
                    else
                    {
                        result = bonusService.getBonusHistByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()));
                    }
                    break;

                //申请得到分红
                case "applybonus":
                    result = bonusService.applyBonus(req.@params[0].ToString());
                    break;

                //得到最新的分红的信息
                case "getcurrentbonus":
                    result = bonusService.getCurrentBonus(req.@params[0].ToString());
                    break;

                //得到某个地址历史分到红的记录
                case "getbonusbyaddress":
                    if ([email protected] < 3)
                    {
                        result = bonusService.getBonusByAddress(req.@params[0].ToString());
                    }
                    else
                    {
                        result = bonusService.getBonusByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()));
                    }
                    break;

                // 根据地址查询域名列表
                case "getdomainbyaddress":
                    if ([email protected] < 5)
                    {
                        result = domainService.getDomainByAddressNew(req.@params[0].ToString(), req.@params[1].ToString(), "", int.Parse(req.@params[2].ToString()), int.Parse(req.@params[3].ToString()));
                    }
                    else if ([email protected] < 6)
                    {
                        result = domainService.getDomainByAddressNew(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString(), int.Parse(req.@params[3].ToString()), int.Parse(req.@params[4].ToString()));
                    }
                    else
                    {
                        result = domainService.getDomainByAddressNew(req.@params[0].ToString(), req.@params[1].ToString(), req.@params[2].ToString(), int.Parse(req.@params[3].ToString()), int.Parse(req.@params[4].ToString()), req.@params[5].ToString());
                    }
                    break;

                // 根据地址查询交易列表
                case "gettransbyaddressOld":
                    result = commonService.getTransByAddress(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()));
                    break;

                case "gettransbyaddress":
                    result = commonService.getTransByAddress_new(req.@params[0].ToString(), int.Parse(req.@params[1].ToString()), int.Parse(req.@params[2].ToString()));
                    break;

                // test
                case "getnodetype":
                    result = new JArray {
                        new JObject {
                            { "nodeType", netnode }
                        }
                    };
                    break;
                }
                if (result.Count == 0)
                {
                    JsonPRCresponse_Error resE = new JsonPRCresponse_Error(req.id, -1, "No Data", "Data does not exist");
                    return(resE);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("errMsg:{0},errStack:{1}", e.Message, e.StackTrace);
                JsonPRCresponse_Error resE = new JsonPRCresponse_Error(req.id, -100, "Parameter Error", e.Message);
                return(resE);
            }

            JsonPRCresponse res = new JsonPRCresponse();

            res.jsonrpc = req.jsonrpc;
            res.id      = req.id;
            res.result  = result;

            return(res);
        }