Ejemplo n.º 1
0
        /// <summary>
        ///     Determines of the tree tool is enabled for the specified selection of items.
        /// </summary>
        /// <param name="selection">The selection.</param>
        /// <returns>
        ///     Returns bitwise flag combination of the <see cref="mmToolState" /> to specify if enabled.
        /// </returns>
        protected virtual int InternalEnabled(IMMTreeViewSelection selection)
        {
            if (selection == null)
            {
                return(0);
            }

            if (selection.Count != 1)
            {
                return(0);
            }

            selection.Reset();
            IMMPxNode node = (IMMPxNode)selection.Next;
            IMMPxTask task = ((IMMPxNode3)node).GetTaskByName(this.Name);

            if (task == null)
            {
                return(0);
            }

            if (task.get_Enabled(node))
            {
                return(3);
            }

            return(0);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Gets the deleter that is used to clean up the associated parent node (i.e. the Session or Design,  Work Request).
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns>
        ///     Returns the <see cref="Miner.Interop.Process.IMMPxDeleter" /> representing the deleter for the node.
        /// </returns>
        protected IMMPxDeleter GetNodeDeleter(IMMPxNode node)
        {
            if (this.PxApplication == null || node == null)
            {
                return(null);
            }

            if (node.NodeType == this.PxApplication.Helper.GetNodeTypeID(Design.NodeTypeName))
            {
                return(new clsDNDeleterClass());
            }

            if (node.NodeType == this.PxApplication.Helper.GetNodeTypeID(WorkRequest.NodeTypeName))
            {
                return(new clsWRDeleterClass());
            }

            if (node.NodeType == this.PxApplication.Helper.GetNodeTypeID(Session.NodeTypeName))
            {
                Type   t   = Type.GetTypeFromProgID("mmSessionManager.clsSessionDeleter");
                object obj = Activator.CreateInstance(t);
                return((IMMPxDeleter)obj);
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Finds the transition that matches the specified <paramref name="transitionName" /> in the name or display name for
        ///     the available transitions.
        /// </summary>
        /// <param name="source">The node.</param>
        /// <param name="transitionName">Name of the transition.</param>
        /// <returns>
        ///     Returns a <see cref="IMMPxTransition" /> representing the state that matches the identifier; otherwise <c>null</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">transitionName</exception>
        public static IMMPxTransition GetTransition(this IMMPxNode source, string transitionName)
        {
            if (source == null)
            {
                return(null);
            }
            if (transitionName == null)
            {
                throw new ArgumentNullException("transitionName");
            }

            foreach (var transition in source.Transitions.AsEnumerable())
            {
                if (string.Equals(transition.Name, transitionName, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(transition);
                }

                if (string.Equals(transition.DisplayName, transitionName, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(transition);
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Executes the cost engine for the specified report.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns>
        ///     An XML <see cref="string" /> of the report.
        /// </returns>
        /// <remarks>
        ///     By default it will return the XML string for the ArcFM Inventory.
        /// </remarks>
        protected override string InternalExecute(IMMPxNode node)
        {
            IMMWMSReportingEngine engine = new clsMMInventoryEngineClass();

            if (engine.Initialize(this.PxApplication))
            {
                return(engine.Execute(node));
            }

            return(string.Empty);
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IMMEnumPxState" />
 /// </summary>
 /// <param name="source">An <see cref="IMMEnumPxState" /> 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 <IMMPxNode> AsEnumerable(this IMMPxNode source)
 {
     if (source != null)
     {
         while (source != null)
         {
             source = ((ID8ListItem)source).ContainedBy as IMMPxNode;
             yield return(source);
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        ///     Gets the fully qualified name of the version.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="node">The node.</param>
        /// <returns>Returns a <see cref="string" /> representing the name of the version.</returns>
        public static string GetVersionName(this IMMPxSDEVersionNamer source, IMMPxNode node)
        {
            var baseVersion = source.GetBaseVersionName(node.Id);
            var versionName = source.GetVersionName(node.Id);

            if (string.IsNullOrEmpty(baseVersion))
            {
                return(versionName);
            }

            return(string.Format("{0}{1}", baseVersion, versionName));
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Executes the cost engine for the specified report.
        /// </summary>
        /// <param name="pPxNode">The node.</param>
        /// <returns>
        ///     An XML <see cref="string" /> of the report.
        /// </returns>
        public virtual string Execute(IMMPxNode pPxNode)
        {
            try
            {
                return(this.InternalExecute(pPxNode));
            }
            catch (Exception e)
            {
                Log.Error("Error Executing Reporting Engine " + this.DisplayName, e);
            }

            return(string.Empty);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Sets the <see cref="IMMPxApplication" /> to reference the specified <paramref name="node" />.
        /// </summary>
        /// <param name="source">The process framework application.</param>
        /// <param name="node">The node.</param>
        /// <exception cref="ArgumentNullException">node</exception>
        public static void SetCurrentNode(this IMMPxApplication source, IMMPxNode node)
        {
            if (source == null)
            {
                return;
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            ((IMMPxApplicationEx)source).CurrentNode = node;
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Executes the subtask using the specified px node.
        /// </summary>
        /// <param name="pPxNode">The node.</param>
        /// <returns><c>true</c> if the success; otherwise false.</returns>
        public virtual bool Execute(IMMPxNode pPxNode)
        {
            try
            {
                return(this.InternalExecute(pPxNode));
            }
            catch (Exception e)
            {
                Log.Error("Error Executing Subtask " + this.Name, e);
            }

            return(false);
        }
Ejemplo n.º 10
0
 /// <summary>
 ///     Called when the user clicks a command.
 /// </summary>
 /// <remarks>
 ///     Note to inheritors: override OnClick and use this method to
 ///     perform the actual work of the custom command.
 /// </remarks>
 public override void OnClick()
 {
     try
     {
         IMMPxApplication pxApp = this.Application.GetPxApplication();
         IMMPxNode        node  = pxApp.GetCurrentNode();
         IMMPxTask        task  = node.GetTask(this.TaskName, true);
         task.Execute(node);
     }
     catch (Exception ex)
     {
         Log.Error(this.Caption, ex);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        ///     Gets the name of the version for the specified <paramref name="node" />.
        /// </summary>
        /// <param name="source">The process framework application reference.</param>
        /// <param name="node">The node.</param>
        /// <returns>
        ///     Returns a <see cref="String" /> representing the name of the version; otherwise <c>null</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">node</exception>
        /// <remarks>
        ///     The node needs to be refer to a session or design, otherwise the
        ///     version name will be <c>null</c>.
        /// </remarks>
        public static string GetVersionName(this IMMPxApplication source, IMMPxNode node)
        {
            if (source == null)
            {
                return(null);
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            var version = ((IMMPxApplicationEx2)source).GetVersionNamer(node.NodeType);

            return(version.GetVersionName(node));
        }
Ejemplo n.º 12
0
        /// <summary>
        ///     Finds the transition using the specified <paramref name="transitionID" />.
        /// </summary>
        /// <param name="source">The node.</param>
        /// <param name="transitionID">The transition ID.</param>
        /// <returns>
        ///     The <see cref="IMMPxTransition" /> matching the specified transition name; otherwise <c>null</c>.
        /// </returns>
        public static IMMPxTransition GetTransition(this IMMPxNode source, int transitionID)
        {
            if (source == null)
            {
                return(null);
            }

            foreach (var transition in source.Transitions.AsEnumerable())
            {
                if (transition.TransitionID == transitionID)
                {
                    return(transition);
                }
            }

            return(null);
        }
Ejemplo n.º 13
0
        /// <summary>
        ///     Adds the node as a child to the specified <paramref name="parent" />.
        /// </summary>
        /// <param name="source">The node.</param>
        /// <param name="parent">The parent.</param>
        /// <exception cref="ArgumentNullException">parent</exception>
        public static void Add(this IMMPxNode source, IMMPxNode parent)
        {
            if (source == null)
            {
                return;
            }
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            ID8List list = (ID8List)parent;

            ((ID8ListEx)parent).BuildChildren = true;

            list.Add((ID8ListItem)source);
        }
Ejemplo n.º 14
0
        /// <summary>
        ///     Returns the current top level node of the list that the specified node belongs to.
        /// </summary>
        /// <param name="source">The starting node.</param>
        /// <returns>
        ///     Returns the <see cref="Miner.Interop.Process.IMMPxNode" /> representing the top level node; otherwise <c>null</c>.
        /// </returns>
        public static IMMPxNode GetTopLevelNode(this IMMPxNode source)
        {
            if (source == null)
            {
                return(null);
            }

            foreach (var node in source.AsEnumerable())
            {
                if (((IMMPxNode2)node).IsPxTopLevel)
                {
                    return(node);
                }
            }

            return(null);
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     Deletes the specified px node from the process framework database table.
        /// </summary>
        /// <param name="pPxNode">The node.</param>
        /// <param name="sMsg">The message.</param>
        /// <param name="status">The status.</param>
        public virtual void Delete(IMMPxNode pPxNode, ref string sMsg, ref int status)
        {
            try
            {
                this.InternalDelete(pPxNode, ref sMsg, ref status);

                if (string.IsNullOrEmpty(sMsg) && this.PxApplication != null)
                {
                    sMsg = string.Format("{0} {1} deleted successfully.", this.PxApplication.GetNodeTypeName(pPxNode), pPxNode.Id);
                }
            }
            catch (Exception e)
            {
                Log.Error("Error Executing Deleter " + this.DisplayName, e);
                this.Notify(e.Message, mmUserMessageType.mmUMTDataError);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        ///     Executes the task with the given name, if it exists, on the given node.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="taskName">Name of the task.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing <c>true</c> when successfully executed the task.
        /// </returns>
        public static bool ExecuteTask(this IMMPxNode source, string taskName)
        {
            var task = source.GetTask(taskName);

            if (task == null)
            {
                return(false);
            }

            var transition = ((IMMPxTask2)task).Transition;

            if (!transition.FromStates.Contains(source.State))
            {
                return(false);
            }

            return(task.Execute(source));
        }
Ejemplo n.º 17
0
        /// <summary>
        ///     Rollbacks the subtask using the specified px node.
        /// </summary>
        /// <param name="pPxNode">The node.</param>
        /// <returns><c>true</c> if rollback successfully; otherwise <c>false</c>.</returns>
        public virtual bool Rollback(IMMPxNode pPxNode)
        {
            try
            {
                return(this.InternalRollback(pPxNode));
            }
            catch (Exception e)
            {
                if (MinerRuntimeEnvironment.IsUserInterfaceSupported)
                {
                    MessageBox.Show(Document.ParentWindow, e.Message, string.Format("Error Rollback Subtask {0}", this.Name), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Log.Error("Error Rollback Subtask " + this.Name, e);
            }

            return(false);
        }
Ejemplo n.º 18
0
        /// <summary>
        ///     Executes the tree tool within error handling.
        /// </summary>
        /// <param name="selection">The selection.</param>
        protected virtual void InternalExecute(IMMTreeViewSelection selection)
        {
            // Only enable if 1 item is selected.
            if (selection == null || selection.Count != 1)
            {
                return;
            }

            // Execute the Task for the specified node.
            selection.Reset();
            IMMPxNode node = (IMMPxNode)selection.Next;
            IMMPxTask task = ((IMMPxNode3)node).GetTaskByName(this.Name);

            if (task == null)
            {
                return;
            }

            task.Execute(node);
        }
Ejemplo n.º 19
0
        /// <summary>
        ///     Finds the task using the specified <paramref name="source" /> and <paramref name="taskID" />.
        /// </summary>
        /// <param name="source">The node.</param>
        /// <param name="taskID">The task ID.</param>
        /// <returns>
        ///     Returns a <see cref="IMMPxTask" /> representing the tasks that matches specified task name for the given node;
        ///     otherwise <c>null</c>.
        /// </returns>
        public static IMMPxTask GetTask(this IMMPxNode source, int taskID)
        {
            IMMPxNode3 node3 = source as IMMPxNode3;

            if (node3 == null)
            {
                return(null);
            }

            IMMEnumPxTasks tasks = node3.EnabledTasks;

            foreach (var task in tasks.AsEnumerable())
            {
                if (taskID == task.TaskID)
                {
                    return(task);
                }
            }

            return(null);
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     Performs the queries necessary to build the list.
        /// </summary>
        /// <param name="pList">The list.</param>
        public override void BuildList(ID8List pList)
        {
            if (pList == null)
            {
                return;
            }

            if (!this.Validate((IMMPxNode)pList))
            {
                return;
            }

            foreach (var nodeID in _NodeIDs)
            {
                IMMPxNode node = this.GetNode(nodeID);
                if (node != null)
                {
                    pList.Add((ID8ListItem)node);
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        ///     Deletes the specified <paramref name="node" />from the process framework database table
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="message">The message.</param>
        /// <param name="status">The status.</param>
        protected override void InternalDelete(IMMPxNode node, ref string message, ref int status)
        {
            if (node == null)
            {
                return;
            }

            IMMPxDeleter deleter = this.GetNodeDeleter(node);

            if (deleter != null)
            {
                deleter.PxApplication = base.PxApplication;
                deleter.Delete(node, ref message, ref status);
            }

            BasePxEdmRepository edm = this.GetEdmRepository(base.PxApplication);

            if (edm != null && edm.Initialize(base.PxApplication))
            {
                edm.Delete(node.Id);
                message += string.Format(CultureInfo.CurrentCulture, ". Deleted the EDM values for the node with ID: {0}.", node.Id);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Finds the task using the specified <paramref name="source" /> and <paramref name="taskName" />.
        /// </summary>
        /// <param name="source">The node.</param>
        /// <param name="taskName">Name of the task.</param>
        /// <param name="enabledTask">if set to <c>true</c> if the task must be enabled.</param>
        /// <returns>
        ///     Returns a <see cref="IMMPxTask" /> representing the tasks that matches specified task name for the given node;
        ///     otherwise <c>null</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">taskName</exception>
        public static IMMPxTask GetTask(this IMMPxNode source, string taskName, bool enabledTask)
        {
            if (source == null)
            {
                return(null);
            }
            if (taskName == null)
            {
                throw new ArgumentNullException("taskName");
            }

            IEnumerable <IMMPxTask> tasks;

            if (enabledTask)
            {
                IMMPxNode3 node3 = source as IMMPxNode3;
                if (node3 == null)
                {
                    return(null);
                }

                tasks = node3.EnabledTasks.AsEnumerable();
            }
            else
            {
                IMMPxNode4 node4 = source as IMMPxNode4;
                if (node4 == null)
                {
                    return(null);
                }

                tasks = node4.AllTasks.AsEnumerable();
            }

            return(tasks.FirstOrDefault(o => o.Name.Equals(taskName, StringComparison.OrdinalIgnoreCase)));
        }
Ejemplo n.º 23
0
 /// <summary>
 ///     Finds the task using the specified <paramref name="source" /> and <paramref name="taskName" />.
 /// </summary>
 /// <param name="source">The node.</param>
 /// <param name="taskName">Name of the task.</param>
 /// <returns>
 ///     Returns a <see cref="IMMPxTask" /> representing the tasks that matches specified task name for the given node;
 ///     otherwise <c>null</c>.
 /// </returns>
 /// <exception cref="ArgumentNullException">taskName</exception>
 public static IMMPxTask GetTask(this IMMPxNode source, string taskName)
 {
     return(source.GetTask(taskName, false));
 }
Ejemplo n.º 24
0
 /// <summary>
 ///     Executes the cost engine for the specified report.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <returns>
 ///     An XML <see cref="string" /> of the report.
 /// </returns>
 protected virtual string InternalExecute(IMMPxNode node)
 {
     return(string.Empty);
 }
Ejemplo n.º 25
0
        public void IMMPxApplication_GetCurrentNode_IsNull()
        {
            IMMPxNode node = base.PxApplication.GetCurrentNode();

            Assert.IsNull(node);
        }
Ejemplo n.º 26
0
 /// <summary>
 ///     Deletes the specified <paramref name="node" />from the process framework database table
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="message">The message.</param>
 /// <param name="status">The status.</param>
 protected abstract void InternalDelete(IMMPxNode node, ref string message, ref int status);
Ejemplo n.º 27
0
 /// <summary>
 ///     Determines if the list should be built given the list node.
 /// </summary>
 /// <param name="node">The node of the root list.</param>
 /// <returns>
 ///     Returns a <see cref="bool" /> representing <c>true</c> if the list should be built; otherwise <c>false</c>.
 /// </returns>
 protected virtual bool Validate(IMMPxNode node)
 {
     return(node != null && node.NodeType != _NodeTypeID);
 }
Ejemplo n.º 28
0
 /// <summary>
 ///     Gets the name of the node type.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="node">The node.</param>
 /// <returns>Returns a <see cref="string" /> representing the name of the node type.</returns>
 public static string GetNodeTypeName(this IMMPxApplication source, IMMPxNode node)
 {
     return(((IMMPxHelper2)source.Helper).GetNodeTypeName(node.NodeType));
 }
Ejemplo n.º 29
0
 /// <summary>
 ///     Gets the collection of history for the specified node.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="node">The node.</param>
 /// <returns>
 ///     Returns a <see cref="IMMPxNodeHistory" /> representing the history collection.
 /// </returns>
 public static IMMPxNodeHistory GetHistory(this IMMPxApplication source, IMMPxNode node)
 {
     return(source.GetHistory(node.Id, node.NodeType));
 }
Ejemplo n.º 30
0
 /// <summary>
 ///     Adds the history record for the specified node.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="node">The node.</param>
 /// <param name="description">The description.</param>
 /// <param name="extraData">The extra data.</param>
 /// <returns>
 ///     Returns a <see cref="IMMPxNodeHistory" /> representing the history records.
 /// </returns>
 public static IMMPxNodeHistory AddHistory(this IMMPxApplication source, IMMPxNode node, string description, string extraData)
 {
     return(source.AddHistory(node.Id, node.NodeType, description, extraData));
 }