private static void ShowNotifications(IList notificationInfos, RibbonForm form) { DynamicDataServiceContext dbcontext = new DynamicDataServiceContext(); AlertControl alertControl = new AlertControl(); alertControl.AutoHeight = true; alertControl.AlertClick += (sender, e) => { NotificationData data = (NotificationData)e.Info.Tag; var notificationUser = dbcontext.GetOrNew("NotificationRecipient", data.NotificationRecipientId); notificationUser.AsDyanmic().NotificationStatus = "Readed"; notificationUser.AsDyanmic().ReadedOn = DateTime.Now; dbcontext.SaveChanges(); e.AlertForm.Hide(); }; AlertManage manager = new AlertManage(alertControl, form); foreach (var notificationInfo in notificationInfos) { var notificationUser = dbcontext.GetOrNew("NotificationRecipient", notificationInfo.AsDyanmic().NotificationRecipientId); notificationUser.NotificationStatus = "Opened"; manager.ShowAlert(notificationInfo); } dbcontext.SaveChanges(); }
private static void ShowNotifications(IList notificationInfos, RibbonForm form) { IObjectSpace objectSpace = new ODataObjectSpace(); AlertControl alertControl = new AlertControl(); alertControl.AutoHeight = true; AlertButton setReaded = new AlertButton(new Bitmap(WinFormsResourceService.GetBitmap("notification"), new Size(16, 16))); setReaded.Style = AlertButtonStyle.CheckButton; setReaded.Down = false; setReaded.Hint = "Mark Readed"; setReaded.Name = "MarkReaded"; alertControl.Buttons.Add(setReaded); AlertButton deleteBtn = new AlertButton(new Bitmap(WinFormsResourceService.GetBitmap("overlay_delete"), new Size(16, 16))); deleteBtn.Style = AlertButtonStyle.CheckButton; deleteBtn.Down = false; deleteBtn.Hint = "Delete Notification"; deleteBtn.Name = "DelNotification"; alertControl.Buttons.Add(deleteBtn); alertControl.ButtonClick += new AlertButtonClickEventHandler(DelButtonClick); alertControl.BeforeFormShow += (sender, e) => { e.AlertForm.BackgroundImage = WinFormsResourceService.GetBitmap("nback"); e.AlertForm.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; int l = 1; while (e.AlertForm.AlertInfo.Text.Length > 12 * l) { e.AlertForm.AlertInfo.Text = e.AlertForm.AlertInfo.Text.Insert(12 * l, " "); l++; } e.AlertForm.Size = new System.Drawing.Size(320, 300); }; alertControl.AlertClick += (sender, e) => { NotificationDTO data = (NotificationDTO)e.Info.Tag; MarkReaded(objectSpace, data); e.AlertForm.Tag = data; e.AlertForm.Disposed += AlertForm_Disposed; e.AlertForm.Close(); }; AlertManage manager = new AlertManage(alertControl, form); foreach (var notificationInfo in notificationInfos) { var pro = notificationInfo.GetType().GetProperty("NotificationRecipientId"); if (pro == null) { continue; } Guid notificationRecipientId = (Guid)pro.GetValue(notificationInfo, null); var notificationUser = (Katrin.Domain.Impl.NotificationRecipient)objectSpace.GetOrNew("NotificationRecipient", notificationRecipientId, null); notificationUser.NotificationStatus = "Opened"; manager.ShowAlert((NotificationDTO)notificationInfo); } objectSpace.SaveChanges(); }