public void Apply(ServerRuleApplyTimeEnum applyTime, CommandProcessor theProcessor) { try { if (_studyRulesEngine == null || !_studyRulesEngine.RuleApplyTime.Equals(applyTime)) { _studyRulesEngine = new ServerRulesEngine(applyTime, _location.ServerPartitionKey); _studyRulesEngine.Load(); } List <string> files = GetFirstInstanceInEachStudySeries(); if (files.Count == 0) { string message = String.Format("Unexpectedly unable to find SOP instances for rules engine in each series in study: {0}", _location.StudyInstanceUid); Platform.Log(LogLevel.Error, message); throw new ApplicationException(message); } Platform.Log(LogLevel.Info, "Processing Study Level rules for study {0} on partition {1} at {2} apply time", _location.StudyInstanceUid, _partition.Description, applyTime.Description); foreach (string seriesFilePath in files) { var theFile = new DicomFile(seriesFilePath); theFile.Load(DicomReadOptions.Default); var context = new ServerActionContext(theFile, _location.FilesystemKey, _partition, _location.Key, theProcessor) { RuleEngine = _studyRulesEngine }; _studyRulesEngine.Execute(context); ProcessSeriesRules(theFile, theProcessor); } if (applyTime.Equals(ServerRuleApplyTimeEnum.StudyProcessed)) { // This is a bit kludgy, but we had a problem with studies with only 1 image incorectlly // having archive requests inserted when they were scheduled for deletion. Calling // this command here so that if a delete is inserted at the study level, we will remove // the previously inserted archive request for the study. Note also this has to be done // after the rules engine is executed. theProcessor.AddCommand(new InsertArchiveQueueCommand(_location.ServerPartitionKey, _location.Key)); } } finally { if (_studyRulesEngine != null) { _studyRulesEngine.Complete(_studyRulesEngine.RulesApplied); } } }
/// <summary> /// Apply the Rules engine. /// </summary> /// <remarks> /// <para> /// This method applies the rules engine to the first image in each series within a study. /// The assumption is that the actions generated by the engine can handle being applied more /// than once for the same study. This is also done to handle the case of multi-modality /// studies where you may want the rules to be run against each series, because they may /// apply differently. /// </para> /// <para> /// Note that we are still applying series level moves, although there currently are not /// any series level rules. We've somewhat turned the study level rules into series /// level rules. /// </para> /// </remarks> public void Apply(ServerRuleApplyTimeEnum applyTime) { using (var theProcessor = new ServerCommandProcessor("Study Rule Processor")) { Apply(applyTime, theProcessor); if (false == theProcessor.Execute()) { Platform.Log(LogLevel.Error, "Unexpected failure processing Study level rules for study {0} on partition {1} for {2} apply time", _location.StudyInstanceUid, _partition.Description, applyTime.Description); } } }
public void Insert(Guid Guid, short EnumX, string Lookup, string Description, string LongDescription) { var item = new ServerRuleApplyTimeEnum(); item.Guid = Guid; item.EnumX = EnumX; item.Lookup = Lookup; item.Description = Description; item.LongDescription = LongDescription; item.Save(UserName); }
public void LoadRules() { var criteria = new ServerRuleSelectCriteria(); // only query for device in this partition criteria.ServerPartitionKey.EqualTo(ServerPartition.GetKey()); if (!String.IsNullOrEmpty(RuleApplyTimeDropDownList.Text)) { if (!RuleApplyTimeDropDownList.SelectedValue.Equals("ALL")) { ServerRuleApplyTimeEnum en = ServerRuleApplyTimeEnum.GetEnum(RuleApplyTimeDropDownList.SelectedItem.Value); criteria.ServerRuleApplyTimeEnum.EqualTo(en); } } if (!String.IsNullOrEmpty(RuleTypeDropDownList.Text)) { if (!RuleTypeDropDownList.SelectedValue.Equals("ALL")) { ServerRuleTypeEnum en = ServerRuleTypeEnum.GetEnum(RuleTypeDropDownList.SelectedItem.Value); criteria.ServerRuleTypeEnum.EqualTo(en); } else { criteria.ServerRuleTypeEnum.NotEqualTo(ServerRuleTypeEnum.DataAccess); } } else { criteria.ServerRuleTypeEnum.NotEqualTo(ServerRuleTypeEnum.DataAccess); } if (StatusFilter.SelectedIndex != 0) { criteria.Enabled.EqualTo(StatusFilter.SelectedIndex == 1); } if (DefaultFilter.SelectedIndex != 0) { criteria.DefaultRule.EqualTo(DefaultFilter.SelectedIndex == 1); } ServerRuleGridViewControl.ServerRules = _controller.GetServerRules(criteria); ServerRuleGridViewControl.DataBind(); }
public UpdateStudyCommand(ServerPartition partition, StudyStorageLocation studyLocation, IList <BaseImageLevelUpdateCommand> imageLevelCommands, ServerRuleApplyTimeEnum applyTime) : base("Update existing study") { _partition = partition; _oldStudyLocation = studyLocation; _commands = imageLevelCommands; _statistics = new UpdateStudyStatistics(_oldStudyLocation.StudyInstanceUid); // Load the engine for editing rules. _rulesEngine = new ServerRulesEngine(applyTime, _partition.Key); if (applyTime.Equals(ServerRuleApplyTimeEnum.SopProcessed)) { _rulesEngine.AddIncludeType(ServerRuleTypeEnum.AutoRoute); } _rulesEngine.Load(); }
protected void Page_Load(object sender, EventArgs e) { ServerRuleGridViewControl.ServerRulePanel = this; // setup child controls GridPagerTop.InitializeGridPager(SR.GridPagerServerRulesSingleItem, SR.GridPagerServerRulesMultipleItems, ServerRuleGridViewControl.TheGrid, () => ServerRuleGridViewControl.ServerRules == null ? 0 : ServerRuleGridViewControl.ServerRules.Count, ImageServerConstants.GridViewPagerPosition.Top); ServerRuleGridViewControl.Pager = GridPagerTop; GridPagerTop.Reset(); int prevSelectIndex = RuleApplyTimeDropDownList.SelectedIndex; RuleApplyTimeDropDownList.Items.Clear(); RuleApplyTimeDropDownList.Items.Add(new ListItem(SR.All, "ALL")); foreach (ServerRuleApplyTimeEnum applyTimeEnum in ServerRuleApplyTimeEnum.GetAll()) { RuleApplyTimeDropDownList.Items.Add( new ListItem(ServerEnumDescription.GetLocalizedDescription(applyTimeEnum), applyTimeEnum.Lookup)); } RuleApplyTimeDropDownList.SelectedIndex = prevSelectIndex; prevSelectIndex = RuleTypeDropDownList.SelectedIndex; RuleTypeDropDownList.Items.Clear(); RuleTypeDropDownList.Items.Add(new ListItem(SR.All, "ALL")); foreach (ServerRuleTypeEnum typeEnum in ServerRuleTypeEnum.GetAll()) { RuleTypeDropDownList.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(typeEnum), typeEnum.Lookup)); } RuleTypeDropDownList.SelectedIndex = prevSelectIndex; if (Page.IsPostBack) { DataBind(); } }
public DeleteFilesystemQueueCommand(ServerEntityKey storageLocationKey, ServerRuleApplyTimeEnum applyTime) : base("Delete FilesystemQueue") { _storageLocationKey = storageLocationKey; _applyTime = applyTime; }
public void Update(Guid Guid, short EnumX, string Lookup, string Description, string LongDescription) { var item = new ServerRuleApplyTimeEnum(); item.MarkOld(); item.IsLoaded = true; item.Guid = Guid; item.EnumX = EnumX; item.Lookup = Lookup; item.Description = Description; item.LongDescription = LongDescription; item.Save(UserName); }
/// <summary> /// Constructor. /// </summary> /// <remarks> /// A rules engine will only load rules that apply at a specific time. The /// apply time is specified by the <paramref name="applyTime"/> parameter. /// </remarks> /// <param name="applyTime">An enumerated value as to when the rules shall apply.</param> /// <param name="serverPartitionKey">The Server Partition the rules engine applies to.</param> public ServerRulesEngine(ServerRuleApplyTimeEnum applyTime, ServerEntityKey serverPartitionKey) { _applyTime = applyTime; _serverPartitionKey = serverPartitionKey; Statistics = new RulesEngineStatistics(applyTime.Lookup, applyTime.LongDescription); }