Esempio n. 1
0
        public void ReportUsage(UsageData data)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(ServerSettings.SpeciesDsn))
                {
                    connection.Open();

                    SqlCommand command = new SqlCommand("TerrariumReportUsage", connection);
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@Alias", data.Alias);
                    command.Parameters.AddWithValue("@Domain", data.Domain);
                    command.Parameters.AddWithValue("@IPAddress", Context.Request.ServerVariables["REMOTE_ADDR"]);
                    command.Parameters.AddWithValue("@GameVersion", data.GameVersion);
                    command.Parameters.AddWithValue("@PeerChannel", data.PeerChannel);
                    command.Parameters.AddWithValue("@PeerCount", data.PeerCount);
                    command.Parameters.AddWithValue("@AnimalCount", data.AnimalCount);
                    command.Parameters.AddWithValue("@MaxAnimalCount", data.MaxAnimalCount);
                    command.Parameters.AddWithValue("@WorldWidth", data.WorldWidth);
                    command.Parameters.AddWithValue("@WorldHeight", data.WorldHeight);
                    command.Parameters.AddWithValue("@MachineName", data.MachineName);
                    command.Parameters.AddWithValue("@OSVersion", data.OSVersion);
                    command.Parameters.AddWithValue("@ProcessorCount", data.ProcessorCount);
                    command.Parameters.AddWithValue("@ClrVersion", data.ClrVersion);
                    command.Parameters.AddWithValue("@WorkingSet", data.WorkingSet);
                    command.Parameters.AddWithValue("@MaxWorkingSet", data.MaxWorkingSet);
                    command.Parameters.AddWithValue("@MinWorkingSet", data.MinWorkingSet);
                    command.Parameters.AddWithValue("@ProcessorTime", data.ProcessorTimeInSeconds);
                    command.Parameters.AddWithValue("@ProcessStartTime", data.ProcessStartTime);

                    command.ExecuteNonQuery();

                    command.Dispose();
                }
            }
            catch (Exception e)
            {
                InstallerInfo.WriteEventLog("ReportUsage", e.ToString());
            }
        }
        public void ReportUsage(UsageData data)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(ServerSettings.SpeciesDsn))
                {
                    connection.Open();

                    SqlCommand command = new SqlCommand("TerrariumReportUsage", connection);
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@Alias", data.Alias);
                    command.Parameters.AddWithValue("@Domain", data.Domain);
                    command.Parameters.AddWithValue("@IPAddress", Context.Request.ServerVariables["REMOTE_ADDR"]);
                    command.Parameters.AddWithValue("@GameVersion", data.GameVersion);
                    command.Parameters.AddWithValue("@PeerChannel", data.PeerChannel);
                    command.Parameters.AddWithValue("@PeerCount", data.PeerCount);
                    command.Parameters.AddWithValue("@AnimalCount", data.AnimalCount);
                    command.Parameters.AddWithValue("@MaxAnimalCount", data.MaxAnimalCount);
                    command.Parameters.AddWithValue("@WorldWidth", data.WorldWidth);
                    command.Parameters.AddWithValue("@WorldHeight", data.WorldHeight);
                    command.Parameters.AddWithValue("@MachineName", data.MachineName);
                    command.Parameters.AddWithValue("@OSVersion", data.OSVersion);
                    command.Parameters.AddWithValue("@ProcessorCount", data.ProcessorCount);
                    command.Parameters.AddWithValue("@ClrVersion", data.ClrVersion);
                    command.Parameters.AddWithValue("@WorkingSet", data.WorkingSet);
                    command.Parameters.AddWithValue("@MaxWorkingSet", data.MaxWorkingSet);
                    command.Parameters.AddWithValue("@MinWorkingSet", data.MinWorkingSet);
                    command.Parameters.AddWithValue("@ProcessorTime", data.ProcessorTimeInSeconds);
                    command.Parameters.AddWithValue("@ProcessStartTime", data.ProcessStartTime);

                    command.ExecuteNonQuery();

                    command.Dispose();
                }
            }
            catch (Exception e)
            {
                InstallerInfo.WriteEventLog("ReportUsage", e.ToString());
            }
        }
        public static ReadOnlyCollection<UsageData> GetUserDetails(string alias, UsagePeriod period)
        {
            SqlConnection connection = null;
            SqlCommand command = null;
            SqlDataReader reader = null;

            try
            {
                connection = new SqlConnection(ServerSettings.SpeciesDsn);
                connection.Open();

                command = new SqlCommand();
                command.Connection = connection;
                command.CommandType = CommandType.Text;
                command.CommandText = "SELECT * FROM Usage WHERE Alias = @Alias AND (TickTime >= @StartDate AND TickTime <= @EndDate)";
                command.Parameters.AddWithValue("@Alias", alias);

                DateTime startDate = DateTime.MinValue;
                DateTime endDate = DateTime.MinValue;

                GetPeriodDates(period, ref startDate, ref endDate);

                command.Parameters.AddWithValue("@StartDate", startDate.ToString());
                command.Parameters.AddWithValue("@EndDate", endDate.ToString());

                reader = command.ExecuteReader();

                UserUsageSummary summary = new UserUsageSummary();
                summary.Alias = alias;
                summary.Period = period;

                List<UsageData> usageList = new List<UsageData>();

                while (reader.Read())
                {
                    UsageData data = new UsageData();
                    data.Alias = Convert.ToString(reader["Alias"]);
                    data.Domain = Convert.ToString(reader["Domain"]);
                    data.TickTime = Convert.ToDateTime(reader["TickTime"]);
                    data.UsageMinutes = Convert.ToInt32(reader["UsageMinutes"]);
                    data.IPAddress = Convert.ToString(reader["IPAddress"]);
                    data.GameVersion = Convert.ToString(reader["GameVersion"]);
                    data.PeerChannel = Convert.ToString(reader["PeerChannel"]);
                    data.PeerCount = Convert.ToInt32(reader["PeerCount"]);
                    data.AnimalCount = Convert.ToInt32(reader["AnimalCount"]);
                    data.MaxAnimalCount = Convert.ToInt32(reader["MaxAnimalCount"]);
                    data.WorldHeight = Convert.ToInt32(reader["WorldHeight"]);
                    data.WorldWidth = Convert.ToInt32(reader["WorldWidth"]);
                    data.MachineName = Convert.ToString(reader["MachineName"]);
                    data.OSVersion = Convert.ToString(reader["OSVersion"]);
                    data.ProcessorCount = Convert.ToInt32(reader["ProcessorCount"]);
                    data.ClrVersion = Convert.ToString(reader["ClrVersion"]);
                    data.WorkingSet = Convert.ToInt32(reader["WorkingSet"]);
                    data.MaxWorkingSet = Convert.ToInt32(reader["MaxWorkingSet"]);
                    data.MinWorkingSet = Convert.ToInt32(reader["MinWorkingSet"]);
                    data.ProcessorTimeInSeconds = Convert.ToInt32(reader["ProcessorTime"]);
                    data.ProcessStartTime = Convert.ToDateTime(reader["ProcessStartTime"]);

                    usageList.Add(data);
                }

                return new ReadOnlyCollection<UsageData>(usageList);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader = null;
                }
                if (command != null)
                {
                    command.Dispose();
                    command = null;
                }
                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
        }
