예제 #1
0
 public ProjectPolicyIndex(PolicyCollection src)
 {
     foreach (var p in src.Policies)
     {
         AddPolicy(p);
     }
 }
예제 #2
0
        public PolicyCollection MapPolicySearchResultToPolicyCollection(IEnumerable <Policy.Contracts.Models.Policy> policies)
        {
            var policyCollection = new PolicyCollection();

            foreach (var policy in policies)
            {
                policyCollection.Add(policy);
            }
            return(policyCollection);
        }
예제 #3
0
        public ProjectPolicyIndex(PolicyCollection src)
        {
            if (src == null)
            {
                return;
            }

            foreach (var p in src.Policies)
            {
                AddPolicy(p);
            }
        }
        /// <summary>
        /// Adds the information rights policies.
        /// </summary>
        /// <param name="targetCT">The target content type.</param>
        /// <param name="sourceCT">The source content type.</param>
        private void AddInformationRightsPolicies(SPContentType targetCT, SPContentType sourceCT)
        {
#if MOSS
            // Set information rights policy - must be done after the new content type is added to the collection.
            using (Policy sourcePolicy = Policy.GetPolicy(sourceCT))
            {
                if (sourcePolicy != null)
                {
                    PolicyCatalog    catalog    = new PolicyCatalog(targetCT.ParentWeb.Site);
                    PolicyCollection policyList = catalog.PolicyList;

                    Policy tempPolicy = null;
                    try
                    {
                        tempPolicy = policyList[sourcePolicy.Id];
                        if (tempPolicy == null)
                        {
                            XmlDocument exportedSourcePolicy = sourcePolicy.Export();
                            try
                            {
                                Logger.Write("Progress: Adding policy '{0}' to content type...", sourcePolicy.Name);

                                PolicyCollection.Add(targetCT.ParentWeb.Site, exportedSourcePolicy.OuterXml);
                            }
                            catch (Exception ex)
                            {
                                if (ex is NullReferenceException || ex is SEHException)
                                {
                                    throw;
                                }
                                // Policy already exists
                                Logger.WriteException(new System.Management.Automation.ErrorRecord(new SPException("An error occured creating the information rights policy: {0}", ex), null, System.Management.Automation.ErrorCategory.NotSpecified, exportedSourcePolicy));
                            }
                        }
                        Logger.Write("Progress: Associating content type with policy '{0}'...", sourcePolicy.Name);
                        // Associate the policy with the content type.
                        Policy.CreatePolicy(targetCT, sourcePolicy);
                    }
                    finally
                    {
                        if (tempPolicy != null)
                        {
                            tempPolicy.Dispose();
                        }
                    }
                }
                targetCT.Update();
            }
#endif
        }
예제 #5
0
        public Policy_LapsedIterator(PolicyCollection collection) : base(collection)
        {
            _collection = collection;
            _currIndex  = 0;
            InsurancePolicy p;

            do
            {
                p = _collection.GetPolicy(_currIndex);
                if (p == null)
                {
                    break;
                }
            } while (p.State is Policy_LapsedState);
        }
예제 #6
0
        private static String GetFlatPolicyNames(PolicyCollection policies,
                                                 IEnumerable <int> policyIds)
        {
            StringBuilder b = new StringBuilder();

            foreach (var pid in policyIds)
            {
                if (b.Length > 0)
                {
                    b.Append(';');
                }

                b.Append(policies.GetPolicyById(pid).Name);
            }

            return(b.ToString());
        }
예제 #7
0
        public void FindPoliciesAsync(PolicySearch policySearch, Action <IOperationResult <PolicyCollection> > callback)
        {
            this.PolicyServiceWS.BeginFindPolicies(
                policySearch,
                (ar) =>
            {
                var operationResult = new OperationResult <PolicyCollection>();
                try
                {
                    PolicyCollection policies =
                        this.MapPolicySearchResultToPolicyCollection(this.PolicyServiceWS.EndFindPolicies(ar));
                    operationResult.Result = policies;
                }
                catch (Exception ex)
                {
                    operationResult.Error = ex;
                }

                this.synchronizationContext.Post((state) => callback(operationResult), null);
            },
                null);
        }
예제 #8
0
 public Agent(string name, float commission, PolicyCollection pc) : this()
 {
     this.name          = name;
     this.commission    = commission;
     this.ownedPolicies = pc;
 }
예제 #9
0
        private void CheckPolicy(LoginDataContract selectedLogin, GroupDataContract selectedGroup)
        {
            try
            {
                UpdateSelectedPolicyCollection();

                if (PolicyCollection == null || !PolicyCollection.Any())
                {
                    return;
                }

                foreach (var selectedPolicy in PolicyCollection)
                {
                    selectedPolicy.IsSelected = selectedPolicy.IsGroupPolitics = false;
                }

                using (var policySetService =
                           _ppsClientViewModel.ServiceProxy.GetPpsChannelFactory <IPolicySetService>())
                {
                    var channel = policySetService.CreateChannel();
                    Result <PolicySetDataContract[]> result;

                    if (IsUserPolicySet && selectedLogin != null)
                    {
                        result = channel.GetPolicySetForLogin(selectedLogin.LoginId);
                    }
                    else if (IsGroupPolicySet && selectedGroup != null)
                    {
                        result = channel.GetPolicySetForGroup(selectedGroup.GroupId);
                    }
                    else
                    {
                        return;
                    }

                    if (result == null)
                    {
                        throw new Exception("Ошибка вызова службы");
                    }

                    if (!result.BoolRes || result.SomeResult == null)
                    {
                        throw new Exception(result.ErrorRes);
                    }

                    var policySetCollection = result.SomeResult;

                    foreach (var selectedPolicy in PolicyCollection)
                    {
                        var policySet = policySetCollection.FirstOrDefault(x => x.PolicyId == selectedPolicy.PolicyId);
                        selectedPolicy.IsSelected = policySet != null;

                        if (selectedPolicy.IsSelected && policySet != null)
                        {
                            selectedPolicy.PolicyParam = policySet.PolicyParam;
                        }
                    }

                    if (!IsUserPolicySet || _groupIdAndPolicyIdDct == null || !_groupIdAndPolicyIdDct.Any())
                    {
                        return;
                    }

                    var grpPoliciesForLogin = _groupIdAndPolicyIdDct[selectedLogin.GroupId];

                    if (grpPoliciesForLogin == null || !grpPoliciesForLogin.Any())
                    {
                        return;
                    }

                    foreach (var selectedPolicy in PolicyCollection)
                    {
                        selectedPolicy.IsGroupPolitics = grpPoliciesForLogin.Any(x => x == selectedPolicy.PolicyId);
                    }
                }
            }
            catch (Exception ex)
            {
                _ppsClientViewModel.WriteLogMessage(string.Concat("Не удалось отметить политику - ", ex.Message));
            }
        }
예제 #10
0
 public NormalAgent(string name, float commission, PolicyCollection pc) : base(name, commission, pc)
 {
 }
예제 #11
0
 public Policy_ActiveIterator(PolicyCollection collection) : base(collection)
 {
 }
예제 #12
0
 public PolicyIterator(PolicyCollection collection)
 {
     _collection = collection;
     _currIndex  = -1;
 }
 public Policy_TerminatedIterator(PolicyCollection collection) : base(collection)
 {
 }