当前位置: 首页>>代码示例>>C#>>正文


C# IEditableRoot.ReadValueByPropertyName方法代码示例

本文整理汇总了C#中IEditableRoot.ReadValueByPropertyName方法的典型用法代码示例。如果您正苦于以下问题:C# IEditableRoot.ReadValueByPropertyName方法的具体用法?C# IEditableRoot.ReadValueByPropertyName怎么用?C# IEditableRoot.ReadValueByPropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEditableRoot的用法示例。


在下文中一共展示了IEditableRoot.ReadValueByPropertyName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        /// <summary>
        /// Executes the specified item.
        /// </summary>
        /// <param name="item">The target item.</param>
        /// <param name="oldItem">The old item.</param>
        public override void Execute(IEditableRoot item, IEditableRoot oldItem)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            var approval = item.ReadValueByPropertyName<IApprovalEdit>(ApprovalFieldName);

            if (approval == null)
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Approval field \"{0}\" not found in item \"{1}\" or you don't have access. Action will not run.", ApprovalFieldName, item.GetType()), "item");

            var membersFound = new HashSet<int>();

            foreach (var member in approval.MemberResults.Where(am => am.ApprovalLevel == approval.CurrentLevel))
            {
                if (member.GetApprovalMemberResult() != ApprovalMemberResults.Undecided)
                    continue;

                if (!member.Person.HasValue || !member.OriginalApprover.HasValue || membersFound.Contains(member.OriginalApprover.Value))
                    continue;

                membersFound.Add(member.OriginalApprover.Value);

                var person = PersonManager.GetPerson(member.Person.Value);
                if (person == null)
                    continue;

                var basePersonId = member.OriginalApprover.Value;
                var actionItem = DynamicTypeManager.NewActionItem();
                actionItem.ActionGuid = Guid.ToString();
                actionItem.Process = item.ProcessName;
                actionItem.PersonId = person.Id;
                actionItem.BasePersonId = basePersonId;
                actionItem.ItemId = item.Id;
                actionItem.IsActionNew = true;

                var supportStates = item as ISupportStates;
                if (supportStates != null)
                    actionItem.ItemStateId = supportStates.CurrentState;

                actionItem.Save();
                CommunicationService.NotifyActionsChanged(person.Id);

                if (SendEmail && !string.IsNullOrWhiteSpace(person.Email))
                {
                    SendMessage(item, person);
                }
            }

            if (SendEmail && !string.IsNullOrWhiteSpace(EmailFieldName))
            {
                var email = item.ReadValueByPropertyName<string>(EmailFieldName);

                if (!string.IsNullOrWhiteSpace(email))
                {
                    SendMessage(item, email);
                }
            }

            base.Execute(item, oldItem);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:65,代码来源:ApprovalActionDefinition.cs

示例2: Execute

        /// <summary>
        /// Executes the specified item.
        /// </summary>
        /// <param name="item">The source item.</param>
        /// <param name="oldItem">The old item.</param>
        public override void Execute(IEditableRoot item, IEditableRoot oldItem)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            foreach (var originalAssignee in DataContext.GetNewAssignees(item).DistinctBy(p => p.Id))
            {
                var assignee = originalAssignee;

                if (originalAssignee.OutOfOffice == true && originalAssignee.DelegateApproverId != null)
                {
                    assignee = PersonManager.GetFirstActivePerson(originalAssignee.Id) ?? originalAssignee;
                }

                var actionItem = DynamicTypeManager.NewActionItem();
                actionItem.ActionGuid = Guid.ToString();
                actionItem.Process = item.ProcessName;
                actionItem.PersonId = assignee.Id;
                actionItem.BasePersonId = originalAssignee.Id;
                actionItem.ItemId = item.Id;
                actionItem.IsActionNew = true;

                var states = item as ISupportStates;
                if (states != null)
                {
                    actionItem.ItemStateId = states.CurrentState;
                }

                actionItem.Save();

                CommunicationService.NotifyActionsChanged(assignee.Id);

                if (SendEmail && !string.IsNullOrWhiteSpace(assignee.Email))
                {
                    SendMessage(item, assignee);
                }
            }

            if (SendEmail && !string.IsNullOrWhiteSpace(EmailFieldName))
            {
                var email = item.ReadValueByPropertyName<string>(EmailFieldName);

                if (!string.IsNullOrWhiteSpace(email))
                {
                    SendMessage(item, email);
                }
            }

            base.Execute(item, oldItem);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:55,代码来源:AssignmentActionDefinition.cs


注:本文中的IEditableRoot.ReadValueByPropertyName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。