예제 #1
0
        public static ReportConditionDef AddAttributeCondition(this ReportDef def, Guid leftSourceId, Guid leftAttrId,
                                                               CompareOperation condition, Guid rightSourceId, Guid rightAttrId)
        {
            Check(def);
            CheckSourceAttribute(def, leftSourceId, leftAttrId);
            CheckSourceAttribute(def, rightSourceId, rightAttrId);

            var conditionId  = Guid.NewGuid();
            var conditionDef = new ReportConditionDef
            {
                Id            = conditionId,
                Operation     = ExpressionOperation.And,
                LeftAttribute = new ReportAttributeDef {
                    SourceId = leftSourceId, AttributeId = leftAttrId
                },
                Condition = condition,
                RightPart = new ReportConditionRightAttributeDef
                {
                    Attribute = new ReportAttributeDef
                    {
                        SourceId    = rightSourceId,
                        AttributeId = rightAttrId
                    }
                }
            };

            def.Conditions.Add(conditionDef);
            return(conditionDef);
        }
예제 #2
0
        public static ReportConditionDef AddCondition(this ReportDef def, Guid leftSourceId, Guid leftAttrId, CompareOperation condition, ReportConditionDefType type = ReportConditionDefType.Param, string caption = null)
        {
            Check(def);
            var attrDef = CheckSourceAttribute(def, leftSourceId, leftAttrId);
            var s       = !String.IsNullOrEmpty(caption)
                ? caption
                : attrDef is AttrDef
                    ? ((AttrDef)attrDef).Caption ?? ((AttrDef)attrDef).Name
                    : ((ReportSourceSystemAttributeDef)attrDef).Caption;

            var rightPart = (type == ReportConditionDefType.Param)
                ? (ReportConditionRightPartDef) new ReportConditionRightParamDef {
                Caption = s
            }
                : new ReportConditionRightAttributeDef {
                Attribute = new ReportAttributeDef()
            };

            var conditionDef = new ReportConditionDef
            {
                Id            = Guid.NewGuid(),
                Operation     = ExpressionOperation.And,
                LeftAttribute = new ReportAttributeDef
                {
                    SourceId    = leftSourceId,
                    AttributeId = leftAttrId
                },
                Condition = condition,
                RightPart = rightPart
            };

            def.Conditions.Add(conditionDef);

            return(conditionDef);
        }
예제 #3
0
        public static ReportConditionDef AddParamCondition(this ReportDef def, Guid sourceId, Guid attrDefId, CompareOperation condition, object value, string paramCaption)
        {
            Check(def);
            GetSourceDef(def, sourceId);

            var conditionId  = Guid.NewGuid();
            var conditionDef = new ReportConditionDef
            {
                Id            = conditionId,
                Operation     = ExpressionOperation.And,
                LeftAttribute = new ReportAttributeDef {
                    SourceId = sourceId, AttributeId = attrDefId
                },
                Condition = condition,
                RightPart = new ReportConditionRightParamDef
                {
                    Caption = paramCaption,
                    Value   = value
                }
            };

            def.Conditions.Add(conditionDef);
            return(conditionDef);
        }