public ExcutedResult Query(string name, string tag, int pageIndex = 1, int pagesize = 10, string sortName = "", bool?order = null)
 {
     try
     {
         TokenParam param = new TokenParam()
         {
             Name            = name,
             PageIndex       = pageIndex,
             PageSize        = pagesize,
             SortName        = "Order",
             IsSortOrderDesc = true
         };
         if (!string.IsNullOrEmpty(sortName))
         {
             param.SortName = sortName;
         }
         if (order.HasValue)
         {
             param.IsSortOrderDesc = order.Value;
         }
         var result = _tokensLogic.AdvQuery(param);
         return(ExcutedResult.SuccessResult(result));
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
 }
Exemple #2
0
        //----------------------------------
        // トークン取得
        internal string GetToken(string ApiPassword)
        {
            var param = new TokenParam
            {
                APIPassword = ApiPassword
            };

            var json = "";

            using (var stream = new MemoryStream())
            {
                var serializer = new DataContractJsonSerializer(typeof(TokenParam));
                serializer.WriteObject(stream, param);
                json = Encoding.UTF8.GetString(stream.ToArray());
            }

            var url     = domain + CustomRibbon._port + "/kabusapi/token";
            var request = new HttpRequestMessage(HttpMethod.Post, url);

            request.Content = new StringContent(json);
            request.Content.Headers.ContentType.MediaType = @"application/json";
            request.Content.Headers.ContentType.CharSet   = null;


            HttpResponseMessage response = client.SendAsync(request).Result;

            return(response.Content.ReadAsStringAsync().Result);
        }
Exemple #3
0
 //Get Chat
 public int GetChat(int friendId = -1, int playerId = 0, string token = "")
 {
     if (friendId == -1) //Get Public Chat
     {
         string defaultNotFound = "{\"chat\":[]}";
         API    api             = new API("chat/chat.ray", "RGetChatPublic", "", -1);
         StartCoroutine(Congest.ReadTempFile(this, api, defaultNotFound));
         return(api.seed);
     }
     else if (friendId == 0) //Get Private Chat List
     {
         if (ParseToken(playerId, token))
         {
             TokenParam param = new TokenParam();
             param.player_id = apiPlayerId;
             param.token     = apiToken;
             string paramJson = JsonUtility.ToJson(param);
             API    api       = new API("getchat.php", "RGetChatList", paramJson, 1);
             param = null; paramJson = "";
             StartCoroutine(Congest.SendPOST(this, api));
             return(api.seed);
         }
     }
     else //Get Private Chat
     {
         string fromto          = (apiPlayerId < friendId ? Mathf.FloorToInt(apiPlayerId / 1000).ToString() : Mathf.FloorToInt(friendId / 1000).ToString()) + "/" + (apiPlayerId < friendId ? apiPlayerId.ToString() : friendId.ToString()) + "/" + (apiPlayerId > friendId ? apiPlayerId.ToString() : friendId.ToString());
         string defaultNotFound = "{\"chat\":[]}";
         API    api             = new API("chat/" + fromto + "/chat.ray", "RGetChatPrivate", "", -1);
         StartCoroutine(Congest.ReadTempFile(this, api, defaultNotFound));
         return(api.seed);
     }
     return(0);
 }
Exemple #4
0
        private async Task <Result> GetAccessTokenAsync()
        {
            string apiGetToken = _configuration.GetValue <string>("AuthenToken:api");

            if (string.IsNullOrEmpty(apiGetToken))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:api trong file appsettings.json"));
            }

            string username = _configuration.GetValue <string>("AuthenToken:username");

            if (string.IsNullOrEmpty(username))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:username trong file appsettings.json"));
            }

            string password = _configuration.GetValue <string>("AuthenToken:password");

            if (string.IsNullOrEmpty(password))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:password trong file appsettings.json"));
            }

            string client_id = _configuration.GetValue <string>("AuthenToken:client_id");

            if (string.IsNullOrEmpty(client_id))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:client_id trong file appsettings.json"));
            }

            string grant_type = _configuration.GetValue <string>("AuthenToken:grant_type");

            if (string.IsNullOrEmpty(grant_type))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:grant_type trong file appsettings.json"));
            }

            string tendiaban = _configuration.GetValue <string>("AuthenToken:tendiaban");

            if (string.IsNullOrEmpty(tendiaban))
            {
                return(Result.Fail("Không tìm thấy cấu hình AuthenToken:tendiaban trong file appsettings.json"));
            }

            TokenParam tokenParam = new TokenParam
            {
                username   = username,
                password   = password,
                client_id  = client_id,
                grant_type = grant_type,
                tendiaban  = tendiaban
            };

            HttpClientPost httpClientPost = new HttpClientPost();

            return(await httpClientPost.SendsRequest(apiGetToken, "", tokenParam));
        }
