public StatReferrerCollection StatsGetPhotostreamReferrers(DateTime date, string domain, int perPage, int page)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.stats.getPhotostreamReferrers");
     dictionary.Add("date", date.ToUnixTimestamp());
     dictionary.Add("domain", domain);
     if (perPage != 0) dictionary.Add("per_page", perPage.ToString(CultureInfo.InvariantCulture));
     if (page != 0) dictionary.Add("page", page.ToString(CultureInfo.InvariantCulture));
     return GetResponse<StatReferrerCollection>(dictionary);
 }
		public void ToUnixTimestamp_LocalTimeValues(int year, int month, int day, double expectedResult)
		{
			// Arrange
			var given = new DateTime(year, month, day);

			// Act, Assert
			given.ToUnixTimestamp().Should().Be(expectedResult);
		}
 public Stats StatsGetPhotostreamStats(DateTime date)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.stats.getPhotostreamStats");
     dictionary.Add("date", date.ToUnixTimestamp());
     return GetResponse<Stats>(dictionary);
 }
 public StatDomainCollection StatsGetPhotosetDomains(DateTime date, string photosetId, int page, int perPage)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.stats.getPhotosetDomains");
     dictionary.Add("date", date.ToUnixTimestamp());
     if (photosetId != null) dictionary.Add("photoset_id", photosetId);
     if (page != 0) dictionary.Add("page", page.ToString(CultureInfo.InvariantCulture));
     if (perPage != 0) dictionary.Add("per_page", perPage.ToString(CultureInfo.InvariantCulture));
     return GetResponse<StatDomainCollection>(dictionary);
 }
 public Stats StatsGetCollectionStats(DateTime date, string collectionId)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.stats.getCollectionStats");
     dictionary.Add("date", date.ToUnixTimestamp());
     dictionary.Add("collection_id", collectionId);
     return GetResponse<Stats>(dictionary);
 }
 public PhotoCollection PhotosRecentlyUpdated(DateTime minDate, PhotoSearchExtras extras, int page, int perPage)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.photos.recentlyUpdated");
     dictionary.Add("min_date", minDate.ToUnixTimestamp());
     if (extras != PhotoSearchExtras.None) dictionary.Add("extras", UtilityMethods.ExtrasToString(extras));
     if (page != 0) dictionary.Add("page", page.ToString(CultureInfo.InvariantCulture));
     if (perPage != 0) dictionary.Add("per_page", perPage.ToString(CultureInfo.InvariantCulture));
     return GetResponse<PhotoCollection>(dictionary);
 }
Example #7
0
 protected void byCreatedAt(DateTime startCreatedAt, DateTime endCreatedAt)
 {
     this.createdAt = String.Format("{0}-{1}", startCreatedAt.ToUnixTimestamp(), endCreatedAt.ToUnixTimestamp());
 }
Example #8
0
 public ExpireAtCommand(String key, DateTime expiration) :
     this(key, expiration.ToUnixTimestamp())
 {
 }
        public FlowDataView GetCoinFlow(string game, AWSRegion region, DateTime start, DateTime end)
        {
            GameMonitoringConfig GameToGet = Games.Instance.GetMonitoredGames().Where(x => x.ShortTitle == game).FirstOrDefault();
            FlowDataView chart = new FlowDataView() {
                Inflows = GetFlowData(GameToGet.Id, TransactionType.AddCredits, start, end),
                Outflows = GetFlowData(GameToGet.Id, TransactionType.Purchase, start, end),
                StartDate = start.ToUnixTimestamp() * 1000
            };

            return chart;
        }
 public async Task AddIpBan(string ip, DateTime bandate, DateTime unbandate, string bannedby, string banreason)
 {
     await ExecuteNonQuery("INSERT INTO `ip_banned` (ip, bandate, unbandate, bannedby, banreason) VALUES (@ip, @bandate, @unbandate, @bannedby, @banreason)",
         new MySqlParameter("@ip", ip), new MySqlParameter("@bandate", bandate.ToUnixTimestamp()), new MySqlParameter("@unbandate", unbandate.ToUnixTimestamp()),
         new MySqlParameter("@bannedby", bannedby), new MySqlParameter("@banreason", banreason));
 }
