コード例 #1
0
ファイル: SqlQueryJoin.cs プロジェクト: tilekchubakov/CISSA
        public SqlQueryJoin(SqlQuerySource source, SqlQuerySource target, SqlSourceJoinType joinType,
                            Guid attrDefId)
        {
            Source   = source;
            Target   = target;
            JoinType = joinType;

            SqlQuerySource attrSource;

            JoinAttrDef = Source.FindAttributeDef(attrDefId);
            if (JoinAttrDef != null)
            {
                attrSource = Source;
            }
            else
            {
                JoinAttrDef       = Target.FindAttributeDef(attrDefId);
                attrSource        = Target;
                IsTargetAttribute = true;
            }

//            if (JoinAttrDef.Type.Id == (short)CissaDataType.Doc)
            if (JoinAttrDef != null)
            {
                JoinAttribute = attrSource.GetAttribute(JoinAttrDef.Id);
            }
        }
コード例 #2
0
        private ICollection <SqlQueryCondition> GetSourceConditions(SqlQuerySource source)
        {
            var sourceConditions = new List <SqlQueryCondition>();

            FillSourceConditions(source, sourceConditions);

            return(sourceConditions);
        }
コード例 #3
0
        private static SqlQuerySource AddJoinDocConditions(SqlQuery query, SqlQuerySource master, DocAttribute attr)
        {
            var source = query.JoinSource(master, attr.Document.DocDef.Id, SqlSourceJoinType.Inner, attr.AttrDef.Id);

            AddDocConditions(query, source, attr.Document);

            return(source);
        }
コード例 #4
0
        private ICollection <SqlQueryCondition> GetExternalSourceConditions(SqlQuerySource source,
                                                                            ICollection <SqlQueryCondition> sourceConditions)
        {
            var externalConditions = new List <SqlQueryCondition>();

            FillExternalSourceConditions(source, sourceConditions, externalConditions);

            return(externalConditions);
        }
コード例 #5
0
        public void FillSourceConditions(SqlQuerySource source, ICollection <SqlQueryCondition> sourceConditions)
        {
            if (!HasOrConditions())
            {
                foreach (var condition in this)
                {
                    if (condition.Condition == ConditionOperation.Include || condition.Condition == ConditionOperation.Exp)
                    {
                        if (condition.Conditions == null || condition.Conditions.Count == 0)
                        {
                            continue;
                        }

                        if (condition.Conditions.HasOrConditions())
                        {
                            var sources = condition.Conditions.GetSources();

                            if (sources.Count == 1 && sources[0] == source)
                            {
                                sourceConditions.Add(condition);
                            }

                            /*foreach (var sub in conditions)
                             *  sourceConditions.Add(sub);*/
                        }
                        else
                        {
                            condition.Conditions.FillSourceConditions(source, sourceConditions);
                        }
                    }
                    else
                    {
                        var sources = new List <SqlQuerySource>();

                        FillConditionSources(sources, condition);

                        if (sources.Count == 1 && sources[0] == source)
                        {
                            sourceConditions.Add(condition);
                        }
                    }
                }
            }
            else
            {
                var sources = GetSources();

                if (sources.Count == 1 && sources[0] == source)
                {
                    foreach (var condition in this)
                    {
                        sourceConditions.Add(condition);
                    }
                }
            }
        }
コード例 #6
0
        public int TryGetAttributeIndex(SqlQuerySource source, Guid attrDefId)
        {
            var attr =
                Query.Attributes.FirstOrDefault(a => a.Source == source && a.Def != null && a.Def.Id == attrDefId);

            if (attr == null)
            {
                return(-1);
            }

            return(Query.Attributes.IndexOf(attr));
        }
コード例 #7
0
ファイル: SqlQueryJoin.cs プロジェクト: tilekchubakov/CISSA
        public SqlQueryCondition AddCondition(ExpressionOperation operation, SqlQuerySource source1, string attrDefName1, ConditionOperation condition, SqlQuerySource source2, string attrDefName2, SqlQueryCondition parentCondition = null)
        {
            var item = new SqlQueryCondition(operation, source1, attrDefName1, condition, source2, attrDefName2);

            if (parentCondition == null)
            {
                Conditions.Add(item);
            }
            else
            {
                parentCondition.Conditions.Add(item);
            }

            return(item);
        }
