예제 #1
0
 public PXGraph this[IBqlTable row]
 {
     get
     {
         Type    itemType = row.GetType();
         PXCache cache    = Graph.Caches[itemType];
         Type    graphType;
         object  copy = cache.CreateCopy(row);
         PXPrimaryGraphAttribute.FindPrimaryGraph(cache, ref copy, out graphType);
         return(this[graphType]);
     }
 }
예제 #2
0
        private static void ProcessValidation(PXGraph graph, Contact record, ValidationFilter Filter)
        {
            Type    itemType = record.GetType();
            PXCache cache    = PXGraph.CreateInstance <PXGraph>().Caches[itemType];
            Type    graphType;
            object  copy = cache.CreateCopy(record);

            PXPrimaryGraphAttribute.FindPrimaryGraph(cache, ref copy, out graphType);

            if (graphType == null)
            {
                throw new PXException(Messages.UnableToFindGraph);
            }

            graph = PXGraph.CreateInstance(graphType);


            graph.Views[graph.PrimaryView].Cache.Current = copy;

            CRDuplicateEntities <PXGraph, Contact> .RunActionWithAppliedAutomation(
                graph,
                copy,
                nameof(CRDuplicateEntities <PXGraph, Contact> .CheckForDuplicates));

            DuplicateDocument document = graph.Caches[typeof(DuplicateDocument)].Current as DuplicateDocument;

            record.DuplicateStatus = document?.DuplicateStatus;
            record.DuplicateFound  = document?.DuplicateFound;

            var maxScore = graph
                           .Caches[typeof(CRDuplicateRecord)]
                           .Cached
                           .Cast <CRDuplicateRecord>()
                           .Max(_ => _?.Score) ?? 0;

            if (record.DuplicateStatus == DuplicateStatusAttribute.PossibleDuplicated &&
                record.ContactType == ContactTypesAttribute.Lead
                //&& record.Status == LeadStatusesAttribute.New
                && Filter.CloseNoActivityLeads == true &&
                maxScore > Filter.CloseThreshold)
            {
                CRActivity activity = PXSelect <CRActivity,
                                                Where <CRActivity.refNoteID, Equal <Required <Contact.noteID> > > > .SelectWindowed(graph, 0, 1, record.NoteID);

                if (activity == null)
                {
                    CRDuplicateEntities <PXGraph, Contact> .RunActionWithAppliedAutomation(
                        graph,
                        copy,
                        nameof(CRDuplicateEntities <PXGraph, Contact> .CloseAsDuplicate));
                }
            }
        }
        private static void ProcessValidation(BusinessAccountMaint graph, Contact record, ValidationFilter Filter)
        {
            Type    itemType = record.GetType();
            PXCache cache    = PXGraph.CreateInstance <PXGraph>().Caches[itemType];
            Type    graphType;
            object  copy = cache.CreateCopy(record);

            PXPrimaryGraphAttribute.FindPrimaryGraph(cache, ref copy, out graphType);

            graph.Views[graph.PrimaryView].Cache.Current = copy as BAccount;

            CRDuplicateEntities <PXGraph, BAccount> .RunActionWithAppliedAutomation(
                graph,
                copy,
                nameof(CRDuplicateEntities <PXGraph, BAccount> .CheckForDuplicates));
        }
예제 #4
0
    //Gets url to navigate for entering required data
    private string GetNextUrl(ref PXSetupNotEnteredException exception)
    {
        Type    graphType           = null;
        PXGraph gettingCache        = new PXGraph();
        bool    createInstanceError = true;

        //Get graph that user must use at first
        while (createInstanceError)
        {
            createInstanceError = false;
            PXPrimaryGraphBaseAttribute attr = PXPrimaryGraphAttribute.FindPrimaryGraph(gettingCache.Caches[exception.DAC], out graphType);

            if (graphType != null)
            {
                try
                {
                    PXGraph tmpGraph = PXGraph.CreateInstance(graphType) as PXGraph;
                }
                catch (PXSetupNotEnteredException ctrException)
                {
                    createInstanceError = true;
                    exception           = ctrException;
                }
            }
        }

        try
        {
            string link = graphType == null ? null : PXBaseDataSource.getMainForm(graphType);
            if (exception.KeyParams != null)
            {
                char pref = '?';
                foreach (var keyparam in exception.KeyParams)
                {
                    link += String.Format(pref + "{0}={1}", keyparam.Key.Name.ToString(), keyparam.Value.ToString());
                    pref  = '&';
                }
            }
            return(link);
        }
        //we cang get url if we don't have rights to the screen
        catch
        {
            return(null);
        }
    }
