// Token: 0x06000832 RID: 2098 RVA: 0x0003A39C File Offset: 0x0003859C private SqlCommand ComposeSelectCountCommand(Guid typeId, NotificationItemFilter filter) { SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(NotificationID) FROM NotificationItems"); SqlCommand result; try { StringBuilder stringBuilder = new StringBuilder(); if (typeId != Guid.Empty) { SqlHelper.AddCondition(stringBuilder, "NotificationTypeID=@NotificationTypeID", "AND"); sqlCommand.Parameters.AddWithValue("@NotificationTypeID", typeId); } if (!filter.IncludeAcknowledged) { SqlHelper.AddCondition(stringBuilder, "AcknowledgedAt IS NULL", "AND"); } if (!filter.IncludeIgnored) { SqlHelper.AddCondition(stringBuilder, "Ignored=0", "AND"); } SqlCommand sqlCommand2 = sqlCommand; sqlCommand2.CommandText += stringBuilder.ToString(); result = sqlCommand; } catch (Exception ex) { sqlCommand.Dispose(); NotificationItemDAL.log.Error(string.Format("Error while composing SELECT COUNT SQL command for {0}: ", base.GetType().Name) + ex.ToString()); throw; } return(result); }
public static ICollection <NotificationItemDAL> GetItemsByTypeId( Guid typeId, NotificationItemFilter filter) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } if (typeId == Guid.Empty) { throw new ArgumentException("Value can't be empty GUID", nameof(typeId)); } try { using (SqlCommand sqlCommand = new NotificationItemDAL().ComposeSelectCollectionCommand(typeId, filter)) { using (IDataReader rd = SqlHelper.ExecuteReader(sqlCommand)) { List <NotificationItemDAL> notificationItemDalList = new List <NotificationItemDAL>(); while (rd.Read()) { NotificationItemDAL notificationItemDal = new NotificationItemDAL(); notificationItemDal.LoadFromReader(rd); notificationItemDalList.Add(notificationItemDal); } return((ICollection <NotificationItemDAL>)notificationItemDalList); } } } catch (ResultCountException ex) { NotificationItemDAL.log.DebugFormat("Can't get notification item collection from database: TypeID={0}", (object)typeId); return((ICollection <NotificationItemDAL>)null); } }
// Token: 0x06000775 RID: 1909 RVA: 0x0003329C File Offset: 0x0003149C protected override SqlCommand ComposeSelectCountCommand(NotificationItemFilter filter) { SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(BlogID) FROM NotificationBlogs LEFT JOIN NotificationItems ON \r\n NotificationBlogs.BlogID = NotificationItems.NotificationID"); SqlCommand result; try { StringBuilder stringBuilder = new StringBuilder(); if (!filter.IncludeAcknowledged) { SqlHelper.AddCondition(stringBuilder, "AcknowledgedAt IS NULL", "AND"); } if (!filter.IncludeIgnored) { SqlHelper.AddCondition(stringBuilder, "Ignored=0", "AND"); } SqlCommand sqlCommand2 = sqlCommand; sqlCommand2.CommandText += stringBuilder.ToString(); result = sqlCommand; } catch (Exception ex) { sqlCommand.Dispose(); BlogItemDAL.log.Error(string.Format("Error while composing SELECT COUNT SQL command for {0}: ", base.GetType().Name) + ex.ToString()); throw; } return(result); }
protected override SqlCommand ComposeSelectLatestItemCommand( NotificationItemFilter filter) { SqlCommand sqlCommand = new SqlCommand("SELECT TOP 1 * FROM NotificationMaintenanceRenewals LEFT JOIN NotificationItems ON \r\n NotificationMaintenanceRenewals.RenewalID = NotificationItems.NotificationID"); try { StringBuilder stringBuilder = new StringBuilder(); if (!filter.IncludeAcknowledged) { SqlHelper.AddCondition(stringBuilder, "AcknowledgedAt IS NULL", "AND"); } if (!filter.IncludeIgnored) { SqlHelper.AddCondition(stringBuilder, "Ignored=0", "AND"); } if (filter is MaintenanceRenewalFilter maintenanceRenewalFilter && !string.IsNullOrEmpty(maintenanceRenewalFilter.ProductTag)) { SqlHelper.AddCondition(stringBuilder, "ProductTag=@ProductTag", "AND"); sqlCommand.Parameters.AddWithValue("@ProductTag", (object)maintenanceRenewalFilter.ProductTag); } sqlCommand.CommandText += stringBuilder.ToString(); sqlCommand.CommandText += " ORDER BY DateReleased DESC"; return(sqlCommand); } catch (Exception ex) { sqlCommand.Dispose(); NotificationItemDAL.log.Error((object)(string.Format("Error while composing SELECT SQL command for latest {0}: ", (object)this.GetType().Name) + ex.ToString())); throw; } }
protected virtual SqlCommand ComposeSelectLatestItemCommand( Guid typeId, NotificationItemFilter filter) { SqlCommand sqlCommand = new SqlCommand("SELECT TOP 1 * FROM NotificationItems"); try { StringBuilder stringBuilder = new StringBuilder(); if (typeId != Guid.Empty) { SqlHelper.AddCondition(stringBuilder, "NotificationTypeID=@NotificationTypeID", "AND"); sqlCommand.Parameters.AddWithValue("@NotificationTypeID", (object)typeId); } if (!filter.IncludeAcknowledged) { SqlHelper.AddCondition(stringBuilder, "AcknowledgedAt IS NULL", "AND"); } if (!filter.IncludeIgnored) { SqlHelper.AddCondition(stringBuilder, "Ignored=0", "AND"); } sqlCommand.CommandText += stringBuilder.ToString(); sqlCommand.CommandText += " ORDER BY CreatedAt DESC"; return(sqlCommand); } catch (Exception ex) { sqlCommand.Dispose(); NotificationItemDAL.log.Error((object)(string.Format("Error while composing SELECT SQL command for latest {0}: ", (object)this.GetType().Name) + ex.ToString())); throw; } }
// Token: 0x060008C2 RID: 2242 RVA: 0x0003F144 File Offset: 0x0003D344 protected override SqlCommand ComposeSelectCountCommand(NotificationItemFilter filter) { SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(RenewalID) FROM NotificationMaintenanceRenewals LEFT JOIN NotificationItems ON \r\n NotificationMaintenanceRenewals.RenewalID = NotificationItems.NotificationID"); SqlCommand result; try { StringBuilder stringBuilder = new StringBuilder(); if (!filter.IncludeAcknowledged) { SqlHelper.AddCondition(stringBuilder, "AcknowledgedAt IS NULL", "AND"); } if (!filter.IncludeIgnored) { SqlHelper.AddCondition(stringBuilder, "Ignored=0", "AND"); } MaintenanceRenewalFilter maintenanceRenewalFilter = filter as MaintenanceRenewalFilter; if (maintenanceRenewalFilter != null && !string.IsNullOrEmpty(maintenanceRenewalFilter.ProductTag)) { SqlHelper.AddCondition(stringBuilder, "ProductTag=@ProductTag", "AND"); sqlCommand.Parameters.AddWithValue("@ProductTag", maintenanceRenewalFilter.ProductTag); } SqlCommand sqlCommand2 = sqlCommand; sqlCommand2.CommandText += stringBuilder.ToString(); result = sqlCommand; } catch (Exception ex) { sqlCommand.Dispose(); NotificationItemDAL.log.Error(string.Format("Error while composing SELECT COUNT SQL command for {0}: ", base.GetType().Name) + ex.ToString()); throw; } return(result); }
protected override SqlCommand ComposeSelectCollectionCommand( NotificationItemFilter filter) { SqlCommand sqlCommand = new SqlCommand("SELECT{0} * FROM NotificationBlogs LEFT JOIN NotificationItems ON \r\n NotificationBlogs.BlogID = NotificationItems.NotificationID"); try { StringBuilder stringBuilder = new StringBuilder(); if (!filter.IncludeAcknowledged) { SqlHelper.AddCondition(stringBuilder, "AcknowledgedAt IS NULL", "AND"); } if (!filter.IncludeIgnored) { SqlHelper.AddCondition(stringBuilder, "Ignored=0", "AND"); } if (filter is BlogFilter blogFilter && blogFilter.MaxResults > 0) { sqlCommand.CommandText = string.Format(sqlCommand.CommandText, (object)(" TOP " + (object)blogFilter.MaxResults)); } else { sqlCommand.CommandText = string.Format(sqlCommand.CommandText, (object)string.Empty); } sqlCommand.CommandText += stringBuilder.ToString(); sqlCommand.CommandText += " ORDER BY PublicationDate DESC"; return(sqlCommand); }
// Token: 0x06000830 RID: 2096 RVA: 0x0003A280 File Offset: 0x00038480 protected virtual SqlCommand ComposeSelectLatestItemsWithCountCommand(NotificationItemFilter filter) { SqlCommand sqlCommand = new SqlCommand("SELECT (SELECT COUNT(NotificationID) FROM NotificationItems {0}) as NotificationCount, i1.*\r\n FROM NotificationItems i1 LEFT OUTER JOIN \r\n NotificationItems i2 ON (i1.NotificationTypeID = i2.NotificationTypeID AND i1.CreatedAt < i2.CreatedAt)"); SqlCommand result; try { StringBuilder stringBuilder = new StringBuilder(); SqlHelper.AddCondition(stringBuilder, "NotificationTypeID = i1.NotificationTypeID", "AND"); StringBuilder stringBuilder2 = new StringBuilder(); SqlHelper.AddCondition(stringBuilder2, "i2.NotificationID IS NULL", "AND"); if (!filter.IncludeAcknowledged) { SqlHelper.AddCondition(stringBuilder, "AcknowledgedAt IS NULL", "AND"); SqlHelper.AddCondition(stringBuilder2, "i1.AcknowledgedAt IS NULL", "AND"); } if (!filter.IncludeIgnored) { SqlHelper.AddCondition(stringBuilder, "Ignored=0", "AND"); SqlHelper.AddCondition(stringBuilder2, "i1.Ignored=0", "AND"); } sqlCommand.CommandText = string.Format(CultureInfo.InvariantCulture, sqlCommand.CommandText, stringBuilder); SqlCommand sqlCommand2 = sqlCommand; sqlCommand2.CommandText += stringBuilder2.ToString(); result = sqlCommand; } catch (Exception ex) { sqlCommand.Dispose(); NotificationItemDAL.log.Error(string.Format("Error while composing SELECT SQL command for latest {0}: ", base.GetType().Name) + ex.ToString()); throw; } return(result); }
public static int GetNotificationsCountByType(Guid typeId, NotificationItemFilter filter) { using (SqlCommand sqlCommand = new NotificationItemDAL().ComposeSelectCountCommand(typeId, filter)) { object obj = SqlHelper.ExecuteScalar(sqlCommand); return(obj == null || obj == DBNull.Value ? 0 : (int)obj); } }
public static int GetNotificationsCount <TNotificationItem>(NotificationItemFilter filter) where TNotificationItem : NotificationItemDAL, new() { using (SqlCommand sqlCommand = new TNotificationItem().ComposeSelectCountCommand(filter)) { object obj = SqlHelper.ExecuteScalar(sqlCommand); return(obj == null || obj == DBNull.Value ? 0 : (int)obj); } }
// Token: 0x06000841 RID: 2113 RVA: 0x0003AE8C File Offset: 0x0003908C public static int GetNotificationsCount <TNotificationItem>(NotificationItemFilter filter) where TNotificationItem : NotificationItemDAL, new() { int result; using (SqlCommand sqlCommand = Activator.CreateInstance <TNotificationItem>().ComposeSelectCountCommand(filter)) { object obj = SqlHelper.ExecuteScalar(sqlCommand); result = ((obj == null || obj == DBNull.Value) ? 0 : ((int)obj)); } return(result); }
public static ICollection <TNotificationItem> GetItems <TNotificationItem>( NotificationItemFilter filter) where TNotificationItem : NotificationItemDAL, new() { try { return(NotificationItemDAL.LoadCollectionFromDB <TNotificationItem>(filter)); } catch (ResultCountException ex) { NotificationItemDAL.log.DebugFormat("Can't get notification item collection from database: Type={0}", (object)typeof(TNotificationItem).Name); return((ICollection <TNotificationItem>)null); } }
// Token: 0x06000826 RID: 2086 RVA: 0x00039D70 File Offset: 0x00037F70 public static ICollection <TNotificationItem> GetItems <TNotificationItem>(NotificationItemFilter filter) where TNotificationItem : NotificationItemDAL, new() { ICollection <TNotificationItem> result; try { result = NotificationItemDAL.LoadCollectionFromDB <TNotificationItem>(filter); } catch (ResultCountException) { NotificationItemDAL.log.DebugFormat("Can't get notification item collection from database: Type={0}", typeof(TNotificationItem).Name); result = null; } return(result); }
// Token: 0x0600082A RID: 2090 RVA: 0x00039F78 File Offset: 0x00038178 public static void GetLatestItemsWithCount(NotificationItemFilter filter, Action <NotificationItemDAL, int> readerDelegate) { using (SqlCommand sqlCommand = new NotificationItemDAL().ComposeSelectLatestItemsWithCountCommand(filter)) { using (IDataReader dataReader = SqlHelper.ExecuteReader(sqlCommand)) { while (dataReader.Read()) { NotificationItemDAL notificationItemDAL = new NotificationItemDAL(); notificationItemDAL.LoadFromReader(dataReader); readerDelegate(notificationItemDAL, DatabaseFunctions.GetInt32(dataReader, "NotificationCount")); } } } }
public static TNotificationItem GetLatestItem <TNotificationItem>(NotificationItemFilter filter) where TNotificationItem : NotificationItemDAL, new() { TNotificationItem notificationItem = new TNotificationItem(); using (SqlCommand sqlCommand = notificationItem.ComposeSelectLatestItemCommand(filter)) { using (IDataReader rd = SqlHelper.ExecuteReader(sqlCommand)) { if (!rd.Read()) { return(default(TNotificationItem)); } notificationItem.LoadFromReader(rd); return(notificationItem); } } }
public static NotificationItemDAL GetLatestItemByType( Guid typeId, NotificationItemFilter filter) { NotificationItemDAL notificationItemDal = new NotificationItemDAL(); using (SqlCommand sqlCommand = notificationItemDal.ComposeSelectLatestItemCommand(typeId, filter)) { using (IDataReader rd = SqlHelper.ExecuteReader(sqlCommand)) { if (!rd.Read()) { return((NotificationItemDAL)null); } notificationItemDal.LoadFromReader(rd); return(notificationItemDal); } } }
// Token: 0x06000772 RID: 1906 RVA: 0x00033044 File Offset: 0x00031244 protected override SqlCommand ComposeSelectCollectionCommand(NotificationItemFilter filter) { SqlCommand sqlCommand = new SqlCommand("SELECT{0} * FROM NotificationBlogs LEFT JOIN NotificationItems ON \r\n NotificationBlogs.BlogID = NotificationItems.NotificationID"); SqlCommand result; try { StringBuilder stringBuilder = new StringBuilder(); if (!filter.IncludeAcknowledged) { SqlHelper.AddCondition(stringBuilder, "AcknowledgedAt IS NULL", "AND"); } if (!filter.IncludeIgnored) { SqlHelper.AddCondition(stringBuilder, "Ignored=0", "AND"); } BlogFilter blogFilter = filter as BlogFilter; if (blogFilter != null && blogFilter.MaxResults > 0) { sqlCommand.CommandText = string.Format(sqlCommand.CommandText, " TOP " + blogFilter.MaxResults); } else { sqlCommand.CommandText = string.Format(sqlCommand.CommandText, string.Empty); } SqlCommand sqlCommand2 = sqlCommand; sqlCommand2.CommandText += stringBuilder.ToString(); SqlCommand sqlCommand3 = sqlCommand; sqlCommand3.CommandText += " ORDER BY PublicationDate DESC"; result = sqlCommand; } catch (Exception ex) { sqlCommand.Dispose(); BlogItemDAL.log.Error(string.Format("Error while composing SELECT SQL command for {0} collection: ", base.GetType().Name) + ex.ToString()); throw; } return(result); }
// Token: 0x06000828 RID: 2088 RVA: 0x00039E8C File Offset: 0x0003808C public static TNotificationItem GetLatestItem <TNotificationItem>(NotificationItemFilter filter) where TNotificationItem : NotificationItemDAL, new() { TNotificationItem tnotificationItem = Activator.CreateInstance <TNotificationItem>(); TNotificationItem result; using (SqlCommand sqlCommand = tnotificationItem.ComposeSelectLatestItemCommand(filter)) { using (IDataReader dataReader = SqlHelper.ExecuteReader(sqlCommand)) { if (dataReader.Read()) { tnotificationItem.LoadFromReader(dataReader); result = tnotificationItem; } else { result = default(TNotificationItem); } } } return(result); }
// Token: 0x06000829 RID: 2089 RVA: 0x00039F0C File Offset: 0x0003810C public static NotificationItemDAL GetLatestItemByType(Guid typeId, NotificationItemFilter filter) { NotificationItemDAL notificationItemDAL = new NotificationItemDAL(); NotificationItemDAL result; using (SqlCommand sqlCommand = notificationItemDAL.ComposeSelectLatestItemCommand(typeId, filter)) { using (IDataReader dataReader = SqlHelper.ExecuteReader(sqlCommand)) { if (dataReader.Read()) { notificationItemDAL.LoadFromReader(dataReader); result = notificationItemDAL; } else { result = null; } } } return(result); }
private static ICollection <TNotificationItem> LoadCollectionFromDB <TNotificationItem>( NotificationItemFilter filter) where TNotificationItem : NotificationItemDAL, new() { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } using (SqlCommand sqlCommand = new TNotificationItem().ComposeSelectCollectionCommand(filter)) { using (IDataReader rd = SqlHelper.ExecuteReader(sqlCommand)) { List <TNotificationItem> notificationItemList = new List <TNotificationItem>(); while (rd.Read()) { TNotificationItem notificationItem = new TNotificationItem(); notificationItem.LoadFromReader(rd); notificationItemList.Add(notificationItem); } return((ICollection <TNotificationItem>)notificationItemList); } } }
public static ICollection <GenericNotificationItemDAL> GetItems( NotificationItemFilter filter) { return(NotificationItemDAL.GetItems <GenericNotificationItemDAL>(filter)); }
// Token: 0x060008C4 RID: 2244 RVA: 0x0003F23C File Offset: 0x0003D43C public static MaintenanceRenewalItemDAL GetLatestItem(NotificationItemFilter filter) { return(NotificationItemDAL.GetLatestItem <MaintenanceRenewalItemDAL>(filter)); }
// Token: 0x06000827 RID: 2087 RVA: 0x00039DBC File Offset: 0x00037FBC public static ICollection <NotificationItemDAL> GetItemsByTypeId(Guid typeId, NotificationItemFilter filter) { if (filter == null) { throw new ArgumentNullException("filter"); } if (typeId == Guid.Empty) { throw new ArgumentException("Value can't be empty GUID", "typeId"); } ICollection <NotificationItemDAL> result; try { using (SqlCommand sqlCommand = new NotificationItemDAL().ComposeSelectCollectionCommand(typeId, filter)) { using (IDataReader dataReader = SqlHelper.ExecuteReader(sqlCommand)) { List <NotificationItemDAL> list = new List <NotificationItemDAL>(); while (dataReader.Read()) { NotificationItemDAL notificationItemDAL = new NotificationItemDAL(); notificationItemDAL.LoadFromReader(dataReader); list.Add(notificationItemDAL); } result = list; } } } catch (ResultCountException) { NotificationItemDAL.log.DebugFormat("Can't get notification item collection from database: TypeID={0}", typeId); result = null; } return(result); }
// Token: 0x06000835 RID: 2101 RVA: 0x0003A5C0 File Offset: 0x000387C0 private static ICollection <TNotificationItem> LoadCollectionFromDB <TNotificationItem>(NotificationItemFilter filter) where TNotificationItem : NotificationItemDAL, new() { if (filter == null) { throw new ArgumentNullException("filter"); } ICollection <TNotificationItem> result; using (SqlCommand sqlCommand = Activator.CreateInstance <TNotificationItem>().ComposeSelectCollectionCommand(filter)) { using (IDataReader dataReader = SqlHelper.ExecuteReader(sqlCommand)) { List <TNotificationItem> list = new List <TNotificationItem>(); while (dataReader.Read()) { TNotificationItem tnotificationItem = Activator.CreateInstance <TNotificationItem>(); tnotificationItem.LoadFromReader(dataReader); list.Add(tnotificationItem); } result = list; } } return(result); }
// Token: 0x06000831 RID: 2097 RVA: 0x0003A38C File Offset: 0x0003858C protected virtual SqlCommand ComposeSelectCountCommand(NotificationItemFilter filter) { return(this.ComposeSelectCountCommand(this.GetNotificationItemTypeId(), filter)); }