public void Parse(
     PXGraph graph,
     List <IBqlParameter> pars,
     List <Type> tables,
     List <Type> fields,
     List <IBqlSortColumn> sortColumns,
     StringBuilder text,
     BqlCommand.Selection selection)
 {
 }
Beispiel #2
0
        public void Parse(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text,
                          BqlCommand.Selection selection)
        {
            if (graph != null && text != null)
            {
                string fieldName = BqlCommand.GetSingleField(typeof(TOrganizationIDField), graph, tables, selection, BqlCommand.FieldPlace.Condition);

                int?organizationID = GetOrganizationID(graph);

                text.Append($"{fieldName} = {organizationID}");
            }

            if (pars != null)
            {
                pars.Add(BranchIDParameter);
            }
        }
Beispiel #3
0
        public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            if (graph == null || !info.BuildExpression)
            {
                return(true);
            }

            SQLExpression fld = BqlCommand.GetSingleExpression(typeof(TOrganizationIDField), graph, info.Tables, selection, BqlCommand.FieldPlace.Condition);

            int?organizationID = GetOrganizationID(graph);

            exp = fld.Equal(organizationID);

            return(true);
        }
Beispiel #4
0
        public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool status = true;

            SQLExpression userID = null;

            status &= BqlCommand.AppendExpression <UserID>(ref userID, graph, info, selection, ref _operand);

            if (graph == null || !info.BuildExpression)
            {
                return(status);
            }

            SimpleTable epEmployee = new SimpleTable <EPEmployee>(EMPLOYEERALIAS);

            exp = exp.In(new Query()
                         .Select <EPWingman.employeeID>().From <EPWingman>()
                         .InnerJoin(epEmployee)
                         .On(new Column <EPEmployee.bAccountID>(epEmployee).EQ(new Column(typeof(EPWingman.wingmanID)))
                             .And(new Column <EPEmployee.userID>(epEmployee).EQ(userID)))
                         .Where(new SQLConst(1)
                                .EQ(new SQLConst(1))));

            return(status);
        }
Beispiel #5
0
 public virtual void Parse(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, BqlCommand.Selection selection)
 {
     _realWhere.Parse(graph, pars, tables, fields, sortColumns, text, selection);
 }
Beispiel #6
0
        public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool status = true;

            SQLExpression userID = null;

            status &= BqlCommand.AppendExpression <UserID>(ref userID, graph, info, selection, ref _operand);

            if (graph == null)
            {
                return(status);
            }

            exp.VerifyComparisonExpression();

            SimpleTable epEmployee = new SimpleTable <EPEmployee>(EMPLOYEERALIAS);

            exp.SetOper(SQLExpression.Operation.IN);

            exp = exp.LExpr().In(new Query()
                                 .Select <EPWingman.employeeID>().From <EPWingman>()
                                 .InnerJoin(epEmployee)
                                 .On(new Column <EPEmployee.bAccountID>(epEmployee).Equal(new Column(typeof(EPWingman.wingmanID)))
                                     .And(new Column <EPEmployee.userID>(epEmployee).Equal(userID)))
                                 .Where(PX.Data.SQLTree.Constant.SQLConstant(1)
                                        .Equal(PX.Data.SQLTree.Constant.SQLConstant(1))));

            return(status);
        }
Beispiel #7
0
 public void Parse(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, BqlCommand.Selection selection)
 {
     if (fields != null)
     {
         fields.Add(typeof(Field));
     }
 }
Beispiel #8
0
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 {
     info.Fields?.Add(typeof(Field));
     return(true);
 }
Beispiel #9
0
        public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool   status = true;
            object val    = null;

            if (_parameter == null)
            {
                _parameter = new Parameter();
            }

            if (graph != null && info.BuildExpression)
            {
                if (_parameter.HasDefault)
                {
                    Type ft = _parameter.GetReferencedType();
                    if (ft.IsNested)
                    {
                        Type    ct    = BqlCommand.GetItemType(ft);
                        PXCache cache = graph.Caches[ct];
                        if (cache.Current != null)
                        {
                            val = cache.GetValue(cache.Current, ft.Name);
                        }
                    }
                }

                SQLExpression fld = BqlCommand.GetSingleExpression(typeof(Field), graph, info.Tables, selection, BqlCommand.FieldPlace.Condition);
                exp = fld.IsNull();

                List <int> branches = null;

                if (val != null)
                {
                    branches = GetSameOrganizationBranches((int?)val);
                }
                if (branches != null && branches.Count > 0)
                {
                    SQLExpression inn = null;
                    foreach (int numBranch in branches)
                    {
                        if (null == inn)
                        {
                            inn = new SQLConst(numBranch);
                        }
                        else
                        {
                            inn = inn.Seq(numBranch);
                        }
                    }
                    exp = exp.Or(fld.In(inn)).Embrace();
                }
            }

            if (info.Fields?.Contains(typeof(Field)) == false)
            {
                info.Fields.Add(typeof(Field));
            }

            if (!selection.FromProjection)
            {
                exp = AddParameterExpression(exp, info, selection, val);
            }

            return(status);
        }
