예제 #1
0
        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);
            }
        }
예제 #2
0
        private bool IsPassed(Table item, EPAssignmentRoute route)
        {
            try
            {
                List <EPAssignmentRule> rules = new List <EPAssignmentRule>();
                foreach (EPAssignmentRule rule in PXSelectReadonly <EPAssignmentRule,
                                                                    Where <EPAssignmentRule.assignmentRouteID, Equal <Required <EPAssignmentRoute.assignmentRouteID> > > > .Select(this, route.AssignmentRouteID))
                {
                    rules.Add(rule);
                }

                if (rules.Count == 0)
                {
                    return(true);
                }
                switch (route.RuleType)
                {
                case RuleType.AllTrue:
                    return(rules.All(rule => IsTrue(item, rule)));

                case RuleType.AtleastOneConditionIsTrue:
                    return(rules.Any(rule => IsTrue(item, rule)));

                case RuleType.AtleastOneConditionIsFalse:
                    return(rules.Any(rule => !IsTrue(item, rule)));

                default:
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
예제 #3
0
        protected virtual void EPAssignmentRoute_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
        {
            EPAssignmentRoute row = e.Row as EPAssignmentRoute;

            if (row != null && AssigmentMap.Current != null)
            {
                IEnumerable list = items(PositionFilter.Current.NodeID);

                int maxSequence = 0;
                foreach (PXResult <EPAssignmentRoute, EPCompanyTree> item in list)
                {
                    if (((EPAssignmentRoute)item[0]).Sequence.Value > maxSequence)
                    {
                        maxSequence = ((EPAssignmentRoute)item[0]).Sequence.Value;
                    }
                }

                if (IsImport && !PXGraph.ProxyIsActive)
                {
                    if (PositionFilter.Current.UseCurrentTreeItem == true && Nodes.Current != null)
                    {
                        PositionFilter.Current.RouteParentID = Nodes.Current.AssignmentRouteID != RootNodeID ? Nodes.Current.AssignmentRouteID : null;
                    }
                    PositionFilter.Current.UseCurrentTreeItem = false;
                    row.Parent = PositionFilter.Current.RouteParentID;
                }
                else
                {
                    row.Parent = PositionFilter.Current.NodeID;
                }

                row.Sequence        = maxSequence + 1;
                row.AssignmentMapID = AssigmentMap.Current.AssignmentMapID;
            }
        }
예제 #4
0
        private IEnumerable <EntityItemSource> GraphTypeList()
        {
            if (this.AssigmentMap.Current == null)
            {
                yield break;
            }

            var aMap = AssigmentMap.Current;
            EPAssignmentRoute route = PXSelect <EPAssignmentRoute,
                                                Where <EPAssignmentRoute.assignmentMapID, Equal <Required <EPAssignmentRoute.assignmentMapID> > > >
                                      .Select(this, aMap.AssignmentMapID);

            if (route != null && aMap.EntityType != null)
            {
                Type graphType;

                if (aMap.GraphType != null)
                {
                    graphType = GraphHelper.GetType(aMap.GraphType);
                }
                else
                {
                    Type entityType = System.Web.Compilation.PXBuildManager.GetType(aMap.EntityType, false);
                    graphType      = EntityHelper.GetPrimaryGraphType(this, entityType);
                    aMap.GraphType = graphType.FullName;
                }

                if (graphType != null)
                {
                    PXSiteMapNode node = PXSiteMap.Provider.FindSiteMapNodeUnsecure(graphType);
                    if (node != null)
                    {
                        yield return(new EntityItemSource(node, aMap.GraphType));
                    }
                }
                else
                {
                    foreach (var e in EMailSourceHelper.TemplateScreens(this, null, null))
                    {
                        yield return(e);
                    }
                }
            }
            else
            {
                foreach (EntityItemSource e in EMailSourceHelper.TemplateScreensByCondition(this, null, null,
                                                                                            type => type.IsDefined(typeof(PXEMailSourceAttribute), true) && typeof(PX.Data.EP.IAssign).IsAssignableFrom(type)))
                {
                    if (!String.IsNullOrEmpty(e.ScreenID))
                    {
                        PXSiteMapNode node = PXSiteMap.Provider.FindSiteMapNodeByScreenID(e.ScreenID);
                        if (node != null && !String.IsNullOrEmpty(node.GraphType))
                        {
                            e.SubKey = node.GraphType;
                            yield return(e);
                        }
                    }
                }
            }
        }
예제 #5
0
        protected virtual void EPAssignmentRoute_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
        {
            EPAssignmentRoute row = (EPAssignmentRoute)e.Row;

            if (row == current && e.TranStatus == PXTranStatus.Completed)
            {
                PositionFilter.Current.MapID  = row.AssignmentMapID;
                PositionFilter.Current.NodeID = row.AssignmentRouteID;
            }
        }
예제 #6
0
        protected virtual void EPAssignmentRoute_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            EPAssignmentRoute row = e.Row as EPAssignmentRoute;

            if (row != null && AssigmentMap.Current != null)
            {
                PositionFilter.Current.NodeID      = row.RouteID;
                PositionFilter.Current.RouteItemID = row.AssignmentRouteID;
            }
        }
예제 #7
0
 private void UpdateSequence(PXCache sender, EPAssignmentRoute route, int?from, int?to, int step)
 {
     foreach (EPAssignmentRoute r in PXSelect <EPAssignmentRoute,
                                               Where <EPAssignmentRoute.assignmentMapID, Equal <Required <EPAssignmentRoute.assignmentMapID> >,
                                                      And <EPAssignmentRoute.sequence,
                                                           Between <Required <EPAssignmentRoute.sequence>, Required <EPAssignmentRoute.sequence> > > > >
              .Select(this, route.AssignmentMapID, from, to))
     {
         if (r.AssignmentRouteID != route.AssignmentRouteID)
         {
             r.Sequence += step;
             sender.SetStatus(r, PXEntryStatus.Updated);
         }
     }
 }
예제 #8
0
        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);
            }
        }
