Beispiel #1
0
        public void Show(double databaseSize, double percent)
        {
            string description = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}|{1}", (object)databaseSize, (object)percent);
            bool   isWarning   = percent < 90.0;
            Guid   typeId      = isWarning ? DatabaseLimitNotificationItemDAL.warningNotificationTypeGuid : DatabaseLimitNotificationItemDAL.reachedNotificationTypeGuid;
            DatabaseLimitNotificationItemDAL notificationItemDal = DatabaseLimitNotificationItemDAL.GetItem();

            if (notificationItemDal == null)
            {
                NotificationItemDAL.Insert(DatabaseLimitNotificationItemDAL.DatabaseLimitNotificationItemId, typeId, this.GetNotificationMessage(isWarning), description, false, (string)null, new DateTime?(), (string)null);
            }
            else
            {
                bool flag = double.Parse(notificationItemDal.Description.Split('|')[1], (IFormatProvider)CultureInfo.InvariantCulture) < 90.0;
                if (flag == isWarning)
                {
                    return;
                }
                if (flag != isWarning)
                {
                    notificationItemDal.SetNotAcknowledged();
                }
                notificationItemDal.TypeId      = typeId;
                notificationItemDal.Title       = this.GetNotificationMessage(isWarning);
                notificationItemDal.Description = description;
                notificationItemDal.Update();
            }
        }
 public static bool AcknowledgeAllItems(
     string accountId,
     DateTime acknowledgedAt,
     DateTime createdBefore)
 {
     return(NotificationItemDAL.AcknowledgeItems(new Guid?(), new Guid?(), accountId, acknowledgedAt, createdBefore));
 }
        // Token: 0x060006F4 RID: 1780 RVA: 0x0002C4B8 File Offset: 0x0002A6B8
        public static void Show(Dictionary <string, int> warningEngines, Dictionary <string, int> reachedEngines)
        {
            if (warningEngines == null)
            {
                throw new ArgumentNullException("warningEngines");
            }
            if (reachedEngines == null)
            {
                throw new ArgumentNullException("reachedEngines");
            }
            bool isWarning = reachedEngines.Count == 0;
            Guid typeId    = (reachedEngines.Count > 0) ? PollerLimitNotificationItemDAL.PollerLimitReachedNotificationTypeGuid : PollerLimitNotificationItemDAL.PollerLimitWarningNotificationTypeGuid;

            PollerLimitNotificationItemDAL.EnginesStatus enginesStatus = new PollerLimitNotificationItemDAL.EnginesStatus(warningEngines, reachedEngines);
            string description = enginesStatus.Serialize();
            PollerLimitNotificationItemDAL item = PollerLimitNotificationItemDAL.GetItem();
            string url = "javascript:SW.Core.SalesTrigger.ShowPollerLimitPopupAsync();";

            if (item == null)
            {
                NotificationItemDAL.Insert(PollerLimitNotificationItemDAL.PollerStatusNotificationItemId, typeId, PollerLimitNotificationItemDAL.GetNotificationMessage(isWarning), description, false, url, null, null);
                return;
            }
            PollerLimitNotificationItemDAL.EnginesStatus value = new PollerLimitNotificationItemDAL.EnginesStatus(item.Description);
            if (enginesStatus.Extends(value))
            {
                item.SetNotAcknowledged();
            }
            item.TypeId      = typeId;
            item.Description = description;
            item.Url         = url;
            item.Title       = PollerLimitNotificationItemDAL.GetNotificationMessage(isWarning);
            item.Update();
        }
        public static void Show(IEnumerable <string> elementsOverLimit)
        {
            string description = string.Join(";", elementsOverLimit.ToArray <string>());
            LicenseSaturationNotificationItemDAL notificationItemDal = LicenseSaturationNotificationItemDAL.GetItem();

            if (notificationItemDal == null)
            {
                NotificationItemDAL.Insert <LicenseSaturationNotificationItemDAL>(LicenseSaturationNotificationItemDAL.LicenseSaturationNotificationItemId, LicenseSaturationNotificationItemDAL.NotificationMessge, description, false, LicenseSaturationNotificationItemDAL.popupCallFunction, new DateTime?(), (string)null);
            }
            else
            {
                if (description == notificationItemDal.Description)
                {
                    return;
                }
                int num;
                if (!string.IsNullOrEmpty(notificationItemDal.Description))
                {
                    num = elementsOverLimit.Except <string>((IEnumerable <string>)notificationItemDal.Description.Split(';')).Count <string>() > 0 ? 1 : 0;
                }
                else
                {
                    num = 1;
                }
                if (num != 0)
                {
                    notificationItemDal.SetNotAcknowledged();
                }
                notificationItemDal.Description = description;
                notificationItemDal.Update();
            }
        }
 public static bool AcknowledgeItemsByType(
     Guid typeId,
     string accountId,
     DateTime createdBefore)
 {
     return(NotificationItemDAL.AcknowledgeItems(new Guid?(), new Guid?(typeId), accountId, DateTime.UtcNow, createdBefore));
 }
        // Token: 0x060006C0 RID: 1728 RVA: 0x0002AE08 File Offset: 0x00029008
        public void Show(double databaseSize, double percent)
        {
            string description = string.Format(CultureInfo.InvariantCulture, "{0}|{1}", databaseSize, percent);
            bool   flag        = percent < 90.0;
            Guid   typeId      = flag ? DatabaseLimitNotificationItemDAL.warningNotificationTypeGuid : DatabaseLimitNotificationItemDAL.reachedNotificationTypeGuid;
            DatabaseLimitNotificationItemDAL item = DatabaseLimitNotificationItemDAL.GetItem();

            if (item == null)
            {
                NotificationItemDAL.Insert(DatabaseLimitNotificationItemDAL.DatabaseLimitNotificationItemId, typeId, this.GetNotificationMessage(flag), description, false, null, null, null);
                return;
            }
            bool flag2 = double.Parse(item.Description.Split(new char[]
            {
                '|'
            })[1], CultureInfo.InvariantCulture) < 90.0;

            if (flag2 == flag)
            {
                return;
            }
            if (flag2 != flag)
            {
                item.SetNotAcknowledged();
            }
            item.TypeId      = typeId;
            item.Title       = this.GetNotificationMessage(flag);
            item.Description = description;
            item.Update();
        }
 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: 0x0600079B RID: 1947 RVA: 0x000347DC File Offset: 0x000329DC
        protected static TNotificationItem Create <TNotificationItem>(string title, string url) where TNotificationItem : GenericPopupNotificationItemDAL, new()
        {
            Guid popupNotificationItemId = Activator.CreateInstance <TNotificationItem>().GetPopupNotificationItemId();

            if (popupNotificationItemId == Guid.Empty)
            {
                throw new ArgumentException("Can't obtain Popup Notification Item GUID", "TNotificationItem");
            }
            TNotificationItem itemById = NotificationItemDAL.GetItemById <TNotificationItem>(popupNotificationItemId);

            if (itemById == null)
            {
                return(NotificationItemDAL.Insert <TNotificationItem>(popupNotificationItemId, title, null, false, url, null, null));
            }
            itemById.Title       = title;
            itemById.Description = null;
            itemById.Url         = url;
            itemById.CreatedAt   = DateTime.UtcNow;
            itemById.SetNotAcknowledged();
            itemById.Ignored = false;
            if (!itemById.Update())
            {
                return(default(TNotificationItem));
            }
            return(itemById);
        }
        // Token: 0x06000666 RID: 1638 RVA: 0x00026794 File Offset: 0x00024994
        public static void Show(DiscoveryResultBase result, StartImportStatus status)
        {
            DiscoveryAutoImportNotificationItemDAL item = DiscoveryAutoImportNotificationItemDAL.GetItem();
            string description = string.Format(CultureInfo.InvariantCulture, "DiscoveryImportStatus:{0}", status);
            string title       = string.Empty;

            switch (status)
            {
            case StartImportStatus.Failed:
                title = Resources2.Notification_DiscoveryAutoImport_Failed;
                break;

            case StartImportStatus.LicenseExceeded:
                title = Resources2.Notification_DiscoveryAutoImport_LicenseExceeded;
                break;

            case StartImportStatus.Finished:
                title = Resources2.Notification_DiscoveryAutoImport_Succeeded;
                break;

            default:
                return;
            }
            if (item == null)
            {
                NotificationItemDAL.Insert(DiscoveryAutoImportNotificationItemDAL.DiscoveryAutoImportNotificationItemId, DiscoveryAutoImportNotificationItemDAL.DiscoveryAutoImportNotificationTypeGuid, title, description, false, DiscoveryAutoImportNotificationItemDAL.NetworkSonarDiscoveryURL, null, null);
                return;
            }
            item.SetNotAcknowledged();
            item.Title       = title;
            item.Description = description;
            item.Update();
        }
 public static NotificationItemDAL Insert(
     Guid notificationId,
     Guid typeId,
     string title,
     string description,
     bool ignored,
     string url,
     DateTime?acknowledgedAt,
     string acknowledgedBy)
 {
     using (SqlConnection connection = DatabaseFunctions.CreateConnection())
     {
         using (SqlTransaction tr = connection.BeginTransaction())
         {
             try
             {
                 NotificationItemDAL notificationItemDal = NotificationItemDAL.Insert <NotificationItemDAL>(connection, tr, notificationId, typeId, title, description, ignored, url, acknowledgedAt, acknowledgedBy);
                 tr.Commit();
                 return(notificationItemDal);
             }
             catch (Exception ex)
             {
                 tr.Rollback();
                 NotificationItemDAL.log.Error((object)(string.Format("Can't INSERT item with ID {0}, typeId {1} ", (object)notificationId, (object)typeId) + ex.ToString()));
                 throw;
             }
         }
     }
 }
 protected static TNotificationItem Insert <TNotificationItem>(
     Guid notificationId,
     string title,
     string description,
     bool ignored,
     string url,
     DateTime?acknowledgedAt,
     string acknowledgedBy)
     where TNotificationItem : NotificationItemDAL, new()
 {
     using (SqlConnection connection = DatabaseFunctions.CreateConnection())
     {
         using (SqlTransaction tr = connection.BeginTransaction())
         {
             try
             {
                 TNotificationItem notificationItem = NotificationItemDAL.Insert <TNotificationItem>(connection, tr, notificationId, title, description, ignored, url, acknowledgedAt, acknowledgedBy);
                 tr.Commit();
                 return(notificationItem);
             }
             catch (Exception ex)
             {
                 tr.Rollback();
                 NotificationItemDAL.log.Error((object)(string.Format("Can't INSERT item of type {0}", (object)typeof(TNotificationItem).Name) + ex.ToString()));
                 throw;
             }
         }
     }
 }