Beispiel #10
0
        /// <summary>
        /// Method adds a parameter to SQLExpression. This is necessary for correct work with the platform cache,
        /// otherwise you can get the result from the cache, even if SOOrder.branchId (or your Parameter) has changed.
        /// </summary>
        /// <returns>currentExpression and the new expression that contains the parameter, the last expression is alwaya true.</returns>
        private SQLExpression AddParameterExpression(SQLExpression currentExpression, BqlCommandInfo info, BqlCommand.Selection selection, object parameterValue)
        {
            SQLExpression parameterExpression     = Literal.NewParameter(selection.ParamCounter++);
            SQLExpression parameterTrueExpression = (parameterValue != null) ? parameterExpression.IsNotNull() : parameterExpression.IsNull();

            info.Parameters?.Add(_parameter);

            return(parameterTrueExpression.And(currentExpression).Embrace());
        }
        public void Parse(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, BqlCommand.Selection selection)
        {
            if (graph != null && text != null)
            {
                if (_parameter == null)
                {
                    _parameter = new Parameter();
                }

                object val = null;
                if (_parameter.HasDefault)
                {
                    Type ft = _parameter.GetReferencedType();
                    if (ft.IsNested)
                    {
                        Type    ct    = BqlCommand.GetItemType(ft);
                        PXCache cache = graph.Caches[ct];
                        if (cache.Current != null)
                        {
                            val = cache.GetValue(cache.Current, ft.Name);
                        }
                    }
                }
                String toAppend = BqlCommand.GetSingleField(typeof(Field), graph, tables, selection, BqlCommand.FieldPlace.Condition);
                text.Append("(").Append(toAppend).Append(" IS NULL ");

                List <int> branches = null;

                if (val != null)
                {
                    branches = GetSameOrganizationBranches((int?)val);
                }
                if (branches != null && branches.Count > 0)
                {
                    text.Append(" OR ").Append(toAppend).Append(" IN (");
                    foreach (int numBranch in branches)
                    {
                        text.Append(numBranch).Append(",");
                    }
                    text.Remove(text.Length - 1, 1);
                    text.Append(")");
                }
                text.Append(")");
            }
        }
Beispiel #12
0
 private void ParseOperand(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, BqlCommand.Selection selection)
 {
     BqlCommand.EqualityList list = fields as BqlCommand.EqualityList;
     if (list != null)
     {
         list.NonStrict = true;
     }
     if (!typeof(IBqlCreator).IsAssignableFrom(typeof(Operand)))
     {
         if (graph != null && text != null)
         {
             text.Append(" ").Append(BqlCommand.GetSingleField(typeof(Operand), graph, tables, selection, BqlCommand.FieldPlace.Condition));
         }
         if (fields != null)
         {
             fields.Add(typeof(Operand));
         }
     }
     else
     {
         if (_operand == null)
         {
             _operand = _operand.createOperand <Operand>();
         }
         _operand.Parse(graph, pars, tables, fields, sortColumns, text, selection);
     }
 }