Exemple #5
0
 //Get Money Slot
 public int GetMoneySlot(int playerId = 0, string token = "")
 {
     if (ParseToken(playerId, token))
     {
         TokenParam param = new TokenParam();
         param.player_id = apiPlayerId;
         param.token     = apiToken;
         string paramJson = JsonUtility.ToJson(param);
         API    api       = new API("getmoneyslot.php", "RGetMoneySlot", paramJson, 1);
         param = null; paramJson = "";
         StartCoroutine(Congest.SendPOST(this, api));
         return(api.seed);
     }
     return(0);
 }
Exemple #6
0
 public int SendCoinHistory(int playerId = 0, string token = "")
 {
     if (ParseToken(playerId, token))
     {
         TokenParam param = new TokenParam();
         param.player_id = apiPlayerId;
         param.token     = apiToken;
         string paramJson = JsonUtility.ToJson(param);
         API    api       = new API("sendcoinhistory.php", "RSendCoinHistory", paramJson, 1);
         param = null; paramJson = "";
         StartCoroutine(Congest.SendPOST(this, api));
         return(api.seed);
     }
     return(0);
 }
Exemple #7
0
        /// <summary>
        /// 获取合约列表
        /// </summary>
        /// <returns></returns>
        public List <GetTokenListResponse> GetTokenList(ChainModel model)
        {
            if (string.IsNullOrEmpty(model.ChainCode))
            {
                throw new BusinessException(BusinessResultCode.ArgumentError, "参数错误");
            }
            var param = new TokenParam
            {
                ChainCode = model.ChainCode
            };
            var list = Repository.QueryList(param).ToList();

            if (CurrentUser.Id != Guid.Empty)
            {
                var favoriteParam = new UserFavoriteParam
                {
                    UserId     = CurrentUser.Id,
                    ItemType   = (int)EnumItemType.Token,
                    RelatedIds = list.Select(p => p.Id).ToList()
                };
            }

            var result = list.OrderByDescending(p => p.IsSystem).ThenByDescending(p => p.Order).Select(p =>
                                                                                                       new GetTokenListResponse()
            {
                Name          = p.Name,
                Symbol        = p.Symbol,
                Issuer        = p.Issuer,
                Contract      = p.Contract,
                Logo          = p.Logo.HasValue ? _filePreUrl + p.Logo.Value : "",
                IsSystem      = p.IsSystem,
                DollarPrice   = p.DollarPrice,
                FaceBookUrl   = p.FaceBookUrl,
                IssueCost     = p.IssueCost,
                IssueDate     = p.IssueDate,
                IssueState    = p.IssueState,
                RmbPrice      = p.RmbPrice,
                TwitterUrl    = p.TwitterUrl,
                WebSite       = p.WebSite,
                WhitePaperUrl = p.WhitePaperUrl,
                Decimals      = p.Precision,
                Precision     = p.TransactionPrecision
            }).ToList();

            return(result);
        }
 /// <summary>Does the token posses certain optional params</summary>
 /// <param name="p">The param to check for</param>
 /// <returns>true if the flag exists on this token</returns>
 public bool HasFlag(TokenParam p)
 {
     return(((TokenParam)this.Parameters & p) > 0);
 }