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);
            }
        }
示例#2
0
        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();
        }
        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);
            }
        }
        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();
        }
示例#5
0
        private void ShowRelatedView(string relatedObjectName, string objectName, object selectedEntity)
        {
            var relationshipRoles = MetadataRepository.EntityRelationshipRoles.Where(role => role.Entity.PhysicalName == objectName && role.NavPanelDisplayOption == 1);
            EntityRelationship entityRelationship = relationshipRoles.Where(c =>
                                                                            c.EntityRelationship.EntityRelationshipRoles
                                                                            .FirstOrDefault(r => r != c &&
                                                                                            r.RelationshipRoleType != (int)RelationshipRoleType.Relationship &&
                                                                                            r.Entity.PhysicalName == relatedObjectName) != null).FirstOrDefault().EntityRelationship;
            EntityRelationshipType relationshipType = (EntityRelationshipType)entityRelationship.EntityRelationshipType;
            IObjectSpace           objectSpace      = new ODataObjectSpace();
            var    currentEntityRelationRole        = entityRelationship.EntityRelationshipRoles.Single(r => r.Entity.PhysicalName == objectName);
            string relationTitle = GetLocationCaption(currentEntityRelationRole.Entity.PhysicalName) + "-";

            if (relationshipType == EntityRelationshipType.OneToMany)
            {
                var roleType     = (RelationshipRoleType)currentEntityRelationRole.RelationshipRoleType;
                var relationship = entityRelationship.EntityRelationshipRelationships.Single().Relationship;
                if (roleType == RelationshipRoleType.OneToMany)
                {
                    var desiredEntityName   = relationship.ReferencingEntity.PhysicalName;
                    var entityId            = objectSpace.GetObjectId(objectName, selectedEntity);
                    CriteriaOperator filter = new BinaryOperator(relationship.ReferencingAttribute.Name, entityId, BinaryOperatorType.Equal);
                    var result = objectSpace.GetObjects(desiredEntityName, filter, null);
                    if (result.Count > 0)
                    {
                        var parameters = new ActionParameters(relatedObjectName, Guid.Empty, ViewShowType.Show)
                        {
                            { "FixedFilter", filter }
                        };
                        App.Instance.Invoke(relatedObjectName, "List", parameters);
                    }
                    else
                    {
                        XtraMessageBox.Show(GetLocationCaption("NoRelatedData"), GetLocationCaption("Katrin"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    var    entityName          = relationship.ReferencedEntity.PhysicalName;
                    string desiredPropertyName = relationship.ReferencingAttribute.PhysicalName;
                    Guid   currentId           = objectSpace.GetObjectId(objectName, selectedEntity);
                    var    currentObject       = objectSpace.GetOrNew(objectName, currentId, null);
                    var    propertyInfo        = currentObject.GetType().GetProperty(desiredPropertyName);
                    var    id = propertyInfo.GetValue(currentObject, null);
                    if (id != null)
                    {
                        var relatedObject = objectSpace.GetOrNew(this.Parameter, (Guid)id, string.Empty);
                        if (relatedObject == null)
                        {
                            MessageService.ShowMessage(GetLocationCaption("NoRelatedData"));
                            return;
                        }
                        string detail     = "Detail";
                        var    parameters = new ActionParameters(relatedObjectName, (Guid)id, ViewShowType.Show)
                        {
                            { "WorkingMode", EntityDetailWorkingMode.View }
                        };
                        App.Instance.Invoke(relatedObjectName, detail, parameters);
                    }
                    else
                    {
                        XtraMessageBox.Show(GetLocationCaption("NoRelatedData"),
                                            GetLocationCaption("Katrin"),
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                var relationshipRole = entityRelationship.EntityRelationshipRoles
                                       .Single(r => (RelationshipRoleType)r.RelationshipRoleType == RelationshipRoleType.Relationship);
                var desiredEntityRole = entityRelationship.EntityRelationshipRoles
                                        .Single(r => r != relationshipRole && r != currentEntityRelationRole);
                var desiredEntityPropertyName =
                    entityRelationship.EntityRelationshipRelationships.Select(r => r.Relationship)
                    .Single(r => r.ReferencedEntity.EntityId == desiredEntityRole.Entity.EntityId).
                    ReferencedAttribute.PhysicalName;
                var knownPropertyName = entityRelationship.EntityRelationshipRelationships.Select(r => r.Relationship)
                                        .Single(r => r.ReferencedEntity.EntityId == currentEntityRelationRole.Entity.EntityId).
                                        ReferencedAttribute.PhysicalName;

                CriteriaOperator filter = new BinaryOperator(knownPropertyName, objectSpace.GetObjectId(objectName, selectedEntity));
                var relationships       = objectSpace.GetObjects(relationshipRole.Entity.PhysicalName, filter, null);

                List <object>    desiredEntityIds = new List <object>();
                CriteriaOperator relatedFilter    = null;
                for (int index = 0; index < relationships.Count; index++)
                {
                    var relatedObject   = relationships[index];
                    var propertyInfo    = relatedObject.GetType().GetProperty(desiredEntityPropertyName);
                    var desiredEntityId = propertyInfo.GetValue(relatedObject, null);
                    desiredEntityIds.Add(desiredEntityId);
                    relatedFilter |= new BinaryOperator(desiredEntityPropertyName, desiredEntityId);
                }
                if (desiredEntityIds.Any())
                {
                    if (desiredEntityIds.Count == 1)
                    {
                        string detail     = "Detail";
                        var    parameters = new ActionParameters(relatedObjectName, (Guid)desiredEntityIds[0], ViewShowType.Show)
                        {
                            { "WorkingMode", EntityDetailWorkingMode.View }
                        };
                        App.Instance.Invoke(desiredEntityRole.Entity.PhysicalName, detail, parameters);
                    }
                    else
                    {
                        var parameters = new ActionParameters(desiredEntityRole.Entity.PhysicalName, Guid.Empty, ViewShowType.Show)
                        {
                            { "FixedFilter", relatedFilter }
                        };
                        App.Instance.Invoke(desiredEntityRole.Entity.PhysicalName, "List", parameters);
                    }
                }
                else
                {
                    XtraMessageBox.Show(GetLocationCaption("NoRelatedData"),
                                        GetLocationCaption("Katrin"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }