Пример #1
0
    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();
    }
Пример #2
0
        /// <summary>
        /// Searching after path in database
        /// </summary>
        /// <param name="path">Insert path</param>
        /// <param name="siteMapNodeId"></param>
        /// <param name="langId">Insert langId</param>
        /// <returns>Return anonymous object</returns>
        protected cSiteMapNode GetSiteMapNode_Single(int siteMapNodeId,
                                                     int langId)
        {
            Searchwar_netEntities db = new Searchwar_netEntities();

            // Get UserRoles
            string[] roleNamesByUser = Roles.GetRolesForUser();

            LangaugeSystem ls            = new LangaugeSystem();
            string         langShortName = ls.CurrentLang;

            // Get the cSiteMapNode by the "path"
            cSiteMapNode cSiteMapNodeNode = (from s in db.SW_SiteMapNode
                                             join sd in db.SW_SiteMapNodeData
                                             on s.SiteMapNodeId equals sd.SiteMapNodeId
                                             where s.SiteMapNodeId == siteMapNodeId &&
                                             sd.LangId == langId &&
                                             (s.SW_SiteMapNodeRoles.Count() != 0 ? s.SW_SiteMapNodeRoles.Where(r => roleNamesByUser.Contains(r.aspnet_Roles.RoleName)).Count() > 0 : true) == true
                                             select new cSiteMapNode
            {
                SiteMapNodeId = (int)s.SiteMapNodeId,
                SiteMapNodeSubId = (int?)s.SiteMapNodeSubId,
                SiteMapNodePath = (string)s.SiteMapNodePath,
                SiteMapNodeRewrittedPath = (string)sd.SiteMapNodeRewriteUrl == null ? "" : "~/" + sd.SiteMapNodeRewriteUrl,
                SiteMapNodeAddedUserId = (Guid)s.SiteMapNodeAddedUserId,
                SiteMapNodeEditUserId = (Guid)s.SiteMapNodeEditUserId,
                SiteMapNodeShow = (bool)s.SiteMapNodeShow,
                SiteMapNodeAddedDate = (DateTime)s.SiteMapNodeAddedDate,
                SiteMapNodeEditDate = (DateTime)s.SiteMapNodeEditDate,
                SiteMapNodeTitle = (string)sd.SiteMapNodeTitle,
                SiteMapNodeSort = (int)s.SiteMapNodeSort,
                LangId = (int)sd.LangId,
                SiteMapNodeRoles = s.SW_SiteMapNodeRoles.Where(r => r.SiteMapNodeId == s.SiteMapNodeId)
                                   // Check if user is allowed to see SiteMapNodes
            }).SingleOrDefault <cSiteMapNode>();

            // Checking cSiteMapNode is in databasen
            if (cSiteMapNodeNode != null)
            {
                return(cSiteMapNodeNode);
            }
            else
            {
                throw (new ArgumentNullException("siteMapNodeId", "Cant find '" + siteMapNodeId + "' in database"));
            }
        }