コード例 #8
0
ファイル: SqlQueryJoin.cs プロジェクト: tilekchubakov/CISSA
        public SqlQueryCondition AddCondition(ExpressionOperation operation, SqlQuerySource source, string attrDefName, ConditionOperation condition, object value, SqlQueryCondition parentCondition = null)
        {
            var item = new SqlQueryCondition(source, operation, attrDefName, condition, value);

            if (parentCondition == null)
            {
                Conditions.Add(item);
            }
            else
            {
                parentCondition.Conditions.Add(item);
            }

            return(item);
        }
コード例 #9
0
        public void FillExternalSourceConditions(SqlQuerySource source,
                                                 ICollection <SqlQueryCondition> sourceConditions, ICollection <SqlQueryCondition> externalConditions)
        {
            foreach (var condition in this)
            {
                if (condition.Condition == ConditionOperation.Include || condition.Condition == ConditionOperation.Exp)
                {
                    if (sourceConditions.Contains(condition))
                    {
                        continue;
                    }

                    if (condition.Conditions == null || condition.Conditions.Count == 0)
                    {
                        continue;
                    }

                    if (condition.Conditions.HasOrConditions())
                    {
                        externalConditions.Add(condition);
                    }
                    else
                    {
                        condition.Conditions.FillExternalSourceConditions(source, sourceConditions, externalConditions);
                    }
                }
                else
                {
                    if (sourceConditions.Contains(condition))
                    {
                        continue;
                    }

                    var sources = new List <SqlQuerySource>();

                    FillConditionSources(sources, condition);

                    if (sources.Contains(source))
                    {
                        externalConditions.Add(condition);
                    }
                }
            }
        }
コード例 #10
0
        /*private static void AddFormControls(SqlQuery query, SqlQuerySource source, IEnumerable<BizControl> children)
         * {
         *  if (children == null) return;
         *
         *  foreach(var control in children)
         *  {
         *      if (control is BizDataControl && ((BizDataControl)control).AttributeDefId != null)
         *      {
         *          if (control is BizDocumentControl && control.Children != null && control.Children.Count > 0)
         *          {
         *              var docControl = (BizDocumentControl) control;
         *              var attr = source.GetDocDef().Attributes.First(a => a.Id == (Guid) docControl.AttributeDefId);
         *
         *              var slave = query.JoinSource(source, attr.DocDefType, SqlSourceJoinType.Inner, attr.Id);
         *
         *              AddFormControls(query, slave, control.Children);
         *          }
         *          else
         *              query.AddAttribute(source, (Guid) ((BizDataControl) control).AttributeDefId);
         *      }
         *
         *  }
         * }*/

        public static void AddDocConditions(SqlQuery query, SqlQuerySource source, Doc filter)
        {
            if (filter == null)
            {
                return;
            }

            foreach (var attr in filter.Attributes)
            {
                if (attr is DocAttribute)
                {
                    if (((DocAttribute)attr).Document != null && HasDocumentValue(((DocAttribute)attr).Document))
                    {
                        AddJoinDocConditions(query, source, (DocAttribute)attr);
                    }
                }
                else if (attr is DocListAttribute)
                {
                    //                    if (((DocListAttribute)attr).AddedDocIds != null)
                }
                else if (attr.ObjectValue != null)
                {
                    if (attr is TextAttribute)
                    {
                        var txt = ((TextAttribute)attr).Value;
                        if (!String.IsNullOrEmpty(txt))
                        {
                            query.AddCondition(ExpressionOperation.And, attr.AttrDef.Id, ConditionOperation.Like, txt);
                        }
                    }
                    else
                    {
                        query.AddCondition(ExpressionOperation.And, attr.AttrDef.Id, ConditionOperation.Equal, attr.ObjectValue);
                    }
                }
            }
        }
コード例 #11
0
        public int TryGetAttributeIndex(SqlQuerySource source, string attrDefName)
        {
            SqlQuerySelectAttribute attr;

            if (attrDefName.Length > 0 && attrDefName[0] == '&')
            {
                var ident = SystemIdentConverter.Convert(attrDefName);

                attr = Query.Attributes.FirstOrDefault(a => a.Source == source && a.IsSystemIdent && a.Attribute.Ident == ident);
            }
            else
            {
                attr =
                    Query.Attributes.FirstOrDefault(
                        a => a.Source == source && String.Equals(a.Def.Name, attrDefName, StringComparison.OrdinalIgnoreCase));
            }

            if (attr == null)
            {
                return(-1);
            }

            return(Query.Attributes.IndexOf(attr));
        }
