Esempio n. 1
0
        public List <MerchantProfile> GetMerchantVerifyListL1(string cellphone, int countryId, int?status, string orderByFiled, bool isDesc, int pageSize, int index, out int totalCount)
        {
            totalCount = 0;
            GetMerchnatVerifyListIM input = new GetMerchnatVerifyListIM();

            input.cellphone    = cellphone;
            input.countryId    = countryId;
            input.status       = status;
            input.orderByFiled = orderByFiled;
            input.isDesc       = isDesc;
            input.pageSize     = pageSize;
            input.index        = index;
            var url    = $"{baseAddress}/GetMerchantVerifyListL1";
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(input));
            var data   = JsonConvert.DeserializeObject <ServiceResult <GetMerchnatVerifyListOM> >(result);

            if (data.Code == 0)
            {
                totalCount = data.Data.TotalCount;
                return(data.Data.ResultSet);
            }
            throw new CommonException(10000, data.Message);
        }
Esempio n. 2
0
        public List <UserProfile> GetUserProfileListForL2(string cellphone, int country, string orderByFiled, bool isDesc, int?l2VerifyStatus, int pageSize, int index, out int totalCount)
        {
            UserProfileListIM input = new UserProfileListIM();

            input.Cellphone    = cellphone;
            input.Country      = country;
            input.OrderByFiled = orderByFiled;
            input.IsDesc       = isDesc;
            input.VerifyStatus = l2VerifyStatus;
            input.PageSize     = pageSize;
            input.Index        = index;
            var url = $"{baseAddress}/GetUserProfileListForL2";

            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(input));
            var data   = JsonConvert.DeserializeObject <ServiceResult <UserProfileListOM> >(result);

            if (data.Code == 0)
            {
                totalCount = data.Data.TotalCount;
                return(data.Data.ResultSet);
            }
            throw new CommonException(10000, data.Message);
        }
Esempio n. 3
0
        public string DeleteGame(
            int game_id)
        {
            BasicResponse response = new BasicResponse();

            if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result))
            {
                GameDeleteRequestProcessor requestProcessor =
                    new GameDeleteRequestProcessor(
                        RestUtilities.GetSessionAccountID(Session),
                        game_id);

                if (requestProcessor.ProcessRequest(
                        ApplicationConstants.CONNECTION_STRING,
                        Application,
                        out response.result))
                {
                    response.result = SuccessMessages.GENERAL_SUCCESS;
                }
            }

            return(JSONUtilities.SerializeJSONResponse <BasicResponse>(response));
        }
Esempio n. 4
0
        public string BindCharacterToGame(
            int character_id,
            int game_id)
        {
            BasicResponse response = new BasicResponse();

            if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result) &&
                RestUtilities.ValidateJSONRequestSessionOwnsCharacter(Session, character_id, out response.result))
            {
                BindCharacterToGameRequestProcessor requestProcessor =
                    new BindCharacterToGameRequestProcessor(character_id, game_id);

                if (requestProcessor.ProcessRequest(
                        ApplicationConstants.CONNECTION_STRING,
                        Application,
                        out response.result))
                {
                    response.result = SuccessMessages.GENERAL_SUCCESS;
                }
            }

            return(JSONUtilities.SerializeJSONResponse <BasicResponse>(response));
        }
Esempio n. 5
0
        public string CreateGame(
            string game_name,
            int dungeon_size,
            int dungeon_difficulty,
            bool irc_enabled,
            string irc_server,
            int irc_port,
            bool irc_encryption_enabled)
        {
            BasicResponse response = new BasicResponse();

            if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result))
            {
                int account_id = RestUtilities.GetSessionAccountID(Session);

                GameCreateRequestProcessor requestProcessor =
                    new GameCreateRequestProcessor(
                        RestUtilities.GetSessionAccountID(Session),
                        game_name,
                        (GameConstants.eDungeonSize)dungeon_size,
                        (GameConstants.eDungeonDifficulty)dungeon_difficulty,
                        irc_enabled,
                        irc_server,
                        irc_port,
                        irc_encryption_enabled);

                if (requestProcessor.ProcessRequest(
                        ApplicationConstants.CONNECTION_STRING,
                        Application,
                        out response.result))
                {
                    response.result = SuccessMessages.GENERAL_SUCCESS;
                }
            }

            return(JSONUtilities.SerializeJSONResponse <BasicResponse>(response));
        }
Esempio n. 6
0
        private ServiceResult <string> DownloadImage(string id)
        {
            var url = _router.ServerAddress + "/File/Download?id=" + id;

            var resultStr = RestUtilities.GetJson(url, GetHeaders());

            if (string.IsNullOrWhiteSpace(resultStr))
            {
                _log.Error($"Download region image error. url = {url}, profile route = {_router}");
            }
            var responseJson = JsonConvert.DeserializeObject <ServiceResult <string> >(resultStr);

            if (responseJson == null)
            {
                throw new ApplicationException();
            }

            if (responseJson.Code != 0)
            {
                throw new ApplicationException(responseJson.Data);
            }

            return(responseJson);
        }
