Exemple #1
0
        public DataSet GetTopAnimals(string version, OrganismType tat, int num)
        {
            if (num == 0)
            {
                num = 3;
            }

            return(ChartBuilder.GetTopAnimals(version, tat, num));
        }
        /*
         *  Method:     OnReportingTimerElapsed
         *  Purpose:    Callback function used when the reporting timer has
         *  signalled.  This function is responsible for constructing a database
         *  call to the Terrarium reporting aggregation procedure.  Once called
         *  the latest data from clients will be rolled up to be displayed on
         *  the stats pages.
         *
         *  After rollup is complete a call to ChartBuilder.ResetSpeciesList is
         *  made so that the latest data is shown on the website.
         */
        protected internal void OnReportingTimerElapsed(Object src, ElapsedEventArgs args)
        {
            bool     exceptionOccurred = false;
            DateTime startTime         = DateTime.Now;

            try {
                using (SqlConnection myConnection = new SqlConnection(dsn)) {
                    myConnection.Open();
                    SqlCommand command = new SqlCommand("TerrariumAggregate", myConnection);
                    command.CommandType = CommandType.StoredProcedure;

                    SqlParameter parmExpirationError    = command.Parameters.Add("@Expiration_Error", SqlDbType.Int, 4);
                    SqlParameter parmRollupError        = command.Parameters.Add("@Rollup_Error", SqlDbType.Int, 4);
                    SqlParameter parmTimeOutAddError    = command.Parameters.Add("@Timeout_Add_Error", SqlDbType.Int, 4);
                    SqlParameter parmTimeOutDeleteError = command.Parameters.Add("@Timeout_Delete_Error", SqlDbType.Int, 4);
                    SqlParameter parmExtinctionError    = command.Parameters.Add("@Extinction_Error", SqlDbType.Int, 4);

                    parmExpirationError.Direction    = ParameterDirection.Output;
                    parmRollupError.Direction        = ParameterDirection.Output;
                    parmTimeOutAddError.Direction    = ParameterDirection.Output;
                    parmTimeOutDeleteError.Direction = ParameterDirection.Output;
                    parmExtinctionError.Direction    = ParameterDirection.Output;

                    command.ExecuteNonQuery();

                    if (((int)parmExpirationError.Value) != 0)
                    {
                        InstallerInfo.WriteEventLog("Report", "Expiration Code failed: " + parmExpirationError.Value);
                    }
                    if (((int)parmRollupError.Value) != 0)
                    {
                        InstallerInfo.WriteEventLog("Report", "Rollup Code failed: " + parmRollupError.Value);
                    }
                    if (((int)parmTimeOutAddError.Value) != 0)
                    {
                        InstallerInfo.WriteEventLog("Report", "Time Out Add Code failed: " + parmTimeOutAddError.Value);
                    }
                    if (((int)parmTimeOutDeleteError.Value) != 0)
                    {
                        InstallerInfo.WriteEventLog("Report", "Time Out Delete Code failed: " + parmTimeOutDeleteError.Value);
                    }
                    if (((int)parmExtinctionError.Value) != 0)
                    {
                        InstallerInfo.WriteEventLog("Report", "Extinction Code failed: " + parmExtinctionError.Value);
                    }
                }

                // Update the species list
                try {
                    ChartBuilder.RefreshSpeciesList();
                }
                catch (Exception e) {
                    InstallerInfo.WriteEventLog("SpeciesList", e.ToString());
                }
            }
            catch (Exception e) {
                exceptionOccurred = true;
                InstallerInfo.WriteEventLog("Report", e.ToString());
            }

            if (rollupExecutionTimePerformanceCounter != null)
            {
                if (exceptionOccurred)
                {
                    rollupExecutionTimePerformanceCounter.RawValue = 0;
                }
                else
                {
                    TimeSpan executionTime = DateTime.Now.Subtract(startTime);
                    rollupExecutionTimePerformanceCounter.RawValue = executionTime.Milliseconds;
                }
            }
        }
Exemple #3
0
 public DataSet GrabLatestSpeciesData(string species)
 {
     return(ChartBuilder.GrabLatestSpeciesData(species));
 }