Example #1
0
        /// Returns true if it is possible to go from start state to end state
        protected bool IsValidStateTransition(EProcessAction action, POV pu,
                                              EProcessState start, EProcessState end)
        {
            bool ok = false;

            switch (action)
            {
            case EProcessAction.Start:
                ok = start == EProcessState.NotStarted;
                break;

            case EProcessAction.Promote:
                ok = start >= EProcessState.FirstPass && start <EProcessState.ReviewLevel10 &&
                                                                end >= EProcessState.ReviewLevel1 && end <= EProcessState.ReviewLevel10 &&
                                                                end> start;
                break;

            case EProcessAction.Reject:
                ok = start != EProcessState.NotStarted;
                break;

            case EProcessAction.SignOff:
                ok = start >= EProcessState.ReviewLevel1;
                break;

            case EProcessAction.Submit:
                ok = start >= EProcessState.FirstPass && start < EProcessState.Submitted;
                break;

            case EProcessAction.Approve:
                ok = start == EProcessState.Submitted;
                break;

            case EProcessAction.Publish:
                ok = start >= EProcessState.Submitted && start < EProcessState.Published;
                break;
            }
            if (ok)
            {
                _log.TraceFormat("{0} {1} is in a valid state to {2}",
                                 ProcessUnitType.Capitalize(), pu, action);
            }
            else
            {
                _log.WarnFormat("{0} {1} is in the wrong state ({2}) to {3}",
                                ProcessUnitType.Capitalize(), pu, start, action);
            }
            return(ok);
        }
Example #2
0
	// 
	public void Perform( ECsgOperation inOper, CSGObject inMaster, CSGObject inSlave )
	{
		// we are processing our slave faces
		processState = EProcessState.Process_Slave;
		
		// process faces against master tree
		PerformFaces( inMaster.rootNode, inSlave.faces );
		
		// process face from master tree
		processState = EProcessState.Process_Master;
		
		// perform master faces on slave bsp tree
		PerformTree( inMaster.rootNode, inSlave.rootNode );
		
		// check if how do we need to process generated faces
		if( inOper == ECsgOperation.CsgOper_Additive || inOper == ECsgOperation.CsgOper_Subtractive )
		{
			// add deferred faces to master tree...
			for( int i = 0; i < deferredFaces.Count; i++ )
			{
				Face defFace = ((DeferredFace)deferredFaces[i]).face;
				BspNode startNode = ((DeferredFace)deferredFaces[i]).node;
				
				// testing
				startNode = inMaster.rootNode;
				// add node to master tree
				BspGen.AddNodeRecursive( startNode, defFace, BspNode.BspFlags_IsNew );
			}
		}
		else
		{
			// clear old faces list
			inMaster.faces.Clear();
			
			// copy created faces
			for( int i = 0; i < deferredFaces.Count; i++ )
			{
				inMaster.faces.Add( deferredFaces[i].face );
			}
			
		}
		
		// clear deferred faces
		deferredFaces.Clear();
		
	}
Example #3
0
        //
        public void Perform(ECsgOperation inOper, CSGObject inMaster, CSGObject inSlave)
        {
            // we are processing our slave faces
            processState = EProcessState.Process_Slave;

            // process faces against master tree
            PerformFaces(inMaster.rootNode, inSlave.faces);

            // process face from master tree
            processState = EProcessState.Process_Master;

            // perform master faces on slave bsp tree
            PerformTree(inMaster.rootNode, inSlave.rootNode);

            // check if how do we need to process generated faces
            if (inOper == ECsgOperation.CsgOper_Additive || inOper == ECsgOperation.CsgOper_Subtractive)
            {
                // add deferred faces to master tree...
                for (int i = 0; i < deferredFaces.Count; i++)
                {
                    Face    defFace   = ((DeferredFace)deferredFaces[i]).face;
                    BspNode startNode = ((DeferredFace)deferredFaces[i]).node;

                    // testing
                    startNode = inMaster.rootNode;
                    // add node to master tree
                    BspGen.AddNodeRecursive(startNode, defFace, BspNode.BspFlags_IsNew);
                }
            }
            else
            {
                // clear old faces list
                inMaster.faces.Clear();

                // copy created faces
                for (int i = 0; i < deferredFaces.Count; i++)
                {
                    inMaster.faces.Add(deferredFaces[i].face);
                }
            }

            // clear deferred faces
            deferredFaces.Clear();
        }
