Esempio n. 1
0
        public ActionResult CreateSubCondition(policyData vData, int id, int linkId)
        {
            vData.PolicyLink = new PolicyLinkEntity(linkId);

            DecisionNodeEntity ce = new DecisionNodeEntity(id);

            vData.Condition        = new DecisionNodeEntity();
            vData.Condition.Type   = constants.conditionType;
            vData.Condition.Parent = ce;

            DecisionNodeCollection maxColl = new DecisionNodeCollection();
            PredicateExpression    pe      = new PredicateExpression(DecisionNodeFields.ParentId == id);
            object maxObj = maxColl.GetScalar(DecisionNodeFieldIndex.Order, null, AggregateFunction.Max, pe);

            if (maxObj != null && maxObj != DBNull.Value)
            {
                vData.Condition.Order = (int)maxObj + 1;
            }
            else
            {
                vData.Condition.Order = 0;
            }

            vData.Condition.Save();

            ViewData["title"] = "new sub-condition";

            return(View("EditCondition", vData));
        }
Esempio n. 2
0
        public ActionResult DecisionNodeOrder(policyData vData, int id, int id2, int linkId, FormCollection collection)
        {
            DecisionNodeEntity     match = new DecisionNodeEntity(id2);
            DecisionNodeCollection coll  = new DecisionNodeCollection();

            PredicateExpression pe = new PredicateExpression(DecisionNodeFields.Id != match.Id);

            pe.Add(DecisionNodeFields.ParentId == id);
            SortExpression se = null;

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

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

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

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

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

            string action = collection["backTo"];

            if (action == "EditRule")
            {
                vData.Condition = new DecisionNodeEntity(id);
                id = vData.Condition.Rule[0].Id;
            }

            return(RedirectToAction(action, new { id = id, linkId = linkId }));
        }
Esempio n. 3
0
        public ActionResult SetAttribute(policyData vData, int id, int id2, int linkId, FormCollection collection)
        {
            vData.DecisionNode = new DecisionNodeEntity(id);
            if (vData.DecisionNode.IsNew)
            {
                vData.DecisionNode.Type = constants.attributeMatchType;

                DecisionNodeCollection maxColl = new DecisionNodeCollection();
                PredicateExpression    pe      = new PredicateExpression(DecisionNodeFields.ParentId == id2);
                object maxObj = maxColl.GetScalar(DecisionNodeFieldIndex.Order, null, AggregateFunction.Max, pe);
                if (maxObj != null && maxObj != DBNull.Value)
                {
                    vData.DecisionNode.Order = (int)maxObj + 1;
                }
                else
                {
                    vData.DecisionNode.Order = 0;
                }

                AttributeValueEntity ave = new AttributeValueEntity();
                ave.AttributeMatch = vData.DecisionNode;
                ave.Literal        = true;
                ave.Value          = string.Empty;
            }
            vData.DecisionNode.ParentId    = id2;
            vData.DecisionNode.AttributeId = int.Parse(collection["AttributeId"]);

            if (vData.DecisionNode.Attribute.AttributeType.Name == "uri")
            {
                vData.DecisionNode.Extra = collection["uriExtra"];
            }
            else if (vData.DecisionNode.Attribute.AttributeType.Name == "param")
            {
                vData.DecisionNode.Extra = collection["extra"];
            }
            else
            {
                vData.DecisionNode.Extra = string.Empty;
            }

            vData.DecisionNode.Save(true);

            TempData["message"] = policyData.detailsSaved;

            return(RedirectToAction("EditMatch", new { id = vData.DecisionNode.Id, linkId = linkId }));
        }
        public ActionResult SetAttribute(policyData vData, int id, int id2, int linkId, FormCollection collection)
        {
            vData.DecisionNode = new DecisionNodeEntity(id);
            if (vData.DecisionNode.IsNew)
            {
                vData.DecisionNode.Type = constants.attributeMatchType;

                DecisionNodeCollection maxColl = new DecisionNodeCollection();
                PredicateExpression pe = new PredicateExpression(DecisionNodeFields.ParentId == id2);
                object maxObj = maxColl.GetScalar(DecisionNodeFieldIndex.Order, null, AggregateFunction.Max, pe);
                if (maxObj != null && maxObj != DBNull.Value)
                    vData.DecisionNode.Order = (int)maxObj + 1;
                else
                    vData.DecisionNode.Order = 0;

                AttributeValueEntity ave = new AttributeValueEntity();
                ave.AttributeMatch = vData.DecisionNode;
                ave.Literal = true;
                ave.Value = string.Empty;
            }
            vData.DecisionNode.ParentId = id2;
            vData.DecisionNode.AttributeId = int.Parse(collection["AttributeId"]);

            if (vData.DecisionNode.Attribute.AttributeType.Name == "uri")
                vData.DecisionNode.Extra = collection["uriExtra"];
            else if (vData.DecisionNode.Attribute.AttributeType.Name == "param")
                vData.DecisionNode.Extra = collection["extra"];
            else
                vData.DecisionNode.Extra = string.Empty;

            vData.DecisionNode.Save(true);

            TempData["message"] = policyData.detailsSaved;

            return RedirectToAction("EditMatch", new { id = vData.DecisionNode.Id, linkId = linkId });
        }
        public ActionResult DecisionNodeOrder(policyData vData, int id, int id2, int linkId, FormCollection collection)
        {
            DecisionNodeEntity match = new DecisionNodeEntity(id2);
            DecisionNodeCollection coll = new DecisionNodeCollection();

            PredicateExpression pe = new PredicateExpression(DecisionNodeFields.Id != match.Id);
            pe.Add(DecisionNodeFields.ParentId == id);
            SortExpression se = null;

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

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

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

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

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

            string action = collection["backTo"];
            if (action == "EditRule")
            {
                vData.Condition = new DecisionNodeEntity(id);
                id = vData.Condition.Rule[0].Id;
            }

            return RedirectToAction(action, new { id = id, linkId = linkId });
        }
        public ActionResult CreateSubCondition(policyData vData, int id, int linkId)
        {
            vData.PolicyLink = new PolicyLinkEntity(linkId);

            DecisionNodeEntity ce = new DecisionNodeEntity(id);

            vData.Condition = new DecisionNodeEntity();
            vData.Condition.Type = constants.conditionType;
            vData.Condition.Parent = ce;

            DecisionNodeCollection maxColl = new DecisionNodeCollection();
            PredicateExpression pe = new PredicateExpression(DecisionNodeFields.ParentId == id);
            object maxObj = maxColl.GetScalar(DecisionNodeFieldIndex.Order, null, AggregateFunction.Max, pe);
            if (maxObj != null && maxObj != DBNull.Value)
                vData.Condition.Order = (int)maxObj + 1;
            else
                vData.Condition.Order = 0;

            vData.Condition.Save();

            ViewData["title"] = "new sub-condition";

            return View("EditCondition", vData);
        }