Пример #1
0
        static private bool DeletePolicyFromLib(int id)
        {
            PredicateExpression pe   = new PredicateExpression(PolicyLinkFields.PolicyId == id);
            PredicateExpression peOr = new PredicateExpression(new FieldCompareSetPredicate(PolicyLinkFields.Id, PolicyDocumentFields.PolicyLinkId, SetOperator.In, null));

            peOr.AddWithOr(PolicyLinkFields.ParentId != DBNull.Value);
            pe.Add(peOr);

            PolicyLinkCollection plcoll = new PolicyLinkCollection();

            if (plcoll.GetMulti(pe) && plcoll.Count == 0)
            {
                // Policy isn't referenced in any policy document.
                PolicyEntity delPolicy = new PolicyEntity(id);
                delPolicy.PolicyLink.DeleteMulti();

                DeletePolicy(delPolicy);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public ActionResult PolicyOrder(policyData vData, int id, FormCollection collection)
        {
            PolicyLinkEntity     policyLink = new PolicyLinkEntity(id);
            PolicyLinkCollection coll       = new PolicyLinkCollection();

            PredicateExpression pe = new PredicateExpression(PolicyLinkFields.Id != policyLink.Id);

            pe.Add(PolicyLinkFields.ParentId == policyLink.ParentId);
            SortExpression se = null;

            if (collection["up"] != null)
            {
                // Find all categories with display index less than ours.
                pe.Add(PolicyLinkFields.Order <= policyLink.Order);

                // Order by display index, highest first.
                se = new SortExpression(PolicyLinkFields.Order | SortOperator.Descending);
            }
            else
            {
                // Find all categories with display index greater than ours.
                pe.Add(PolicyLinkFields.Order >= policyLink.Order);

                // Order by display index, lowest first.
                se = new SortExpression(PolicyLinkFields.Order | SortOperator.Ascending);
            }

            // Swap with closest one.
            if (coll.GetMulti(pe, 1, se) && coll.Count > 0)
            {
                int temp = coll[0].Order;
                coll[0].Order    = policyLink.Order;
                policyLink.Order = temp;

                policyLink.Save();
                coll.SaveMulti();
            }

            return(RedirectToAction("EditPolicySet", new { id = policyLink.ParentId }));
        }
Пример #3
0
        public ActionResult EditPolicyFromLib(policyData vData, int id)
        {
            PredicateExpression pe = new PredicateExpression(PolicyLinkFields.ParentId == DBNull.Value);

            pe.Add(PolicyLinkFields.PolicyId == id);
            pe.Add(new FieldCompareSetPredicate(PolicyLinkFields.Id, PolicyDocumentFields.PolicyLinkId, SetOperator.In, null, true));

            PolicyLinkCollection plcoll = new PolicyLinkCollection();

            if (plcoll.GetMulti(pe) && plcoll.Count > 0)
            {
                vData.PolicyLink = plcoll[0];
            }
            else
            {
                vData.PolicyLink          = new PolicyLinkEntity();
                vData.PolicyLink.PolicyId = id;
                vData.PolicyLink.Save();
            }

            return(RedirectToAction("EditPolicy", new { id = vData.PolicyLink.Id }));
        }
        private static bool DeletePolicyFromLib(int id)
        {
            PredicateExpression pe = new PredicateExpression(PolicyLinkFields.PolicyId == id);
            PredicateExpression peOr = new PredicateExpression(new FieldCompareSetPredicate(PolicyLinkFields.Id, PolicyDocumentFields.PolicyLinkId, SetOperator.In, null));
            peOr.AddWithOr(PolicyLinkFields.ParentId != DBNull.Value);
            pe.Add(peOr);

            PolicyLinkCollection plcoll = new PolicyLinkCollection();
            if (plcoll.GetMulti(pe) && plcoll.Count == 0)
            {
                // Policy isn't referenced in any policy document.
                PolicyEntity delPolicy = new PolicyEntity(id);
                delPolicy.PolicyLink.DeleteMulti();

                DeletePolicy(delPolicy);

                return true;
            }
            else
                return false;
        }
        public ActionResult PolicyOrder(policyData vData, int id, FormCollection collection)
        {
            PolicyLinkEntity policyLink = new PolicyLinkEntity(id);
            PolicyLinkCollection coll = new PolicyLinkCollection();

            PredicateExpression pe = new PredicateExpression(PolicyLinkFields.Id != policyLink.Id);
            pe.Add(PolicyLinkFields.ParentId == policyLink.ParentId);
            SortExpression se = null;

            if (collection["up"] != null)
            {
                // Find all categories with display index less than ours.
                pe.Add(PolicyLinkFields.Order <= policyLink.Order);

                // Order by display index, highest first.
                se = new SortExpression(PolicyLinkFields.Order | SortOperator.Descending);
            }
            else
            {
                // Find all categories with display index greater than ours.
                pe.Add(PolicyLinkFields.Order >= policyLink.Order);

                // Order by display index, lowest first.
                se = new SortExpression(PolicyLinkFields.Order | SortOperator.Ascending);
            }

            // Swap with closest one.
            if (coll.GetMulti(pe, 1, se) && coll.Count > 0)
            {
                int temp = coll[0].Order;
                coll[0].Order = policyLink.Order;
                policyLink.Order = temp;

                policyLink.Save();
                coll.SaveMulti();
            }

            return RedirectToAction("EditPolicySet", new { id = policyLink.ParentId });
        }
        public ActionResult EditPolicyFromLib(policyData vData, int id)
        {
            PredicateExpression pe = new PredicateExpression(PolicyLinkFields.ParentId == DBNull.Value);
            pe.Add(PolicyLinkFields.PolicyId == id);
            pe.Add(new FieldCompareSetPredicate(PolicyLinkFields.Id, PolicyDocumentFields.PolicyLinkId, SetOperator.In, null, true));

            PolicyLinkCollection plcoll = new PolicyLinkCollection();
            if (plcoll.GetMulti(pe) && plcoll.Count > 0)
                vData.PolicyLink = plcoll[0];
            else
            {
                vData.PolicyLink = new PolicyLinkEntity();
                vData.PolicyLink.PolicyId = id;
                vData.PolicyLink.Save();
            }

            return RedirectToAction("EditPolicy", new { id = vData.PolicyLink.Id });
        }