コード例 #12
0
 public SqlQueryJoinBuilder(SqlQuery query, SqlQuerySource source) : this(null, query, source)
 {
 }
コード例 #13
0
 public SqlQueryOrderAttribute(SqlQuerySource source, SqlQuerySourceAttribute attribute, bool asc) : base(source, attribute)
 {
     Asc = asc;
 }
コード例 #14
0
 public SqlQueryConditionBuilder(SqlQueryConditionBuilder parent, SqlQuery query, SqlQuerySource source)
 {
     Parent = parent;
     Query  = query;
     Source = source;
 }
コード例 #15
0
 public SqlQueryJoinBuilder(SqlQueryJoinBuilder parent, SqlQuery query, SqlQuerySource source)
 {
     Query  = query;
     Source = source;
     Parent = parent;
 }
コード例 #16
0
 protected SqlQueryAttribute(SqlQuerySource source, Guid attrDefId, string expression)
     : this(source, attrDefId)
 {
     Expression = expression;
 }
コード例 #17
0
 protected SqlQueryAttribute(SqlQuerySource source, string attrDefName, string expression)
     : this(source, attrDefName)
 {
     Expression = expression;
 }
コード例 #18
0
 protected SqlQueryAttribute(SqlQuerySource source, SystemIdent attrIdent)
 {
     _attributes.Add(new SqlQuerySourceAttributeRef(source, source.GetAttribute(attrIdent)));
 }
コード例 #19
0
 protected SqlQueryAttribute(SqlQuerySource source, SystemIdent attrIdent, string exp) : this(source, attrIdent)
 {
     Expression = exp;
 }
コード例 #20
0
 public SqlQuerySourceAttributeRef(SqlQuerySource source, string attrDefName)
 {
     Source    = source;
     Attribute = source.GetAttribute(attrDefName);
 }
コード例 #21
0
 public SqlQueryOrderAttribute(SqlQuerySource source, Guid attrDefId) : this(source, attrDefId, true)
 {
 }
コード例 #22
0
 public SqlQueryOrderAttribute(SqlQuerySource source, SystemIdent attrIdent, string exp, bool asc)
     : base(source, attrIdent, exp)
 {
     Asc = asc;
 }
コード例 #23
0
 public SqlQueryOrderAttribute(SqlQuerySource source, Guid attrDefId, bool asc) : base(source, attrDefId)
 {
     Asc = asc;
 }
コード例 #24
0
 public SqlQuerySourceAttributeRef(SqlQuerySource source, SystemIdent attrIdent)
 {
     Source    = source;
     Attribute = source.GetAttribute(attrIdent);
 }
コード例 #25
0
 public SqlQueryOrderAttribute(SqlQuerySource source, string attrDefName, bool asc) : base(source, attrDefName)
 {
     Asc = asc;
 }
コード例 #26
0
 protected SqlQueryAttribute(SqlQuerySource source, SqlQuerySourceAttribute attribute)
 {
     _attributes.Add(new SqlQuerySourceAttributeRef(source, attribute));
 }
コード例 #27
0
 public SqlQueryOrderAttribute(SqlQuerySource source, Guid attrDefId, string expression, bool asc)
     : base(source, attrDefId, expression)
 {
     Asc = asc;
 }
コード例 #28
0
 protected SqlQueryAttribute(SqlQuerySource source, Guid attrDefId)
 {
     _attributes.Add(new SqlQuerySourceAttributeRef(source, source.GetAttribute(attrDefId)));
 }
コード例 #29
0
 public SqlQueryOrderAttribute(SqlQuerySource source, string attrDefName) : this(source, attrDefName, true)
 {
 }
コード例 #30
0
 protected SqlQueryAttribute(SqlQuerySource source, string attrDefName)
 {
     _attributes.Add(new SqlQuerySourceAttributeRef(source, source.GetAttribute(attrDefName)));
 }