Esempio n. 4
0
        public static ReadOnlyCollection <UsageData> GetUserDetails(string alias, UsagePeriod period)
        {
            SqlConnection connection = null;
            SqlCommand    command    = null;
            SqlDataReader reader     = null;

            try
            {
                connection = new SqlConnection(ServerSettings.SpeciesDsn);
                connection.Open();

                command             = new SqlCommand();
                command.Connection  = connection;
                command.CommandType = CommandType.Text;
                command.CommandText =
                    "SELECT * FROM Usage WHERE Alias = @Alias AND (TickTime >= @StartDate AND TickTime <= @EndDate)";
                command.Parameters.AddWithValue("@Alias", alias);

                DateTime startDate = DateTime.MinValue;
                DateTime endDate   = DateTime.MinValue;

                GetPeriodDates(period, ref startDate, ref endDate);

                command.Parameters.AddWithValue("@StartDate", startDate.ToString());
                command.Parameters.AddWithValue("@EndDate", endDate.ToString());

                reader = command.ExecuteReader();

                UserUsageSummary summary = new UserUsageSummary();
                summary.Alias  = alias;
                summary.Period = period;

                List <UsageData> usageList = new List <UsageData>();

                while (reader.Read())
                {
                    UsageData data = new UsageData();
                    data.Alias                  = Convert.ToString(reader["Alias"]);
                    data.Domain                 = Convert.ToString(reader["Domain"]);
                    data.TickTime               = Convert.ToDateTime(reader["TickTime"]);
                    data.UsageMinutes           = Convert.ToInt32(reader["UsageMinutes"]);
                    data.IPAddress              = Convert.ToString(reader["IPAddress"]);
                    data.GameVersion            = Convert.ToString(reader["GameVersion"]);
                    data.PeerChannel            = Convert.ToString(reader["PeerChannel"]);
                    data.PeerCount              = Convert.ToInt32(reader["PeerCount"]);
                    data.AnimalCount            = Convert.ToInt32(reader["AnimalCount"]);
                    data.MaxAnimalCount         = Convert.ToInt32(reader["MaxAnimalCount"]);
                    data.WorldHeight            = Convert.ToInt32(reader["WorldHeight"]);
                    data.WorldWidth             = Convert.ToInt32(reader["WorldWidth"]);
                    data.MachineName            = Convert.ToString(reader["MachineName"]);
                    data.OSVersion              = Convert.ToString(reader["OSVersion"]);
                    data.ProcessorCount         = Convert.ToInt32(reader["ProcessorCount"]);
                    data.ClrVersion             = Convert.ToString(reader["ClrVersion"]);
                    data.WorkingSet             = Convert.ToInt32(reader["WorkingSet"]);
                    data.MaxWorkingSet          = Convert.ToInt32(reader["MaxWorkingSet"]);
                    data.MinWorkingSet          = Convert.ToInt32(reader["MinWorkingSet"]);
                    data.ProcessorTimeInSeconds = Convert.ToInt32(reader["ProcessorTime"]);
                    data.ProcessStartTime       = Convert.ToDateTime(reader["ProcessStartTime"]);

                    usageList.Add(data);
                }

                return(new ReadOnlyCollection <UsageData>(usageList));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader = null;
                }
                if (command != null)
                {
                    command.Dispose();
                    command = null;
                }
                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
        }