Пример #3
0
        /// <summary>
        /// Get all MainPaths (MainPaths is paths without a SiteMapSubId)
        /// </summary>
        /// <returns>Return a list of anonymous objects</returns>
        protected List <cSiteMapNode> GetMainSiteMapNodes(int langId,
                                                          bool siteMapNodeShow)
        {
            Searchwar_netEntities db = new Searchwar_netEntities();

            // Get UserRoles
            LangaugeSystem ls = new LangaugeSystem();

            string[] roleNamesByUser = Roles.GetRolesForUser();
            string   langShortName   = ls.CurrentLang;

            // Get all SiteMaps
            return((from s in db.SW_SiteMapNode
                    join sd in db.SW_SiteMapNodeData
                    on s.SiteMapNodeId equals sd.SiteMapNodeId
                    where s.SiteMapNodeSubId == null &&
                    (siteMapNodeShow == true ? true : s.SiteMapNodeShow == true) &&
                    sd.LangId == langId &&
                    // Check if user is allowed to see SiteMaps
                    (s.SW_SiteMapNodeRoles.Count() != 0
                                   ? s.SW_SiteMapNodeRoles.Where(r => roleNamesByUser.Contains(r.aspnet_Roles.RoleName)).
                     Count() > 0
                                   : true) == true
                    orderby s.SiteMapNodeSort
                    select new cSiteMapNode
            {
                SiteMapNodeId = (int)s.SiteMapNodeId,
                SiteMapNodePath = (string)s.SiteMapNodePath,
                SiteMapNodeRewrittedPath =
                    String.IsNullOrEmpty(sd.SiteMapNodeRewriteUrl)
                                               ? ""
                                               : (string)"~/" + sd.SiteMapNodeRewriteUrl,
                SiteMapNodeAddedUserId = (Guid)s.SiteMapNodeAddedUserId,
                SiteMapNodeEditUserId = (Guid)s.SiteMapNodeEditUserId,
                SiteMapNodeShow = (bool)s.SiteMapNodeShow,
                SiteMapNodeAddedDate = (DateTime)s.SiteMapNodeAddedDate,
                SiteMapNodeEditDate = (DateTime)s.SiteMapNodeEditDate,
                SiteMapNodeTitle = (string)sd.SiteMapNodeTitle,
                LangId = (int)sd.LangId,
                SiteMapNodeRoles =
                    s.SW_SiteMapNodeRoles.Where(r => r.SiteMapNodeId == s.SiteMapNodeId)
            }).ToList <cSiteMapNode>());
        }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Set values of current lang
        LangaugeSystem ls = new LangaugeSystem();

        CurrentLang   = ls.CurrentLang;
        CurrentLangId = ls.CurrentLangId;

        if (CurrentLang.ToLower() == "da-dk")
        {
            _timePickerHourType = true;
        }

        if (!Page.IsPostBack)
        {
            // Create/bind search control
            Wsc.CurrentLang   = CurrentLang;
            Wsc.CurrentLangId = CurrentLangId;
            Wsc.CurrentUserIP = CurrentUserIP;
            Wsc.DataBind();

            // Bind newest match searchs
            const int defaultFromLastSeconds = 10;
            // check cache
            List <NewestSearchObject> newestMatchSearchs = (List <NewestSearchObject>)Cache["default_newestMatchSearch"];

            if (newestMatchSearchs == null)
            {
                newestMatchSearchs = SearchEngine.GetNewestMatchSearchs(3, CurrentLangId, defaultFromLastSeconds);

                // add Cache
                Cache.Add("default_newestMatchSearch", newestMatchSearchs, null, TimeZoneManager.DateTimeNow.AddSeconds(defaultFromLastSeconds),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }

            Wnms.DataSource = newestMatchSearchs;
            Wnms.DataBind();

            // Bind blog news
            // Check cache of blog
            BlogObject newestBlog = (BlogObject)Cache["Default_Blogs" + CurrentLangId];
            if (newestBlog == null)
            {
                BlogSystem Bs = new BlogSystem();
                newestBlog = Bs.GetBlogs(CurrentLangId, 0, 1).FirstOrDefault();
                if (newestBlog != null)
                {
                    // add Cache for blog
                    Cache.Add("Default_Blogs" + CurrentLangId, newestBlog, null, TimeZoneManager.DateTimeNow.AddHours(1),
                              System.Web.Caching.Cache.NoSlidingExpiration,
                              System.Web.Caching.CacheItemPriority.Normal,
                              null);
                }
            }

            if (newestBlog != null)
            {
                H4BlogTitle.InnerText = newestBlog.BlogTitle;
                LblBlogDateAdded.Text = newestBlog.BlogAddedDate.ToString();
                LblBlogText.Text      = newestBlog.BlogText + "... ";
            }
            else
            {
                PnlNewestBlog.Visible = false;
            }
        }
    }
Пример #5
0
    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);
        }
    }