Beispiel #12
0
 // Token: 0x06000847 RID: 2119 RVA: 0x0003B164 File Offset: 0x00039364
 public static bool AcknowledgeItem(Guid notificationId, string accountId, DateTime createdBefore)
 {
     if (notificationId == Guid.Empty)
     {
         throw new ArgumentException("notificationId GUID can't be Guid.Empty", "notificationId");
     }
     return(NotificationItemDAL.AcknowledgeItems(new Guid?(notificationId), null, accountId, DateTime.UtcNow, createdBefore));
 }
 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);
     }
 }
Beispiel #14
0
        // Token: 0x06000848 RID: 2120 RVA: 0x0003B1AC File Offset: 0x000393AC
        public static bool AcknowledgeItems <TNotificationItem>(string accountId, DateTime acknowledgedAt, DateTime createdBefore) where TNotificationItem : NotificationItemDAL, new()
        {
            Guid notificationItemTypeId = Activator.CreateInstance <TNotificationItem>().GetNotificationItemTypeId();

            if (notificationItemTypeId == Guid.Empty)
            {
                throw new ArgumentException("Can't obtain Type GUID", "TNotificationItem");
            }
            return(NotificationItemDAL.AcknowledgeItems(null, new Guid?(notificationItemTypeId), accountId, acknowledgedAt, createdBefore));
        }
        private static MaintenanceRenewalItemDAL Insert(
            SqlConnection con,
            SqlTransaction tr,
            Guid renewalId,
            string title,
            string description,
            bool ignored,
            string url,
            DateTime?acknowledgedAt,
            string acknowledgedBy,
            string productTag,
            DateTime dateReleased,
            string newVersion)
        {
            if (tr == null)
            {
                throw new ArgumentNullException(nameof(tr));
            }
            if (string.IsNullOrEmpty(productTag))
            {
                throw new ArgumentNullException(nameof(productTag));
            }
            if (dateReleased == DateTime.MinValue)
            {
                throw new ArgumentNullException(nameof(dateReleased));
            }
            if (string.IsNullOrEmpty(newVersion))
            {
                throw new ArgumentNullException(nameof(newVersion));
            }
            MaintenanceRenewalItemDAL maintenanceRenewalItemDal = NotificationItemDAL.Insert <MaintenanceRenewalItemDAL>(con, tr, renewalId, title, description, ignored, url, acknowledgedAt, acknowledgedBy);

            if (maintenanceRenewalItemDal == null)
            {
                return((MaintenanceRenewalItemDAL)null);
            }
            using (SqlCommand sqlCommand = new SqlCommand("INSERT INTO NotificationMaintenanceRenewals (RenewalID, ProductTag, DateReleased, Version) VALUES (@RenewalID, @ProductTag, @DateReleased, @NewVersion)"))
            {
                sqlCommand.Parameters.AddWithValue("@RenewalID", (object)renewalId);
                sqlCommand.Parameters.AddWithValue("@ProductTag", (object)productTag);
                sqlCommand.Parameters.AddWithValue("@DateReleased", (object)dateReleased);
                sqlCommand.Parameters.AddWithValue("@NewVersion", (object)newVersion);
                if (SqlHelper.ExecuteNonQuery(sqlCommand, con, tr) == 0)
                {
                    maintenanceRenewalItemDal = (MaintenanceRenewalItemDAL)null;
                }
                else
                {
                    maintenanceRenewalItemDal.ProductTag   = productTag;
                    maintenanceRenewalItemDal.DateReleased = dateReleased;
                    maintenanceRenewalItemDal.NewVersion   = newVersion;
                }
            }
            return(maintenanceRenewalItemDal);
        }
 public static GenericNotificationItemDAL Insert(
     Guid notificationId,
     string title,
     string description,
     bool ignored,
     string url,
     DateTime?acknowledgedAt,
     string acknowledgedBy)
 {
     return(NotificationItemDAL.Insert <GenericNotificationItemDAL>(notificationId, title, description, ignored, url, acknowledgedAt, acknowledgedBy));
 }
