0

我正在定制以向现有数据视图添加一些过滤器。员工时间活动页面上
活动数据视图。
我已将 Customer 属性添加到PMTimeActivityOwnedFilter。现在我需要修改activity方法以考虑客户过滤器。这样做的唯一方法是使用以下场景之一覆盖该方法:

  • 无需调用基本方法并复制代码并添加过滤器部分

  • 调用基本方法并检查每个返回记录的条件。

第一种情况是使这部分自定义非常有问题,因为每次将自定义升级到任何其他构建时都需要查看此代码。

从性能的角度来看,第二种情况并不好。

有没有人遇到过这个问题,如何以可接受的方式做到这一点?

下面是该activity方法的代码:

    protected virtual IEnumerable activity()
    {
        List<object> args = new List<object>();
        EmployeeActivitiesEntry.PMTimeActivityFilter filterRow = this.Filter.Current;
        if (filterRow == null)
        {
            return null;
        }
        BqlCommand cmd = BqlCommand.CreateInstance(new Type[]
        {
            typeof(Select2<EPActivityApprove, LeftJoin<EPEarningType, On<EPEarningType.typeCD, Equal<PMTimeActivity.earningTypeID>>, LeftJoin<CRActivityLink, On<CRActivityLink.noteID, Equal<PMTimeActivity.refNoteID>>, LeftJoin<CRCase, On<CRCase.noteID, Equal<CRActivityLink.refNoteID>>, LeftJoin<ContractEx, On<CRCase.contractID, Equal<ContractEx.contractID>>>>>>, Where<EPActivityApprove.ownerID, Equal<Current<EmployeeActivitiesEntry.PMTimeActivityFilter.ownerID>>, And<EPActivityApprove.trackTime, Equal<True>, And<PMTimeActivity.isCorrected, Equal<False>>>>, OrderBy<Desc<EPActivityApprove.date>>>)
        });
        if (filterRow.ProjectID != null)
        {
            cmd = cmd.WhereAnd<Where<EPActivityApprove.projectID, Equal<Current<EmployeeActivitiesEntry.PMTimeActivityFilter.projectID>>>>();
        }
        if (filterRow.ProjectTaskID != null)
        {
            cmd = cmd.WhereAnd<Where<EPActivityApprove.projectTaskID, Equal<Current<EmployeeActivitiesEntry.PMTimeActivityFilter.projectTaskID>>>>();
        }
        if (filterRow.FromWeek != null || filterRow.TillWeek != null)
        {
            List<Type> cmdList = new List<Type>();
            bool? includeReject = filterRow.IncludeReject;
            bool flag = true;
            if (includeReject.GetValueOrDefault() == flag & includeReject != null)
            {
                cmdList.Add(typeof(Where<, , >));
                cmdList.Add(typeof(EPActivityApprove.approvalStatus));
                cmdList.Add(typeof(Equal<ActivityStatusListAttribute.rejected>));
                cmdList.Add(typeof(Or<>));
            }
            if (filterRow.FromWeek != null)
            {
                if (filterRow.TillWeek != null)
                {
                    cmdList.Add(typeof(Where<, , >));
                }
                else
                {
                    cmdList.Add(typeof(Where<, >));
                }
                cmdList.Add(typeof(EPActivityApprove.weekID));
                cmdList.Add(typeof(GreaterEqual<Required<EmployeeActivitiesEntry.PMTimeActivityFilter.fromWeek>>));
                args.Add(filterRow.FromWeek);
                if (filterRow.TillWeek != null)
                {
                    cmdList.Add(typeof(And<>));
                }
            }
            if (filterRow.TillWeek != null)
            {
                cmdList.Add(typeof(Where<EPActivityApprove.weekID, LessEqual<Required<EmployeeActivitiesEntry.PMTimeActivityFilter.tillWeek>>>));
                args.Add(filterRow.TillWeek);
            }
            cmd = cmd.WhereAnd(BqlCommand.Compose(cmdList.ToArray()));
        }
        return new PXView(this, false, cmd).SelectMultiBound(new object[]
        {
            this.Filter.Current
        }, args.ToArray());
    }
4

1 回答 1

1

我会考虑尝试使用 PXView,这是 Sergey在这里描述的。

如果是员工活动时间卡,它可能如下所示:

public class EmployeeExt : PXGraphExtension<EmployeeActivitiesEntry>
{
    protected virtual IEnumerable activity()
    {
        var sel = new PXView(Base, true, Base.Activity.View.BqlSelect);

        if(true)
        {
            sel.WhereAnd<Where<EPActivityApprove.projectID, Equal<Current<EmployeeActivitiesEntry.PMTimeActivityFilter.projectID>>>>();
        }

        int totalRow = 0;
        int startRow = PXView.StartRow;

        return sel.Select(PXView.Currents, PXView.Parameters,
            PXView.Searches, PXView.SortColumns, PXView.Descendings,
            PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRow);
    }
}
于 2019-09-09T08:21:34.767 回答