Пример #6
0
    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 override void DataBind()
    {
        LangaugeSystem ls = new LangaugeSystem();

        CurrentUserCountry = ls.CurrentUserCountry;

        TxtClanName.Text = "GuestClan" + new Random().Next(1, 9999).ToString();


        SkillsSystem ss = new SkillsSystem();
        // !Skills!
        // check cache
        List <dynamic> getSkills = (List <dynamic>)Cache["WebSearch_getSkills" + CurrentLangId];

        if (getSkills == null)
        {
            getSkills = ss.GetSkills(CurrentLangId);
            if (getSkills != null)
            {
                // add Cache
                Cache.Add("WebSearch_getSkills" + CurrentLangId, getSkills, null, TimeZoneManager.DateTimeNow.AddDays(5),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }

        DdlClanSkill.Items.Clear();
        DdlClanSkill.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(), string.Empty));
        DdlSearchSkill.Items.Clear();
        DdlSearchSkill.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(), string.Empty));
        foreach (dynamic g in getSkills)
        {
            DdlClanSkill.Items.Add(new ListItem(g.SearchWarSkillName, g.SearchWarSkillId.ToString()));
            DdlSearchSkill.Items.Add(new ListItem(g.SearchWarSkillName, g.SearchWarSkillId.ToString()));

            // DdlSearchSkill.Items.Add(new ListItem(currentSkill.GetAnonymousObject("SearchWarSkillName").GetValue<string>(), currentSkill.GetAnonymousObject("SearchWarSkillId").GetValue<int>().ToString()));
        }

        // !Games!
        // check cache
        GamesSystem             gs       = new GamesSystem();
        List <SW_SearchWarGame> getGames = (List <SW_SearchWarGame>)Cache["WebSearch_getGames"];

        if (getGames == null)
        {
            getGames = gs.GetGames().OrderBy(g => g.SearchWarGameName).ToList <SW_SearchWarGame>();
            if (getGames != null)
            {
                // add Cache
                Cache.Add("WebSearch_getGames", getGames, null, TimeZoneManager.DateTimeNow.AddDays(1),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }

        DdlSearchGame.Items.Clear();
        DdlSearchGame.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(), string.Empty));
        for (int i = 0; i < getGames.Count(); i++)
        {
            var g = getGames[i];
            DdlSearchGame.Items.Add(new ListItem(g.SearchWarGameName, g.SearchWarGameId.ToString()));
        }


        DdlSearchGameType.Items.Clear();
        DdlSearchGameType.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(), string.Empty));
        HfSearchGameType.Value = DdlSearchGameType.Items.FindByText(GetLocalResourceObject("ListItemChooseResource1").ToString()).Value;


        // !Continents!
        // check cache
        ContinentSystem cs = new ContinentSystem();

        List <dynamic> getContinents = (List <dynamic>)Cache["WebSearch_getContinents" + CurrentLangId];

        if (getContinents == null)
        {
            getContinents = cs.GetContinents(CurrentLangId);
            if (getContinents != null)
            {
                // add Cache
                Cache.Add("WebSearch_getContinents" + CurrentLangId, getContinents, null, TimeZoneManager.DateTimeNow.AddDays(1),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }
        if (getContinents != null && getContinents.Count > 0)
        {
            DdlClanContinent.Items.Clear();
            DdlClanContinent.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(),
                                                    string.Empty));

            for (int i = 0; i < getContinents.Count(); i++)
            {
                dynamic currentContinent = getContinents[i];

                DdlClanContinent.Items.Add(
                    new ListItem(currentContinent.SearchWarContinentName,
                                 currentContinent.SearchWarContinentId.ToString()));
            }
            DdlClanContinent.DataBind();


            DdlSearchContinent.Items.Clear();
            DdlSearchContinent.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(),
                                                      string.Empty));

            for (int i = 0; i < getContinents.Count(); i++)
            {
                dynamic currentContinent = getContinents[i];

                DdlSearchContinent.Items.Add(
                    new ListItem(currentContinent.SearchWarContinentName,
                                 currentContinent.SearchWarContinentId.ToString()));
            }
            DdlSearchContinent.DataBind();
        }


        // !Countries!
        CountrySystem  CS           = new CountrySystem();
        List <dynamic> getCountries = CS.GetCountries(CurrentLangId);

        if (getCountries != null && getCountries.Count > 0)
        {
            // find contient for usercountry
            for (int i = 0; i < getCountries.Count(); i++)
            {
                dynamic currentCountry = getCountries[i];

                if (CurrentUserCountry ==
                    currentCountry.SearchWarCountryTLD)
                {
                    DdlClanContinent.Items.FindByValue(
                        currentCountry.SearchWarContinentId.ToString()).
                    Selected = true;
                }
            }
            // Remove countries there is not in the continent
            getCountries =
                getCountries.Where(
                    C =>
                    C.SearchWarContinentId ==
                    Convert.ToInt32(DdlClanContinent.SelectedValue)).ToList <dynamic>();



            // Add "Select" for dropdownbox
            DdlClanCountry.Items.Clear();
            DdlClanCountry.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(),
                                                  string.Empty));

            // Loop countries
            for (int i = 0; i < getCountries.Count(); i++)
            {
                dynamic currentCountry = getCountries[i];

                // Add Country to dropdownbox
                DdlClanCountry.Items.Add(
                    new ListItem(currentCountry.SearchWarCountryName,
                                 currentCountry.SearchWarCountryId.ToString()));

                // Select current country
                if (CurrentUserCountry ==
                    currentCountry.SearchWarCountryTLD)
                {
                    // Set current country in dropdownbox
                    DdlClanCountry.Items.FindByValue(
                        currentCountry.SearchWarCountryId.ToString()).Selected
                        = true;

                    // set value in hiddenfield
                    HfClanCountry.Value =
                        DdlClanCountry.Items.FindByValue(currentCountry.SearchWarCountryId.ToString()).
                        Value;
                }
            }


            // Add "Select" for dropdownbox
            DdlSearchCountry.Items.Clear();
            DdlSearchCountry.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(),
                                                    string.Empty));
            // Loop all countries
            for (int i = 0; i < getCountries.Count(); i++)
            {
                dynamic currentCountry = getCountries[i];

                // Add country to dropdownbox
                DdlSearchCountry.Items.Add(
                    new ListItem(currentCountry.SearchWarCountryName,
                                 currentCountry.SearchWarCountryId.ToString()));

                // Select that current country
                if (CurrentUserCountry ==
                    currentCountry.SearchWarCountryTLD)
                {
                    // Set current continent for country
                    DdlSearchContinent.Items.FindByValue(
                        currentCountry.SearchWarContinentId.ToString()).Selected = true;

                    // set value for country ("empty" because the system need to search after more than one country)
                    HfSearchCountry.Value = "";
                }
            }
        }


        // !Players!
        const int maxPlayer = 16;

        DdlSearchXvsX.Items.Clear();
        for (int p = 1; p <= maxPlayer; p++)
        {
            DdlSearchXvsX.Items.Add(new ListItem(p.ToString() + GetLocalResourceObject("LblVersusResource1.Text") + p.ToString(), p.ToString() + "-" + p.ToString()));
        }
        DdlSearchXvsX.Items.FindByValue("5-5").Selected = true;

        // !DATETIME!
        TimeZoneManager timeMng = new TimeZoneManager(CurrentUserIP);

        DateTime datetimeNow         = timeMng.ConvertDateTimeFromUtc(TimeZoneManager.DateTimeNow).AddMinutes(20);
        DateTime getDateTimePlusHour = datetimeNow.AddHours(1);

        txtFromDate.Text = datetimeNow.Day.ToString("00") + "/" + datetimeNow.Month.ToString("00") + "/" + datetimeNow.Year.ToString("0000");
        amorpm.InnerText = datetimeNow.ToString("tt");
        if (CurrentLang.ToLower() == "da-dk")
        {
            txtFromTime.Text = datetimeNow.ToString("HH:mm");
            amorpm.Attributes.Add("style", "display: none");
        }
        else
        {
            txtFromTime.Text = datetimeNow.ToString("hh:mm");
        }
    }
Пример #8
0
    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();
        }