예제 #5
0
    //Gets url to navigate for entering required data
    private string GetNextUrl(ref PXSetupNotEnteredException exception)
    {
        Type    graphType           = null;
        PXGraph gettingCache        = new PXGraph();
        bool    createInstanceError = true;

        //Get graph that user must use at first
        while (createInstanceError)
        {
            createInstanceError = false;
            PXPrimaryGraphBaseAttribute attr = PXPrimaryGraphAttribute.FindPrimaryGraph(gettingCache.Caches[exception.DAC], out graphType);

            if (graphType != null)
            {
                try
                {
                    PXGraph tmpGraph = PXGraph.CreateInstance(graphType) as PXGraph;
                }
                catch (PXSetupNotEnteredException ctrException)
                {
                    createInstanceError = true;
                    exception           = ctrException;
                }
            }
        }

        try
        {
            return(graphType == null ? null : PXBaseDataSource.getMainForm(graphType));
        }
        //we cang get url if we don't have rights to the screen
        catch
        {
            return(null);
        }
    }
        private void CreateActivity(int classId, Guid?refNoteID, string typeCode, Guid?owner, PXRedirectHelper.WindowMode windowMode = PXRedirectHelper.WindowMode.NewWindow)
        {
            var graphType = CRActivityPrimaryGraphAttribute.GetGraphType(classId);

            if (!PXAccess.VerifyRights(graphType))
            {
                throw new AccessViolationException(CR.Messages.FormNoAccessRightsMessage(graphType));
            }

            CRActivity activity = null;

            var cache = CreateInstanceCache <CRActivity>(graphType);

            if (cache == null)
            {
                return;
            }

            if (owner == null)
            {
                owner = EmployeeMaint.GetCurrentEmployeeID(cache.Graph);
            }

            Action <object> initializeHandler = delegate(object act1)
            {
                var act = act1 as CRActivity;
                if (act == null)
                {
                    return;
                }

                act.ClassID   = classId;
                act.RefNoteID = refNoteID;
                if (!string.IsNullOrEmpty(typeCode))
                {
                    act.Type = typeCode;
                }
                act.OwnerID = owner;
            };

            EntityHelper helper = new EntityHelper(cache.Graph);
            var          type   = helper.GetEntityRowType(refNoteID);
            var          entity = helper.GetEntityRow(type, refNoteID);

            Type entityGraphType = null;

            if (type != null)
            {
                PXPrimaryGraphAttribute.FindPrimaryGraph(cache.Graph.Caches[type], ref entity, out entityGraphType);
            }
            if (entityGraphType != null)
            {
                PXGraph entry = PXGraph.CreateInstance(entityGraphType);
                PXCache <CRActivity> activityCache = entry.Caches[typeof(CRActivity)] as PXCache <CRActivity>;
                if (activityCache != null)
                {
                    entry.Views[entry.PrimaryView].Cache.Current = entity;
                    activity = (CRActivity)activityCache.CreateInstance();
                    if (initializeHandler != null)
                    {
                        initializeHandler(activity);
                    }
                    activity = activityCache.InitNewRow(activity);
                }
            }

            if (activity == null)
            {
                activity = (CRActivity)cache.CreateInstance();

                initializeHandler(activity);

                activity = ((PXCache <CRActivity>)cache).InitNewRow(activity);
            }

            cache.Update(activity);
            PXRedirectHelper.TryRedirect(cache.Graph, windowMode);
        }