Example #4
0
        void Item_OnProcess(ITopologyItem sender, EProcessState state)
        {
            if (sender == null)
            {
                return;
            }

            UCTopologyItem uc = (UCTopologyItem)sender.Tag;

            if (uc != null)
            {
                // Activamos el procesado
                uc.AreInUse.InUse = state == EProcessState.PreProcess;
                uc.Invalidate();
            }

            // Controlamos las lineas de conexión
            foreach (ConnectedLine l in _Lines)
            {
                if (state == EProcessState.PreProcess)
                {
                    // Desactivar todas las lineas que iban a él
                    if (l.ToItem == sender)
                    {
                        l.AreInUse.InUse = false;
                    }
                }
                else
                {
                    // Activar todas las lineas que salen de él
                    if (l.FromItem == sender)
                    {
                        l.AreInUse.InUse = true;
                    }
                }
            }

            pItems.Invalidate(false);
        }
Example #5
0
        /// <summary>
        /// Returns the current user's access rights to the specified process unit
        /// </summary>
        public EAccessRights GetProcessUnitAccessRights(POV pov, out EProcessState state)
        {
            int   accessRights = 0;
            short currentState = 0;

            if (_metadata.UsesPhasedSubmissions)
            {
                if (HFM.HasVariableCustoms)
                {
#if HFM_11_1_2_2
                    HFM.Try("Retrieving phased submission access rights",
                            () => HsvDataSecurity.GetProcessUnitAccessRightsAndStateExExtDim(pov.HfmPovCOM,
                                                                                             Member.NOT_USED, out accessRights, out currentState));
#else
                    HFM.ThrowIncompatibleLibraryEx();
#endif
                }
                else
                {
                    HFM.Try("Retrieving phased submission access rights",
                            () => HsvDataSecurity.GetProcessUnitAccessRightsAndStateEx(pov.Scenario.Id, pov.Year.Id,
                                                                                       pov.Period.Id, pov.Entity.Id, pov.Entity.ParentId, pov.Value.Id,
                                                                                       pov.Account.Id, pov.ICP.Id, pov.Custom1.Id, pov.Custom2.Id,
                                                                                       pov.Custom3.Id, pov.Custom4.Id, Member.NOT_USED,
                                                                                       out accessRights, out currentState));
                }
            }
            else
            {
                HFM.Try("Retrieving process unit access rights",
                        () => HsvDataSecurity.GetProcessUnitAccessRightsAndState(pov.Scenario.Id, pov.Year.Id,
                                                                                 pov.Period.Id, pov.Entity.Id, pov.Entity.ParentId, pov.Value.Id,
                                                                                 out accessRights, out currentState));
            }
            state = (EProcessState)currentState;
            return((EAccessRights)accessRights);
        }
Example #6
0
        protected override EProcessState SetProcessState(POV pov, EProcessAction action, EProcessState targetState,
                                                         string annotation, string[] paths, string[] files)
        {
            short newState = 0;

            if (HFM.HasVariableCustoms)
            {
#if HFM_11_1_2_2
                HFM.Try("Setting phased submission state for {0}", pov,
                        () => _hsvProcessFlow.PhasedSubmissionProcessManagementChangeStateForMultipleEntities2ExtDim(
                            pov.HfmSliceCOM, annotation, (int)action, false, false,
                            (short)targetState, paths, files, out newState));
#else
                HFM.ThrowIncompatibleLibraryEx();
#endif
            }
            else
            {
                HFM.Try("Setting phased submission state for {0}", pov,
                        () => _hsvProcessFlow.PhasedSubmissionProcessManagementChangeStateForMultipleEntities2(
                            pov.Scenario.Id, pov.Year.Id, pov.Period.Id, new int[] { pov.Entity.Id },
                            new int[] { pov.Entity.ParentId }, pov.Value.Id, new int[] { pov.Account.Id },
                            new int[] { pov.ICP.Id }, new int[] { pov.Custom1.Id }, new int[] { pov.Custom2.Id },
                            new int[] { pov.Custom3.Id }, new int[] { pov.Custom4.Id },
                            annotation, (int)action, false, false, (short)targetState,
                            paths, files, out newState));
            }
            return((EProcessState)newState);
        }
Example #7
0
        protected override EProcessState SetProcessState(POV pu, EProcessAction action, EProcessState targetState,
                                                         string annotation, string[] paths, string[] files)
        {
            short newState = 0;

            HFM.Try("Setting process unit state for {0}", pu,
                    () => _hsvProcessFlow.ProcessManagementChangeStateForMultipleEntities2(
                        pu.Scenario.Id, pu.Year.Id, pu.Period.Id,
                        new int[] { pu.Entity.Id }, new int[] { pu.Entity.ParentId },
                        pu.Value.Id, annotation, (int)action, false, false,
                        (short)targetState, paths, files, out newState));
            return((EProcessState)newState);
        }
