public virtual IEnumerable reminderListCurrent([PXInt] int?taskID) { if (taskID == null) { if (ReminderList.Current == null) { yield break; } taskID = ReminderList.Current.TaskID; } yield return((EPActivity)PXSelectReadonly <EPActivity> .Search <EPActivity.taskID>(this, taskID)); }
public virtual IEnumerable reminderListCurrent([PXGuid] Guid?noteID) { if (noteID == null) { if (ReminderList.Current == null) { yield break; } noteID = ReminderList.Current.NoteID; } yield return((CRActivity)PXSelectReadonly <CRActivity> .Search <CRActivity.noteID>(this, noteID)); }
private bool IsAttributeRuleTrue(object item, EPAssignmentRule rule) { string field = rule.FieldName.Substring(0, rule.FieldName.Length - "_Attribute".Length - 1); CSAttribute attribute = PXSelectReadonly <CSAttribute> .Search <CSAttribute.attributeID>(this, field); if (attribute == null || rule.Condition == null) { //Field Name is not a valid question. return(false); } var noteId = new EntityHelper(_Graph).GetEntityNoteID(item); CSAnswers ans = PXSelect <CSAnswers, Where <CSAnswers.refNoteID, Equal <Required <CSAnswers.refNoteID> >, And <CSAnswers.attributeID, Equal <Required <CSAnswers.attributeID> > > > > .Select(_Graph ?? this, noteId, field); if (ans == null) { //Answer for the given question doesnot exist. switch (rule.Condition.Value) { case (int)PXCondition.ISNULL: return(true); case (int)PXCondition.ISNOTNULL: return(false); case (int)PXCondition.EQ: return(string.IsNullOrEmpty(rule.FieldValue)); case (int)PXCondition.NE: return(!string.IsNullOrEmpty(rule.FieldValue)); } return(false); } this.currentAttribute = ans; PXFilterRow filter = new PXFilterRow(typeof(CSAnswers.value).Name, (PXCondition)rule.Condition.Value, rule.FieldValue, null); int startRow = 0; int totalRows = 0; List <object> result = attributeView.Select(null, null, null, null, null, new PXFilterRow[] { filter }, ref startRow, 1, ref totalRows); return(result.Count > 0); }
protected virtual IEnumerable viewSegment(PXAdapter adapter) { var current = Detail.Current; if (current != null) { Segment row; if (current.Inherited == true) { row = (Segment)PXSelectReadonly2 <Segment, InnerJoin <Dimension, On <Dimension.parentDimensionID, Equal <Segment.dimensionID> > >, Where <Dimension.dimensionID, Equal <Required <Dimension.dimensionID> >, And <Segment.segmentID, Equal <Required <Segment.segmentID> > > > > . Select(this, current.DimensionID, current.SegmentID); } else { row = (Segment)PXSelectReadonly <Segment> . Search <Segment.dimensionID, Segment.segmentID>(this, current.DimensionID, current.SegmentID); } PXRedirectHelper.TryRedirect(Caches[typeof(Segment)], row, string.Empty); } return(adapter.Get()); }
private void CorrectChildDimensions() { var header = Header.Current; if (header != null) { var oldNumbering = header.DimensionID. With(id => (Dimension)PXSelectReadonly <Dimension> . Search <Dimension.dimensionID>(this, id)). With(dim => dim.NumberingID); foreach (Dimension item in PXSelect <Dimension, Where <Dimension.parentDimensionID, Equal <Required <Dimension.parentDimensionID> > > > . Select(this, header.DimensionID)) { item.Length = header.Length; item.Segments = header.Segments; if (string.IsNullOrEmpty(item.NumberingID)) { item.NumberingID = header.NumberingID; } var numbErrors = new List <Exception>(); var oldNumbID = item.NumberingID; if (oldNumbID == oldNumbering) { item.NumberingID = header.NumberingID; CheckLength(Header.Cache, item, numbErrors); if (numbErrors.Count > 0) { numbErrors.Clear(); item.NumberingID = oldNumbID; } else { oldNumbID = item.NumberingID; } } CheckLength(Header.Cache, item, numbErrors); if (numbErrors.Count > 0 && oldNumbID != header.NumberingID) { var oldNumbErrorsCount = numbErrors.Count; item.NumberingID = header.NumberingID; CheckLength(Header.Cache, item, numbErrors); if (numbErrors.Count == oldNumbErrorsCount) { numbErrors.Clear(); } else { item.NumberingID = oldNumbID; } } if (numbErrors.Count > 0) { var sb = new StringBuilder(); foreach (var error in numbErrors) { sb.AppendLine(error.Message); } throw new Exception(sb.ToString()); } Header.Cache.Update(item); InsertNumberingValue(item); } } }
private bool ProcessLevel(Table item, int?assignmentMap, PXResultset <EPAssignmentRoute> routes) { PXSelectReadonly <EPAssignmentRoute, Where <EPAssignmentRoute.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> >, And <EPAssignmentRoute.parent, Equal <Required <EPAssignmentRoute.assignmentRouteID> > > >, OrderBy <Asc <EPAssignmentRoute.sequence> > > rs = new PXSelectReadonly <EPAssignmentRoute, Where <EPAssignmentRoute.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> >, And <EPAssignmentRoute.parent, Equal <Required <EPAssignmentRoute.assignmentRouteID> > > >, OrderBy <Asc <EPAssignmentRoute.sequence> > >(this); foreach (EPAssignmentRoute route in routes) { if (route.AssignmentRouteID == null) { continue; } path.Add(route.AssignmentRouteID.Value); if (IsPassed(item, route)) { if (route.WorkgroupID != null || route.OwnerID != null || route.OwnerSource != null) { item.WorkgroupID = route.WorkgroupID; item.OwnerID = null; if (route.OwnerSource != null) { PXGraph graph = processGraph; PXCache cache = graph.Caches[typeof(Table)]; string code = PXTemplateContentParser.Instance.Process(route.OwnerSource, graph, typeof(Table), null ); EPEmployee emp = PXSelect <EPEmployee, Where <EPEmployee.acctCD, Equal <Required <EPEmployee.acctCD> > > > .SelectWindowed(this, 0, 1, code); item.OwnerID = emp != null ? emp.UserID : GUID.CreateGuid(code); } if (item.OwnerID == null) { item.OwnerID = route.OwnerID; } if (route.UseWorkgroupByOwner == true && item.WorkgroupID != null && item.OwnerID != null) { EPCompanyTreeMember member = PXSelectJoin <EPCompanyTreeMember, InnerJoin <EPCompanyTreeH, On <EPCompanyTreeH.workGroupID, Equal <EPCompanyTreeMember.workGroupID> >, InnerJoin <EPEmployee, On <EPEmployee.userID, Equal <EPCompanyTreeMember.userID> > > >, Where <EPCompanyTreeH.parentWGID, Equal <Required <EPCompanyTreeH.parentWGID> >, And <EPCompanyTreeMember.userID, Equal <Required <EPCompanyTreeMember.userID> > > > > .SelectWindowed(this, 0, 1, item.WorkgroupID, item.OwnerID); if (member != null) { item.WorkgroupID = member.WorkGroupID; } } if (item.WorkgroupID != null && item.OwnerID == null) { EPCompanyTreeMember owner = PXSelectJoin <EPCompanyTreeMember, InnerJoin <EPEmployee, On <EPEmployee.userID, Equal <EPCompanyTreeMember.userID> > >, Where <EPCompanyTreeMember.workGroupID, Equal <Required <EPCompanyTreeMember.workGroupID> >, And <EPCompanyTreeMember.isOwner, Equal <boolTrue> > > > .Select(this, item.WorkgroupID); if (owner != null) { item.OwnerID = owner.UserID; } } PXTrace.WriteInformation(Messages.ProcessRouteSequence, route.Sequence); return(true); } if (route.RouteID != null) { return(!path.Contains(route.RouteID.Value) && ProcessLevel(item, assignmentMap, PXSelectReadonly <EPAssignmentRoute> .Search <EPAssignmentRoute.assignmentRouteID>(this, route.RouteID))); } PXResultset <EPAssignmentRoute> result = rs.Select(assignmentMap, route.AssignmentRouteID); return(ProcessLevel(item, assignmentMap, result)); } } return(false); }
private IEnumerable <ApproveInfo> ProcessLevel(Table item, int?assignmentMap, PXResultset <EPRule> rules) { foreach (EPRule rule in rules) { if (rule.RuleID == null) { continue; } path.Add(rule.RuleID.Value); bool isSuccessful = true; var filteredItems = ExecuteRule(item, rule, ref isSuccessful); Guid?OwnerID = null; int? WorkgroupID = rule.WorkgroupID; switch (rule.RuleType) { case EPRuleType.Direct: if (!isSuccessful || (filteredItems != null && filteredItems.Count == 0)) { continue; } OwnerID = rule.OwnerID; FillOwnerWorkgroup(ref OwnerID, ref WorkgroupID); if (OwnerID == null && WorkgroupID == null) { continue; } yield return(new ApproveInfo() { OwnerID = OwnerID, WorkgroupID = WorkgroupID, RuleID = rule.RuleID, StepID = rule.StepID, WaitTime = rule.WaitTime }); break; case EPRuleType.Document: if (rule.OwnerSource == null || (filteredItems != null && filteredItems.Count == 0)) { continue; } PXView lineView = null; PXView primaryView = null; Type viewType = null; try { var s = rule.OwnerSource; var viewName = s.Substring(s.LastIndexOf("(") + 1, s.IndexOf(".") - (s.LastIndexOf("(") + 1)); if (String.Equals(viewName, processGraph.PrimaryView, StringComparison.InvariantCultureIgnoreCase)) { primaryView = processGraph.Views[viewName]; viewType = primaryView.GetItemType(); } else { lineView = processGraph.Views[viewName]; viewType = lineView.GetItemType(); } } catch (Exception) { // ignored } bool queryContainsDetails = filteredItems != null && filteredItems.Count > 0 && ((PXResult)filteredItems[0])[viewType] != null; var arrayToIterate = queryContainsDetails ? filteredItems : lineView?.SelectMulti() ?? primaryView.Cache.Current.SingleToList() ?? filteredItems; foreach (object filteredItem in arrayToIterate) { if (filteredItem is PXResult) { var line = ((PXResult)filteredItem)[viewType]; processGraph.Caches[viewType].Current = line; } else { processGraph.Caches[viewType].Current = filteredItem; } string code = PXTemplateContentParser.Instance.Process(rule.OwnerSource, processGraph, viewType, null); EPEmployee emp = PXSelect < EPEmployee, Where <EPEmployee.acctCD, Equal <Required <EPEmployee.acctCD> > > > .SelectWindowed(this, 0, 1, code); OwnerID = emp != null ? emp.UserID : GUID.CreateGuid(code); FillOwnerWorkgroup(ref OwnerID, ref WorkgroupID); if (OwnerID == null && WorkgroupID == null) { continue; } yield return(new ApproveInfo() { OwnerID = OwnerID, WorkgroupID = WorkgroupID, RuleID = rule.RuleID, StepID = rule.StepID, WaitTime = rule.WaitTime }); } break; case EPRuleType.Filter: if (filteredItems == null || filteredItems.Count == 0) { continue; } List <EPRuleBaseCondition> conditions = PXSelectReadonly <EPRuleEmployeeCondition, Where <EPRuleEmployeeCondition.ruleID, Equal <Required <EPRule.ruleID> > > > .Select(this, rule.RuleID) .Select(_ => (EPRuleBaseCondition)_) .ToList(); if (conditions.Count == 0) { break; } foreach (var approveInfo in GetEmployeesByFilter(item, rule, conditions)) { yield return(approveInfo); } break; } if (rule.RuleID != null) { if (path.Contains(rule.RuleID.Value)) { continue; } foreach (var approveInfo in ProcessLevel(item, assignmentMap, PXSelectReadonly <EPRule> .Search <EPRule.ruleID>(this, rule.RuleID))) { yield return(approveInfo); } } PXResultset <EPRule> result = PXSelectReadonly < EPRule, Where < EPRule.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> > >, OrderBy < Asc <EPRule.sequence> > > .Select(this, assignmentMap); foreach (var approveInfo in ProcessLevel(item, assignmentMap, result)) { yield return(approveInfo); } } }