Example #1
0
        /// <summary>Get Dashboard statistics</summary>
        /// <cardinality>Many</cardinality>
        public List <DashboardCountsData> DashboardCounts(string dashboardLayoutRcd)
        {
            var ret = new List <DashboardCountsData>();

            string sql = @" 
                select 
                      'UTC'                                     as dashboard_item_rcd
                     ,'Universal Time Coordinated'              as dashboard_item_name
                     ,''                                        as image_source
                     ,convert(nvarchar(240), getutcdate(), 121) as value
					 ,0                                         as last_24_hours_count
                     ,convert(nvarchar(240), getutcdate(), 121) as last_date_time
                     ,''                                        as last_user_name
                     ,''                                        as url
                     ,0                                         as position_left
                     ,0                                         as position_top
                     ,0                                         as position_offset
                union all
                select 
                      'DBV'                                     as dashboard_item_rcd
                     ,'DB Version'                              as dashboard_item_name
                     ,''                                        as image_source
                     ,@@version                                 as value
					 ,0                                         as last_24_hours_count
                     ,convert(nvarchar(240), getutcdate(), 121) as last_date_time
                     ,''                                        as last_user_name
                     ,''                                        as url
                     ,0                                         as position_left
                     ,0                                         as position_top
                     ,0                                         as position_offset";

            sql += "\r\n";

            using (var conn = new SqlConnection(Conn.ConnectionString)) {
                conn.Open();
                conn.BeginTransaction(IsolationLevel.ReadUncommitted).Commit();

                using (var command = new SqlCommand(sql, conn)) {
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);

                    var ordinals = new DashboardCountsDataOrdinals(reader);

                    while (reader.Read())
                    {
                        var data = new DashboardCountsData();
                        data.Populate(reader, ordinals);
                        ret.Add(data);
                    }

                    reader.Close();
                }
            }
            return(ret);
        }
Example #2
0
 // use ordinals to speed up access to DataReader
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/327451c3-64a8-4de8-b359-76742d634497
 // parameters:
 //  reader: IDataReader from SQLClient
 public void Populate(IDataReader reader, DashboardCountsDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.DashboardItemRcd))
     {
         DashboardItemRcd = reader.GetString(ordinals.DashboardItemRcd);
     }
     if (!reader.IsDBNull(ordinals.DashboardItemName))
     {
         DashboardItemName = reader.GetString(ordinals.DashboardItemName);
     }
     if (!reader.IsDBNull(ordinals.ImageSource))
     {
         ImageSource = reader.GetString(ordinals.ImageSource);
     }
     if (!reader.IsDBNull(ordinals.Value))
     {
         Value = reader.GetString(ordinals.Value);
     }
     if (!reader.IsDBNull(ordinals.Last24HoursCount))
     {
         Last24HoursCount = reader.GetInt32(ordinals.Last24HoursCount);
     }
     if (!reader.IsDBNull(ordinals.LastDateTime))
     {
         LastDateTime = reader.GetString(ordinals.LastDateTime);
     }
     if (!reader.IsDBNull(ordinals.LastUserName))
     {
         LastUserName = reader.GetString(ordinals.LastUserName);
     }
     if (!reader.IsDBNull(ordinals.Url))
     {
         Url = reader.GetString(ordinals.Url);
     }
     if (!reader.IsDBNull(ordinals.PositionLeft))
     {
         PositionLeft = reader.GetInt32(ordinals.PositionLeft);
     }
     if (!reader.IsDBNull(ordinals.PositionTop))
     {
         PositionTop = reader.GetInt32(ordinals.PositionTop);
     }
     if (!reader.IsDBNull(ordinals.PositionOffset))
     {
         PositionOffset = reader.GetInt32(ordinals.PositionOffset);
     }
 }