Beispiel #13
0
 public void Parse(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, BqlCommand.Selection selection)
 {
     if (graph != null && text != null)
     {
         text.Append(" IN ").Append(BqlCommand.SubSelect);
         text.Append(typeof(EPWingman).Name).Append('.').Append(typeof(EPWingman.employeeID).Name);
         text.Append(" FROM ").Append(typeof(EPWingman).Name).Append(' ').Append(typeof(EPWingman).Name);
         text.Append(" INNER JOIN ").Append(typeof(EPEmployee).Name).Append(' ').Append(EMPLOYEERALIAS);
         text.Append(" ON ").Append(EMPLOYEERALIAS).Append('.').Append(typeof(EPEmployee.bAccountID).Name);
         text.Append('=').Append(typeof(EPWingman).Name).Append('.').Append(typeof(EPWingman.wingmanID).Name);
         text.Append(" AND ").Append(EMPLOYEERALIAS).Append('.').Append(typeof(EPEmployee.userID).Name);
         text.Append('=');
         ParseOperand(graph, pars, tables, fields, sortColumns, text, selection);
         text.Append(" WHERE 1=1");
         text.Append(')');
     }
     else
     {
         ParseOperand(graph, pars, tables, fields, sortColumns, text, selection);
     }
 }
        //for 2019r1
        //public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        //{
        //    if (graph == null || !info.BuildExpression) return true;
        //    PXMutableCollection.AddMutableItem(this);
        //    exp = new PX.Data.SQLTree.Constant(graph.Accessinfo.BranchID);
        //    return true;
        //}

        //for 2020r1
        public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            if (graph == null || !info.BuildExpression)
            {
                return(true);
            }
            PXMutableCollection.AddMutableItem(this);
            exp = new SQLConst(graph.Accessinfo.BranchID);
            return(true);
        }
 // for 2018r1
 public void Parse(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, BqlCommand.Selection selection)
 {
     if (graph != null && text != null)
     {
         PXMutableCollection.AddMutableItem(this);
         text.Append(' ');
         text.Append(graph.Accessinfo.BranchID);
         text.Append(' ');
     }
 }
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 {
     throw new NotImplementedException();
 }
        public virtual bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool status = true;

            if (info.Fields is BqlCommand.EqualityList list)
            {
                list.NonStrict = true;
            }

            SQLExpression opUser = null;

            if (!typeof(IBqlCreator).IsAssignableFrom(typeof(OperandUser)))
            {
                if (info.BuildExpression)
                {
                    opUser = BqlCommand.GetSingleExpression(typeof(OperandUser), graph, info.Tables, selection, BqlCommand.FieldPlace.Condition);
                }
                info.Fields?.Add(typeof(OperandUser));
            }
            else
            {
                if (_operandUser == null)
                {
                    _operandUser = _operandUser.createOperand <OperandUser>();
                }
                status &= _operandUser.AppendExpression(ref opUser, graph, info, selection);
            }

            Query qin = new Query();

            qin[typeof(EPCompanyTreeH.workGroupID)].From(typeof(EPCompanyTreeH))
            .Join(typeof(EPCompanyTreeMember))
            .On(SQLExpression.EQ(typeof(EPCompanyTreeH.parentWGID), typeof(EPCompanyTreeMember.workGroupID))
                //.And(Column.SQLColumn(typeof(EPCompanyTreeH.parentWGID)).NotEqual(Column.SQLColumn(typeof(EPCompanyTreeH.workGroupID)))
                .And(Column.SQLColumn(typeof(EPCompanyTreeMember.active)).EQ(1))
                .And(Column.SQLColumn(typeof(EPCompanyTreeMember.userID)).EQ(opUser)))
            //)
            .Where(new SQLConst(1).EQ(1));

            Query qout = new Query();

            //Append Tail removes main object, so we fieldNote will not be mapped. Skipping conditions for AppendTail
            if (info.Tables == null || info.Tables.Count <= 0 || info.Tables.Contains(BqlCommand.GetItemType <FieldNote>()))
            {
                qout[typeof(EntityWorkgroup.refNoteID)].From(typeof(EntityWorkgroup))
                .Where(Column.SQLColumn(typeof(EntityWorkgroup.workGroupID)).In(qin)
                       .And(SQLExpression.EQ(typeof(EntityWorkgroup.refNoteID), typeof(FieldNote))));
            }
            else
            {
                qout[typeof(EntityWorkgroup.refNoteID)].From(typeof(EntityWorkgroup))
                .Where(Column.SQLColumn(typeof(EntityWorkgroup.workGroupID)).In(qin));
            }

            qout.Limit(-1);             // prevent limiting of IN subqueries
            exp = exp.In(qout);

            return(status);
        }
        public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool status = true;

            SQLExpression userID1 = null;

            status &= BqlCommand.AppendExpression <UserID>(ref userID1, graph, info, selection, ref _operand);
            SQLExpression userID2 = null;

            status &= BqlCommand.AppendExpression <UserID>(ref userID2, graph, info, selection, ref _operand);

            if (graph == null)
            {
                return(status);
            }

            exp.VerifyComparisonExpression();

            exp = exp.LExpr()
                  .In(new Query()
                      .Select <EPApproval.refNoteID>()
                      .From <EPApproval>()
                      .Where(typeof(EPApproval.ownerID).Equal(userID1)
                             .Or(typeof(EPApproval.workgroupID)
                                 .In(new Query()
                                     .Select <EPCompanyTreeH.workGroupID>()
                                     .From <EPCompanyTreeH>()
                                     .Join <EPCompanyTreeMember>()
                                     .On(typeof(EPCompanyTreeH.parentWGID).Equal(typeof(EPCompanyTreeMember.workGroupID))
                                         .And(typeof(EPCompanyTreeH.parentWGID).NotEqual(typeof(EPCompanyTreeH.workGroupID)))
                                         .And(typeof(EPCompanyTreeMember.active).Equal(true))
                                         .And(typeof(EPCompanyTreeMember.userID).Equal(userID2)))
                                     .Where(PX.Data.SQLTree.Constant.SQLConstant(1)
                                            .Equal(PX.Data.SQLTree.Constant.SQLConstant(1)))))));
            return(status);
        }
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 {
     return(true);
 }
 public void Parse(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, BqlCommand.Selection selection)
 {
     if (graph != null && text != null)
     {
         text.Append(" IN ").Append(BqlCommand.SubSelect);
         text.Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPApproval).Name, typeof(EPApproval.refNoteID).Name));
         //text.Append(typeof (EPApproval).Name).Append('.').Append(typeof (EPApproval.refNoteID).Name);
         text.Append(" FROM ").Append(graph.SqlDialect.quoteDbIdentifier(typeof(EPApproval).Name)).Append(' ').Append(graph.SqlDialect.quoteDbIdentifier(typeof(EPApproval).Name));
         text.Append(" WHERE (").Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPApproval).Name, typeof(EPApproval.ownerID).Name));
         //.Append(typeof (EPApproval).Name).Append('.').Append(typeof (EPApproval.ownerID).Name);
         text.Append('=');
         ParseOperand(graph, pars, tables, fields, sortColumns, text, selection);
         text.Append(" OR ");
         text.Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPApproval).Name, typeof(EPApproval.workgroupID).Name));
         //text.Append(typeof (EPApproval).Name).Append('.').Append(typeof (EPApproval.workgroupID).Name);
         text.Append(" IN ").Append(BqlCommand.SubSelect);
         text.Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPCompanyTreeH).Name, typeof(EPCompanyTreeH.workGroupID).Name));
         //text.Append(typeof (EPCompanyTreeH).Name).Append('.').Append(typeof (EPCompanyTreeH.workGroupID).Name);
         text.Append(" FROM ").Append(graph.SqlDialect.quoteDbIdentifier(typeof(EPCompanyTreeH).Name)).Append(' ').Append(graph.SqlDialect.quoteDbIdentifier(typeof(EPCompanyTreeH).Name));
         text.Append(" INNER JOIN ").Append(graph.SqlDialect.quoteDbIdentifier(typeof(EPCompanyTreeMember).Name)).Append(' ').Append(graph.SqlDialect.quoteDbIdentifier(typeof(EPCompanyTreeMember).Name));
         text.Append(" ON ").Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPCompanyTreeH).Name, typeof(EPCompanyTreeH.parentWGID).Name));
         //.Append(typeof (EPCompanyTreeH).Name).Append('.').Append(typeof (EPCompanyTreeH.parentWGID).Name);
         text.Append('=').Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPCompanyTreeMember).Name, typeof(EPCompanyTreeMember.workGroupID).Name));
         //.Append(typeof (EPCompanyTreeMember).Name).Append('.').Append(typeof (EPCompanyTreeMember.workGroupID).Name);
         text.Append(" AND ").Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPCompanyTreeH).Name, typeof(EPCompanyTreeH.parentWGID).Name));
         //.Append(typeof (EPCompanyTreeH).Name).Append('.').Append(typeof (EPCompanyTreeH.parentWGID).Name);
         text.Append("<>").Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPCompanyTreeH).Name, typeof(EPCompanyTreeH.workGroupID).Name));
         //.Append(typeof (EPCompanyTreeH).Name).Append('.').Append(typeof (EPCompanyTreeH.workGroupID).Name);
         text.Append(" AND ").Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPCompanyTreeMember).Name, typeof(EPCompanyTreeMember.active).Name));
         //.Append(typeof(EPCompanyTreeMember).Name).Append('.').Append(typeof(EPCompanyTreeMember.active).Name);
         text.Append("= CONVERT (BIT, 1)");
         text.Append(" AND ").Append(graph.SqlDialect.quoteTableAndColumn(typeof(EPCompanyTreeMember).Name, typeof(EPCompanyTreeMember.userID).Name));
         //.Append(typeof (EPCompanyTreeMember).Name).Append('.').Append(typeof (EPCompanyTreeMember.userID).Name);
         text.Append('=');
         ParseOperand(graph, pars, tables, fields, sortColumns, text, selection);
         text.Append(" WHERE 1=1");
         text.Append(')').Append(')').Append(')');
     }
     else
     {
         ParseOperand(graph, pars, tables, fields, sortColumns, text, selection);
         ParseOperand(graph, pars, tables, fields, sortColumns, text, selection);
     }
 }
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 => Where.AppendExpression(ref exp, graph, info, selection);
Beispiel #22
0
        public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool status = true;

            status &= _where.AppendExpression(ref exp, graph, info, selection);
            return(status);
        }