Beispiel #17
0
        // Token: 0x06000671 RID: 1649 RVA: 0x00026898 File Offset: 0x00024A98
        public static void Show()
        {
            LicensePreSaturationNotificationItemDAL item = LicensePreSaturationNotificationItemDAL.GetItem();

            if (item == null)
            {
                NotificationItemDAL.Insert <LicensePreSaturationNotificationItemDAL>(LicensePreSaturationNotificationItemDAL.LicensePreSaturationNotificationItemId, LicensePreSaturationNotificationItemDAL.NotificationMessage, string.Empty, false, "javascript:SW.Core.SalesTrigger.ShowLicensePopupAsync();", null, null);
                return;
            }
            item.SetNotAcknowledged();
            item.Update();
        }
        // Token: 0x060006CB RID: 1739 RVA: 0x0002B2A0 File Offset: 0x000294A0
        private void Show(IDictionary <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> expirations)
        {
            EvaluationExpirationNotificationItemDAL item = EvaluationExpirationNotificationItemDAL.GetItem();

            if (item == null)
            {
                string description = EvaluationExpirationNotificationItemDAL.Serialize(expirations);
                NotificationItemDAL.Insert(EvaluationExpirationNotificationItemDAL.EvaluationExpirationNotificationItemId, EvaluationExpirationNotificationItemDAL.EvaluationExpirationNotificationTypeGuid, Resources.LIBCODE_LC0_1, description, false, "javascript:SW.Core.SalesTrigger.ShowEvalPopupAsync();", null, null);
                return;
            }
            Dictionary <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> previousExpirations = EvaluationExpirationNotificationItemDAL.Deserialize(item.Description);
            int showExpiredAgainAt = BusinessLayerSettings.Instance.EvaluationExpirationShowAgainAtDays;
            IEnumerable <KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> > previousExpirations2 = previousExpirations;

            Func <KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo>, bool> < > 9__1;
            Func <KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo>, bool> predicate;

            if ((predicate = < > 9__1) == null)
            {
                predicate = (< > 9__1 = ((KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> previousExpiration) => expirations.ContainsKey(previousExpiration.Key)));
            }
            foreach (KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> keyValuePair in previousExpirations2.Where(predicate))
            {
                expirations[keyValuePair.Key].LastRemindMeLater = keyValuePair.Value.LastRemindMeLater;
            }
            int      daysFromLastRemindMeLater = (int)DateTime.UtcNow.Subtract(item.AcknowledgedAt ?? DateTime.UtcNow).TotalDays;
            DateTime?acknowledgedAt            = item.AcknowledgedAt;

            if (expirations.Any((KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> module) => !previousExpirations.ContainsKey(module.Key) || (previousExpirations.ContainsKey(module.Key) && module.Value.DaysToExpire > 0 && daysFromLastRemindMeLater == showExpiredAgainAt) || (previousExpirations.ContainsKey(module.Key) && previousExpirations[module.Key].DaysToExpire > 0 && module.Value.DaysToExpire <= 0) || (int)DateTime.UtcNow.Subtract(module.Value.LastRemindMeLater ?? DateTime.UtcNow).TotalDays == showExpiredAgainAt))
            {
                item.SetNotAcknowledged();
            }
            if (acknowledgedAt != null)
            {
                IEnumerable <KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> > expirations2 = expirations;
                Func <KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo>, bool> < > 9__2;
                Func <KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo>, bool> predicate2;
                if ((predicate2 = < > 9__2) == null)
                {
                    predicate2 = (< > 9__2 = ((KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> m) => m.Value.DaysToExpire <= 0 && m.Value.LastRemindMeLater == null && previousExpirations.ContainsKey(m.Key) && previousExpirations[m.Key].DaysToExpire <= 0));
                }
                foreach (KeyValuePair <string, EvaluationExpirationNotificationItemDAL.ExpirationInfo> keyValuePair2 in expirations2.Where(predicate2))
                {
                    keyValuePair2.Value.LastRemindMeLater = acknowledgedAt;
                }
            }
            item.TypeId      = EvaluationExpirationNotificationItemDAL.EvaluationExpirationNotificationTypeGuid;
            item.Description = EvaluationExpirationNotificationItemDAL.Serialize(expirations);
            item.Url         = "javascript:SW.Core.SalesTrigger.ShowEvalPopupAsync();";
            item.Title       = Resources.LIBCODE_LC0_1;
            item.Update();
        }
 protected static TNotificationItem Insert <TNotificationItem>(
     SqlConnection con,
     SqlTransaction tr,
     Guid notificationId,
     string title,
     string description,
     bool ignored,
     string url,
     DateTime?acknowledgedAt,
     string acknowledgedBy)
     where TNotificationItem : NotificationItemDAL, new()
 {
     return(NotificationItemDAL.Insert <TNotificationItem>(con, tr, notificationId, Guid.Empty, title, description, ignored, url, acknowledgedAt, acknowledgedBy));
 }
 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);
     }
 }
        public static void Show()
        {
            LicensePreSaturationNotificationItemDAL notificationItemDal = LicensePreSaturationNotificationItemDAL.GetItem();

            if (notificationItemDal == null)
            {
                NotificationItemDAL.Insert <LicensePreSaturationNotificationItemDAL>(LicensePreSaturationNotificationItemDAL.LicensePreSaturationNotificationItemId, LicensePreSaturationNotificationItemDAL.NotificationMessage, string.Empty, false, "javascript:SW.Core.SalesTrigger.ShowLicensePopupAsync();", new DateTime?(), (string)null);
            }
            else
            {
                notificationItemDal.SetNotAcknowledged();
                notificationItemDal.Update();
            }
        }
