コード例 #1
0
        protected override string GetDescription(WorkEvent workEvent, ApplicationUser forUser)
        {
            var user = this._userService.Get(workEvent.Data);

            if (!workEvent.ObjectId.HasValue)
            {
                throw new PmsException("Error in event model");
            }
            var item = this._workItemService.GetWithNoTracking(workEvent.ObjectId.Value);
            var text = GetStartText(forUser);

            text += IsUserAuthor ? $" {NotificationResources.HaveDisappointed} " : $" {NotificationResources.Disappointed} ";
            text += $"{LexicalHelper.GetWorkItemTypeInCase(item.Type, "a")} {item.GetWorkItemIdentityText()} c пользователя {user.GetUserIdentityText()}.";
            return(text);
        }
コード例 #2
0
        protected override string GetDescription(WorkEvent workEvent, ApplicationUser forUser)
        {
            var stateChangedModel = JsonConvert.DeserializeObject <StateChangedModel>(workEvent.Data);

            if (!workEvent.ObjectId.HasValue)
            {
                throw new PmsException("Error in event model");
            }
            var item = _workItemService.GetWithNoTracking(workEvent.ObjectId.Value);

            _isUserExecutor = workEvent.UserId == item.ExecutorId;
            var  user         = _userService.Get(workEvent.UserId);
            var  text         = GetStartText(user);
            bool needAddition = true;

            text += GetTextForStateChanging(stateChangedModel, item, ref needAddition);
            if (needAddition)
            {
                text += LexicalHelper.GetWorkItemTypeInCase(item.Type, "a") + " ";
            }
            text += item.GetWorkItemIdentityText() + ".";
            return(text);
        }
コード例 #3
0
        protected override string GetDescription(WorkEvent workEvent, ApplicationUser forUser)
        {
            var appointedUser = _userService.Get(workEvent.Data);

            if (appointedUser == null)
            {
                throw new PmsException("Invalid event data. Must be Id.");
            }
            var appointedUserText = appointedUser.Id == forUser.Id
                ? (IsUserAuthor ? " себе " : " вам ")
                : " пользователю " + appointedUser.GetUserIdentityText();

            if (!workEvent.ObjectId.HasValue)
            {
                throw new PmsException("Error in event model");
            }
            var user = _userService.Get(workEvent.UserId);
            var item = _workItemService.GetWithNoTracking(workEvent.ObjectId.Value);
            var text = GetStartText(user);

            text += IsUserAuthor ? $" {NotificationResources.HaveAppointed} " : $" {NotificationResources.Appointed} ";
            text += appointedUserText + $"{LexicalHelper.GetWorkItemTypeInCase(item.Type, "a")} {item.GetWorkItemIdentityText()}.";
            return(text);
        }
コード例 #4
0
        private string GetItemName(WorkItemType type, int i, WorkItem parent)
        {
            var name = (parent?.Name ?? "") + " " + LexicalHelper.GetWorkItemTypeInCase(type, "n") + i;

            return(name);
        }
コード例 #5
0
        /// <summary>
        /// Внутренний метод получения описания события
        /// </summary>
        /// <param name="workEvent">Событие</param>
        /// <param name="forUser">Пользователь, для которого создается описание</param>
        /// <returns></returns>
        protected override string GetDescription(WorkEvent workEvent, ApplicationUser forUser)
        {
            var item = this._workItemService.GetWithNoTracking(workEvent.ObjectId.Value);

            return($"{GetStartText(forUser)} {GetActionString()} {LexicalHelper.GetWorkItemTypeInCase(item.Type, "a")} {item.GetWorkItemIdentityText()}.");
        }
コード例 #6
0
        private string GetTextForStateChanging(StateChangedModel stateChangedModel, WorkItem item, ref bool needAddition)
        {
            var oldState = stateChangedModel.Old;
            var newState = stateChangedModel.New;
            var text     = "";

            switch (newState)
            {
            case WorkItemState.New:
            case WorkItemState.Planned:
                text += IsUserAuthor ? $" {NotificationResources.HaveMovedToPlanned} " : $" {NotificationResources.MovedToPlanned} ";
                break;

            case WorkItemState.Done:
                if (oldState == WorkItemState.Reviewing)
                {
                    text        += IsUserAuthor ? $" {NotificationResources.HaveConfirmed} " : $" {NotificationResources.Confirmed} ";
                    text        += LexicalHelper.GetWorkItemTypeInCase(item.Type, "g") + " ";
                    needAddition = false;
                }
                else
                {
                    text += IsUserAuthor ? $" {NotificationResources.HaveFinished} " : $" {NotificationResources.Finished} ";
                }
                break;

            case WorkItemState.Deleted:
                text += IsUserAuthor ? $" {NotificationResources.HaveDeleted} " : $" {NotificationResources.Deleted} ";
                break;

            case WorkItemState.Archive:
                text += IsUserAuthor ? $" {NotificationResources.HaveMovedToArchive} " : $" {NotificationResources.MovedToArchive} ";
                break;

            case WorkItemState.Reviewing:
                if (_isUserExecutor)
                {
                    text += IsUserAuthor ? $" {NotificationResources.HaveMovedToChecking} " : $" {NotificationResources.MovedToChecking} ";
                }
                else
                {
                    text += IsUserAuthor ? $" {NotificationResources.HaveMoved} " : $" {NotificationResources.Moved} ";
                    text += NotificationResources.ToChecking + " ";
                }
                break;

            case WorkItemState.AtWork:
                if (oldState == WorkItemState.Planned)
                {
                    if (_isUserExecutor)
                    {
                        text += IsUserAuthor ? $" {NotificationResources.HaveTook} " : $" {NotificationResources.Took} ";
                    }
                    else
                    {
                        text += IsUserAuthor ? $" {NotificationResources.HaveMoved} " : $" {NotificationResources.Moved} ";
                        text += NotificationResources.ToWork + " ";
                    }
                }
                else
                {
                    if (_isUserExecutor)
                    {
                        text += IsUserAuthor ? $" {NotificationResources.HaveMovedToRebuild} " : $" {NotificationResources.MovedToRebuild} ";
                    }
                    else
                    {
                        text += IsUserAuthor ? $" {NotificationResources.HaveMoved} " : $" {NotificationResources.Moved} ";
                        text += NotificationResources.ToRebuild + " ";
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(newState), newState, null);
            }
            return(text);
        }