コード例 #1
0
        private void Activate(ProcessTracker pt, int activeSetIdx)
        {
            MDRF.Common.DateTimeStampPair dtPair = MDRF.Common.DateTimeStampPair.Now;

            // if needed - deactivate the previous pt in the given index
            ActiveSetItemTracker activeSetItemTracker = activeSetItemTrackerArray[activeSetIdx];

            ProcessTracker priorPT = activeSetItemTracker.ProcessTracker;

            if (priorPT != null)
            {
                // record the last set of values (and the map) from the old ProcessTracker before replacing them with the new values.
                activeSetItemTracker.GroupInfo.Touched = true;
                activeSetMapGroup.GroupInfo.Touched    = true;
                mdrfWriter.RecordGroups(dtPair: dtPair);

                string         deactivateReason    = "pid:{0} '{1}' is being {2}".CheckedFormat(pt.pid, pt.name, pt.elevationRequestReason.IsNullOrEmpty() ? "activated" : "elevated");
                INamedValueSet extraDeactivatedNVS = new NamedValueSet()
                {
                    { "deactivateReason", deactivateReason }, { "activeSetNum", activeSetIdx + 1 }
                }.MakeReadOnly();

                priorPT.activePTSetIndex = -1;
                RecordProcessEvent("Deactivated", priorPT, extraNVS: extraDeactivatedNVS, includeExtraProcessInfo: false, includeTrackedValues: true, dtPair: dtPair);
            }

            // now move the given pt into the active set at the selected index.

            INamedValueSet extraNVS = (pt.elevationRequestReason.IsNullOrEmpty() ? new NamedValueSet()
            {
                { "activeSetNum", activeSetIdx + 1 }
            } : new NamedValueSet()
            {
                { "elevateReason", pt.elevationRequestReason }, { "activeSetNum", activeSetIdx + 1 }
            }).MakeReadOnly();

            RecordProcessEvent("Activated", pt, extraNVS: extraNVS, includeExtraProcessInfo: false, includeTrackedValues: true, dtPair: dtPair);

            pt.activePTSetIndex = activeSetIdx;
            pt.activationBaselineTrackedValues  = pt.prevTrackedValues;
            activeSetItemTracker.ProcessTracker = pt;
            activeSetItemTracker.UpdateGroupItems();
            activeSetItemTracker.GroupInfo.Touched = true;

            activeSetMapGroup.Update(activeSetIdx, pt.pid, pt.name);

            mdrfWriter.RecordGroups(dtPair: dtPair);
        }
コード例 #2
0
        private void RecordProcessEvent(string eventName, ProcessTracker pt, INamedValueSet extraNVS = null, bool includeExtraProcessInfo = false, bool includeTrackedValues = false, MDRF.Common.DateTimeStampPair dtPair = null)
        {
            if (extraNVS.IsNullOrEmpty())
            {
                Log.Info.Emit("{0} pid:{1} name:{2}", eventName, pt.pid, pt.name);
            }
            else
            {
                Log.Info.Emit("{0} pid:{1} name:{2} {3}", eventName, pt.pid, pt.name, extraNVS);
            }

            INamedValueSet nvs = new NamedValueSet()
            {
                { "eventName", eventName }
            }
            .MergeWith(pt.AsNVS(includeExtraProcessInfo: includeExtraProcessInfo, includeTrackedValues: includeTrackedValues))
            .MergeWith(extraNVS, NamedValueMergeBehavior.AddNewItems)
            .ConvertToReadOnly();

            mdrfWriter.RecordOccurrence(ProcessDeltaOccurrenceInfo, new ValueContainer(nvs), dtPair: dtPair);
        }