Beispiel #22
0
        // 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);
        }
Beispiel #23
0
 // 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"));
             }
         }
     }
 }
Beispiel #24
0
        // Token: 0x0600077D RID: 1917 RVA: 0x00033738 File Offset: 0x00031938
        private static BlogItemDAL Insert(SqlConnection con, SqlTransaction tr, Guid blogId, string title, string description, bool ignored, string url, DateTime?acknowledgedAt, string acknowledgedBy, Guid postGuid, long postId, string owner, DateTime publicationDate, string commentsUrl, int commentsCount)
        {
            if (tr == null)
            {
                throw new ArgumentNullException("tr");
            }
            if (postGuid == Guid.Empty)
            {
                throw new ArgumentException("postGuid GUID can't be Guid.Empty", "postGuid");
            }
            if (publicationDate == DateTime.MinValue)
            {
                throw new ArgumentNullException("publicationDate");
            }
            BlogItemDAL blogItemDAL = NotificationItemDAL.Insert <BlogItemDAL>(con, tr, blogId, title, description, ignored, url, acknowledgedAt, acknowledgedBy);

            if (blogItemDAL == null)
            {
                return(null);
            }
            BlogItemDAL result;

            using (SqlCommand sqlCommand = new SqlCommand("INSERT INTO NotificationBlogs (BlogID, PostGUID, PostID, Owner, PublicationDate, CommentsUrl, CommentsCount)\r\n                                              VALUES (@BlogID, @PostGUID, @PostID, @Owner, @PublicationDate, @CommentsUrl, @CommentsCount)"))
            {
                sqlCommand.Parameters.AddWithValue("@BlogID", blogId);
                sqlCommand.Parameters.AddWithValue("@PostGUID", postGuid);
                sqlCommand.Parameters.AddWithValue("@PostID", postId);
                sqlCommand.Parameters.AddWithValue("@Owner", string.IsNullOrEmpty(owner) ? DBNull.Value : owner);
                sqlCommand.Parameters.AddWithValue("@PublicationDate", publicationDate);
                sqlCommand.Parameters.AddWithValue("@CommentsUrl", string.IsNullOrEmpty(commentsUrl) ? DBNull.Value : commentsUrl);
                sqlCommand.Parameters.AddWithValue("@CommentsCount", (commentsCount < 0) ? DBNull.Value : commentsCount);
                if (SqlHelper.ExecuteNonQuery(sqlCommand, con, tr) == 0)
                {
                    result = null;
                }
                else
                {
                    blogItemDAL.PostGuid        = postGuid;
                    blogItemDAL.PostId          = postId;
                    blogItemDAL.Owner           = owner;
                    blogItemDAL.PublicationDate = publicationDate;
                    blogItemDAL.CommentsUrl     = commentsUrl;
                    blogItemDAL.CommentsCount   = commentsCount;
                    result = blogItemDAL;
                }
            }
            return(result);
        }
        public static bool IgnoreItems(ICollection <Guid> notificationIds)
        {
            bool flag = true;

            if (notificationIds != null && notificationIds.Count > 0)
            {
                foreach (Guid notificationId in (IEnumerable <Guid>)notificationIds)
                {
                    if (!NotificationItemDAL.IgnoreItem(notificationId))
                    {
                        flag = false;
                    }
                }
            }
            return(flag);
        }
