Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        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 || !info.BuildExpression)
            {
                return(status);
            }

            exp = exp.In(new Query()
                         .Select <EPApproval.refNoteID>()
                         .From <EPApproval>()
                         .Where(typeof(EPApproval.ownerID).EQ(userID1)
                                .Or(typeof(EPApproval.workgroupID)
                                    .In(new Query()
                                        .Select <EPCompanyTreeH.workGroupID>()
                                        .From <EPCompanyTreeH>()
                                        .Join <EPCompanyTreeMember>()
                                        .On(typeof(EPCompanyTreeH.parentWGID).EQ(typeof(EPCompanyTreeMember.workGroupID))
                                            .And(typeof(EPCompanyTreeH.parentWGID).NE(typeof(EPCompanyTreeH.workGroupID)))
                                            .And(typeof(EPCompanyTreeMember.active).EQ(true))
                                            .And(typeof(EPCompanyTreeMember.userID).EQ(userID2)))
                                        .Where(new SQLConst(1)
                                               .EQ(new SQLConst(1)))))));
            return(status);
        }
Exemple #4
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);
        }
        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;

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

            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);
                    }
                }
            }
            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 Data.SQLTree.Constant(numBranch);
                    }
                    else
                    {
                        inn = inn.Seq(numBranch);
                    }
                }
                exp = exp.Or(fld.In(inn)).Embrace();
            }

            return(status);
        }
        //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);
        }
Exemple #8
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);
        }
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 => Where.AppendExpression(ref exp, graph, info, selection);
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 {
     return(true);
 }
Exemple #11
0
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 {
     info.Fields?.Add(typeof(Field));
     return(true);
 }
 public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
 {
     throw new NotImplementedException();
 }
Exemple #13
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());
        }