private void Proccess()
 {
     using (new PXScreenIDScope("CR306015"))
     {
         try
         {
             if (CreateMessage())
             {
                 ProcessMessage();
             }
         }
         finally
         {
             _graph.Clear();
             _activity = null;
             if (_activityMessage != null)
             {
                 _message.Exception = _activityMessage.Exception;
                 _message.MPStatus  = _activityMessage.MPStatus;
             }
             _message         = null;
             _activityMessage = null;
         }
     }
 }
Ejemplo n.º 2
0
        public static void SegregateRegister(PXGraph graph, int BranchID, string Origin, string PeriodID, DateTime?DocDate, string descr, DocumentList <FARegister> created)
        {
            PXCache doccache  = graph.Caches[typeof(FARegister)];
            PXCache trancache = graph.Caches[typeof(FATran)];

            if (trancache.IsInsertedUpdatedDeleted)
            {
                graph.Actions.PressSave();
                if (doccache.Current != null && created.Find(doccache.Current) == null)
                {
                    created.Add((FARegister)doccache.Current);
                }
                graph.Clear();
            }

            FARegister register = created.Find <FARegister.branchID, FARegister.origin, FARegister.finPeriodID>(BranchID, Origin, PeriodID) ?? new FARegister();

            if (register.RefNbr != null)
            {
                FARegister newreg = PXSelect <FARegister, Where <FARegister.refNbr, Equal <Current <FARegister.refNbr> > > > .SelectSingleBound(graph, new object[] { register });

                if (newreg.DocDesc != descr)
                {
                    newreg.DocDesc = string.Empty;
                    doccache.Update(newreg);
                }
                doccache.Current = newreg;
            }
            else
            {
                graph.Clear();

                register = new FARegister
                {
                    Hold        = false,
                    BranchID    = BranchID,
                    Origin      = Origin,
                    FinPeriodID = PeriodID,
                    DocDate     = DocDate,
                    DocDesc     = descr
                };
                doccache.Insert(register);
            }
        }
        private void EnsureCurrentForUpdate <T>(PXGraph graph) where T : class, IBqlTable, new()
        {
            var cache = graph.Caches <T>();

            if (cache.Current as T == null)
            {
                // just for sure, if there is trash too
                graph.Clear();
                cache.Insert();
            }
        }
        private void EnsureCurrentForInsert <T>(PXGraph graph) where T : class, IBqlTable, new()
        {
            var cache = graph.Caches <T>();

            if (cache.Insert() as T == null)
            {
                // this means there is trash in graph from previous session
                graph.Clear();
                cache.Insert();
            }
        }
 private void Proccess()
 {
     _graph.Accessinfo.ScreenID = "CR.30.60.15";
     PXContext.SetScreenID("CR.30.60.15");
     try
     {
         if (CreateMessage())
         {
             ProcessMessage();
         }
     }
     finally
     {
         _graph.Clear();
         _message = null;
     }
 }
Ejemplo n.º 6
0
 public PXGraph this[Type graphType]
 {
     get
     {
         PXGraph graph = null;
         if (graphType != null && !Graphs.TryGetValue(graphType, out graph))
         {
             graph = PXGraph.CreateInstance(graphType);
             PXDBAttributeAttribute.Activate(graph.Views[graph.PrimaryView].Cache);
             Graphs[graphType] = graph;
         }
         if (graph != null)
         {
             graph.Clear();
         }
         return(graph);
     }
 }
        /// <summary>
        /// Returns BPHandler referencing particular message template.
        /// Is used for Subscriber ID selector
        /// </summary>
        /// <param name="graph"></param>
        /// <returns></returns>
        public IEnumerable <BPHandler> GetHandlers(PXGraph graph)
        {
            graph.Clear(PXClearOption.ClearQueriesOnly);
            var result = PXSelect <MobileNotification,
                                   Where <MobileNotification.deliveryType, Equal <Required <MobileNotification.deliveryType> >
                                          > > .Select(graph, 3).FirstTableItems;

            var resultReadOnly = PXSelectReadonly <MobileNotification,
                                                   Where <MobileNotification.deliveryType, Equal <Required <MobileNotification.deliveryType> >
                                                          > > .Select(graph, 3).FirstTableItems;

            var result2 = PXSelect <MobileNotification,
                                    Where <MobileNotification.deliveryType, Equal <Required <MobileNotification.deliveryType> >,
                                           And <Where <MobileNotification.screenID, Equal <Current <BPEvent.screenID> >,
                                                       Or <Current <BPEvent.screenID>, IsNull> > > > >
                          .Select(graph, 3).FirstTableItems.Where(c => c != null).Select(c =>
                                                                                         new BPHandler()
            {
                Id = c.NoteID, Name = c.Name, Type = TypeName
            });

            return(result2);
        }
Ejemplo n.º 8
0
 public void ClearCaches()
 {
     _graph.Clear();
 }