Example #11
0
            public void ToUnixTimeStampTest()
            {
                var testDate = new DateTime(2014, 1, 1);
                const long expectedTimestamp = 1388534400;

                Assert.Equal(expectedTimestamp, testDate.ToUnixTimestamp());
            }
Example #12
0
        /// <summary>
        /// Initializes a new Snapshot, with the specified Date it was Posted
        /// </summary>
        /// <param name="Snapshot">The snapshot source</param>
        /// <param name="Date">The original date in which this snapshot was created</param>
        public Snapshot(string Snapshot, DateTime Date, StatsDatabase Database)
        {
            // Load out database connection
            this.Driver = Database;
            this.Date = Date;
            this.TimeStamp = Date.ToUnixTimestamp();

            // Get our snapshot key value pairs
            string[] Data = Snapshot.Split('\\');
            Snapshot = null;

            // Check for invalid snapshot string. All snapshots have at least 36 data pairs,
            // and has an Even number of data sectors. We must also have an "End of File" Sector
            if (Data.Length < 36 || Data.Length % 2 != 0 || !Data.Contains("EOF"))
            {
                IsValid = false;
                return;
            }

            // Define if we are central update. the "cdb_update" variable must be the LAST sector in snapshot
            this.IsCentralUpdate = (Data[Data.Length - 2] == "cdb_update" && Data[Data.Length - 1] == "1");

            // Server data
            this.ServerPrefix = Data[0];
            this.ServerName = Data[1];
            this.ServerPort = int.Parse(Data[3].ToString());
            this.QueryPort = int.Parse(Data[5].ToString());

            // Map Data
            this.MapName = Data[7];
            this.MapId = int.Parse(Data[9]);
            this.MapStart = (int)Convert.ToDouble(Data[11], CultureInfo.InvariantCulture.NumberFormat);
            this.MapEnd = (int)Convert.ToDouble(Data[13], CultureInfo.InvariantCulture.NumberFormat);

            // Misc Data
            this.WinningTeam = int.Parse(Data[15]);
            this.GameMode = int.Parse(Data[17]);
            this.Mod = Data[21];
            this.PlayersConnected = int.Parse(Data[23]);

            // Army Data
            this.WinningArmy = int.Parse(Data[25]);
            this.Team1Army = int.Parse(Data[27]);
            this.Team1Tickets = int.Parse(Data[29]);
            this.Team2Army = int.Parse(Data[31]);
            this.Team2Tickets = int.Parse(Data[33]);

            // Setup snapshot variables
            PlayerData = new Dictionary<int, Dictionary<string, string>>();
            KillData = new Dictionary<int, Dictionary<string, string>>();

            // Check for custom map, with no ID
            if (MapId == 99)
            {
                IsCustomMap = true;

                // Check for existing map data
                List<Dictionary<string, object>> Rows = Driver.Query("SELECT id FROM mapinfo WHERE name=@P0", MapName);
                if (Rows.Count == 0)
                {
                    // Create new MapId. Id's 700 - 1000 are reserved for unknown maps in the Constants.py file
                    // There should never be more then 300 unknown map id's, considering 1001 is the start of KNOWN
                    // Custom mod map id's
                    Rows = Driver.Query("SELECT COALESCE(MAX(id), 699) AS id FROM mapinfo WHERE id BETWEEN 700 AND 1000");
                    MapId = Int32.Parse(Rows[0]["id"].ToString()) + 1;

                    // Insert map data, so we dont lose this mapid we generated
                    Driver.Execute("INSERT INTO mapinfo(id, name) VALUES (@P0, @P1)", MapId, MapName);
                }
                else
                    MapId = Int32.Parse(Rows[0]["id"].ToString());
            }
            else
                IsCustomMap = (MapId >= 700);

            // Do player snapshots, sector 36 is first player
            for (int i = 36; i < Data.Length; i += 2)
            {
                // Format: "DataKey_PlayerId". PlayerId is not the PID, but rather
                // the player INDEX
                string[] Parts = Data[i].Split('_');

                // Ignore uncomplete snapshots
                if (Parts.Length == 1)
                {
                    // Unless we are at the end of file, IF there is no PID
                    // Given for an item, the snapshot is invalid!
                    if (Parts[0] == "EOF")
                        break;
                    else
                        IsValid = false;
                    return;
                }

                // If the item key is "pID", then we have a new player record
                int id = int.Parse(Parts[1]);
                if (Parts[0] == "pID")
                {
                    PlayerData.Add(id, new Dictionary<string, string>());
                    KillData.Add(id, new Dictionary<string, string>());
                }

                // Kill and death data has its own array key
                if (Parts[0] == "mvks")
                    continue;

                if (Parts[0] == "mvns")
                    KillData[id].Add(Data[i + 1], Data[i + 3]);
                else
                    PlayerData[id].Add(Parts[0], Data[i + 1]);
            }

            // Set that we appear to be valid
            IsValid = true;
        }
