コード例 #1
0
        /// <summary>
        /// Determines if a transition exists between the <paramref name="fromState" /> and
        /// the <paramref name="toState" /> states for the specified <paramref name="user" />.
        /// </summary>
        /// <param name="source">The transitions.</param>
        /// <param name="user">The user.</param>
        /// <param name="fromState">The From state.</param>
        /// <param name="toState">The To state.</param>
        /// <returns>
        /// Returns a <see cref="bool" /> representing <c>true</c> if there exists a transition; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// user
        /// or
        /// fromState
        /// or
        /// toState
        /// </exception>
        public static bool IsValidTransition(this IMMPxTransition source, IMMPxUser user, IMMPxState fromState, IMMPxState toState)
        {
            if (source == null)
            {
                return(false);
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (fromState == null)
            {
                throw new ArgumentNullException("fromState");
            }
            if (toState == null)
            {
                throw new ArgumentNullException("toState");
            }

            // Compare the from and to states from the enumerations.
            if (source.FromStates.Contains(fromState) && source.ToStates.Contains(toState))
            {
                // Found a transition with matching To/From states, now check to see
                // if the user has the proper role assigned to run the transition.
                if (user.AnyRoleForTransition(source))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
ファイル: WorkLocation.cs プロジェクト: wey12138/Wave
        /// <summary>
        ///     Initializes the process framework node wrapper using the specified <paramref name="user" /> for the node.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <param name="user"></param>
        /// <returns>
        ///     Returns <see cref="bool" /> representing <c>true</c> if the node was successfully initialized; otherwise
        ///     <c>false</c>.
        /// </returns>
        protected override bool Initialize(IMMWorkflowManager extension, IMMPxUser user)
        {
            string nodeTypeName = NodeTypeName;

            _Worklocation = (IMMWMSWorklocation)extension.CreateWMSNode(ref nodeTypeName);

            return(_Worklocation != null);
        }
コード例 #3
0
ファイル: CompatibleUnit.cs プロジェクト: wey12138/Wave
        /// <summary>
        ///     Initializes the process framework node wrapper using the specified <paramref name="user" /> for the node.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <param name="user"></param>
        /// <returns>
        ///     Returns <see cref="bool" /> representing <c>true</c> if the node was successfully initialized; otherwise
        ///     <c>false</c>.
        /// </returns>
        protected override bool Initialize(IMMWorkflowManager extension, IMMPxUser user)
        {
            string nodeTypeName = NodeTypeName;

            _CompatibleUnit = (IMMWMSCompatibleUnit)extension.CreateWMSNode(ref nodeTypeName);

            return(_CompatibleUnit != null);
        }
コード例 #4
0
        /// <summary>
        ///     Creates the process framework node wrapper for the specified the <paramref name="user" />.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <param name="user">The current user.</param>
        /// <returns>
        ///     Returns <see cref="Boolean" /> representing <c>true</c> if the node was successfully created; otherwise
        ///     <c>false</c>.
        /// </returns>
        protected override bool Initialize(IMMSessionManager extension, IMMPxUser user)
        {
            string createUser = user.Name;

            _Session = extension.CreateSession();
            _Session.set_CreateUser(ref createUser);

            return(_Session != null);
        }
コード例 #5
0
        /// <summary>
        ///     Creates the process framework node wrapper for the specified the <paramref name="user" />.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <param name="user">The current user.</param>
        protected override bool Initialize(IMMWorkflowManager extension, IMMPxUser user)
        {
            int    ownerID      = user.Id;
            string nodeTypeName = NodeTypeName;

            _WorkRequest = (IMMWMSWorkRequest)extension.CreateWMSNode(ref nodeTypeName);
            _WorkRequest.set_OwnerID(ref ownerID);

            return(_WorkRequest != null);
        }
コード例 #6
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IMMEnumPxUser" />
        /// </summary>
        /// <param name="source">An <see cref="IMMEnumPxUser" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>
        ///     An <see cref="IEnumerable{T}" /> that contains the fields from the input source.
        /// </returns>
        public static IEnumerable <IMMPxUser> AsEnumerable(this IMMEnumPxUser source)
        {
            if (source != null)
            {
                source.Reset();
                IMMPxUser user = source.Next();
                while (user != null)
                {
                    yield return(user);

                    user = source.Next();
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Determines if a transition exists between the <paramref name="fromState" /> and
        /// the <paramref name="toState" /> states for the specified <paramref name="user" />.
        /// </summary>
        /// <param name="source">The transitions.</param>
        /// <param name="user">The user.</param>
        /// <param name="fromState">The From state.</param>
        /// <param name="toState">The To state.</param>
        /// <returns>
        /// Returns a <see cref="bool" /> representing <c>true</c> if there exists a transition; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// user
        /// or
        /// fromState
        /// or
        /// toState
        /// </exception>
        public static bool IsValidTransition(this IMMEnumPxTransition source, IMMPxUser user, IMMPxState fromState, IMMPxState toState)
        {
            if (source == null)
            {
                return(false);
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (fromState == null)
            {
                throw new ArgumentNullException("fromState");
            }
            if (toState == null)
            {
                throw new ArgumentNullException("toState");
            }

            return(source.AsEnumerable().Any(transition => transition.IsValidTransition(user, fromState, toState)));
        }
コード例 #8
0
ファイル: PxUserExtensions.cs プロジェクト: wey12138/Wave
        /// <summary>
        /// Determines whether the given <paramref name="source" /> has at least one matching
        /// role for the <paramref name="transition" />.
        /// </summary>
        /// <param name="source">The user.</param>
        /// <param name="transition">The transition.</param>
        /// <returns>
        ///   <c>true</c> if the user has at least one matching role with the transition; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">transition</exception>
        public static bool AnyRoleForTransition(this IMMPxUser source, IMMPxTransition transition)
        {
            if (source == null)
            {
                return(false);
            }
            if (transition == null)
            {
                throw new ArgumentNullException("transition");
            }

            foreach (var userRole in source.Roles.AsEnumerable())
            {
                foreach (var transitionRole in transition.Roles.AsEnumerable())
                {
                    if (userRole == transitionRole)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #9
0
        public void IMMPxApplication_GetUserByName_IsNotNull()
        {
            IMMPxUser user = base.PxApplication.GetUser("adams");

            Assert.IsNotNull(user);
        }
コード例 #10
0
        public void IMMPxApplication_GetUserByID_IsNotNull()
        {
            IMMPxUser user = base.PxApplication.GetUser(base.PxApplication.User.Id);

            Assert.IsNotNull(user);
        }
コード例 #11
0
ファイル: DesignTest.cs プロジェクト: wey12138/Wave
        /// <summary>
        ///     Creates the process framework node wrapper for the specified the <paramref name="user" />.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <param name="user">The current user.</param>
        /// <returns>
        ///     Returns <see cref="bool" /> representing <c>true</c> if the node was successfully created; otherwise <c>false</c>.
        /// </returns>
        protected override bool Initialize(IMMWorkflowManager extension, IMMPxUser user)
        {
            this.IsNew = true;

            return(base.Initialize(extension, user));
        }
コード例 #12
0
ファイル: BasePxNode.cs プロジェクト: wey12138/Wave
 /// <summary>
 ///     Initializes the process framework node wrapper using the specified <paramref name="user" /> for the node.
 /// </summary>
 /// <param name="extension">The extension.</param>
 /// <param name="user">The user.</param>
 /// <returns>
 ///     Returns <see cref="Boolean" /> representing <c>true</c> if the node was successfully created; otherwise
 ///     <c>false</c>.
 /// </returns>
 protected abstract bool Initialize(TFrameworkExtension extension, IMMPxUser user);