コード例 #1
0
        public ActionResult ReferencePolicy(policyData vData, int id, bool isDoc, FormCollection collection)
        {
            int parse;

            if (int.TryParse(collection["libraryPolicyId"], out parse) && parse > 0)
            {
                PolicyEntity copy = duplicator.dupPolicy(parse);

                vData.PolicyLink          = new PolicyLinkEntity();
                vData.PolicyLink.PolicyId = copy.Id;

                if (isDoc)
                {
                    vData.PolicyDocument            = new PolicyDocumentEntity(id);
                    vData.PolicyDocument.PolicyLink = vData.PolicyLink;
                    vData.PolicyDocument.Save(true);

                    return(RedirectToAction("EditPolicyDoc", new { id = id }));
                }
                else
                {
                    vData.PolicyLink.ParentId = id;

                    PolicyLinkCollection maxColl = new PolicyLinkCollection();
                    PredicateExpression  pe      = new PredicateExpression(PolicyLinkFields.ParentId == id);
                    object maxObj = maxColl.GetScalar(PolicyLinkFieldIndex.Order, null, AggregateFunction.Max, pe);
                    if (maxObj != null && maxObj != DBNull.Value)
                    {
                        vData.PolicyLink.Order = (int)maxObj + 1;
                    }
                    else
                    {
                        vData.PolicyLink.Order = 0;
                    }

                    vData.PolicyLink.Save();

                    return(RedirectToAction("EditPolicySet", new { id = id }));
                }
            }
            else
            {
                return(RedirectToAction("AddPolicy", new { id = id, isDoc = isDoc }));
            }
        }
コード例 #2
0
        private void CreatePolicy(policyData vData, int?id, bool set, bool isLibrary)
        {
            vData.Policy                    = new PolicyEntity();
            vData.Policy.LibraryId          = vData.Library.Id;
            vData.Policy.Description        = set ? "new policy set" : "new policy";
            vData.Policy.Set                = set;
            vData.Policy.IsLibrary          = isLibrary;
            vData.Policy.Target.Description = string.Empty;

            vData.PolicyLink        = new PolicyLinkEntity();
            vData.PolicyLink.Policy = vData.Policy;

            if (id.HasValue)
            {
                vData.PolicyLink.ParentId = id;

                PolicyLinkCollection maxColl = new PolicyLinkCollection();
                PredicateExpression  pe      = new PredicateExpression(PolicyLinkFields.ParentId == id);
                object maxObj = maxColl.GetScalar(PolicyLinkFieldIndex.Order, null, AggregateFunction.Max, pe);
                if (maxObj != null && maxObj != DBNull.Value)
                {
                    vData.PolicyLink.Order = (int)maxObj + 1;
                }
                else
                {
                    vData.PolicyLink.Order = 0;
                }
            }

            CombineModeCollection cmcoll = new CombineModeCollection();

            cmcoll.GetMulti((CombineModeFields.Name == "deny-overrides"));
            vData.Policy.CombineModeId = cmcoll[0].Id;

            vData.Policy.Save(true);
        }
コード例 #3
0
        private void CreatePolicy(policyData vData, int? id, bool set,bool isLibrary)
        {
            vData.Policy = new PolicyEntity();
            vData.Policy.LibraryId = vData.Library.Id;
            vData.Policy.Description = set ? "new policy set" : "new policy";
            vData.Policy.Set = set;
            vData.Policy.IsLibrary = isLibrary;
            vData.Policy.Target.Description = string.Empty;

            vData.PolicyLink = new PolicyLinkEntity();
            vData.PolicyLink.Policy = vData.Policy;

            if (id.HasValue)
            {
                vData.PolicyLink.ParentId = id;

                PolicyLinkCollection maxColl = new PolicyLinkCollection();
                PredicateExpression pe = new PredicateExpression(PolicyLinkFields.ParentId == id);
                object maxObj = maxColl.GetScalar(PolicyLinkFieldIndex.Order, null, AggregateFunction.Max, pe);
                if (maxObj != null && maxObj != DBNull.Value)
                    vData.PolicyLink.Order = (int)maxObj + 1;
                else
                    vData.PolicyLink.Order = 0;
            }

            CombineModeCollection cmcoll = new CombineModeCollection();
            cmcoll.GetMulti((CombineModeFields.Name == "deny-overrides"));
            vData.Policy.CombineModeId = cmcoll[0].Id;

            vData.Policy.Save(true);
        }
コード例 #4
0
        public ActionResult ReferencePolicy(policyData vData,int id, bool isDoc, FormCollection collection)
        {
            int parse;
            if (int.TryParse(collection["libraryPolicyId"], out parse) && parse > 0)
            {
                PolicyEntity copy = duplicator.dupPolicy(parse);

                vData.PolicyLink = new PolicyLinkEntity();
                vData.PolicyLink.PolicyId = copy.Id;

                if (isDoc)
                {
                    vData.PolicyDocument = new PolicyDocumentEntity(id);
                    vData.PolicyDocument.PolicyLink = vData.PolicyLink;
                    vData.PolicyDocument.Save(true);

                    return RedirectToAction("EditPolicyDoc", new { id = id });
                }
                else
                {
                    vData.PolicyLink.ParentId = id;

                    PolicyLinkCollection maxColl = new PolicyLinkCollection();
                    PredicateExpression pe = new PredicateExpression(PolicyLinkFields.ParentId == id);
                    object maxObj = maxColl.GetScalar(PolicyLinkFieldIndex.Order, null, AggregateFunction.Max, pe);
                    if (maxObj != null && maxObj != DBNull.Value)
                        vData.PolicyLink.Order = (int)maxObj + 1;
                    else
                        vData.PolicyLink.Order = 0;

                    vData.PolicyLink.Save();

                    return RedirectToAction("EditPolicySet", new { id = id });
                }
            }
            else
                return RedirectToAction("AddPolicy", new { id = id, isDoc = isDoc });
        }