private void GetOccurrences(ProdactObject selectedItem) { Occurrences.Clear(); var Structures = AppService.StaticStoredObjs.ObjStructures.ToList().Where(e => e.LinkToObj.ProdactObj == selectedItem); foreach (var str in Structures) { Occurrences.Add(str.ProdactObject); } }
/// <summary> /// Evaluates <see cref="Alarm"/>s for the given recurring component, <paramref name="rc"/>. /// This evaluation is based on the evaluation period for the <see cref="RecurringComponent"/>. /// </summary> /// <param name="rc">The </param> /// <returns></returns> virtual public List <AlarmOccurrence> Evaluate(RecurringComponent rc) { Occurrences.Clear(); // If the trigger is relative, it can recur right along with // the recurring items, otherwise, it happens once and // only once (at a precise time). if (Trigger.IsRelative) { Duration d = null; foreach (Period p in rc.Periods) { Date_Time dt = p.StartTime; if (Trigger.Related == Trigger.TriggerRelation.END) { if (p.EndTime != null) { dt = p.EndTime; if (d == null) { d = p.Duration; } } // Use the "last-found" duration as a reference point else if (d != null) { dt = p.StartTime + d; } else { throw new ArgumentException("Alarm trigger is relative to the END of the occurrence; however, the occurence has no discernible end."); } } Occurrences.Add(new AlarmOccurrence(this, dt + Trigger.Duration, rc)); } } else { Occurrences.Add(new AlarmOccurrence(this, Trigger.DateTime.Copy(), rc)); } // If a REPEAT and DURATION value were specified, // then handle those repetitions here. AddRepeatedItems(); return(Occurrences); }