public virtual IEnumerable CreateUpdate(PXAdapter adapter)
        {
            var templateItem  = GetTemplateItem();
            var itemsToCreate = MatrixItemsForCreation.Cache.Cached.RowCast <MatrixInventoryItem>().Where(mi => mi.Selected == true).ToList();

            if (templateItem != null && itemsToCreate.Any())
            {
                var clone = Base.Clone();
                var graph = (templateItem.StkItem == true)
                                        ? (InventoryItemMaintBase)PXGraph.CreateInstance <InventoryItemMaint>()
                                        : PXGraph.CreateInstance <NonStockItemMaint>();
                var helper = this.GetHelper(graph);
                var attributeGroupHelper = this.GetAttributeGroupHelper(graph);
                PXLongOperation.StartOperation(Base, delegate()
                {
                    helper.CreateUpdateMatrixItems(graph, templateItem, itemsToCreate, true,
                                                   (t, item) => attributeGroupHelper.OnNewItem(templateItem, item, t.AttributeIDs, t.AttributeValues));
                    var ext = clone.FindImplementation <CreateMatrixItemsExt <TGraph, TMainItem> >();
                    ext.RecalcMatrixGrid();
                    Base.SelectTimeStamp();
                    PXLongOperation.SetCustomInfo(clone);
                });
            }

            return(adapter.Get());
        }
Esempio n. 2
0
        protected virtual void AddMatrixItemsToOrder(int?siteID)
        {
            var clone = Base.Clone();

            PXLongOperation.StartOperation(Base, delegate()
            {
                PXLongOperation.SetCustomInfo(clone);

                var ext = clone.FindImplementation <SmartPanelExt <Graph, MainItemType> >();
                if (ext == null)
                {
                    throw new PXArgumentException(nameof(SmartPanelExt <Graph, MainItemType>));
                }

                foreach (var row in ext.GetResult())
                {
                    var addQty = row.Qty - ext.GetQty(siteID, row.InventoryID);

                    if (addQty > 0)
                    {
                        ext.IncreaseQty(siteID, row.InventoryID, addQty);
                    }
                    else if (addQty < 0)
                    {
                        ext.DecreaseQty(siteID, row.InventoryID, addQty);
                    }
                }
            });
        }
Esempio n. 3
0
        public static void RunLongOperationKeepingCurrentMessages(PXGraph graph, PXToggleAsyncDelegate method)
        {
            Exception        longOperationException = null;
            PXProcessingInfo currentInfo            = PXLongOperation.GetCustomInfo() as PXProcessingInfo;

            try
            {
                method();
            }
            catch (Exception e)
            {
                longOperationException = e;
            }

            try
            {
                PXLongOperation.WaitCompletion(graph.UID);
            }
            catch (Exception e)
            {
                if (longOperationException == null)
                {
                    longOperationException = e;
                }
            }

            PXLongOperation.SetCustomInfo(currentInfo);

            if (longOperationException != null)
            {
                throw longOperationException;
            }
        }
Esempio n. 4
0
        public static void ReleaseBatch(List <GLVoucherBatch> list)
        {
            GLVoucherBatchMaint pg = PXGraph.CreateInstance <GLVoucherBatchMaint>();

            Dictionary <string, Dictionary <Guid, CAMessage> > errorLog = new Dictionary <string, Dictionary <Guid, CAMessage> >();
            List <int> failed = new List <int>();

            PXLongOperation.SetCustomInfo(errorLog);
            int failedCount = 0;

            for (int i = 0; i < list.Count; i++)
            {
                pg.Clear(PXClearOption.PreserveData);
                GLVoucherBatch batch = list[i];
                try
                {
                    pg.ReleaseBatchProc(batch, errorLog);
                }
                catch (Exception)
                {
                    failedCount++;
                }
            }
            if (failedCount > 0)
            {
                throw new PXException(Messages.BatchReleaseFiled);
            }
        }
        protected void ProcessSyncCC(ProcessListDelegate processor, List <Table> list, AUSchedule schedule)
        {
            beforeScheduleProcessAll?.Invoke();
            PXLongOperation.SetCustomInfo(new List <SyncCCProcessingInfoEntry>(), ProcessingInfo.processingKey);
            list.Clear();
            _InProc = new PXResultset <Table>();
            base._ProcessScheduled(processor, list, schedule);
            var histCache = _Graph.Caches[typeof(AUScheduleHistory)];
            List <SyncCCProcessingInfoEntry> infoList = PXLongOperation.GetCustomInfoForCurrentThread(ProcessingInfo.processingKey) as List <SyncCCProcessingInfoEntry>;

            if (infoList != null)
            {
                foreach (SyncCCProcessingInfoEntry infoEntry in infoList)
                {
                    AUScheduleHistory hist = new PX.SM.AUScheduleHistory();
                    hist.ExecutionResult = infoEntry.ProcessingMessage.Message;
                    hist.ErrorLevel      = (short)infoEntry.ProcessingMessage.ErrorLevel;
                    hist.ScheduleID      = schedule.ScheduleID;
                    hist.ScreenID        = schedule.ScreenID;
                    var      timeZone = PXTimeZoneInfo.FindSystemTimeZoneById(schedule.TimeZoneID);
                    DateTime startUtc = PXTimeZoneInfo.UtcNow;
                    DateTime start    = PXTimeZoneInfo.ConvertTimeFromUtc(startUtc, timeZone);
                    hist.ExecutionDate = start;
                    hist.RefNoteID     = infoEntry.NoteId;
                    histCache.Insert(hist);
                }
            }

            histCache.Persist(PXDBOperation.Insert);
        }
