コード例 #1
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
        public void Promote(
            ProcessUnits slice,
            [Parameter("Review level to promote to (a value between 1 and 10)")]
            string reviewLevel,
            [Parameter("Annotations to be applied to each process unit or phased submission",
                       DefaultValue = null)]
            string annotation,
            [Parameter("Document attachment(s) to be applied to each process unit or phased submission",
                       DefaultValue = null)]
            IEnumerable <string> attachments,
            [Parameter("Consolidate the process unit if consolidation is necessary to promote.",
                       DefaultValue = true)]
            bool consolidateIfNeeded,
            IOutput output)
        {
            var           re    = new Regex("^(?:ReviewLevel)?([0-9]|10)$", RegexOptions.IgnoreCase);
            var           match = re.Match(reviewLevel);
            EProcessState targetState;
            ERole         roleNeeded;

            if (match.Success)
            {
                targetState = (EProcessState)Enum.Parse(typeof(EProcessState), "ReviewLevel" + match.Groups[1].Value);
                roleNeeded  = (ERole)Enum.Parse(typeof(ERole), "ProcessFlowReviewer" + (int.Parse(match.Groups[1].Value) - 1));
            }
            else
            {
                throw new ArgumentException("Review level must be a value between 1 and 10");
            }

            SetProcessState(slice, EProcessAction.Promote, roleNeeded, targetState,
                            annotation, attachments, consolidateIfNeeded, output);
        }
コード例 #2
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
        protected override void GetProcessState(ProcessUnits slice, IOutput output)
        {
            short state = 0;

            output.SetHeader("POV", 58, "Process State", 15);
            foreach (var pov in GetProcessUnits(slice))
            {
                if (HFM.HasVariableCustoms)
                {
#if HFM_11_1_2_2
                    HFM.Try("Retrieving phased submission process state for {0}", pov,
                            () => _hsvProcessFlow.GetPhasedSubmissionStateExtDim(pov.HfmPovCOM, out state));
#else
                    HFM.ThrowIncompatibleLibraryEx();
#endif
                }
                else
                {
                    HFM.Try("Retrieving phased submission process state for {0}", pov,
                            () => _hsvProcessFlow.GetPhasedSubmissionState(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, out state));
                }
                output.WriteRecord(pov, (EProcessState)state);
            }
            output.End();
        }
コード例 #3
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 public void GetProcessHistory(ProcessUnits slice, IOutput output)
 {
     POV[] PUs = GetProcessUnits(slice);
     foreach (var pu in PUs)
     {
         GetHistory(pu, output);
     }
 }
コード例 #4
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 public void Reject(
     ProcessUnits slice,
     [Parameter("Annotations to be applied to each process unit or phased submission",
                DefaultValue = null)]
     string annotation,
     [Parameter("Document attachment(s) to be applied to each process unit or phased submission",
                DefaultValue = null)]
     IEnumerable <string> attachments,
     IOutput output)
 {
     SetProcessState(slice, EProcessAction.Reject, ERole.ProcessFlowReviewer1, EProcessState.NotSupported,
                     annotation, attachments, false, output);
 }
コード例 #5
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 public void Start(
     ProcessUnits slice,
     [Parameter("Annotations to be applied to each process unit or phased submission",
                DefaultValue = null)]
     string annotation,
     [Parameter("Document attachment(s) to be applied to each process unit or phased submission",
                DefaultValue = null)]
     IEnumerable <string> attachments,
     IOutput output)
 {
     SetProcessState(slice, EProcessAction.Start, ERole.ProcessFlowSupervisor,
                     EProcessState.FirstPass, annotation, attachments, false, output);
 }
コード例 #6
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
        public void EnumGroupPhases(ProcessUnits slice, IOutput output)
        {
            int group, phase;

            DefaultMembers(slice, false);
            output.SetHeader("Cell", 50, "Submission Group", "Submission Phase", 20);
            foreach (var pov in slice.POVs)
            {
                GetGroupPhase(pov, out group, out phase);
                output.WriteRecord(pov, group, phase);
            }
            output.End();
        }