Esempio n. 7
0
        public string PortalCharacter(
            int character_id,
            float x,
            float y,
            float z,
            float angle,
            int portal_id)
        {
            CharacterPortalResponse response = new CharacterPortalResponse();

            if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result) &&
                RestUtilities.ValidateJSONRequestSessionOwnsCharacter(Session, character_id, out response.result))
            {
                PortalRequestProcessor requestProcessor =
                    new PortalRequestProcessor(
                        character_id,
                        new Point3d(x, y, z),
                        angle,
                        portal_id);

                if (requestProcessor.ProcessRequest(
                        ApplicationConstants.CONNECTION_STRING,
                        Application,
                        out response.result))
                {
                    response.event_list = requestProcessor.ResultEventList;
                    response.result     = SuccessMessages.GENERAL_SUCCESS;
                }
                else
                {
                    response.event_list = new GameEvent[] { };
                }
            }

            return(JSONUtilities.SerializeJSONResponse <CharacterPortalResponse>(response));
        }
Esempio n. 8
0
        public async Task <string> UploadAsync(string fileName, byte[] bytes)
        {
            if (string.IsNullOrEmpty(blob_URL))
            {
                throw new ArgumentException("Blob_URL not found");
            }

            var url   = blob_URL.TrimEnd('/') + "/File/Upload";
            var token = GenerateToken();

            var json = JsonConvert.SerializeObject(new
            {
                FileName = fileName,
                File     = bytes,
                FileType = "img"
            });
            var result = await RestUtilities.PostJsonAsync(url, new Dictionary <string, string> {
                { "Authorization", "bearer " + token }
            }, json);

            var data = JsonConvert.DeserializeObject <ServiceResult <object> >(result);

            return(data.Code == 0 ? data.Data.ToString() : null);
        }
Esempio n. 9
0
        public string GetRoomData(
            int game_id,
            int room_x,
            int room_y,
            int room_z)
        {
            WorldGetRoomDataResponse response = new WorldGetRoomDataResponse();

            if (RestUtilities.ValidateJSONRequestHasAuthenticatedSession(Session, out response.result))
            {
                RoomRequestProcessor roomRequest =
                    new RoomRequestProcessor(new RoomKey(game_id, room_x, room_y, room_z));

                if (roomRequest.ProcessRequest(
                        ApplicationConstants.CONNECTION_STRING,
                        Application,
                        out response.result))
                {
                    // Room Data for the room that requesting player is in
                    response.room_x      = roomRequest.RoomKey.x;
                    response.room_y      = roomRequest.RoomKey.y;
                    response.room_z      = roomRequest.RoomKey.z;
                    response.world_x     = roomRequest.RoomWorldPosition.x;
                    response.world_y     = roomRequest.RoomWorldPosition.y;
                    response.world_z     = roomRequest.RoomWorldPosition.z;
                    response.portals     = roomRequest.Portals;
                    response.mobs        = roomRequest.Mobs;
                    response.energyTanks = roomRequest.EnergyTanks;
                    response.data        = roomRequest.StaticRoomData;

                    response.result = SuccessMessages.GENERAL_SUCCESS;
                }
            }

            return(JSONUtilities.SerializeJSONResponse <WorldGetRoomDataResponse>(response));
        }
