Exemple #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));
        }
Exemple #2
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 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);
        }