protected override void OnInit(EventArgs e) { base.OnInit(e); // Check if revisit is valid or not if (!base.IsPostBack) { ANO_User cooike = ANOProfile.GetCookieValues(HttpContext.Current.Request.UserHostAddress); if (cooike != null) { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.ReVisit)) { Response.End(); } } else { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.FirstVisit)) { Response.End(); } } } else { // Limit number of postbacks if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.Postback)) { Response.End(); } } }
protected void DdlSelectLang_SelectedIndexChanged(object sender, EventArgs e) { Response.Clear(); string selectedLang = ((DropDownList)sender).SelectedItem.Value; // Save cookie ANOProfile.SaveCookies(selectedLang, CurrentUserIP, null); CustomSiteMapNode csm = new CustomSiteMapNode(); LangaugeSystem ls = new LangaugeSystem(); Page.Culture = selectedLang; Page.UICulture = selectedLang; cSiteMapNode homeSiteMapNode = csm.GetSiteMapNode(2, ls.GetLang(selectedLang).LangId); string getPath = homeSiteMapNode.SiteMapNodePath; if (homeSiteMapNode.SiteMapNodeRewrittedPath != null) { getPath = "http://" + selectedLang.Split('-')[0] + "." + GetDomain.GetDomainFromUrl(Request.Url.ToString()) + VirtualPathUtility.ToAbsolute(homeSiteMapNode.SiteMapNodeRewrittedPath); } Response.Redirect(getPath); Response.End(); }
// updating user activity private SearchNoticeMessage UpdateUserActivity(UserSearchInfo usi, int userActivityMinSeconds, HttpContext context, SearchNoticeMessage noticemessage) { DateTime DateTimeNow = TimeZoneManager.DateTimeNow; Guid?searchId = ANOProfile.GetCookieValues(usi.UserIpAddress, context).SearchMatchID; SW_SearchWar getSearch = db.SW_SearchWar.SingleOrDefault <SW_SearchWar>( s => s.SearchWarUserID == usi.UserID && (s.SearchWarId == searchId || s.SearchWarId == usi.SearchMatchID)); if (getSearch != null) { if (getSearch.SearchWarEditDate.AddSeconds(userActivityMinSeconds) > DateTimeNow) { getSearch.SearchWarEditDate = DateTimeNow.AddSeconds(5); db.SaveChanges(); return(noticemessage); } } return(SearchNoticeMessage.NoConnection); }
/// <summary> /// Bind all data /// </summary> public override void DataBind() { _shortLang = ANOProfile.GetCookieValues(_currentUserIP).ShortLang; base.DataBind(); this.RSiteMap.DataSource = _dataSource; this.RSiteMap.DataBind(); }
public ChatSystem(HttpContext context, string currentUserIP) { mngInfo = new TimeZoneManager(currentUserIP); this.context = context; this.currentUserIp = currentUserIP; user = ANOProfile.GetCookieValues(currentUserIP); }
protected void DdlTimeZones_SelectedIndexChanged(object sender, EventArgs e) { Response.Clear(); DivTimeZone.Visible = false; // Save cookie ANOProfile.SaveTimeZone(CurrentUserIP, DdlTimeZones.SelectedValue); Response.Redirect("~/"); Response.End(); }
// check max idle time private SearchNoticeMessage CheckUserIdleActivity(UserSearchInfo usi, int maxIdleSearch_Seconds, HttpContext context, SearchNoticeMessage noticemessage) { Guid?searchID = ANOProfile.GetCookieValues(usi.UserIpAddress, context).SearchMatchID; SW_SearchWar obj = db.SW_SearchWar.SingleOrDefault <SW_SearchWar>(s => s.SearchWarUserID == usi.UserID && (s.SearchWarId == searchID)); DateTime getAddedDateTime; if (obj != null) { getAddedDateTime = obj.SearchWarAddedDate; } else { return(SearchNoticeMessage.NoResults); } return(getAddedDateTime.AddSeconds(maxIdleSearch_Seconds) > TimeZoneManager.DateTimeNow ? noticemessage : SearchNoticeMessage.NoResults); }
public SearchEngineMng(string currentUserIp, HttpContext context, string action) { _currentUserIp = currentUserIp; this.context = context; currentR = context.Request; currentS = context.Server; mngInfo = new TimeZoneManager(currentUserIp); string sLangId = context.Request.QueryString["li"]; if (string.IsNullOrEmpty(sLangId)) { isValid = false; errorMessage = "You forgot langid (querystring li)"; } // Convert langid querystring to int32 if (!Int32.TryParse(sLangId, out currentLangId)) { isValid = false; errorMessage = "Problem with converting langauge ID (querystring li)"; } if (context.Session["usi"] == null || action == "1") { // Create user default information usi.UserID = (Guid)ANOProfile.GetCookieValues(currentUserIp, context).UserID; usi.UserIpAddress = currentUserIp; #region Set ints data (Get data by QueryStrings) var dataConvertToInts = new { clanSkillID = (string)currentR.QueryString["cs"], clanContinentID = (string)currentR.QueryString["cct"], clanCountryID = (string)currentR.QueryString["cc"], searchContinentID = (string)currentR.QueryString["sct"], searchCountryID = (string)currentR.QueryString["sc"], searchGameID = (string)currentR.QueryString["sg"], searchGameModeID = (string)currentR.QueryString["sgt"], searchXvs = (string)currentR.QueryString["sxv"], searchvsX = (string)currentR.QueryString["svx"] }.ToAnonymousObjectCollection(); int MaxIntValue = int.MaxValue; var intdata = new { clanSkillID = (int?)null, clanContinentID = (int)MaxIntValue, clanCountryID = (int)MaxIntValue, searchContinentID = (int)MaxIntValue, searchCountryID = (int?)null, searchGameID = (int)MaxIntValue, searchGameModeID = (int?)null, searchXvs = (int?)null, searchvsX = (int?)null, searchYearFrom = (int)MaxIntValue, searchDayFrom = (int)MaxIntValue, searchMonthFrom = (int)MaxIntValue, searchHourFrom = (int)MaxIntValue, searchMinutesFrom = (int)MaxIntValue, }.ToAnonymousObjectCollection(); #endregion #region validate and convert properties to ints for (int i = 0; i < dataConvertToInts.Count; i++) { AnonymousObject o = dataConvertToInts.GetAnonymousObject(i); if (!string.IsNullOrEmpty(o.GetValue <string>())) { int result; if (int.TryParse(o.GetValue <string>(), out result)) { intdata.GetAnonymousObject(o.KeyName).SetValue(result); } } if (intdata.GetAnonymousObject(o.KeyName).GetValue_UnknownObject() != null && Convert.ToInt32(intdata.GetAnonymousObject(o.KeyName).GetValue_UnknownObject()) == MaxIntValue) { isValid = false; errorMessage = "'" + o.KeyName + "' much be more than empty"; } } #endregion #region Set strings data (convert to HtmlEncode strings) var stringData = new { ClanName = (string)currentS.HtmlEncode(currentS.UrlDecode(currentR.QueryString["cn"])), SearchMap = (string)currentS.HtmlEncode(currentS.UrlDecode(currentR.QueryString["sm"])), }; #endregion #region Set datetime data (Replace + and . (This chars is used to avoid problems)) if (string.IsNullOrEmpty(currentR.QueryString["sfd"])) { isValid = false; errorMessage = "'SearchMatchStart' much be more than empty"; } else { var datetimeData = new { SearchMatchStart = (DateTime)DateTime.ParseExact(currentS.UrlDecode(currentR.QueryString["sfd"]), "dd-MM-yyyy HH:mm:ss", new DateTimeFormatInfo()) }; #endregion // Edit/Create user search information usi.ClanName = stringData.ClanName; usi.ClanSkillID = intdata.GetAnonymousObject("clanSkillID").GetValue <int?>(); usi.ClanContinentID = intdata.GetAnonymousObject("clanContinentID").GetValue <int>(); usi.ClanCountryID = intdata.GetAnonymousObject("clanCountryID").GetValue <int>(); usi.SearchContinentID = intdata.GetAnonymousObject("searchContinentID").GetValue <int>(); usi.SearchCountryID = intdata.GetAnonymousObject("searchCountryID").GetValue <int?>(); usi.SearchGameID = intdata.GetAnonymousObject("searchGameID").GetValue <int>(); usi.SearchGameModeID = intdata.GetAnonymousObject("searchGameModeID").GetValue <int?>(); usi.SearchMap = stringData.SearchMap; usi.SearchXvs = intdata.GetAnonymousObject("searchXvs").GetValue <int>(); usi.SearchvsX = intdata.GetAnonymousObject("searchvsX").GetValue <int>(); usi.SearchMatchStart = new TimeZoneManager(currentUserIp).ConvertDateTimeToUtc(datetimeData.SearchMatchStart); userOption = SearchWar.SearchEngine.SearchEngine.UserSearchOption.CreateUserSearch; context.Session["usi"] = usi; } } else { usi = (UserSearchInfo)context.Session["usi"]; } if (isValid == true) { LangaugeSystem ls = new LangaugeSystem(); string getLang = ls.GetLang(Convert.ToInt32(sLangId)).LangShortname; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(getLang); Thread.CurrentThread.CurrentUICulture = new CultureInfo(getLang); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { ImgLoading.ImageUrl = ImgLoading.ImageUrl.ChangeToImageHost(); H1Results.InnerHtml += " - " + Request.QueryString["sg"]; // insert game name #region Search engine HttpRequest currentR = Request; // Set values of current lang LangaugeSystem ls = new LangaugeSystem(); CurrentLang = ls.CurrentLang; CurrentLangId = ls.CurrentLangId; #region Get QueryStringsDatas (Convert to htmlencodes) var searchQueryDatas = new { ClanSkill = currentR.QueryString["cs"], ClanContinent = currentR.QueryString["cct"], ClanCountry = currentR.QueryString["cc"], SearchSkill = currentR.QueryString["ss"], SearchContinent = currentR.QueryString["sct"], SearchCountry = (string)currentR.QueryString["sc"], SearchGame = (string)currentR.QueryString["sg"], SearchGameMode = (string)currentR.QueryString["sgt"] }.ToAnonymousObjectCollection(); foreach (AnonymousObject s in searchQueryDatas) { s.SetValue(Server.HtmlEncode(Server.UrlDecode(s.GetValue <string>()))); } #endregion #region Get QueryStrings custom text data (no validate or convert) var searchQueryCustomTextData = new { ClanName = Server.HtmlEncode(Server.UrlDecode(currentR.QueryString["cn"])), SearchMap = Server.HtmlEncode(Server.UrlDecode(currentR.QueryString["sm"])) }; #endregion #region Get QueryStrings customdata var searchQueryCustomData = new { SearchMatchStart = currentR.QueryString["sfd"], SearchXvs = currentR.QueryString["sxv"], SearchvsX = currentR.QueryString["svx"] }; #endregion try { #region Get IDs of searchQueryDatas int? clanSkillId = null; SkillsSystem ss = new SkillsSystem(); if (!string.IsNullOrEmpty(searchQueryDatas.GetAnonymousObject("ClanSkill").GetValue <string>())) { clanSkillId = ((dynamic)ss.GetSkill(searchQueryDatas.GetAnonymousObject("ClanSkill").GetValue <string>(), CurrentLangId)).SearchWarSkillId; } int?searchSkillId = null; if (!string.IsNullOrEmpty(searchQueryDatas.GetAnonymousObject("SearchSkill").GetValue <string>())) { searchSkillId = ((dynamic)ss.GetSkill(searchQueryDatas.GetAnonymousObject("SearchSkill").GetValue <string>(), CurrentLangId)).SearchWarSkillId; } ContinentSystem cs = new ContinentSystem(); int clanContinentId = ((dynamic)cs.GetContinent(CurrentLangId, searchQueryDatas.GetAnonymousObject("ClanContinent"). GetValue <string>())).SearchWarContinentId; CountrySystem cys = new CountrySystem(); int clanCountryId = ((dynamic)cys.GetCountry(CurrentLangId, searchQueryDatas.GetAnonymousObject("ClanCountry").GetValue <string>())).SearchWarCountryId; int searchContinent = ((dynamic)cs.GetContinent(CurrentLangId, searchQueryDatas.GetAnonymousObject("SearchContinent") . GetValue <string>())).SearchWarContinentId; int?searchCountryId = null; if (!string.IsNullOrEmpty(searchQueryDatas.GetAnonymousObject("SearchCountry").GetValue <string>())) { searchCountryId = ((dynamic)cys.GetCountry(CurrentLangId, searchQueryDatas.GetAnonymousObject("SearchCountry"). GetValue <string>())).SearchWarCountryId; } GamesSystem gs = new GamesSystem(); int searchGameId = gs.GetGame(searchQueryDatas.GetAnonymousObject("SearchGame").GetValue <string>()).SearchWarGameId; int?searchGameModeId = null; if (!string.IsNullOrEmpty(searchQueryDatas.GetAnonymousObject("SearchGameMode").GetValue <string>())) { GameModeSystem gms = new GameModeSystem(); searchGameModeId = gms.GetGameType(searchQueryDatas.GetAnonymousObject("SearchGameMode").GetValue <string>()).SearchWarGameTypeId; } #endregion #region Create url to the "client javascript" (get "data search results" as xml) ANO_User getprofile = ANOProfile.GetCookieValues(CurrentUserIP); Guid newID = Guid.NewGuid(); ANOProfile.SaveCookies(CurrentUserIP, newID); xmlSearchUrl = "http://" + GetDomain.GetDomainFromUrl(Context.Request.Url.ToString()) + "/m.ashx"; xmlSearchUrlaction = xmlSearchUrl + "?li= " + CurrentLangId.ToString() + "&cn=" + Server.UrlEncode(searchQueryCustomTextData.ClanName) + ((clanSkillId.HasValue) ? "&cs=" + clanSkillId.Value.ToString() : "") + "&cct=" + clanContinentId.ToString() + "&cc=" + clanCountryId.ToString() + "&sg=" + searchGameId.ToString() + ((searchGameModeId.HasValue) ? "&sgt=" + searchGameModeId.Value.ToString() : "") + ((searchSkillId.HasValue) ? "&ss=" + searchSkillId.Value.ToString() : "") + "&sct=" + searchContinent.ToString() + ((searchCountryId.HasValue) ? "&sc=" + searchCountryId.Value.ToString() : "") + "&sxv=" + searchQueryCustomData.SearchXvs + "&svx=" + searchQueryCustomData.SearchvsX + (!string.IsNullOrEmpty(searchQueryCustomTextData.SearchMap) ? "&sm=" + Server.UrlEncode(searchQueryCustomTextData.SearchMap) : "") + "&sfd=" + Server.UrlEncode(searchQueryCustomData.SearchMatchStart) + "&option=search,chat&action=1"; xmlSearchUrl = xmlSearchUrl + "?option=search,chat&li= " + CurrentLangId.ToString(); #endregion } catch { // nothing "error" } } catch { } #endregion } }
public TimeZoneManager(string currentUserIP) { _getCookie = ANOProfile.GetCookieValues(currentUserIP); }
public void ProcessRequest(HttpContext context) { // Set defaults values string data = null; string currentUserIp = "62.107.21.129"; HttpRequest currentR = context.Request; HttpServerUtility currentS = context.Server; int currentLangId; bool isValid = true; string errorMessage = "succes"; ANO_User getUser = ANOProfile.GetCookieValues(currentUserIp, context); string userAction = context.Request.QueryString["a"]; if (string.IsNullOrEmpty(userAction)) { isValid = false; errorMessage = "You forgot action (querystring a)"; } // Create documet and root element called "c" for "chat" XDocument createXml = new XDocument( new XDeclaration("1.0", "iso-8859-1", "true"), new XElement("chat")); // Get root element "c" XElement getRootElement = createXml.Descendants("chat").Single(); if (userAction == ChatCmds.SendMessage.ToString()) { string userText = context.Request["t"]; if (string.IsNullOrEmpty(userText)) { isValid = false; errorMessage = "You forgot the message (post/querystring t)"; } string chatIdQuery = context.Request["c"]; Guid? chatId = null; if (string.IsNullOrEmpty(chatIdQuery)) { isValid = false; errorMessage = "You forgot the chat window id (post/querystring c"; } // Convert chatid querystring to Guid try { chatId = new Guid(chatIdQuery); } catch { isValid = false; errorMessage = "Problem with converting chat window id (querystring c)"; } if (isValid == true && chatId.HasValue) { string getUsername = null; if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { getUsername = Membership.GetUser(getUser.UserID).UserName; } if (string.IsNullOrEmpty(getUsername)) { Searchwar_netEntities db = new Searchwar_netEntities(); SW_SearchWar matchSearch = db.SW_SearchWar.SingleOrDefault(w => w.SearchWarId == getUser.SearchMatchID); if (matchSearch != null) { getUsername = matchSearch.SearchWarClanName; } } if (!string.IsNullOrEmpty(getUsername)) { ChatSystem mngChat = new ChatSystem(context, currentUserIp); mngChat.CreateMsg(userText, chatId, getUser.UserID, getUsername); } else { isValid = false; errorMessage = "You muct be logged in or searching for a match"; } } } // write status for result getRootElement.Add(new XElement("status", new XAttribute("bool", isValid.ToString()), errorMessage)); // Write/save data StringWriter sw = new StringWriter(); XmlWriter xw = XmlWriter.Create(sw); createXml.Save(xw); xw.Close(); data = sw.ToString(); context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = Encoding.UTF8; context.Response.Write(XmlWhiteSpaceModule.RemoveWhitespace(data)); }
protected void Page_Load(object sender, EventArgs e) { // Select current langauge string currentLang = new LangaugeSystem().CurrentLang; // Show if javascript is disable ErrorJS.InnerText = GetLocalResourceObject("JavascriptBoxErrorMessageError").ToString(); // url for JS string pageId = Context.Request.AppRelativeCurrentExecutionFilePath.ToString(); string jsurl = ("~/js.axd?p=" + HttpUtility.UrlEncode(pageId)).ChangeToJsHost(); scriptsall.Scripts.Add(new System.Web.UI.ScriptReference(jsurl)); if (Page.IsPostBack) { return; } // get timezone ANO_User GetUserCookie = ANOProfile.GetCookieValues(CurrentUserIP); string currentZone = GetUserCookie.TimeZone; if (string.IsNullOrEmpty(currentZone)) { DivTimeZone.Visible = true; } else { DivTimeZone.Visible = false; } // check cache System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo> getTimeZones = (System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo>)Cache["masterpage_timezones"]; if (getTimeZones == null) { getTimeZones = TimeZoneInfo.GetSystemTimeZones(); if (getTimeZones != null) { // add Cache Cache.Add("masterpage_timezones", getTimeZones, null, TimeZoneManager.DateTimeNow.AddDays(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } DdlTimeZones.Items.Clear(); foreach (var zone in getTimeZones) { DdlTimeZones.Items.Add(new ListItem(zone.DisplayName.ToString(), zone.BaseUtcOffset.ToString())); } if (!string.IsNullOrEmpty(currentZone)) { DdlTimeZones.Items.FindByValue(currentZone).Selected = true; } // Insert Langauges in DropDownList DropDownList ddlLang = DdlSelectLang; ddlLang.Items.Clear(); // check cache List <SW_Lang> langs = (List <SW_Lang>)Cache["masterpage_langs"]; LangaugeSystem ls = new LangaugeSystem(); if (langs == null) { langs = ls.GetLangs(); if (langs != null) { // add Cache Cache.Add("masterpage_langs", langs, null, TimeZoneManager.DateTimeNow.AddDays(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } foreach (var lang in langs) { ddlLang.Items.Add(new ListItem(lang.LangName, lang.LangShortname)); } // check cache int?currentLangId = (int?)Cache["masterpage_LangId" + currentLang]; if (currentLangId.HasValue == false) { currentLangId = ls.GetLang(currentLang).LangId; if (currentLangId.HasValue == true) { // add Cache Cache.Add("masterpage_LangId" + currentLang, currentLangId, null, TimeZoneManager.DateTimeNow.AddDays(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } if (!string.IsNullOrEmpty(currentLang)) { DdlSelectLang.Items.FindByValue(currentLang).Selected = true; } // change url for logo (Now with shortlang) CustomSiteMapNode csm = new CustomSiteMapNode(); cSiteMapNode homeCSiteMapNode = csm.GetSiteMapNode(2, currentLangId.Value); string getPath = homeCSiteMapNode.SiteMapNodePath; if (!string.IsNullOrEmpty(homeCSiteMapNode.SiteMapNodeRewrittedPath)) { getPath = homeCSiteMapNode.SiteMapNodeRewrittedPath; } HyperImgLogo.NavigateUrl = getPath; // Insert menu data // check cache List <cSiteMapNode> sitemapnodes = (List <cSiteMapNode>)Cache["masterpage_nodes" + currentLangId]; if (sitemapnodes == null) { sitemapnodes = csm.GetSiteMapNodes((int)currentLangId, false); if (sitemapnodes != null) { // add Cache Cache.Add("masterpage_nodes" + currentLangId, sitemapnodes, null, TimeZoneManager.DateTimeNow.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } CMenu.DataSource = sitemapnodes; CMenu.CurrentUserIP = CurrentUserIP; CMenu.DataBind(); // Properties for metatags event SiteMapNodeMetatagsObject getMapMetaTags = null; cSiteMapNode getCurrentSiteMap = null; int currentSiteMapId; // Get CurrentSiteMapNode getCurrentSiteMap = csm.GetCurrentSiteMapNode((int)currentLangId); currentSiteMapId = getCurrentSiteMap.SiteMapNodeId; // Get Metatags for current cSiteMapNode // check cache getMapMetaTags = (SiteMapNodeMetatagsObject)Cache["masterpage_NodeMetatags" + currentSiteMapId.ToString() + currentLangId.ToString()]; SiteMapNodeMetaTags smm = new SiteMapNodeMetaTags(); if (getMapMetaTags == null) { getMapMetaTags = smm.GetMetaTags(currentSiteMapId, (int)currentLangId); if (getMapMetaTags != null) { // add cache Cache.Add("masterpage_NodeMetatags" + currentSiteMapId.ToString() + currentLangId.ToString(), getMapMetaTags, null, TimeZoneManager.DateTimeNow.AddDays(4), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } // Insert MetaTags string pageTitle = Request.Url.Host; if (getMapMetaTags != null) { MetaAuthor.Content = getMapMetaTags.MetaTagAuthor; MetaCache.Content = getMapMetaTags.MetaTagCache; MetaCopyright.Content = getMapMetaTags.MetaTagCopyright; MetaDescription.Content = getMapMetaTags.MetaTagDescription; MetaKeywords.Content = getMapMetaTags.MetaTagKeywords; MetaLanguage.Content = getMapMetaTags.MetaTagLanguage; MetaPublisher.Content = getMapMetaTags.MetaTagPublisher; MetaRobots.Content = getMapMetaTags.MetaTagRobots; MetaRevisitAfter.Content = getMapMetaTags.MetaTagRevisitAfter; MetaCacheControl.Content = getMapMetaTags.MetaTagCacheControl; pageTitle += " - " + getMapMetaTags.MetaTagTitle; } Page.Title = pageTitle; }
public void ProcessRequest(HttpContext context) { // Set defaults values string data = null; string currentUserIp = "62.107.21.129"; HttpRequest currentR = context.Request; HttpServerUtility currentS = context.Server; int currentLangId; bool isValid = true; bool isUpdateInfoSucces = true; string errorMessage = "succes"; _currentUserIp = currentUserIp; string sLangId = context.Request.QueryString["li"]; if (string.IsNullOrEmpty(sLangId)) { isValid = false; errorMessage = "You forgot langid (querystring li)"; } string userAction = context.Request.QueryString["a"]; if (string.IsNullOrEmpty(userAction)) { isValid = false; errorMessage = "You forgot action (querystring a)"; } // Convert langid querystring to int32 if (!Int32.TryParse(sLangId, out currentLangId)) { isValid = false; errorMessage = "Problem with converting langauge ID (querystring li)"; } #region Go search SearchEngine engine = new SearchEngine(); // default option SearchEngine.UserSearchOption userOption = SearchEngine.UserSearchOption.UpdateUserSearch; #region Set default user data var otherData = new { UserID = (Guid)ANOProfile.GetCookieValues(currentUserIp, context).UserID, UserIpAddress = (string)currentUserIp }; #endregion // Create user default information UserSearchInfo usi = new UserSearchInfo { UserID = otherData.UserID, UserIpAddress = otherData.UserIpAddress }; // CREATE match search! if (userAction == "1") { #region Set ints data (Get data by QueryStrings) var dataConvertToInts = new { clanSkillID = (string)currentR.QueryString["cs"], clanContinentID = (string)currentR.QueryString["cct"], clanCountryID = (string)currentR.QueryString["cc"], searchContinentID = (string)currentR.QueryString["sct"], searchCountryID = (string)currentR.QueryString["sc"], searchGameID = (string)currentR.QueryString["sg"], searchGameModeID = (string)currentR.QueryString["sgt"], searchXvs = (string)currentR.QueryString["sxv"], searchvsX = (string)currentR.QueryString["svx"] }.ToAnonymousObjectCollection(); int MaxIntValue = int.MaxValue; var intdata = new { clanSkillID = (int?)null, clanContinentID = (int)MaxIntValue, clanCountryID = (int)MaxIntValue, searchContinentID = (int)MaxIntValue, searchCountryID = (int?)null, searchGameID = (int)MaxIntValue, searchGameModeID = (int?)null, searchXvs = (int?)null, searchvsX = (int?)null, searchYearTo = (int)MaxIntValue, searchYearFrom = (int)MaxIntValue, searchDayTo = (int)MaxIntValue, searchDayFrom = (int)MaxIntValue, searchMonthTo = (int)MaxIntValue, searchMonthFrom = (int)MaxIntValue, searchHourFrom = (int)MaxIntValue, searchHourTo = (int)MaxIntValue, searchMinutesFrom = (int)MaxIntValue, searchMinutesTo = (int)MaxIntValue }.ToAnonymousObjectCollection(); #endregion #region validate and convert properties to ints for (int i = 0; i < dataConvertToInts.Count; i++) { AnonymousObject o = dataConvertToInts.GetAnonymousObject(i); if (!string.IsNullOrEmpty(o.GetValue <string>())) { int result; if (int.TryParse(o.GetValue <string>(), out result)) { intdata.GetAnonymousObject(o.KeyName).SetValue(result); } } if (intdata.GetAnonymousObject(o.KeyName).GetValue_UnknownObject() != null && Convert.ToInt32(intdata.GetAnonymousObject(o.KeyName).GetValue_UnknownObject()) == MaxIntValue) { isValid = false; errorMessage = "'" + o.KeyName + "' much be more than empty"; } } #endregion #region Set strings data (convert to HtmlEncode strings) var stringData = new { ClanName = (string)currentS.HtmlEncode(currentS.UrlDecode(currentR.QueryString["cn"])), SearchMap = (string)currentS.HtmlEncode(currentS.UrlDecode(currentR.QueryString["sm"])), }; #endregion #region Set datetime data (Replace + and . (This chars is used to avoid problems)) var datetimeData = new { SearchMatchStart = (DateTime)DateTime.ParseExact(currentS.UrlDecode(currentR.QueryString["sfd"]), "dd-MM-yyyy HH:mm:ss", new DateTimeFormatInfo()) }; #endregion // Edit/Create user search information usi.ClanName = stringData.ClanName; usi.ClanSkillID = intdata.GetAnonymousObject("clanSkillID").GetValue <int?>(); usi.ClanContinentID = intdata.GetAnonymousObject("clanContinentID").GetValue <int>(); usi.ClanCountryID = intdata.GetAnonymousObject("clanCountryID").GetValue <int>(); usi.SearchContinentID = intdata.GetAnonymousObject("searchContinentID").GetValue <int>(); usi.SearchCountryID = intdata.GetAnonymousObject("searchCountryID").GetValue <int?>(); usi.SearchGameID = intdata.GetAnonymousObject("searchGameID").GetValue <int>(); usi.SearchGameModeID = intdata.GetAnonymousObject("searchGameModeID").GetValue <int?>(); usi.SearchMap = stringData.SearchMap; usi.SearchXvs = intdata.GetAnonymousObject("searchXvs").GetValue <int>(); usi.SearchvsX = intdata.GetAnonymousObject("searchvsX").GetValue <int>(); usi.SearchMatchStart = new TimeZoneManager(currentUserIp).ConvertDateTimeToUtc(datetimeData.SearchMatchStart); userOption = SearchEngine.UserSearchOption.CreateUserSearch; } // Update user activity if (userAction == "2") { userOption = SearchEngine.UserSearchOption.UpdateUserSearch; // Get UserSearchInfo from database usi.SearchMatchID = ANOProfile.GetCookieValues(usi.UserIpAddress, context).SearchMatchID; isUpdateInfoSucces = engine.GetUserMatchInfo(usi); } if (userAction == "3") { userOption = SearchEngine.UserSearchOption.UpdateActivity; // Get UserSearchInfo from database usi.SearchMatchID = ANOProfile.GetCookieValues(usi.UserIpAddress, context).SearchMatchID; isUpdateInfoSucces = engine.GetUserMatchInfo(usi); if (isValid == true) { errorMessage = "UpdatingUserActivity"; } } // Validate DateTimes if (isUpdateInfoSucces == true) { if (TimeNowValidate(usi.SearchMatchStart) == true) { if (DateNowValidate(usi.SearchMatchStart) != true) { isValid = false; errorMessage = "FromDateIsSmallerThanDateNow"; } } else { isValid = false; errorMessage = "FromTimeIsSmallerThanTimeNow"; } } else { isValid = false; errorMessage = "UserSearchMatchIsNotOnline"; } SearchEngine.SearchNoticeMessage searchNotice = SearchEngine.SearchNoticeMessage.Searching; const int defaultMaxResult = 10; const int defaultPageIndex = 0; const int defaultMaxSearchTimeSeconds = 1200; const int defaultMinUserActivitySeconds = 10; const int defaultFromLastSeconds = 10; List <SearchObject> searchResult = engine.UserSearchMatch(usi, userOption, defaultMaxResult, defaultPageIndex, currentLangId, defaultMaxSearchTimeSeconds, defaultMinUserActivitySeconds, out searchNotice, defaultFromLastSeconds, context); #endregion LangaugeSystem ls = new LangaugeSystem(); string getLang = ls.GetLang(Convert.ToInt32(sLangId)).LangShortname; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(getLang); Thread.CurrentThread.CurrentUICulture = new CultureInfo(getLang); // Create documet and first element called "ss" for "Searchs" XDocument createXmlSearchs = new XDocument( new XDeclaration("1.0", "iso-8859-1", "true"), new XElement("ssi")); // Get element "ssi" for "Searchs" XElement getSearchsElement = createXmlSearchs.Descendants("ssi").Single(); // items element getSearchsElement.Add(new XElement("is")); // Get element "is" for "Items" XElement getItemsElement = getSearchsElement.Descendants("is").Single(); // check the result is 0 if (searchResult != null) { if (searchResult.Count() > 0) { TimeZoneManager mngInfo = new TimeZoneManager(currentUserIp); // Insert/Create data as xml for (int i = 0; i < searchResult.Count(); i++) { var s = searchResult[i]; // Create element data getItemsElement.Add( new XElement("i", new XAttribute("id", s.SearchWarID.ToString()), new XElement("cn", s.ClanName), new XElement("ct", new XAttribute("i", s.ClanContinentData.SearchWarContinentId), s.ClanContinentData.SearchWarContinentName), new XElement("cy", new XAttribute("i", s.ClanCountryData.SearchWarCountrytId), new XAttribute("t", s.ClanCountryData.SearchWarCountryTLD), s.ClanCountryData.SearchWarCountryName), new XElement("cs", new XAttribute("i", s.ClanSkillData != null ? s.ClanSkillData.SearchWarSkillId.ToString() : ""), s.ClanSkillData != null ? s.ClanSkillData.SearchWarSkillName : ""), new XElement("st", new XAttribute("i", s.SearchContinentData.SearchWarContinentId), s.SearchContinentData.SearchWarContinentName), new XElement("sy", new XAttribute("i", s.SearchCountryData != null ? s.SearchCountryData.SearchWarCountrytId.ToString() : ""), new XAttribute("t", s.SearchCountryData != null ? s.SearchCountryData.SearchWarCountryTLD : ""), s.SearchCountryData != null ? s.SearchCountryData.SearchWarCountryName : ""), new XElement("ss", new XAttribute("i", s.SearchSkillData != null ? s.SearchSkillData.SearchWarSkillId.ToString() : ""), s.SearchSkillData != null ? s.SearchSkillData.SearchWarSkillName : ""), new XElement("g", new XAttribute("i", s.SearchGame.SearchWarGameId), s.SearchGame.SearchWarGameName), new XElement("gt", new XAttribute("i", s.SearchGameType != null ? s.SearchGameType.SearchWarGameTypeId.ToString() : ""), s.SearchGameType != null ? s.SearchGameType.SearchWarGameTypeName : ""), new XElement("fd", mngInfo.ConvertDateTimeFromUtc(s.SearchMatchStart).ToString()), new XElement("x", s.SearchXvs), new XElement("y", s.SearchvsX), new XElement("m", s.SearchMap))); } } else { if (isValid == true) { isValid = false; errorMessage = "NoResults"; if (userAction == "3") { isValid = true; errorMessage = "UpdatingUserActivity"; } } } } else { if (isValid == true) { isValid = false; errorMessage = "NoResults"; if (userAction == "3") { isValid = true; errorMessage = "UpdatingUserActivity"; } } } // write status for result getSearchsElement.Add(new XElement("status", new XAttribute("bool", isValid.ToString()), errorMessage)); // Write/save data StringWriter sw = new StringWriter(); XmlWriter w = XmlWriter.Create(sw); createXmlSearchs.Save(w); w.Close(); data = sw.ToString(); sw.Close(); context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = Encoding.UTF8; context.Response.Write(XmlWhiteSpaceModule.RemoveWhitespace(data)); // release it context.Response.Flush(); engine.CleanUpAndClose(); }