コード例 #7
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
        protected override void GetProcessState(ProcessUnits slice, IOutput output)
        {
            short state = 0;

            output.SetHeader("Process Unit", 58, "Process State", 15);
            foreach (var pu in GetProcessUnits(slice))
            {
                HFM.Try("Retrieving process state for {0}", pu,
                        () => _hsvProcessFlow.GetState(pu.Scenario.Id, pu.Year.Id, pu.Period.Id,
                                                       pu.Entity.Id, pu.Entity.ParentId, pu.Value.Id,
                                                       out state));
                output.WriteRecord(pu, (EProcessState)state);
            }
            output.End();
        }
コード例 #8
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 public void Publish(
     ProcessUnits slice,
     [Parameter("Annotations to be applied to each process unit or phased submission",
                DefaultValue = null)]
     string annotation,
     [Parameter("Document attachment(s) to be applied to each process unit or phased submission",
                DefaultValue = null)]
     IEnumerable <string> attachments,
     [Parameter("Consolidate the process unit if consolidation is necessary to publish.",
                DefaultValue = true)]
     bool consolidateIfNeeded,
     IOutput output)
 {
     SetProcessState(slice, EProcessAction.Publish, ERole.ProcessFlowSupervisor, EProcessState.Published,
                     annotation, attachments, consolidateIfNeeded, output);
 }
コード例 #9
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 public void SignOff(
     ProcessUnits slice,
     [Parameter("Annotations to be applied to each process unit or phased submission",
                DefaultValue = null)]
     string annotation,
     [Parameter("Document attachment(s) to be applied to each process unit or phased submission",
                DefaultValue = null)]
     IEnumerable <string> attachments,
     [Parameter("Consolidate the process unit if consolidation is necessary to submit.",
                DefaultValue = true)]
     bool consolidateIfNeeded,
     IOutput output)
 {
     SetProcessState(slice, EProcessAction.SignOff, ERole.ProcessFlowReviewer1, EProcessState.NotSupported,
                     annotation, attachments, consolidateIfNeeded, output);
 }
コード例 #10
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 protected void DefaultMembers(ProcessUnits slice, bool overrideExisting)
 {
     // Default each dimension for which phased submission is not enabled
     if (!_metadata.IsPhasedSubmissionEnabledForDimension((int)EDimension.Account) &&
         (overrideExisting || !slice.IsSpecified(EDimension.Account)))
     {
         slice[EDimension.Account] = "[None]";
     }
     if (!_metadata.IsPhasedSubmissionEnabledForDimension((int)EDimension.ICP) &&
         (overrideExisting || !slice.IsSpecified(EDimension.ICP)))
     {
         slice[EDimension.ICP] = "[ICP None]";
     }
     foreach (var id in _metadata.CustomDimIds)
     {
         if (!_metadata.IsPhasedSubmissionEnabledForDimension(id) &&
             (overrideExisting || !slice.IsSpecified(id)))
         {
             slice[id] = "[None]";
         }
     }
 }
コード例 #11
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 protected override POV[] GetProcessUnits(ProcessUnits slice)
 {
     DefaultMembers(slice, true);
     return(slice.POVs);
 }
コード例 #12
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
        /// 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));
            }
        }
コード例 #13
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 /// Method to be implemented in sub-classes for retrieving the state of
 /// process unit(s) represented by the ProcessUnits.
 protected abstract void GetProcessState(ProcessUnits slice, IOutput output);
コード例 #14
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 /// Method to be implemented in sub-classes to return an array of POV
 /// instances for each process unit represented by the slice.
 protected abstract POV[] GetProcessUnits(ProcessUnits slice);
コード例 #15
0
ファイル: ProcessFlow.cs プロジェクト: newbish/hfmcmd
 public void EnumProcessState(ProcessUnits slice, IOutput output)
 {
     GetProcessState(slice, output);
 }