Example #13
0
 protected void byUpdatedAt(DateTime startUpdatedAt, DateTime endUpdatedAt)
 {
     this.updatedAt = String.Format("{0}-{1}", startUpdatedAt.ToUnixTimestamp(), endUpdatedAt.ToUnixTimestamp());
 }
        public bool Edit(string name, DateTime dateOfStart, DateTime dateOfEnd, Teacher teacher, IRoom room, Group group)
        {
            if (EditReservation(Ptr, name, dateOfStart.ToUnixTimestamp(), dateOfEnd.ToUnixTimestamp(), teacher.Ptr, room.Ptr, group.Ptr))
            {
                Teacher = App.Teachers.SingleOrDefault(x => x.Ptr == GetReservationTeacher(Ptr));
                Room = App.Rooms.SingleOrDefault(x => x.Ptr == GetReservationRoom(Ptr));
                Group = App.Groups.SingleOrDefault(x => x.Ptr == GetReservationGroup(Ptr));

                OnPropertyChanged("Name");
                OnPropertyChanged("DateOfStart");
                OnPropertyChanged("DateOfEnd");
                InvokePropertyChanged();

                return true;
            }

            return false;
        }
        public FlowDataView GetCoinFlowByCat(GameMonitoringConfig game, AWSRegion region, DateTime start, DateTime end)
        {
            FlowDataView chart = new FlowDataView()
            {
                Inflows = GetFlowDataByCategory(game.Id, TransactionType.AddCredits, start, end),
                Outflows = GetFlowDataByCategory(game.Id, TransactionType.Purchase, start, end),
                StartDate = start.ToUnixTimestamp() * 1000
            };

            return chart;
        }
 private static bool CheckCollisionsBeforeAdding(DateTime dateOfStart, DateTime dateOfEnd, Teacher teacher, IRoom room, Group group)
 {
     return CheckCollisions(dateOfStart.ToUnixTimestamp(), dateOfEnd.ToUnixTimestamp(), teacher.Ptr, room.Ptr, group.Ptr);
 }
