protected override async Task <HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { string accountName = AccountSession.AccountName; long accountId = AccountSession.AccountID; string response = string.Empty; string requestBody = await request.Content.ReadAsStringAsync(); var result = await base.SendAsync(request, cancellationToken); if (result.Content != null) { response = await result.Content.ReadAsStringAsync(); } NLogManager.LogMessage($"REQUEST BODY => API [{request.RequestUri}]" + "\n" + $"METHOD [{request.Method}] " + "\n" + $"BODY [{requestBody}] " + "\n" + $"RESPONSE [{response}] " + "\n" + $"IP [{IPAddressHelper.GetClientIP()}] " + "\n" + $"AccountName [{accountName}] " + "\n" + $"AccountID [{accountId}]"); return(result); }
/// <summary> /// Xóa ip action cache /// </summary> /// <param name="action">truyền vào tên action</param> /// <returns></returns> public static void IpActionDelete(string action) { string ip = IPAddressHelper.GetClientIP(); System.Runtime.Caching.ObjectCache cache = System.Runtime.Caching.MemoryCache.Default; cache.Remove("P" + ip.ToLower() + "_" + action); }
/// <summary> /// Đếm số lượt của hành động dựa trên IP /// </summary> /// <param name="action">truyền vào tên action</param> /// <returns></returns> public static int IpActionCounter(string action) { string ip = IPAddressHelper.GetClientIP(); System.Runtime.Caching.ObjectCache cache = System.Runtime.Caching.MemoryCache.Default; object cacheCounter = cache.Get("P" + ip.ToLower() + "_" + action); return(Convert.ToInt32(cacheCounter)); }
public ApiAccountInfoReponse AuthenLogin(PostLogin data) { try { var account = AccountDAO.Login(data.username, Security.MD5Encrypt(data.password)); if (account == null || account.AccountID == 0) { return new ApiAccountInfoReponse { Code = -51 } } ; if (account.IsBlocked) { return new ApiAccountInfoReponse { Code = -65 } } ; //if (account.IsOTP) //{ // string token = $"{DateTime.Now.Ticks}|{account.AccountID}|{account.DisplayName}|{data.device}"; // return new ApiAccountReponse // { // Code = 2, // Account = account, // OTPToken = Security.TripleDESEncrypt(ConfigurationManager.AppSettings["OTPKey"], token) // }; //} LogDAO.Login(data.device, IPAddressHelper.GetClientIP(), account.AccountID, 1); SetAuthCookie(account.AccountID, account.DisplayName, data.device, account.UserType); //NLogManager.LogMessage("Login success: " + JsonConvert.SerializeObject(account)); var accountInfo = new { userid = account.AccountID, username = account.DisplayName }; return(new ApiAccountInfoReponse { Code = 1, Account = accountInfo }); } catch (Exception ex) { NLogManager.PublishException(ex); } return(new ApiAccountInfoReponse { Code = -99 }); }
/// <summary> /// Chỉ đếm số lượt trong cache /// </summary> /// <param name="action"></param> /// <returns>số lượt</returns> private int CheckStatusFrequency(string action) { string ip = IPAddressHelper.GetClientIP(); System.Runtime.Caching.ObjectCache cache = System.Runtime.Caching.MemoryCache.Default; object cacheCounter = cache.Get("@Post" + ip.ToLower() + AccountSession.AccountName + "_" + action); if (cacheCounter == null) { return(0); } return(Convert.ToInt32(cacheCounter)); }
/// <summary> /// Thêm số lượt ăn theo tài khoản /// </summary> /// <param name="totalSecond"></param> /// <param name="action"></param> private void AddStatusFrequency(int totalSecond, string action) { string ip = IPAddressHelper.GetClientIP(); System.Runtime.Caching.ObjectCache cache = System.Runtime.Caching.MemoryCache.Default; System.Runtime.Caching.CacheItemPolicy policy = new System.Runtime.Caching.CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddSeconds(totalSecond) }; object cacheCounter = cache.Get("@Post" + ip.ToLower() + AccountSession.AccountName + "_" + action); if (cacheCounter == null) { cache.Set("@Post" + ip.ToLower() + AccountSession.AccountName + "_" + action, 1, policy); } cache.Set("@Post" + ip.ToLower() + AccountSession.AccountName + "_" + action, Convert.ToInt32(cacheCounter) + 1, policy); }
public int MpSpin(long accountId, string username, byte betType, byte roomID, string connectionId, int mobilePl) { int responseStatus; string clientIP = IPAddressHelper.GetClientIP(); int sourceID = 1; int merchantID = 1; MiniPokerSpinResponse miniPokerSpinResponse = this._miniPokerDAO.Spin(accountId, username, (int)betType, (int)roomID, clientIP, sourceID, merchantID, mobilePl); try { if (miniPokerSpinResponse != null) { this.MpSpinResultToClient(miniPokerSpinResponse, connectionId); string groupName = ConnectionHandler.Instance.GetGroupName(betType, roomID, ""); ConnectionHandler.Instance.AddGroup(connectionId, groupName); if (miniPokerSpinResponse.ResponseStatus > -1) { JackpotData jackpotDatum = null; this.JackpotMiniPoker.TryGetValue(groupName, out jackpotDatum); if (jackpotDatum == null) { jackpotDatum = new JackpotData(); jackpotDatum.BetType = (betType); jackpotDatum.RoomID = (roomID); jackpotDatum.Jackpot = (miniPokerSpinResponse.Jackpot); jackpotDatum.LastUpdated = (DateTime.Now); } if (jackpotDatum.Jackpot != miniPokerSpinResponse.Jackpot) { jackpotDatum.Jackpot = (miniPokerSpinResponse.Jackpot); jackpotDatum.IsChanged = (true); this.JackpotMiniPoker.TryUpdate(groupName, jackpotDatum, jackpotDatum); } } responseStatus = miniPokerSpinResponse.ResponseStatus; return(responseStatus); } } catch (Exception exception1) { NLogManager.PublishException(exception1); } responseStatus = -99; return(responseStatus); }
/// <summary> /// Kiểm tra ip thực hiện 1 hành động trong số giây (tự cộng số lượt mỗi lần gọi hàm check) /// Không ăn theo tài khoản /// </summary> /// <param name="totalSecond">Số giây kiểm tra</param> /// <param name="action">tên hành động</param> /// <returns>số lượt gọi hành động</returns> public static int CheckIpPostFrequency(int totalSecond, string action) { string ip = IPAddressHelper.GetClientIP(); System.Runtime.Caching.ObjectCache cache = System.Runtime.Caching.MemoryCache.Default; System.Runtime.Caching.CacheItemPolicy policy = new System.Runtime.Caching.CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddSeconds(totalSecond) }; object cacheCounter = cache.Get("P" + ip.ToLower() + "_" + action); if (cacheCounter == null) { cache.Set("P" + ip.ToLower() + "_" + action, 1, policy); return(0); } cache.Set("P" + ip.ToLower() + "_" + action, Convert.ToInt32(cacheCounter) + 1, policy); return(Convert.ToInt32(cacheCounter)); }
public int User_Login(string username, string password) { try { int responseStatus = 0; int userID = 0; var oCommand = new SqlCommand("[cms].[SP_User_Login]"); oCommand.CommandType = CommandType.StoredProcedure; oCommand.Parameters.Add(new SqlParameter("@_Username", username)); oCommand.Parameters.Add(new SqlParameter("@_Password", password)); oCommand.Parameters.Add(new SqlParameter("@_ClientIP", IPAddressHelper.GetClientIP())); var p_UserID = new SqlParameter("@_UserID", SqlDbType.Int); var p_ResponseStatus = new SqlParameter("@_ResponseStatus", SqlDbType.Int); p_UserID.Direction = ParameterDirection.Output; p_ResponseStatus.Direction = ParameterDirection.Output; oCommand.Parameters.Add(p_UserID); oCommand.Parameters.Add(p_ResponseStatus); db.ExecuteNonQuery(oCommand); userID = p_ResponseStatus.SqlValue.ToString() != "Null" ? (int)p_UserID.Value : 0; responseStatus = p_ResponseStatus.SqlValue.ToString() != "Null" ? (int)p_ResponseStatus.Value : 0; if (responseStatus > 0) { return(userID); } else { return(responseStatus); } } catch (Exception ex) { NLogManager.PublishException(ex); return(-69); } }
public ApiAccountReponse RegisterNormal(PostCreateAccount data) { try { int captchaVeriryStatus = Utilities.Captcha.Verify(data.captcha, data.token); if (captchaVeriryStatus < 0) { return new ApiAccountReponse { Code = captchaVeriryStatus } } ; var account = new Models.Account(); int response = account.RegisterNormal(data.username, data.password); if (response < 0) { return new ApiAccountReponse { Code = response } } ; SetAuthCookie(account.AccountID, "U." + account.AccountID, data.device, 1); LogDAO.Login(data.device, IPAddressHelper.GetClientIP(), account.AccountID, 1, true); return(new ApiAccountReponse { Code = response, Account = account }); } catch (Exception ex) { NLogManager.PublishException(ex); } return(new ApiAccountReponse { Code = -99 }); }
public override SlotMachineSpinData PlaySpin(int roomId, MoneyType moneyType) { var _ClientIP = IPAddressHelper.GetClientIP(); var accountId = AccountSession.AccountID; var accountName = AccountSession.AccountName; //var sourceId = AccountSession.SourceID; SlotMachineSpinData spinData = new SlotMachineSpinData() { ResponseStatus = -99 }; //int sourceGameId = Config.GetIntegerAppSettings("SourceGameId", 1); //if (sourceId == 3) //{ // sourceGameId = Config.GetIntegerAppSettings("SourceGameId_IOS", 1); //} //if (sourceId == 4) //{ // sourceGameId = Config.GetIntegerAppSettings("SourceGameId_ANDROID", 1); //} spinData = _SlotMachineDAO.Spin(moneyType, 1, 1, "", (int)accountId, accountName, "", roomId, _ClientIP); if (spinData.ResponseStatus < 0) { CacheCounter.CheckAccountActionFrequency(accountId.ToString(), 15, "SpinAm"); var totalSecondFail = int.Parse(ConfigurationManager.AppSettings["TimmerFailRq"]); AddStatusFrequency(totalSecondFail, "SpinLoi"); return(spinData); } UpdateCacheJackpot(roomId, spinData.Jackpot, moneyType); return(spinData); }
public async Task <long> PlayNow(MoneyType moneyType, int roomId) { if ((int)moneyType != 1 && (int)moneyType != 2) { return(-999); } if (roomId < 1 || roomId > 4) { return(-888); } try { var accountId = AccountSession.AccountID; var accountName = AccountSession.AccountName; if (accountId < 1 || string.IsNullOrEmpty(accountName)) { return(-1001); } //var connections = ConnectionHandler.Instance.GetConnections(accountId); //if (connections.Count > 1) //{ // var currentConnection = Context.ConnectionId; // foreach(var other in connections.Where(con => !con.Equals(currentConnection))) // { // if(currentConnection != other) // Clients.Client(other).message(-1002, "Tài khoản của bạn đang chơi trên thiết bị khác"); // } //} if (CacheCounter.CheckAccountActionFrequency(accountId.ToString(), 60, "PlayNow") > Config.GetIntegerAppSettings("TotalAllowPlayNow", 60)) { NLogManager.LogMessage($"BlockPlayNow=>Acc:{accountId}|User:{accountName}|Room:{roomId}|Ip:{IPAddressHelper.GetClientIP()}"); return(-1002); } var gameInfo = GameHandler.Instance.PlayNow(moneyType, roomId, accountId, accountName); if (gameInfo.ResponseStatus >= 0) { if (moneyType == MoneyType.Gold) { await Groups.Remove(Context.ConnectionId, "Coin"); await Groups.Add(Context.ConnectionId, "Gold"); } else { await Groups.Remove(Context.ConnectionId, "Gold"); await Groups.Add(Context.ConnectionId, "Coin"); } Clients.Caller.joinGame(gameInfo); } return(accountId); } catch (NotAuthorizedException nig) { NLogManager.PublishException(nig); } catch (Exception ex) { NLogManager.PublishException(ex); } return(-1); }
public int Spin(MoneyType moneyType, int roomId, string lines) { long accountId = AccountSession.AccountID; string accountName = AccountSession.AccountName; try { if (accountId < 1 || String.IsNullOrEmpty(accountName)) { return((int)Enums.ErrorCode.NotAuthen); } if (CacheCounter.AccountActionCounter(accountId.ToString(), "BlockSpamSpin") > 0) { NLogManager.LogMessage($"BlockSpinAm=>Acc:{accountId}|User:{accountName}|Lines:{lines}|Ip:{IPAddressHelper.GetClientIP()}"); return(-1002); } var spinData = GameHandler.Instance.Spin(accountId, accountName, lines, moneyType, roomId); if (spinData != null && spinData.ResponseStatus < 0) { if (CacheCounter.CheckAccountActionFrequency(accountName, 10, "InvalidSpin") > 5) { //Block Spin 10s CacheCounter.CheckAccountActionFrequency(accountName, 10, "BlockSpamSpin"); } string message = "Rất tiếc hệ thống của chúng tôi đang bận!Mời bạn thử lại sau!"; if (spinData.ResponseStatus == -51) { message = "Số dư của bạn không đủ"; } else if (spinData.ResponseStatus == -232) { message = "Số line chọn không hợp lệ"; } Clients.Caller.message(spinData.ResponseStatus, message); } Clients.Caller.resultSpin(spinData); return((int)Enums.ErrorCode.SuccessRequest); } catch (Exception ex) { NLogManager.PublishException(ex); return((int)Enums.ErrorCode.Exception); } }
public ApiAccountReponse LoginOTP(PostLoginOTP data) { try { //NLogManager.LogMessage(JsonConvert.SerializeObject(data)); string decryptToken = Security.TripleDESDecrypt(ConfigurationManager.AppSettings["OTPKey"], System.Web.HttpUtility.UrlDecode(data.tokenOTP).Replace(" ", "+")); string[] splData = decryptToken.Split('|'); long time = long.Parse(splData[0]); if (TimeSpan.FromTicks(DateTime.Now.Ticks - time).TotalSeconds > 120) { return new ApiAccountReponse { Code = -1 } } ; //Experied captcha long accountId = Convert.ToInt64(splData[1]); string displayName = splData[2].ToString(); int device = Convert.ToInt32(splData[3]); var account = AccountDAO.GetAccountById(accountId); if (account.IsBlocked) { return new ApiAccountReponse { Code = -65 } } ;; NLogManager.LogMessage("LOGIN OTP: " + accountId + "|" + data.otp); var infoApp = OtpDAO.GetCurrentCounter(accountId); string token = infoApp?.AppT; if (!string.IsNullOrEmpty(infoApp?.AppT)) { if (OTPApp.ValidateOTP($"{Security.MD5Encrypt($"{accountId}_{token}")}_{token}", data.otp)) { goto doneOTP; } } if (!OTP.OTP.ValidateOTP(accountId, data.otp, account.Tel)) { NLogManager.LogMessage("ValidateOTP: " + -60); return(new ApiAccountReponse { Code = -60 }); } doneOTP: LogDAO.Login(device, IPAddressHelper.GetClientIP(), accountId, 1); SetAuthCookie(accountId, account.DisplayName, device, account.UserType); return(new ApiAccountReponse { Code = 1, Account = account }); } catch (Exception ex) { NLogManager.PublishException(ex); } return(new ApiAccountReponse { Code = -99 }); }
public async Task <ApiAccountInfoReponse> AuthenLoginFacebook(PostLoginFacebook data) { try { var fb = await Utilities.FB.Facebook.GetIDsForBusiness(data.accessToken); if (fb == null) { return new ApiAccountInfoReponse { Code = -50 } } ; string accountIds = fb.Select(x => x.id).Aggregate((i, j) => i + ";" + j); long accountId = AccountDAO.CheckBussinessAccount(accountIds);//request the minium user_id var account = new Models.Account(); if (accountId > 0) { account = AccountDAO.GetAccountInfo(accountId); } if (account == null || account.AccountID == 0) { account = new Models.Account(); } else { if (account.IsBlocked) { return new ApiAccountInfoReponse { Code = -65 } } ; //if (account.IsOTP) //{ // string token = $"{DateTime.Now.Ticks}|{account.AccountID}|{account.DisplayName}|{data.device}"; // return new ApiAccountReponse // { // Code = 2, // Account = account, // OTPToken = Security.TripleDESEncrypt(ConfigurationManager.AppSettings["OTPKey"], token) // }; //} LogDAO.Login(data.device, IPAddressHelper.GetClientIP(), account.AccountID, 2); SetAuthCookie(account.AccountID, account.DisplayName, data.device, 2); return(new ApiAccountInfoReponse { Code = 1, Account = account }); } int response = account.RegisterFacebookAccount($"FB_{fb.FirstOrDefault().id}"); if (response < 0) { return new ApiAccountInfoReponse { Code = response } } ; AccountDAO.CheckBussinessAccount(accountIds); LogDAO.Login(data.device, IPAddressHelper.GetClientIP(), account.AccountID, 2, true); SetAuthCookie(account.AccountID, "U." + account.AccountID, data.device, 2); var accuntInfo = new { userid = account.AccountID, username = account.DisplayName }; return(new ApiAccountInfoReponse { Code = response, Account = accuntInfo }); } catch (Exception ex) { NLogManager.PublishException(ex); } return(new ApiAccountInfoReponse { Code = -99 }); }
public async Task <HttpResponseMessage> Token(string code) { string domainWeb = "https://chanh.win/"; try { var fb = new Facebook.FacebookClient(); dynamic result = fb.Post("oauth/access_token", new { client_id = "1792549730783013", client_secret = "5fd8d1fe75779972717e0881fc121882", redirect_uri = "https://api.buscity.xyz/Account/Token", code = code }); var accessToken = result.access_token; List <IDs_Business> fb1 = await Utilities.FB.Facebook.GetIDsForBusiness(accessToken); if (fb1 == null) { throw new Exception(); } string accountIds = fb1.Select(x => x.id).Aggregate((i, j) => i + ";" + j); long accountId = AccountDAO.CheckBussinessAccount(accountIds);//request the minium user_id var account = new Models.Account(); if (accountId > 0) { account = AccountDAO.GetAccountInfo(accountId); } if (account == null || account.AccountID == 0) { account = new Models.Account(); } else { if (account.IsBlocked) { throw new Exception(); } LogDAO.Login(0, IPAddressHelper.GetClientIP(), account.AccountID, 2); SetAuthCookie(account.AccountID, account.DisplayName, 0, 2); } int response1 = account.RegisterFacebookAccount($"FB_{fb1.FirstOrDefault().id}"); if (response1 < 0) { throw new Exception(); } AccountDAO.CheckBussinessAccount(accountIds); LogDAO.Login(0, IPAddressHelper.GetClientIP(), account.AccountID, 2, true); SetAuthCookie(account.AccountID, "U." + account.AccountID, 0, 2); } catch (Exception ex) { NLogManager.PublishException(ex); } var response = Request.CreateResponse(HttpStatusCode.Moved); response.Headers.Location = new Uri(domainWeb); return(response); }
public void GetAccountInfoHiLo() { try { long accountId = AccountSession.AccountID; string accountName = AccountSession.AccountName; if ((accountId < 1 || string.IsNullOrEmpty(accountName))) { throw new NotAuthorizedException(NOT_LOGIN_MESSAGE); } if (CacheCounter.CheckAccountActionFrequency(accountId.ToString(), 15, "GetAccInfo") > 6) { NLogManager.LogMessage(string.Format("BlockGetAccInfo=>Acc:{0}|User:{1}", accountId, accountName)); return; } var resultAccInfo = AbstractDaoMinigame.Instance().CreateMiniHiloDao() .GetAccountInfo((int)accountId, accountName); NLogManager.LogMessage("resultAccInfo: " + JsonConvert.SerializeObject(resultAccInfo)); if (resultAccInfo.currentTurnId > 0) { if (resultAccInfo.remainTime <= 0) { NLogManager.LogMessage(string.Format("AutoFinishSession:Acc:{0}|User:{1}|Turn:{2}", accountId, accountName, resultAccInfo.currentTurnId)); if (HiLoHandler.Instance.AutoFinishSession(resultAccInfo, accountId, accountName, IPAddressHelper.GetClientIP())) { HiLoHandler.Instance.FinishAccSession(resultAccInfo.currentTurnId); return; } } Clients.Caller.resultHiLoAccountInfo(resultAccInfo); } } catch (Exception exception) { NLogManager.LogError("ERROR GetAccountInfoHiLo: " + exception); NLogManager.PublishException(exception); } }
public void Bet(int moneyType, long betAmount, int betSide) { try { if (betSide != 0 && betSide != 1) { Clients.Caller.Error("Sai cửa đặt cược!"); return; } long accountId = AccountSession.AccountID; if (accountId <= 0) { return; } long outNewBalance; long sumaryBet = 0; string msgError = string.Empty; int response = GameManager.Bet(moneyType, Context.ConnectionId, accountId, AccountSession.AccountName, IPAddressHelper.GetClientIP(), (Models.BetSide)betSide, betAmount, out sumaryBet, out outNewBalance, out msgError); if (response < 0) { Clients.Caller.Error(msgError); return; } Clients.Caller.BetSuccess(moneyType, betSide, sumaryBet, outNewBalance); } catch (Exception ex) { NLogManager.PublishException(ex); Clients.Caller.Error(ex.Message); } }
public int SetBetHiLo(int betType, int stepType, int locationId, int roomId) { try { long accountId = AccountSession.AccountID; string accountName = AccountSession.AccountName; if (accountId < 1 || string.IsNullOrEmpty(accountName)) { NLogManager.LogMessage(string.Format("Chưa đăng nhập")); return(-1001); } if (betType < 1 || betType > 2 || locationId < 0 || locationId > 1 || roomId < 1 || roomId > 5) { Logout(); NLogManager.LogMessage(string.Format("BlockAcc=> {0} ({1}) Wrong Input.", accountName, accountId)); return(-212); } if (CacheCounter.CheckAccountActionFrequency(accountId.ToString(), 1, "SetBet") > 2) { NLogManager.LogMessage(string.Format("BlockAccFast => {0} ({1}) bet liên tục 1 giây 2 lần.", accountName, accountId)); return(-1001); } if (CacheCounter.AccountActionCounter(accountId.ToString(), "SetBetAm") > 5) { NLogManager.LogMessage(string.Format("BlockAccAm => {0} ({1}) bắn âm > 5 lần.", accountName, accountId)); return(-1003); } var result = AbstractDaoMinigame.Instance().CreateMiniHiloDao(). SetBet((int)accountId, accountName, roomId, betType, stepType, locationId, IPAddressHelper.GetClientIP(), 1, 1); if (stepType == 2 || result.prizeValue == 0 || result.responseStatus < 0) { //Kết thúc phiên hoặc thua cuộc HiLoHandler.Instance.FinishAccSession(result.turnId); } else { if (result.responseStatus < 0) { //Add vào list để duyệt check finish phiên var accInfo = new HiLoGetAccountInfoResponse() { currentTurnId = result.turnId, currentRoomId = roomId, currentBetType = betType, AccountId = accountId, AccountName = accountName, currentStep = result.step }; HiLoHandler.Instance.AddOrUpdateSession(accInfo); } } if (result.responseStatus < 0) { CacheCounter.CheckAccountActionFrequency(accountId.ToString(), 15, "SetBetAm"); } Clients.Caller.resultHiLoSetBet(result); return(result.responseStatus); } catch (Exception exception) { NLogManager.PublishException(exception); } return(-99); }
public long Transfer(string accountName, long amount, string reason, string captcha, string token) { NLogManager.LogMessage("Transfer info: " + accountName + "|" + amount + "|" + reason); try { var myAccount = AccountDAO.GetAccountById(AccountSession.AccountID); if (myAccount == null) { NLogManager.LogMessage("EX Result transfer: " + -58); return(-58); } if (amount < 10200) { NLogManager.LogMessage("EX Result transfer: " + -80); return(-80); } NLogManager.LogMessage("AccountInfo: " + JsonConvert.SerializeObject(myAccount)); int captchaVeriryStatus = Utilities.Captcha.Verify(captcha, token); if (captchaVeriryStatus < 0) { return(captchaVeriryStatus); } if (accountName.Length == 13 && accountName.Substring(0, 5) == "UWIN.") { #region Chuyen gold to daily var accountSandbox = ConfigurationManager.AppSettings["AccountSandbox"].Split(',').ToList(); NLogManager.LogMessage("accountSandbox: " + String.Join(",", accountSandbox)); //var accountId = AccountSession.AccountID; if (accountSandbox.Count > 0) { if (accountSandbox.Count(x => x == myAccount.AccountID.ToString()) > 0) { int code = 0; string msg = ""; string phone = ""; amount = (long)(amount / 1.02); NLogManager.LogMessage($"Transfer to agency => {accountName}|{amount}|{reason}"); var d = TransactionDAO.SendGold_v1(myAccount.AccountID, accountName, amount, reason, IPAddressHelper.GetClientIP(), ref code, ref msg, ref phone); NLogManager.LogMessage("result transfer agency: " + JsonConvert.SerializeObject(d) + "\r\ncode: " + code + "\r\nmsg: " + msg + "\r\nphone: " + phone); if (code == 1 && !string.IsNullOrEmpty(phone)) { Models.SMS.SmsService.SendMessage(phone, "yeu cau chuyen tien " + myAccount.Username + " so tien " + formatMoney(amount)); } return(code == 1 ? d.Balance : code); } } #endregion } else { var account = AccountDAO.GetAccountByAccountName(accountName); if (account == null) { NLogManager.LogMessage("EX Result transfer: " + -58); return(-58); } long totalTransfer = amount + (long)(amount * 0.02); long r = TransactionDAO.SendGold(AccountSession.AccountID, account.AccountID, AccountSession.AccountName, account.DisplayName, account.IsAgency, totalTransfer, amount, reason); NLogManager.LogMessage("Result transfer: " + r); return(r); } //NLogManager.LogMessage($"Transfer => {accountName}|{amount}|{reason}"); //amount = (long)(amount / 1.02); //var myAccount = AccountDAO.GetAccountById(AccountSession.AccountID); //NLogManager.LogMessage(JsonConvert.SerializeObject(myAccount)); //if (!myAccount.IsAgency) //{ // long totalTransfer = amount + (long)(amount * 0.02); // long r = TransactionDAO.SendGold(AccountSession.AccountID, // account.AccountID, // AccountSession.AccountName, // account.DisplayName, // account.IsAgency, // totalTransfer, // amount, // reason); // NLogManager.LogMessage("Result transfer: " + r); // return r; //} //else //{ // var agencyInfo = AccountDAO.GetAgencyInfo(AccountSession.AccountID); // if (agencyInfo.Level == 2) // { // long r = TransactionDAO.Transfer( // agencyInfo.ID, // agencyInfo.GameAccountId, // agencyInfo.Username, // amount, // account.IsAgency ? 0 : (long)(amount * 0.02), // agencyInfo.Level, // reason, // account.AccountID, // account.DisplayName, // account.IsAgency // ); // NLogManager.LogMessage("Result transfer: " + r); // return r; // } // else // { // NLogManager.LogMessage("Result transfer: " + -99); // return -99; // } //} } catch (Exception ex) { NLogManager.LogError("Transfer ERROR: " + ex); NLogManager.PublishException(ex); NLogManager.LogMessage("EX Result transfer: " + ex); } NLogManager.LogMessage("EX Result transfer: " + -99); return(-99); }
public void GetJackpot(byte betType, byte roomID) { try { long accountId = AccountSession.AccountID; string accountName = AccountSession.AccountName; if (CacheCounter.CheckIpPostFrequency(10, "GetJackpot") > 50) { NLogManager.LogMessage(string.Format("BlockGetJackpot=>{0},{1}", accountId, IPAddressHelper.GetClientIP())); return; } if ((accountId < 1 || string.IsNullOrEmpty(accountName))) { throw new NotAuthorizedException(NOT_LOGIN_MESSAGE); } if ((betType < 1 || betType > 2 || roomID < 1 || roomID > 4)) { throw new InvalidOperationException(INVALID_DATA_MESSAGE); } MiniPokerHandler.Instance.AddPlayer(accountId); MiniPokerHandler.Instance.MpGetJackpot(betType, roomID, base.Context.ConnectionId); } catch (Exception exception) { NLogManager.PublishException(exception); } }
public void HideSlot() { try { long accountId = AccountSession.AccountID; string accountName = AccountSession.AccountName; if (CacheCounter.CheckIpPostFrequency(10, "HideSlot") > 30) { NLogManager.LogMessage(string.Format("BlockHideSlot=>{0},{1}", accountId, IPAddressHelper.GetClientIP())); return; } if ((accountId < 1 || string.IsNullOrEmpty(accountName))) { throw new NotAuthorizedException(NOT_LOGIN_MESSAGE); } MiniPokerHandler.Instance.RemovePlayer(accountId); MiniPokerHandler.Instance.MpHideSlot(base.Context.ConnectionId); } catch (Exception exception) { NLogManager.PublishException(exception); } }
public SpinData Spin(long accountId, string accountName, string lines, MoneyType montype, int roomId) { var spinData = _slotMachineDAO.Spin((int)accountId, accountName, lines, roomId, IPAddressHelper.GetClientIP(), montype); // Thông tin vinh danh bổ sung sau UpdateCacheJackpot(roomId, spinData.Jackpot, montype); ThreadPool.QueueUserWorkItem(_ => { GameLogHandler.Instance.LogSpin(accountName, roomId, spinData.TotalPrizeValue, spinData.IsJackpot ? 1 : 2); }); return(spinData); }
public int GetJackpotPrize(FormCollection col) { var accountId = UserContext.AccountID; var accountName = UserContext.AccountName; if (accountId < 1) { return(-101); } try { var displayName = col["addfeatures_displayname"]; var gameId = int.Parse(col["gameselection"]); var roomId = int.Parse(col["roomselection"]); if (string.IsNullOrEmpty(displayName)) { return(-2); } return(AddFeaturesDAO.GetJackpotPrize((int)accountId, accountName, displayName, IPAddressHelper.GetClientIP(), gameId, roomId)); } catch (Exception e) { NLogManager.PublishException(e); return(-99); } }