Esempio n. 10
0
        public void UpdateMarketPriceFrmCoinMarketCapToDB(short currencyId)
        {
            // Get all Cryptocurrencies
            List <Cryptocurrency> crypto = new List <Cryptocurrency>();

            //List<PriceInfo> priceinfolist = new List<PriceInfo>();

            //Janet change get cryptocurrencies list without transaction setting
            //crypto = cryptoCurrDAC.GetAllCurrencies();
            crypto = cryptoCurrDAC.List();

            Currencies fiatcurrencyitem = new Currencies();

            fiatcurrencyitem = currenciesDAC.GetByID(currencyId);

            //priceinfolist = priceInfoDAC.GetAll();

            string apiURL = string.Format(CoinMarketCapV2_URL, fiatcurrencyitem.Code.ToUpper());

            //string colName = "price_" + fiatcurrencyitem.Code.ToLower();  // "price_eur"
            //string colName = currency.ToUpper();  // "EUR"

            //HttpClient client = new HttpClient();
            //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //HttpResponseMessage response = client.GetAsync(apiURL).Result;

            var data = RestUtilities.GetJson(apiURL);
            //data = data.Replace(colName, "price_curr");

            CoinMarketCapPriceDetailV2 priceList = JsonConvert.DeserializeObject <CoinMarketCapPriceDetailV2>(data);
            //BittrexModels priceList = JsonConvert.DeserializeObject<BittrexModels>(data);
            //List<Welcome> priceList = JsonConvert.DeserializeObject<List<Welcome>>(data);

            var query = (from cryptoitem in crypto
                         join priceitem in priceList.Data on cryptoitem.Code equals priceitem.Value.Symbol
                         where priceitem.Value.Quotes != null
                         where priceitem.Value.Quotes.Any(x => string.Compare(x.Key, fiatcurrencyitem.Code, true) == 0)
                         select new PriceInfo
            {
                CryptoID = cryptoitem.Id,
                CurrencyID = fiatcurrencyitem.ID,
                //Price = priceitem.Value.Quotes.Select(x => Convert.ToDecimal(x.Value.Price.Value)).First()
                Price = (decimal)priceitem.Value.Quotes
                        .Where(x => string.Compare(x.Key, fiatcurrencyitem.Code, true) == 0).Select(x => x)
                        .FirstOrDefault().Value.Price
            }).ToList();

            if (query.Count > 0)
            {
                foreach (var item in query)
                {
                    var priceinfolist  = PriceInfoDac.GetAll();
                    var existpriceinfo = priceinfolist.SingleOrDefault(x =>
                                                                       x.CryptoID == item.CryptoID && x.CurrencyID == item.CurrencyID);

                    if (existpriceinfo != null)
                    {
                        existpriceinfo.Price          = item.Price;
                        existpriceinfo.LastUpdateDate = DateTime.UtcNow;
                        PriceInfoDac.UpdatePriceInfo(existpriceinfo);

                        Log.Info(MethodBase.GetCurrentMethod().Name + "(): " +
                                 "Succcess updating PriceInfo for CrypoID : " + existpriceinfo.CryptoID +
                                 " to CurrencyID : " + existpriceinfo.CurrencyID);
                    }
                    else
                    {
                        item.LastUpdateDate = DateTime.UtcNow;
                        PriceInfoDac.CreatePriceInfo(item);

                        Log.Info(MethodBase.GetCurrentMethod().Name + "(): " +
                                 "Succcess creating PriceInfo for CrypoID : " + item.CryptoID + " to CurrencyID : " +
                                 item.CurrencyID);
                    }

                    var cryptoCurr2 = (from x in crypto
                                       where string.Compare(x.Code, "BTC", StringComparison.OrdinalIgnoreCase) == 0
                                       select x).SingleOrDefault();
                    var fiatCurr2 = currenciesDAC.GetByCode("USD");
                    if (cryptoCurr2 != null && fiatCurr2 != null && item.CryptoID == cryptoCurr2.Id &&
                        item.CurrencyID == fiatCurr2.ID)
                    {
                        BTCToUSD = item.Price;
                    }
                }
            }
        }
Esempio n. 11
0
        public void Notification(string message, bool reNotification = false)
        {
            lock (_lock)
            {
                if (string.IsNullOrWhiteSpace(_notificationUrl))
                {
                    _log.Error("Invalid Noification URL");
                    return;
                }

                var notificationModel = JsonConvert.DeserializeObject <NotificationModel>(message);

                var mallDac = new MallPaymentOrderDAC();
                if (notificationModel.Type == TradeType.Payment)
                {
                    var status = mallDac.HasNotifiation(notificationModel.MallId);

                    if (status)
                    {
                        return;
                    }
                }
                else
                {
                    var status = mallDac.RefundHasNotifiation(notificationModel.MallId);

                    if (status)
                    {
                        return;
                    }
                }

                var sendNotification = JsonConvert.SerializeObject(new
                {
                    notificationModel.OrderId,
                    Type = Enum.GetName(typeof(TradeType), notificationModel.Type),
                    notificationModel.TradeNo,
                    notificationModel.Status
                });

                var result = "";
                try
                {
                    result = RestUtilities.PostJson(_notificationUrl,
                                                    new Dictionary <string, string>
                    {
                        { "FiiiPay", ConfigurationManager.AppSettings.Get("CallbackKey") }
                    }, sendNotification);
                    _log.InfoFormat("Notification {0} params {1},result {2}", notificationModel.OrderId,
                                    sendNotification, result);
                }
                catch (Exception exception)
                {
                    _log.ErrorFormat("Notification error {0}, param {1}", exception.Message, message);

                    mallDac.UpdateNotificationSource(notificationModel.MallId, message);
                }

                if (result.StartsWith("ok"))
                {
                    if (notificationModel.Type == TradeType.Payment)
                    {
                        mallDac.UpdateNotification(notificationModel.MallId);
                    }
                    else if (notificationModel.Type == TradeType.Refund)
                    {
                        mallDac.UpdateRefundNotification(notificationModel.MallId);
                    }
                }
                else
                {
                    if (!reNotification)
                    {
                        mallDac.UpdateNotificationSource(notificationModel.MallId, message);
                    }
                }
            }
        }