static public void SetPolicyEngineAddresses(PolicyResponseObject pro, PolicyEngine policyEngine, string[] addresses) { if (null == pro) throw new Workshare.Policy.Exceptions.ArgumentNullException("pro", "Invalid policy response object"); if (null != pro.UniversalRequestObject.Source && null != pro.UniversalRequestObject.Source.Items && pro.UniversalRequestObject.Source.Items.Count > 0) { policyEngine.CurrentUser = pro.UniversalRequestObject.Source.Items[0].Content; } policyEngine.Source = pro.UniversalRequestObject.Source; policyEngine.Destination = pro.UniversalRequestObject.Destination; policyEngine.RecipientList = addresses; policyEngine.RequestChannel = RequestChannel.Unknown; if ((null != pro) && (null != pro.UniversalRequestObject) && (pro.UniversalRequestObject.Properties.ContainsKey("RequestChannel"))) { string requestChannel = pro.UniversalRequestObject.Properties["RequestChannel"]; policyEngine.RequestChannel = (RequestChannel)Enum.Parse(typeof(RequestChannel), requestChannel, true); } }
public void SetPolicyEnginesCompiledPolicySetCache(PolicyResponseObject pro, string channel) { if (!m_policyEngines.ContainsKey(channel)) { m_policyEngines[channel] = new Dictionary<string, PolicyEngine>(); } if ((null == pro) || (null == pro.UniversalRequestObject)) return; if (null == m_policyCache.PolicySets) return; PerformanceCounters.Instance.StartTimer(PerformanceCounters.CounterType.Policy_Read); List<string> copyPolicySetsIds = CopyPolicySetIds(m_policyCache.PolicySets); if (m_policyCache.SupportsRefresh()) m_policyCache.AttemptRefresh(); List<IPolicySetCache> policysets = m_policyCache.PolicySets; //get diff between the policyset list now and the copy of original DiffOfPolicySets(copyPolicySetsIds, policysets); if (0 == policysets.Count) Logger.LogError("Warning: Processing content against no policy sets."); Dictionary<string, PolicyEngine> policiesForChannel = m_policyEngines[channel]; RemoveNonExistingPolicesFromEngine(policiesForChannel, copyPolicySetsIds); foreach (IPolicySetCache policySetCache in policysets) { if (policySetCache.LatestVersion == null) { continue; } switch (policySetCache.LatestVersion.Status) { case PolicySetVersionStatus.Disabled: case PolicySetVersionStatus.Deleted: continue; } ICompiledPolicySetCache icps = GetCompiledPolicySet(pro, policySetCache); if (null == icps) continue; PolicyEngine policyEngine; if (!policiesForChannel.TryGetValue(policySetCache.Id, out policyEngine)) { policyEngine = new PolicyEngine(); policyEngine.SetCompiledPolicySetCache(icps); if (m_progressCallback != null) { policyEngine.SetPolicyEvents(m_progressCallback); } policiesForChannel.Add(policySetCache.Id, policyEngine); Logger.LogDebug("Added PolicyEngine. Id: " + policySetCache.Id + "-" + icps.Channel + "-" + icps.Target); #if DEBUG Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro)); #endif } else { policyEngine.SetCompiledPolicySetCache(icps); Logger.LogDebug("Setting icps to id " + policySetCache.Id + "-" + icps.Channel + "-" + icps.Target); #if DEBUG Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro)); #endif } } PerformanceCounters.Instance.StopTimer(PerformanceCounters.CounterType.Policy_Read, 0); Logger.LogDebug("Completed: SetPolicyEnginesCompiledPolicySetCache"); #if DEBUG Logger.LogDebug(PolicyResponseLogHelper.GetDisplayNames(pro)); #endif }