Ejemplo n.º 1
0
        ///
        ///	 <summary> * Create or modify a PhaseTime Audit and fill it If the phase is identical to the prior phase that has been set,
        ///	 * the existing PhaseTime is modified otherwise an existing phaseTime is closed and a new phaseTime is appended
        ///	 * Phasetime elements with different Parts are treated independently
        ///	 *  </summary>
        ///	 * <param name="status"> the node status at this time </param>
        ///	 * <param name="statusDetails"> details of this status </param>
        ///	 * <param name="vmParts"> defines a vector of map of parts for which the PhaseTime is valid </param>
        ///	 * <param name="employees"> Vector of employees that are currently registered for this job </param>
        ///	 * <returns> JDFPhaseTime the newly created PhaseTime audit
        ///	 *
        ///	 *         default: SetPhase(status, null,null,null) </returns>
        ///
        public virtual JDFPhaseTime setPhase(EnumNodeStatus status, string statusDetails, VJDFAttributeMap vmParts, VElement employees)
        {
            string statusDetailsLocal = statusDetails;

            JDFPhaseTime pt = getLastPhase(vmParts, null);

            statusDetailsLocal = StringUtil.getNonEmpty(statusDetailsLocal);
            bool     bChanged    = false;
            VElement ptEmployees = pt == null ? new VElement() : pt.getChildElementVector(ElementName.EMPLOYEE, null);

            if (pt == null)
            {
                bChanged = true;
            }
            else if (!ContainerUtil.Equals(pt.getStatus(), status) || !ContainerUtil.Equals(statusDetailsLocal, pt.getAttribute(AttributeName.STATUSDETAILS, null, null)) || !ptEmployees.isEqual(employees))
            {
                pt.setEnd(new JDFDate());
                bChanged = true;
            }
            if (bChanged)
            {
                pt = addPhaseTime(status, null, vmParts);
                pt.setStatusDetails(statusDetailsLocal);
                pt.copyElements(employees, null);
            }
            return(pt);
        }