コード例 #1
0
        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);
            }
コード例 #2
0
        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;
            }
        }
        // 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);
        }
コード例 #4
0
        // 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);
        }
コード例 #5
0
        // 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);
        }
コード例 #6
0
        // 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);
        }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
        // 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);
        }