Beispiel #26
0
        internal static void Show(
            Dictionary <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo> moduleExpirations)
        {
            bool   expired                = moduleExpirations.Any <KeyValuePair <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo> >((Func <KeyValuePair <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo>, bool>)(m => m.Value.DaysToExpire <= 0));
            int    daysToExpire           = moduleExpirations.Min <KeyValuePair <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo> >((Func <KeyValuePair <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo>, int>)(x => x.Value.DaysToExpire));
            string url                    = "javascript:SW.Core.SalesTrigger.ShowMaintenancePopupAsync();";
            Guid   typeId                 = expired ? MaintenanceExpirationNotificationItemDAL.MaintenanceExpiredNotificationTypeGuid : MaintenanceExpirationNotificationItemDAL.MaintenanceExpirationWarningNotificationTypeGuid;
            int    expiredShowAgainAtDays = BusinessLayerSettings.Instance.MaintenanceExpiredShowAgainAtDays;
            MaintenanceExpirationNotificationItemDAL notificationItemDal = MaintenanceExpirationNotificationItemDAL.GetItem();

            if (notificationItemDal == null)
            {
                string description = MaintenanceExpirationNotificationItemDAL.Serialize(moduleExpirations);
                NotificationItemDAL.Insert(MaintenanceExpirationNotificationItemDAL.MaintenanceExpirationNotificationItemId, typeId, MaintenanceExpirationNotificationItemDAL.GetNotificationMessage(expired, daysToExpire), description, false, url, new DateTime?(), (string)null);
            }
            else
            {
                Dictionary <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo> previousExpirations = MaintenanceExpirationNotificationItemDAL.Deserialize(notificationItemDal.Description);
                foreach (KeyValuePair <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo> keyValuePair in previousExpirations.Where <KeyValuePair <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo> >((Func <KeyValuePair <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo>, bool>)(previousExpiration => moduleExpirations.ContainsKey(previousExpiration.Key))))
                {
                    moduleExpirations[keyValuePair.Key].LastRemindMeLaterDate = keyValuePair.Value.LastRemindMeLaterDate;
                }
                DateTime     utcNow1        = DateTime.UtcNow;
                ref DateTime local1         = ref utcNow1;
                DateTime?    nullable       = notificationItemDal.AcknowledgedAt;
                DateTime     dateTime1      = nullable ?? DateTime.UtcNow;
                int          totalDays      = (int)local1.Subtract(dateTime1).TotalDays;
                DateTime?    acknowledgedAt = notificationItemDal.AcknowledgedAt;
                foreach (KeyValuePair <string, MaintenanceExpirationNotificationItemDAL.ExpirationInfo> moduleExpiration in moduleExpirations)
                {
                    if ((previousExpirations.ContainsKey(moduleExpiration.Key) || totalDays != expiredShowAgainAtDays) && (!previousExpirations.ContainsKey(moduleExpiration.Key) || moduleExpiration.Value.DaysToExpire <= 0 || totalDays != expiredShowAgainAtDays) && (!previousExpirations.ContainsKey(moduleExpiration.Key) || previousExpirations[moduleExpiration.Key].DaysToExpire <= 0 || moduleExpiration.Value.DaysToExpire > 0))
                    {
                        DateTime     utcNow2 = DateTime.UtcNow;
                        ref DateTime local2  = ref utcNow2;
                        nullable = moduleExpiration.Value.LastRemindMeLaterDate;
                        DateTime dateTime2 = nullable ?? DateTime.UtcNow;
                        if ((int)local2.Subtract(dateTime2).TotalDays != expiredShowAgainAtDays)
                        {
                            continue;
                        }
                    }
                    notificationItemDal.SetNotAcknowledged();
                    break;
                }
Beispiel #27
0
        // Token: 0x0600084D RID: 2125 RVA: 0x0003B2D4 File Offset: 0x000394D4
        public static bool IgnoreItems(ICollection <Guid> notificationIds)
        {
            bool result = true;

            if (notificationIds != null && notificationIds.Count > 0)
            {
                using (IEnumerator <Guid> enumerator = notificationIds.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        if (!NotificationItemDAL.IgnoreItem(enumerator.Current))
                        {
                            result = false;
                        }
                    }
                }
            }
            return(result);
        }
        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);
                }
            }
        }
 public static bool Delete(Guid notificationId)
 {
     using (SqlConnection connection = DatabaseFunctions.CreateConnection())
     {
         using (SqlTransaction tr = connection.BeginTransaction())
         {
             try
             {
                 int num = NotificationItemDAL.Delete(connection, tr, notificationId) ? 1 : 0;
                 tr.Commit();
                 return(num != 0);
             }
             catch (Exception ex)
             {
                 tr.Rollback();
                 NotificationItemDAL.log.Error((object)(string.Format("Can't DELETE item with ID {0}", (object)notificationId) + ex.ToString()));
                 throw;
             }
         }
     }
 }
Beispiel #30
0
        protected static TNotificationItem Create <TNotificationItem>(string title, string url) where TNotificationItem : GenericPopupNotificationItemDAL, new()
        {
            Guid notificationItemId = new TNotificationItem().GetPopupNotificationItemId();

            if (notificationItemId == Guid.Empty)
            {
                throw new ArgumentException("Can't obtain Popup Notification Item GUID", nameof(TNotificationItem));
            }
            TNotificationItem itemById = NotificationItemDAL.GetItemById <TNotificationItem>(notificationItemId);

            if ((object)itemById == null)
            {
                return(NotificationItemDAL.Insert <TNotificationItem>(notificationItemId, title, (string)null, false, url, new DateTime?(), (string)null));
            }
            itemById.Title       = title;
            itemById.Description = (string)null;
            itemById.Url         = url;
            itemById.CreatedAt   = DateTime.UtcNow;
            itemById.SetNotAcknowledged();
            itemById.Ignored = false;
            return(!itemById.Update() ? default(TNotificationItem) : itemById);
        }