예제 #9
0
        protected virtual void EPAssignmentRoute_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            EPAssignmentRoute row = e.Row as EPAssignmentRoute;

            if (row == null)
            {
                return;
            }

            this.Rules.Cache.AllowInsert = e.Row != null && row.Sequence != null;
            this.Rules.Cache.AllowUpdate = e.Row != null && row.Sequence != null;
            this.Rules.Cache.AllowDelete = e.Row != null && row.Sequence != null;

            PXUIFieldAttribute.SetEnabled <EPAssignmentRoute.workgroupID>(sender, row, row == null || row.RouterType == EPRouterType.Workgroup);
            PXUIFieldAttribute.SetEnabled <EPAssignmentRoute.ownerID>(sender, row, row == null || row.RouterType == EPRouterType.Workgroup);
            PXUIFieldAttribute.SetEnabled <EPAssignmentRoute.routeID>(sender, row, row != null && row.RouterType == EPRouterType.Router);
        }
예제 #10
0
        protected virtual void EPAssignmentRoute_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            EPAssignmentRoute row    = (EPAssignmentRoute)e.NewRow;
            EPAssignmentRoute oldrow = (EPAssignmentRoute)e.Row;

            if (row.Sequence != oldrow.Sequence && e.ExternalCall)
            {
                if (oldrow.Sequence < row.Sequence)
                {
                    UpdateSequence(sender, row, oldrow.Sequence + 1, row.Sequence, -1);
                }
                else
                {
                    UpdateSequence(sender, row, row.Sequence, oldrow.Sequence, +1);
                }
                this.AssigmentMap.View.RequestRefresh();
            }
        }
예제 #11
0
        protected virtual void EPAssignmentRoute_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            EPAssignmentRoute row = e.Row as EPAssignmentRoute;

            if (row == null || e.Operation == PXDBOperation.Delete)
            {
                return;
            }

            PXDefaultAttribute.SetPersistingCheck <EPAssignmentRoute.routeID>(sender, e.Row,
                                                                              row.RouterType == EPRouterType.Router ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);

            if (e.Operation == PXDBOperation.Insert &&
                PositionFilter.Current.MapID == row.AssignmentMapID &&
                (PositionFilter.Current.NodeID == row.AssignmentRouteID || PositionFilter.Current.NodeID == null))
            {
                current = row;
            }
        }
예제 #12
0
 private static int Comparison(EPAssignmentRoute x, EPAssignmentRoute y)
 {
     return(x.Sequence.Value.CompareTo(y.Sequence.Value));
 }
예제 #13
0
        protected virtual IEnumerable nodes([PXDBInt] int?assignmentRouteID)
        {
            List <EPAssignmentRoute> list = new List <EPAssignmentRoute>();

            if (!assignmentRouteID.HasValue)
            {
                EPAssignmentRoute root = new EPAssignmentRoute();
                root.AssignmentRouteID = RootNodeID;
                root.AssignmentMapID   = PositionFilter.Current.MapID;

                root.Name = this.Accessinfo.CompanyName ?? CR.Messages.Company;

                root.Icon = PX.Web.UI.Sprite.Main.GetFullUrl(PX.Web.UI.Sprite.Main.Folder);
                list.Add(root);
            }
            else
            {
                IEnumerable resultSet;
                if (assignmentRouteID == RootNodeID)
                {
                    resultSet = PXSelectJoin
                                <EPAssignmentRoute, LeftJoin <EPCompanyTree, On <EPAssignmentRoute.workgroupID, Equal <EPCompanyTree.workGroupID> > >,
                                 Where <EPAssignmentRoute.assignmentMapID, Equal <Current <Position.mapID> >,
                                        And <EPAssignmentRoute.parent, IsNull> > > .Select(this);
                }
                else
                {
                    resultSet = PXSelectJoin
                                <EPAssignmentRoute, LeftJoin <EPCompanyTree, On <EPAssignmentRoute.workgroupID, Equal <EPCompanyTree.workGroupID> > >,
                                 Where <EPAssignmentRoute.assignmentMapID, Equal <Current <Position.mapID> >,
                                        And <EPAssignmentRoute.parent, Equal <Required <EPAssignmentRoute.parent> > > > > .Select(this, assignmentRouteID);
                }

                foreach (PXResult <EPAssignmentRoute, EPCompanyTree> record in resultSet)
                {
                    EPAssignmentRoute route = record;

                    if (route.RouterType == EPRouterType.Workgroup)
                    {
                        route.Icon = PX.Web.UI.Sprite.Main.GetFullUrl(PX.Web.UI.Sprite.Main.Roles);
                    }
                    else if (route.RouteID.HasValue)
                    {
                        route.Icon = PX.Web.UI.Sprite.Main.GetFullUrl(PX.Web.UI.Sprite.Main.Redo);
                    }
                    else if (route.OwnerID.HasValue)
                    {
                        route.Icon = PX.Web.UI.Sprite.Main.GetFullUrl(PX.Web.UI.Sprite.Main.Users);
                    }
                    else
                    {
                        route.Icon = PX.Web.UI.Sprite.Main.GetFullUrl(PX.Web.UI.Sprite.Main.Folder);
                    }
                    list.Add(route);
                }
            }

            PositionFilter.Current.UseCurrentTreeItem = PXView.Searches != null && PXView.Searches.Length > 0 && PXView.Searches[0] != null;

            return(list);
        }