private static void DelButtonClick(object sender, AlertButtonClickEventArgs e) { var notifcation = e.AlertForm.AlertInfo.Tag as NotificationDTO; if (notifcation == null) { return; } if (notifcation.NotificationRecipientId == Guid.Empty) { return; } IObjectSpace objectSpace = new ODataObjectSpace(); if (e.ButtonName == "DelNotification") { e.Button.Name = "Deleted"; var recipent = objectSpace.GetOrNew("NotificationRecipient", notifcation.NotificationRecipientId, null); objectSpace.DeleteObject("NotificationRecipient", recipent); objectSpace.SaveChanges(); notifcation.NotificationRecipientId = Guid.Empty; timer_Elapsed(null, null); } else if (e.ButtonName == "MarkReaded") { e.Button.Name = "Marked"; MarkReaded(objectSpace, notifcation); e.Button.Image = new Bitmap(WinFormsResourceService.GetBitmap("sendsysmsg"), new Size(16, 16)); timer_Elapsed(null, null); } }
void View_OnSendSysMessage(object sender, EventArgs e) { IObjectSpace objectSpace = new ODataObjectSpace(); var notification = (Katrin.Domain.Impl.Notification)objectSpace.GetOrNew("Notification", Guid.Empty, "NotificationRecipients"); Guid notificationId = notification.NotificationId; notification.ObjectType = "sysMsg"; notification.Subject = _sysMessageData.Subject; notification.Body = _sysMessageData.Body; var recipients = notification.NotificationRecipients; //Type recipientType = DynamicTypeBuilder.Instance.GetDynamicType("NotificationRecipient"); foreach (Guid receiverId in _sendView.GetReceiverList()) { if (receiverId == AuthorizationManager.CurrentUserId) { continue; } var recipient = new Katrin.Domain.Impl.NotificationRecipient(); recipient.NotificationRecipientId = Guid.NewGuid(); recipient.NotificationId = notificationId; recipient.RecipientId = receiverId; recipient.NotificationStatus = "NotSend"; recipients.Add(recipient); } objectSpace.SaveChanges(); _sendView.CloseView(); }
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(); }
public void MoveTaskToIteration(Guid?iterationId) { IObjectSpace iobjectSpace = new ODataObjectSpace(); Guid projectTaskId = this._objectSpace.GetObjectId(this.ObjectName, this.SelectedObject); object projectTask = iobjectSpace.GetOrNew(this.ObjectName, projectTaskId, null); Katrin.Domain.Impl.ProjectTask task = projectTask as Katrin.Domain.Impl.ProjectTask; task.ProjectIterationId = iterationId; iobjectSpace.SaveChanges(); this.BindListData(); //update detail IList <ProjectTaskDetailController> controllers = this.Context.AppContext.ControllerFinder.FinController <ProjectTaskDetailController>("ProjectTaskDetail"); var detailControllers = controllers.Where(p => p.ObjectId == task.TaskId); foreach (var controller in detailControllers) { controller.UpdateIteration(iterationId); } }