protected virtual void EPAssignmentMap_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { //EPSetup ep = setup.Current; EPAssignmentMap row = e.Row as EPAssignmentMap; if (row != null) { if (row.EntityType != null && row.GraphType == null) { Type entityType = System.Web.Compilation.PXBuildManager.GetType(row.EntityType, false); var primary = EntityHelper.GetPrimaryGraphType(this, entityType); if (primary != null) { AssigmentMap.Current.GraphType = primary.FullName; AssigmentMap.Cache.SetStatus(AssigmentMap.Current, PXEntryStatus.Updated); AssigmentMap.Cache.IsDirty = true; } } PositionFilter.Current.MapID = row.AssignmentMapID; this.Nodes.Cache.AllowInsert = row.EntityType != null; EPAssignmentRoute route = PXSelect <EPAssignmentRoute, Where <EPAssignmentRoute.assignmentMapID, Equal <Required <EPAssignmentRoute.assignmentMapID> > > > .Select(this, row.AssignmentMapID); PXUIFieldAttribute.SetEnabled <EPAssignmentMap.graphType>(sender, row, route == null); } }
public virtual IEnumerable <ApproveInfo> Approve(Table item, EPAssignmentMap map, int?currentStepSequence) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (map == null) { throw new ArgumentOutOfRangeException(nameof(map)); } switch (map.MapType) { case EPMapType.Legacy: return(new EPAssignmentProcessHelper <Table>(_Graph).Assign(item, map, false)); case EPMapType.Assignment: throw new ArgumentException(Messages.AssignmentNotApprovalMap); case EPMapType.Approval: return(new EPAssignmentHelper <Table>(_Graph).Assign(item, map, true, currentStepSequence)); default: return(null); } }
public virtual IEnumerable <ApproveInfo> Assign(Table item, EPAssignmentMap map, bool isApprove) { path.Clear(); processMapType = GraphHelper.GetType(map.EntityType); Type itemType = item.GetType(); PXSelectBase <EPAssignmentRoute> rs = new PXSelectReadonly <EPAssignmentRoute, Where <EPAssignmentRoute.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> >, And <EPAssignmentRoute.parent, IsNull> >, OrderBy <Asc <EPAssignmentRoute.sequence> > >(this); PXResultset <EPAssignmentRoute> routes = rs.Select(map.AssignmentMapID, null); Type mapgraphtype = GraphHelper.GetType(map.GraphType); //impossible, but written to support purpose of legacy db states if (mapgraphtype == null) { mapgraphtype = EntityHelper.GetPrimaryGraphType(this, processMapType); } if (_Graph != null && mapgraphtype.IsAssignableFrom(_Graph.GetType())) { processGraph = _Graph; } else { processGraph = CreateInstance(GraphHelper.GetType(map.GraphType) ?? mapgraphtype); } if (processGraph != null && processMapType != null) { if (processMapType.IsAssignableFrom(itemType)) { this.processGraph.Caches[itemType].Current = item; } else if (itemType.IsAssignableFrom(processMapType)) { object placed = this.processGraph.Caches[processMapType].CreateInstance(); PXCache cache = (PXCache)Activator.CreateInstance(typeof(PXCache <>).MakeGenericType(itemType), this); cache.RestoreCopy(placed, item); this.processGraph.Caches[processMapType].Current = placed; } else { return(null); } } var result = ProcessLevel(item, map.AssignmentMapID, routes).ToList(); if (result.Any()) { return(result); } PXTrace.WriteWarning(Messages.DocumentPreApproved); throw new RequestApproveException(); }
/// <summary> /// Assigns Owner and Workgroup to the given IAssign instance based on the assigmentment rules. /// </summary> /// <param name="item">IAssign object</param> /// <param name="assignmentMapID">Assignment map</param> /// <returns>True if workgroup was assigned; otherwise false</returns> /// <remarks> /// You have to manualy persist the IAssign object to save the changes. /// </remarks> public virtual bool Assign(Table item, int?assignmentMapID) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (assignmentMapID < 0) { throw new ArgumentOutOfRangeException(nameof(assignmentMapID)); } path.Clear(); EPAssignmentMap map = PXSelect <EPAssignmentMap, Where <EPAssignmentMap.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> > > > .SelectWindowed(this, 0, 1, assignmentMapID); if (map == null) { return(false); } if (map.MapType != EPMapType.Legacy) { throw new ArgumentOutOfRangeException(nameof(assignmentMapID)); } return(Assign(item, map, false)?.Any() ?? false); }
protected virtual void EPAssignmentMap_EntityType_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { EPAssignmentMap row = e.Row as EPAssignmentMap; if (row != null) { e.ReturnState = CreateFieldStateForEntity(e.ReturnValue, row.EntityType, row.GraphType); } }
/// <summary> /// Assigns Owner and Workgroup to the given IAssign instance based on the assigmentment rules. /// </summary> /// <param name="item">IAssign object</param> /// <param name="assignmentMapID">Assignment map</param> /// <returns>True if workgroup was assigned; otherwise false</returns> /// <remarks> /// You have to manualy persist the IAssign object to save the changes. /// </remarks> public virtual bool Assign(Table item, int?assignmentMapID) { if (item == null) { throw new ArgumentNullException("item"); } if (assignmentMapID < 0) { throw new ArgumentOutOfRangeException("assignmentMapID"); } path.Clear(); EPAssignmentMap map = PXSelect <EPAssignmentMap, Where <EPAssignmentMap.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> > > > .SelectWindowed(this, 0, 1, assignmentMapID); if (map == null) { return(false); } processMapType = GraphHelper.GetType(map.EntityType); Type itemType = item.GetType(); PXSelectBase <EPAssignmentRoute> rs = new PXSelectReadonly <EPAssignmentRoute, Where <EPAssignmentRoute.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> >, And <EPAssignmentRoute.parent, IsNull> >, OrderBy <Asc <EPAssignmentRoute.sequence> > >(this); PXResultset <EPAssignmentRoute> routes = rs.Select(assignmentMapID, null); this.processGraph = _Graph ?? new EntityHelper(this).GetPrimaryGraph(item, false); if (processGraph != null && processMapType != null) { if (processMapType.IsAssignableFrom(itemType)) { this.processGraph.Caches[itemType].Current = item; } else if (itemType.IsAssignableFrom(processMapType)) { object placed = this.processGraph.Caches[processMapType].CreateInstance(); PXCache cache = (PXCache)Activator.CreateInstance(typeof(PXCache <>).MakeGenericType(itemType), this); cache.RestoreCopy(placed, item); this.processGraph.Caches[processMapType].Current = placed; } else { return(false); } } return(ProcessLevel(item, assignmentMapID, routes)); }
protected override void EPAssignmentMap_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { EPAssignmentMap row = e.Row as EPAssignmentMap; addStep.SetEnabled(row != null && row.EntityType != null); PXUIFieldAttribute.SetVisible(Rules.Cache, null, CurrentNode.Current != null); PXUIFieldAttribute.SetVisible(this.EmployeeCondition.Cache, null, false); base.EPAssignmentMap_RowSelected(sender, e); }
protected virtual void EPAssignmentMap_GraphType_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { EPAssignmentMap row = e.Row as EPAssignmentMap; if (row != null) { var list = Definitions.SiteMapNodes.OrderBy(x => x.Title); PXStringListAttribute.SetLocalizable <EPAssignmentMap.graphType>(sender, null, false); PXStringListAttribute.SetList <EPAssignmentMap.graphType>(sender, row, list.Select(x => x.GraphType).ToArray(), list.Select(x => x.Title).ToArray()); } }
protected virtual void EPAssignmentMap_GraphType_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { EPAssignmentMap row = e.Row as EPAssignmentMap; if (row != null && row.GraphType != null) { Type type = GraphHelper.GetType(row.GraphType); var graph = PXGraph.CreateInstance(type); Type primary = graph.Views[graph.PrimaryView].Cache.GetItemType(); row.EntityType = primary.FullName; } }
protected virtual void EPAssignmentMap_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { EPSetup ep = setup.Current; EPAssignmentMap row = e.Row as EPAssignmentMap; if (row != null) { PositionFilter.Current.MapID = row.AssignmentMapID; this.Nodes.Cache.AllowInsert = row.EntityType != null; EPAssignmentRoute route = PXSelect <EPAssignmentRoute, Where <EPAssignmentRoute.assignmentMapID, Equal <Required <EPAssignmentRoute.assignmentMapID> > > > .Select(this, row.AssignmentMapID); PXUIFieldAttribute.SetEnabled <EPAssignmentMap.entityType>(sender, row, route == null); } }
protected virtual void EPAssignmentMap_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { PXUIFieldAttribute.SetEnabled(CurrentNode.Cache, CurrentNode.Current, null, CurrentNode.Current != null); EPAssignmentMap row = e.Row as EPAssignmentMap; addRule.SetEnabled(row != null && row.EntityType != null); if (row != null) { if (row.EntityType != null && row.GraphType == null) { Type entityType = System.Web.Compilation.PXBuildManager.GetType(row.EntityType, false); var primary = EntityHelper.GetPrimaryGraphType(this, entityType); if (primary != null) { AssigmentMap.Current.GraphType = primary.FullName; AssigmentMap.Cache.SetStatus(AssigmentMap.Current, PXEntryStatus.Updated); AssigmentMap.Cache.IsDirty = true; } } this.Nodes.Cache.AllowInsert = row.EntityType != null; var nodes = Nodes.Select(); PXUIFieldAttribute.SetEnabled <EPAssignmentMap.graphType>(sender, row, nodes == null || nodes.Count == 0); } up.SetEnabled(this.CurrentNode.Current != null); down.SetEnabled(this.CurrentNode.Current != null); deleteRoute.SetEnabled(this.CurrentNode.Current != null); if (NodesTree.Current == null) { var step = (EPRuleTree)NodesTree.SelectSingle(); if (step != null) { var rule = (EPRuleTree)NodesTree.Select(step.RuleID); NodesTree.Cache.ActiveRow = rule ?? step; NodesTree.Current = (EPRuleTree)NodesTree.Cache.ActiveRow; } } }
public virtual bool Assign(Table item, int?assignmentMapID) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (assignmentMapID < 0) { throw new ArgumentOutOfRangeException(nameof(assignmentMapID)); } EPAssignmentMap map = PXSelect <EPAssignmentMap, Where <EPAssignmentMap.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> > > > .SelectWindowed(this, 0, 1, assignmentMapID); if (map == null) { return(false); } ApproveInfo info; switch (map.MapType) { case EPMapType.Legacy: try { info = new EPAssignmentProcessHelper <Table>(_Graph).Assign(item, map, false).FirstOrDefault(); if (info != null) { item.OwnerID = info.OwnerID; item.WorkgroupID = info.WorkgroupID; return(true); } } catch { return(false); } return(false); case EPMapType.Assignment: try { info = new EPAssignmentHelper <Table>(_Graph).Assign(item, map, false, 0).FirstOrDefault(); if (info != null) { item.OwnerID = info.OwnerID; item.WorkgroupID = info.WorkgroupID; return(true); } } catch { return(false); } return(false); case EPMapType.Approval: throw new ArgumentException(nameof(assignmentMapID)); default: return(false); } }
public virtual IEnumerable <ApproveInfo> Assign(Table item, EPAssignmentMap map, bool isApprove, int?currentStepSequence) { path.Clear(); processMapType = GraphHelper.GetType(map.EntityType); Type itemType = item.GetType(); PXSelectBase <EPRule> rs = new PXSelectReadonly < EPRule, Where < EPRule.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> > >, OrderBy < Asc <EPAssignmentRoute.sequence> > >(this); PXResultset <EPRule> rules; if (isApprove) { PXSelectBase <EPRule> ss = new PXSelectReadonly < EPRule, Where < EPRule.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> >, And <EPRule.sequence, Greater <Required <EPRule.sequence> >, And <EPRule.stepID, IsNull> > >, OrderBy < Asc <EPAssignmentRoute.sequence> > >(this); EPRule nextStep = ss.Select(map.AssignmentMapID, currentStepSequence ?? -1); if (nextStep == null) { yield break; } rs.WhereAnd <Where <EPRule.stepID, Equal <Required <EPRule.stepID> > > >(); rules = rs.Select(map.AssignmentMapID, nextStep.RuleID, null); rules.ForEach(_ => ((EPRule)_).StepName = nextStep.Name); } else { rules = rs.Select(map.AssignmentMapID, null); } Type mapgraphtype = GraphHelper.GetType(map.GraphType); //impossible, but written to support purpose of legacy db states if (mapgraphtype == null) { mapgraphtype = EntityHelper.GetPrimaryGraphType(this, processMapType); } if (_Graph != null && mapgraphtype.IsAssignableFrom(_Graph.GetType())) { processGraph = _Graph; } else { processGraph = CreateInstance(GraphHelper.GetType(map.GraphType) ?? mapgraphtype); } if (processGraph != null && processMapType != null) { if (processMapType.IsAssignableFrom(itemType)) { processGraph.Caches[itemType].Current = item; } else if (itemType.IsAssignableFrom(processMapType)) { object placed = processGraph.Caches[processMapType].CreateInstance(); PXCache cache = (PXCache)Activator.CreateInstance(typeof(PXCache <>).MakeGenericType(itemType), this); cache.RestoreCopy(placed, item); processGraph.Caches[processMapType].Current = placed; } else { yield break; } } foreach (var approveInfo in ProcessLevel(item, map.AssignmentMapID, rules)) { yield return(approveInfo); } }