Esempio n. 6
0
        public static void DeleteBatch(GLVoucherBatch batch, object[] processingList)
        {
            GLVoucherBatchMaint pg = PXGraph.CreateInstance <GLVoucherBatchMaint>();
            Dictionary <string, Dictionary <Guid, CAMessage> > errorLog = new Dictionary <string, Dictionary <Guid, CAMessage> >();

            PXLongOperation.SetCustomInfo(errorLog, processingList);
            pg.Clear(PXClearOption.PreserveData);
            pg.DeleteBatchProc(batch, errorLog);
        }
Esempio n. 7
0
        protected virtual void AddItemsToOrder(int?siteID)
        {
            var templateItem  = InventoryItem.PK.Find(Base, Header.Current.TemplateItemID);
            var itemsToCreate = MatrixItems.Cache.Cached.RowCast <MatrixInventoryItem>().Where(mi => mi.New == true).ToList();

            if (templateItem != null)
            {
                var clone = Base.Clone();

                var inventoryItemGraph = (templateItem.StkItem == true) ?
                                         (InventoryItemMaintBase)PXGraph.CreateInstance <InventoryItemMaint>() :
                                         PXGraph.CreateInstance <NonStockItemMaint>();

                var helper = GetCreateMatrixItemsHelper(Base);
                var attributeGroupHelper = GetAttributeGroupHelper(inventoryItemGraph);

                PXLongOperation.StartOperation(Base, delegate()
                {
                    PXLongOperation.SetCustomInfo(clone);

                    helper.CreateUpdateMatrixItems(inventoryItemGraph, templateItem, itemsToCreate, true,
                                                   (t, item) => attributeGroupHelper.OnNewItem(templateItem, item, t.AttributeIDs, t.AttributeValues));

                    var ext = clone.FindImplementation <SmartPanelExt <Graph, MainItemType> >();
                    if (ext == null)
                    {
                        throw new PXArgumentException(nameof(SmartPanelExt <Graph, MainItemType>));
                    }

                    foreach (MatrixInventoryItem item in ext.MatrixItems.Cache.Cached)
                    {
                        if (item.Qty == null)
                        {
                            continue;
                        }

                        if (item.InventoryID == null)
                        {
                            string attributeIDs = string.Join(";", item.AttributeIDs ?? throw new PXArgumentException(nameof(item.AttributeIDs)));
                            string values       = string.Join(";", item.AttributeIDs ?? throw new PXArgumentException(nameof(item.AttributeValues)));
                            throw new RowNotFoundException(MatrixItems.Cache, string.Join("; ", item.AttributeIDs), string.Join(", ", item.AttributeValues));
                        }


                        ext.IncreaseQty(siteID, (int)item.InventoryID, item.TaxCategoryID, (decimal)item.Qty);
                    }
                });
            }
        }
        public virtual IEnumerable AddSSUser(PXAdapter adapter)
        {
            PMProject pmProjectRow = this.Base.Project.Current;

            ProjectEntry     projectEntryGraph = PXGraph.CreateInstance <ProjectEntry>();
            SmartsheetClient smartsheetClient  = CheckTokenSheetSS(projectEntryGraph, pmProjectRow);

            PXLongOperation.StartOperation(this.Base, delegate()
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    CreateEmployeesAcuUserSS(projectEntryGraph, smartsheetClient);
                    ts.Complete();
                }
                PXLongOperation.SetCustomInfo(this.Base);
            });
            return(adapter.Get());
        }