Example #8
0
 /// Method to be implemented in sub-classes for setting the state of a
 /// single process unit represented by the POV.
 protected abstract EProcessState SetProcessState(POV processUnit, EProcessAction action,
                                                  EProcessState targetState, string annotation, string[] paths, string[] files);
Example #9
0
        // Check user has sufficient access rights for action
        protected bool HasSufficientAccess(EProcessAction action, POV pu, EAccessRights access, EProcessState state)
        {
            bool ok = false;

            switch (action)
            {
            case EProcessAction.Start:
                ok = access == EAccessRights.All;
                break;

            case EProcessAction.Promote:
                ok = access == EAccessRights.Promote || access == EAccessRights.All;
                break;

            case EProcessAction.Reject:
                ok = access == EAccessRights.All ||
                     ((access == EAccessRights.Read || access == EAccessRights.Promote) &&
                      state != EProcessState.Published);
                break;

            case EProcessAction.SignOff:
                ok = access == EAccessRights.Read || access == EAccessRights.Promote ||
                     access == EAccessRights.All;
                break;

            case EProcessAction.Submit:
                ok = access == EAccessRights.Promote || access == EAccessRights.All;
                break;

            case EProcessAction.Approve:
                ok = access == EAccessRights.Promote || access == EAccessRights.All;
                break;

            case EProcessAction.Publish:
                ok = access == EAccessRights.All;
                break;
            }
            if (ok)
            {
                _log.TraceFormat("User has sufficient privileges to {0} {1} {2}",
                                 action, ProcessUnitType, pu);
            }
            else
            {
                _log.WarnFormat("Insufficient privileges to {0} {1} {2}",
                                action, ProcessUnitType, pu);
            }
            return(ok);
        }
Example #10
0
        /// Method to be implemented in sub-classes for setting the state of
        /// process unit(s) represented by the ProcessUnits.
        protected void SetProcessState(ProcessUnits slice, EProcessAction action, ERole role,
                                       EProcessState targetState, string annotation, IEnumerable <string> documents,
                                       bool consolidateIfNeeded, IOutput output)
        {
            string[]      paths = null, files = null;
            int           processed = 0, skipped = 0, errored = 0, invalid = 0;
            EProcessState state;

            _security.CheckPermissionFor(ETask.ProcessManagement);
            if (role != ERole.Default)
            {
                _security.CheckRole(role);
            }

            // Convert document references
            if (documents != null)
            {
                var docs = documents.ToArray();
                paths = new string[docs.Length];
                files = new string[docs.Length];
                for (int i = 0; i < docs.Length; ++i)
                {
                    paths[i] = Path.GetDirectoryName(docs[i]);
                    files[i] = Path.GetFileName(docs[i]);
                }
            }

            // Iterate over process units, performing action
            var PUs = GetProcessUnits(slice);

            output.InitProgress("Processing " + action.ToString(), PUs.Length);
            foreach (var pu in PUs)
            {
                var access = _security.GetProcessUnitAccessRights(pu, out state);
                if (state == targetState)
                {
                    _log.FineFormat("{1} {2} is already at {2}", ProcessUnitType, pu, targetState);
                    skipped++;
                }
                else if (IsValidStateTransition(action, pu, state, targetState) &&
                         HasSufficientAccess(action, pu, access, state) &&
                         CanAction(action, pu, consolidateIfNeeded, output))
                {
                    try {
                        SetProcessState(pu, action, targetState, annotation, paths, files);
                        processed++;
                    }
                    catch (HFMException ex) {
                        _log.Error(string.Format("Unable to {0} {1} {2}",
                                                 action, ProcessUnitType, pu), ex);
                        errored++;
                    }
                }
                else
                {
                    invalid++;
                }
                if (output.IterationComplete())
                {
                    break;
                }
            }
            output.EndProgress();
            _log.InfoFormat("Results for {0} of {1} {2}s: {3} successful, {4} skipped, {5} errored, {6} invalid",
                            action, PUs.Length, ProcessUnitType, processed, skipped, errored, invalid);
            if (errored > 0)
            {
                throw new Exception(string.Format("Failed to {0} {1} {2}s", action, errored, ProcessUnitType));
            }
        }
Example #11
0
 /// <summary>
 /// Lanza el evento de procesado
 /// </summary>
 /// <param name="state">Estado</param>
 protected void RaiseOnProcess(EProcessState state)
 {
     OnProcess?.Invoke(this, state);
 }