Ejemplo n.º 9
0
        private void processLines(
            List <POEnabledFSSODet> originalItemList,
            PXGraph <CreatePurchaseOrderProcess> graphCreatePurchaseOrderByServiceOrder,
            List <List <POEnabledFSSODet> > groupedFSSODetRows)
        {
            if (groupedFSSODetRows.Count == 0)
            {
                return;
            }

            POOrder          poOrderRow = null;
            POLine           poLineRow  = null;
            POEnabledFSSODet firstPOEnabledFSSODetRow = null;

            PXGraph      processGraph      = new PXGraph();
            POOrderEntry graphPOOrderEntry = CreateInstance <POOrderEntry>();

            foreach (List <POEnabledFSSODet> itemGroup in groupedFSSODetRows)
            {
                if (!this.IsThisItemGroupValid(itemGroup, originalItemList))
                {
                    continue;
                }

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    try
                    {
                        processGraph.Clear(PXClearOption.ClearAll);
                        graphPOOrderEntry.Clear(PXClearOption.ClearAll);

                        this.CreatePOOrderDocument(graphPOOrderEntry, itemGroup, poOrderRow, poLineRow, firstPOEnabledFSSODetRow);

                        foreach (POEnabledFSSODet poEnabledFSSODetRow in itemGroup)
                        {
                            PXUpdate <
                                Set <FSSODet.poType, Required <FSSODet.poType>,
                                     Set <FSSODet.poNbr, Required <FSSODet.poNbr>,
                                          Set <FSSODet.poLineNbr, Required <FSSODet.poLineNbr>,
                                               Set <FSSODet.poStatus, Required <FSSODet.poStatus>,
                                                    Set <FSSODet.poCompleted, Required <FSSODet.poCompleted>,
                                                         Set <FSSODet.poVendorID, Required <FSSODet.poVendorID>,
                                                              Set <FSSODet.poVendorLocationID, Required <FSSODet.poVendorLocationID> > > > > > > >,
                                FSSODet,
                                Where <
                                    FSSODet.sODetID, Equal <Required <FSSODet.sODetID> >,
                                    And <FSSODet.poNbr, IsNull> > >
                            .Update(
                                processGraph,
                                poEnabledFSSODetRow.POType,
                                graphPOOrderEntry.Document.Current.OrderNbr,
                                poEnabledFSSODetRow.POLineNbr,
                                graphPOOrderEntry.Document.Current.Status,
                                poEnabledFSSODetRow.POCompleted,
                                poEnabledFSSODetRow.POVendorID,
                                poEnabledFSSODetRow.POVendorLocationID,
                                poEnabledFSSODetRow.SODetID);

                            PXProcessing <POEnabledFSSODet> .SetInfo(originalItemList.IndexOf(poEnabledFSSODetRow), TX.Messages.RECORD_PROCESSED_SUCCESSFULLY);

                            poEnabledFSSODetRow.PONbrCreated = graphPOOrderEntry.Document.Current.OrderNbr;
                        }

                        ts.Complete();
                    }
                    catch (Exception e)
                    {
                        ts.Dispose();

                        foreach (POEnabledFSSODet poEnabledFSSODetRow in itemGroup)
                        {
                            PXProcessing <POEnabledFSSODet> .SetError(originalItemList.IndexOf(poEnabledFSSODetRow), e);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public void DeleteBatchProc(GLVoucherBatch aBatch, Dictionary <string, Dictionary <Guid, CAMessage> > errorList)
        {
            this.Clear();
            this.Document.Current = aBatch;
            Dictionary <Guid, CAMessage> errorLog = null;

            if (!errorList.ContainsKey(aBatch.VoucherBatchNbr))
            {
                errorList.Add(aBatch.VoucherBatchNbr, new Dictionary <Guid, CAMessage>());
            }
            errorLog = errorList[aBatch.VoucherBatchNbr];

            try
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    List <Guid> failed = new List <Guid>();
                    Dictionary <string, List <GLVoucher> > processQueue = new Dictionary <string, List <GLVoucher> >();
                    foreach (GLVoucher voucher in Details.Select())
                    {
                        if (!processQueue.ContainsKey(voucher.Module + voucher.DocType))
                        {
                            processQueue.Add(voucher.Module + voucher.DocType, new List <GLVoucher>());
                        }
                        processQueue[voucher.Module + voucher.DocType].Add(voucher);
                    }
                    foreach (KeyValuePair <string, List <GLVoucher> > pair in processQueue)
                    {
                        string module    = pair.Value[0].Module;
                        string docType   = pair.Value[0].DocType;
                        Type   graphType = GLWorkBookMaint.GetGraphByDocType(module, docType);
                        if (graphType == null)
                        {
                            throw new PXException(GL.Messages.ModuleDocTypeIsNotSupported, module, docType);
                        }
                        PXGraph deletegraph = PXGraph.CreateInstance(graphType);
                        if (!(deletegraph is IVoucherEntry))
                        {
                            throw new PXException(GL.Messages.ModuleDocTypeIsNotSupported, module, docType);
                        }
                        foreach (GLVoucher voucher in pair.Value)
                        {
                            Guid key = voucher.RefNoteID.Value;
                            try
                            {
                                deletegraph.Clear();
                                GLVoucherBatchEntry.SetVoucherAsCurrent(this, deletegraph, voucher);
                                (deletegraph as IVoucherEntry).DeleteButton.Press();
                            }
                            catch (Exception ex)
                            {
                                failed.Add(key);
                                errorLog.Add(key, FormatError(ex));
                                throw new PXException(Messages.DeletingFailed);
                            }
                        }
                    }
                    this.Document.Delete(aBatch);
                    this.Save.Press();
                    ts.Complete(this);
                }
            }
            catch (PXException ex)
            {
                errorLog.Add(Guid.Empty, FormatError(ex));
                throw ex;
            }
        }