Exemple #1
0
        /// <summary>
        /// Vlidate date
        /// </summary>
        /// <param name="fromUtcDate">from datetime</param>
        /// <param name="toDate">to datetime (Can be null if you only want to validate with datetime now)</param>
        /// <param name="timeValidate">to validate time "00:00:00" then true</param>
        /// <returns>DateValidateMsg</returns>
        public DateValidateMsg ValidateDates(DateTime?fromUtcDate,
                                             bool timeValidate,
                                             string currentUserIp)
        {
            DateTime dateTimeNow = TimeZoneManager.DateTimeNow;

            TimeZoneManager mngInfo = new TimeZoneManager(currentUserIp);


            fromUtcDate = fromUtcDate.Value;

            if (fromUtcDate.HasValue)
            {
                if (timeValidate == true)
                {
                    return(fromUtcDate > new DateTime(dateTimeNow.Year, dateTimeNow.Month, dateTimeNow.Day, dateTimeNow.Hour, dateTimeNow.Minute, 0) ? DateValidateMsg.Valid : DateValidateMsg.FromTimeIsSmallerThanDateTimeNow);
                }
                else
                {
                    return(fromUtcDate >= new DateTime(dateTimeNow.Year, dateTimeNow.Month, dateTimeNow.Day, 0, 0, 0)
                                   ? DateValidateMsg.Valid
                                   : DateValidateMsg.FromDateIsSmallerThanDateTimeNow);
                }
            }

            return(DateValidateMsg.Empty);
        }
Exemple #2
0
        private void RenderBrowserMode(ComponentController paComponentController)
        {
            String lcBase64RegionalConfig;
            String lcBase64AppManifestConfig;
            String lcBase64JSONTable;

            lcBase64RegionalConfig    = General.Base64Encode(clSettingManager.RegionalConfigStr);
            lcBase64AppManifestConfig = General.Base64Encode(General.JSONSerialize(clAppManifestDictionary));
            lcBase64JSONTable         = General.Base64Encode(TimeZoneManager.GetInstance().GetJSONTable());

            IncludeExternalLinkFiles(paComponentController);

            paComponentController.AddElementType(ComponentController.ElementType.Control);
            paComponentController.AddBareAttribute(ctSETRegionalConfig, lcBase64RegionalConfig);
            paComponentController.AddBareAttribute(ctTBLAppManifest, lcBase64AppManifestConfig);
            paComponentController.AddElementAttribute(ComponentController.ElementAttribute.ea_OptionList, lcBase64JSONTable);
            paComponentController.AddAttribute(HtmlAttribute.Class, ctCLSWidControlPOSGeneralSetting);
            paComponentController.RenderBeginTag(HtmlTag.Div);

            RenderContainer(paComponentController);

            paComponentController.RenderEndTag();

            RenderExternalComponentsContainer(paComponentController);
        }
        // ToCalendarTime(nn::time::PosixTime time, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (nn::time::CalendarTime, nn::time::sf::CalendarAdditionalInfo)
        public ResultCode ToCalendarTime(ServiceCtx context)
        {
            long posixTime      = context.RequestData.ReadInt64();
            long bufferPosition = context.Request.SendBuff[0].Position;
            long bufferSize     = context.Request.SendBuff[0].Size;

            if (bufferSize != 0x4000)
            {
                // TODO: find error code here
                Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)");

                throw new InvalidOperationException();
            }

            TimeZoneRule rules = MemoryHelper.Read <TimeZoneRule>(context.Memory, bufferPosition);

            ResultCode resultCode = TimeZoneManager.ToCalendarTime(rules, posixTime, out CalendarInfo calendar);

            if (resultCode == 0)
            {
                context.ResponseData.WriteStruct(calendar);
            }

            return(resultCode);
        }
Exemple #4
0
 public StatsCommand(long chatId, StatsType type)
 {
     ChatId           = chatId.ToString("D");
     _timeZoneManager = new TimeZoneManager();
     InitDates(DateTimeOffset.UtcNow, type);
     Type = type;
 }
        // ToPosixTime(nn::time::CalendarTime calendarTime, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (u32 outCount, buffer<nn::time::PosixTime, 0xa>)
        public ResultCode ToPosixTime(ServiceCtx context)
        {
            long inBufferPosition = context.Request.SendBuff[0].Position;
            long inBufferSize     = context.Request.SendBuff[0].Size;

            CalendarTime calendarTime = context.RequestData.ReadStruct <CalendarTime>();

            if (inBufferSize != 0x4000)
            {
                // TODO: find error code here
                Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{inBufferSize:x} (expected 0x4000)");

                throw new InvalidOperationException();
            }

            TimeZoneRule rules = MemoryHelper.Read <TimeZoneRule>(context.Memory, inBufferPosition);

            ResultCode resultCode = TimeZoneManager.ToPosixTime(rules, calendarTime, out long posixTime);

            if (resultCode == 0)
            {
                long outBufferPosition = context.Request.RecvListBuff[0].Position;
                long outBufferSize     = context.Request.RecvListBuff[0].Size;

                context.Memory.WriteInt64(outBufferPosition, posixTime);
                context.ResponseData.Write(1);
            }

            return(resultCode);
        }