Example #17
0
        /// <summary>
        /// Initializes a new Snapshot, with the specified Date it was Posted
        /// </summary>
        /// <param name="Snapshot">The snapshot source</param>
        /// <param name="Date">The original date in which this snapshot was created</param>
        public Snapshot(string Snapshot, DateTime Date)
        {
            // Load out database connection
            this.Driver = ASPServer.Database.Driver;
            this.Date = Date;
            this.TimeStamp = Date.ToUnixTimestamp();

            // Get our snapshot key value pairs
            string[] Data = Snapshot.Split('\\');
            Snapshot = null;

            // Check for invalid snapshot string
            if (Data.Length < 36 || Data.Length % 2 != 0)
            {
                IsValidSnapshot = false;
                return;
            }

            // Make sure we have an End of file
            if (Data[Data.Length - 2] != "EOF" && Data[Data.Length - 4] != "EOF")
            {
                IsValidSnapshot = false;
                return;
            }

            // Define if we are central update
            this.IsCentralUpdate = (Data[Data.Length - 2] == "cdb_update");

            // Server data
            this.ServerPrefix = Data[0];
            this.ServerName = Data[1];
            this.ServerPort = int.Parse(Data[3].ToString());
            this.QueryPort = int.Parse(Data[5].ToString());

            // Map Data
            this.MapName = Data[7];
            this.MapId = int.Parse(Data[9]);
            this.MapStart = (int)Math.Round(float.Parse(Data[11]), 0);
            this.MapEnd = (int)Math.Round(float.Parse(Data[13]), 0);

            // Misc Data
            this.WinningTeam = int.Parse(Data[15]);
            this.GameMode = int.Parse(Data[17]);
            this.Mod = Data[21];
            this.PlayersConnected = int.Parse(Data[23]);

            // Army Data
            this.WinningArmy = int.Parse(Data[25]);
            this.Team1Army = int.Parse(Data[27]);
            this.Team1Tickets = int.Parse(Data[29]);
            this.Team2Army = int.Parse(Data[31]);
            this.Team2Tickets = int.Parse(Data[33]);

            // Setup snapshot variables
            PlayerData = new List<Dictionary<string, string>>();
            KillData = new List<Dictionary<string, string>>();

            // Check for custom map, with no ID
            if (MapId == 99)
            {
                IsCustomMap = true;

                // Check for existing data
                List<Dictionary<string, object>> Rows = Driver.Query("SELECT id FROM mapinfo WHERE name=@P0", MapName);
                if (Rows.Count == 0)
                {
                    // Create new MapId
                    Rows = Driver.Query("SELECT MAX(id) AS id FROM mapinfo WHERE id >= " + MainForm.Config.ASP_CustomMapID);
                    MapId = (Rows.Count == 0 || String.IsNullOrWhiteSpace(Rows[0]["id"].ToString()))
                        ? MainForm.Config.ASP_CustomMapID
                        : (Int32.Parse(Rows[0]["id"].ToString()) + 1);

                    // make sure the mapid is at least the min custom map id
                    if (MapId < MainForm.Config.ASP_CustomMapID)
                        MapId = MainForm.Config.ASP_CustomMapID;

                    // Insert map data, so we dont lose this mapid we generated
                    if (Rows.Count == 0 || MapId == MainForm.Config.ASP_CustomMapID)
                        Driver.Execute("INSERT INTO mapinfo(id, name) VALUES (@P0, @P1)", MapId, MapName);
                }
                else
                    MapId = Int32.Parse(Rows[0]["id"].ToString());
            }
            else
                IsCustomMap = (MapId > MainForm.Config.ASP_CustomMapID);

            // Do player snapshots, 36 is first player
            for (int i = 36; i < Data.Length; i += 2)
            {
                string[] Parts = Data[i].Split('_');

                // Ignore uncomplete snapshots
                if (Parts.Length == 1)
                {
                    if (Parts[0] == "EOF")
                        break;
                    else
                        IsValidSnapshot = false;
                    return;
                }

                int id = int.Parse(Parts[1]);
                if (Parts[0] == "pID")
                {
                    PlayerData.Add(new Dictionary<string, string>());
                    KillData.Add(new Dictionary<string, string>());
                }

                // Kill and death data has its own array key
                if (Parts[0] == "mvks")
                    continue;

                if (Parts[0] == "mvns")
                    KillData[id].Add(Data[i + 1], Data[i + 3]);
                else
                    PlayerData[id].Add(Parts[0], Data[i + 1]);
            }

            // Set that we appear to be valid
            IsValidSnapshot = true;
        }
Example #18
0
 public bool ExpireAt(string key, DateTime expireDate)
 {
     var unixTimestamp = expireDate.ToUnixTimestamp();
     return _connection.Send<IntegerReply>("EXPIREAT", key, unixTimestamp);
 }
        public void ToUnixTimestamp()
        {
            var date = new DateTime(2015, 11, 11, 23, 13, 51);
            const long EXPECTED = 1447283631;

            date.ToUnixTimestamp().ShouldBeEquivalentTo(EXPECTED);
        }