/// <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 }
public string UpdatePolicyType(PolicyCatalog policyType) { try { dynamic DynamicObj = new { policyType.Id, policyType.Description, policyType.Type, ModificationUser = "******", Action = "UPDATE" }; return(manager.ExeDBNonQuery(DynamicObj, "sp_PolicyType_Manager"));; } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult UpdatePolicyType(PolicyCatalog policy) { policy.ModificationUser = User.Identity.Name; return(Json(policyBus.UpdatePolicyType(policy))); }
/// <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 }