Exemple #6
0
        public ChatSystem(HttpContext context,
                          string currentUserIP)
        {
            mngInfo            = new TimeZoneManager(currentUserIP);
            this.context       = context;
            this.currentUserIp = currentUserIP;

            user = ANOProfile.GetCookieValues(currentUserIP);
        }
Exemple #7
0
        private InsertusiResult CreateUserSearch(UserSearchInfo usi)
        {
            TimeZoneManager mngInfo     = new TimeZoneManager(usi.UserIpAddress);
            DateTime        nowDatetime = TimeZoneManager.DateTimeNow;


            List <SW_SearchWar> getUserMatchs = (from s in db.SW_SearchWar
                                                 where s.SearchWarUserID == usi.UserID &&
                                                 s.SearchWarIsRunning == true
                                                 select s).ToList();

            foreach (SW_SearchWar s in getUserMatchs)
            {
                s.SearchWarIsRunning = false;
            }

            SW_SearchWar createusi = new SW_SearchWar
            {
                SearchWarId                = Guid.NewGuid(),
                SearchWarClanName          = usi.ClanName,
                SearchWarClanContinentId   = usi.ClanContinentID,
                SearchWarClanCountryId     = usi.ClanCountryID,
                SearchWarClanSkillId       = usi.SearchSkillID,
                SearchWarSearchGameId      = usi.SearchGameID,
                SearchWarSearchGameTypeId  = usi.SearchGameModeID,
                SearchWarSearchContinentId = usi.SearchContinentID,
                SearchWarSearchCountryId   = usi.SearchCountryID,
                SearchWarSearchMap         = usi.SearchMap,
                SearchWarIsRunning         = true,
                SearchWarSearchSkillId     = usi.SearchSkillID,
                SearchWarSearchvsX         = usi.SearchvsX,
                SearchWarSearchXvs         = usi.SearchXvs,
                SearchWarSearchMatchStart  = usi.SearchMatchStart,
                SearchWarUserIpAddress     = usi.UserIpAddress,
                SearchWarUserID            = usi.UserID,
                SearchWarAddedDate         = nowDatetime,
                SearchWarEditDate          = nowDatetime
            };

            db.SW_SearchWar.AddObject(createusi);
            db.SaveChanges();

            usi.SearchMatchID       = createusi.SearchWarId;
            _context.Session["usi"] = usi;

            return(InsertusiResult.Done);
        }
Exemple #8
0
 private void RenderExternalComponents(ComponentController paComponentController)
 {
     RenderSelectionPanel(paComponentController, ctPNTTimeZone, ctDYTTimeZoneListTitle, TimeZoneManager.GetInstance().GetTimeZoneDictionary());
     RenderSelectionPanel(paComponentController, ctPNTDateFormat, ctDYTDateFormatListTitle, clSettingManager.GetDateFormatOptionDictionary());
     RenderImagePopUp(paComponentController);
 }
Exemple #9
0
 public JoinTimeNode()
 {
     TimeZoneManager.Update();
 }
Exemple #10
0
 public AsTimeValueUnixNode()
 {
     TimeZoneManager.Update();
 }
Exemple #11
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);
        }
    }
    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");
        }
    }
        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();
        }
Exemple #14
0
 public AsTimeStringUnixNode()
 {
     TimeZoneManager.Update();
 }
Exemple #15
0
 public UpdateTimezoneNode()
 {
     TimeZoneManager.Update();
 }
Exemple #16
0
 public AsTimeValueDecimalAdvancedNode()
 {
     TimeZoneManager.Update();
 }
 public static TimeZoneInfo GetCurrentTimeZone(this Controller controller)
 {
     return(TimeZoneManager.GetCurrent(controller.Session));
 }
 public static void SetCurrentTimeZone(this Controller controller, TimeZoneInfo timeZone)
 {
     TimeZoneManager.SetCurrent(controller.Session, timeZone);
 }
Exemple #19
0
 public ITimeZoneServiceForPsc(TimeZoneManager timeZoneManager, bool writePermission)
 {
     _timeZoneManager = timeZoneManager;
     _writePermission = writePermission;
 }
 public void CallTimeZoneManager()
 {
     var tzm = new TimeZoneManager();
     tzm.ShowDialog();
 }