public static void RemoveAllCookies(bool removeSesstionCookie) { HttpContext.Current.Response.Cookies.Clear(); //foreach (string cookie in HttpContext.Current.Request.Cookies.AllKeys) //{ // HttpContext.Current.Response.Cookies.Set(new HttpCookie(cookie) { Expires = DateTime.Now.AddMonths(-1), Path = "/" }); //} //HttpContext.Current.Response.Cookies.Set(new HttpCookie(cookie) { Expires = DateTime.Now.AddMonths(-1), Path = "/" }); string[] cookies = HttpContext.Current.Request.Cookies.AllKeys; if (cookies == null || cookies.Length == 0) { return; } foreach (string cookie in cookies) { //Thêm cookie đã expire nếu có config Cookie Domain trong FormsAuthentication của web.config if (!string.IsNullOrEmpty(FormsAuthentication.CookieDomain) && cookie.Equals(FormsAuthentication.FormsCookieName)) { HttpContext.Current.Response.Cookies.Add(new HttpCookie(cookie) { Name = FormsAuthentication.FormsCookieName, Domain = FormsAuthentication.CookieDomain, Expires = DateTime.Now.AddYears(-1) }); } //if (cookie == FormsAuthentication.FormsCookieName) continue; //if (cookie == SSO_SESSION_COOKIES && !removeSesstionCookie) continue; //if (!cookie.ToLower().Contains("sso")) continue; try { //lấy cookie có sẵn HttpCookie httpCookie = HttpContext.Current.Request.Cookies[cookie]; if (httpCookie != null) { //set expires cho cookie httpCookie.Domain = HttpContext.Current.Request.Url.Host.Contains("localhost") ? null : "." + HttpContext.Current.Request.Url.Host;; httpCookie.Expires = DateTime.Now.AddYears(-1); //update cookie HttpContext.Current.Response.Cookies.Set(httpCookie); } if (removeSesstionCookie) { HttpContext.Current.Request.Cookies.Remove(cookie); } } catch (Exception ex) { NLogLogger.PublishException(ex); } } }
public string GetSampleData(int betType) { if (!IsDataTest) { return("Tính năng đã disabled"); } var accountId = 0; var accountName = string.Empty; try { string accountInfo = HttpContext.Current.User.Identity.Name; if (accountInfo.Split('|').Length >= 4) { accountId = int.Parse(accountInfo.Split('|')[0]); accountName = string.Format(accountInfo.Split('|')[1]); NLogLogger.LogInfo("acc: {0} - access: {1}"); } if (accountId <= 0) { return(string.Empty); } string l = string.Empty; string accountTest = string.Empty; var accountFile = new StreamReader(HttpContext.Current.Server.MapPath(AccountTestFile)); while ((l = accountFile.ReadLine()) != null) { accountTest += l + ","; } accountFile.Close(); //chi nhung tai khoan test moi duoc su dung data test if (accountTest.IndexOf("," + accountName + ",", StringComparison.Ordinal) < 0) { return("Tài khoản của bạn có quyền truy cập"); } string dataTest = string.Empty; dataTest = AbstractDaoFactory.Instance().CreateMiniGame().GetSlotData(accountId, betType); //neu du lieu trong file test khong co if (dataTest.Length <= 0) { return(""); } return(dataTest); } catch (Exception ex) { NLogLogger.PublishException(ex); return("Lỗi:" + ex.Message); } }
public int CreateSampleData([FromBody] dynamic data) { if (!IsDataTest) { return(-99); } var accountId = 0; var accountName = string.Empty; try { string accountInfo = HttpContext.Current.User.Identity.Name; if (accountInfo.Split('|').Length >= 4) { accountId = int.Parse(accountInfo.Split('|')[0]); accountName = string.Format(accountInfo.Split('|')[1]); NLogLogger.LogInfo("acc: {0} - access: {1}"); } if (accountId <= 0) { return(-2); } string l = string.Empty; string accountTest = string.Empty; var accountFile = new StreamReader(HttpContext.Current.Server.MapPath(AccountTestFile)); while ((l = accountFile.ReadLine()) != null) { accountTest += l + ","; } accountFile.Close(); //chi nhung tai khoan test moi duoc su dung data test if (accountTest.IndexOf("," + accountName + ",", StringComparison.Ordinal) < 0) { return(-1); } string cards = data.card; int betType = data.betType; var result = AbstractDaoFactory.Instance().CreateMiniGame().SetSlotData(accountId, cards, betType); return(result); } catch (Exception ex) { NLogLogger.PublishException(ex); return(-99); } }
private bool CheckBlockedUser() { try { string line = null; var source = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["BlackList"]); using (StreamReader sr = new StreamReader(source)) { line = sr.ReadToEnd(); } if (line.Contains(";" + AccountSession.AccountID + ";")) { return(true); } return(false); } catch (Exception ex) { NLogLogger.PublishException(ex); return(false); } }
public long GetAccouuntId(string connectionId) { const long accountId = 0; try { if (string.IsNullOrEmpty(connectionId)) { return(accountId); } var lst = _mapHubAccount.ToList(); var player = lst.FindAll(c => c.Key == connectionId); if (player.Count <= 0) { return(accountId); } return(player.FirstOrDefault().Value); } catch (Exception exception) { NLogLogger.PublishException(exception); } return(accountId); }