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);
        }
示例#2
0
        public static void AppendProcessingInfo(Guid noteId, string info)
        {
            List <SyncCCProcessingInfoEntry> list = PXLongOperation.GetCustomInfoForCurrentThread(processingKey) as List <SyncCCProcessingInfoEntry>;

            if (list != null)
            {
                PXProcessingMessage msg = new PXProcessingMessage()
                {
                    ErrorLevel = PXErrorLevel.RowInfo, Message = info
                };
                list.Add(new SyncCCProcessingInfoEntry()
                {
                    NoteId = noteId, ProcessingMessage = msg
                });
            }
        }
示例#3
0
        protected virtual IEnumerable LumGererateYUSENNLFile(PXAdapter adapter)
        {
            int totalLine = 1;

            try
            {
                var currtShipments = adapter.Get <SOShipment>().ToList();

                StringBuilder sb   = new StringBuilder();
                string        line = string.Empty;

                #region FileHeader - HDR

                sb = CombineYusenHedaer(sb);

                #endregion

                var result = CombineYusenDetail(sb, currtShipments, totalLine);
                sb = result.sb;

                #region Filetrailer – TRL

                sb = CombineYusenFooter(sb, result.totalLine);

                #endregion

                // Create SM.FileInfo
                var      fileName = $"Yusen-{DateTime.Now.ToString("yyyyMMddHHmmss")}.csv";
                var      data     = new UTF8Encoding(true).GetBytes(sb.ToString());
                FileInfo fi       = new FileInfo(fileName, null, data);

                // DownLoad File
                if ((PXLongOperation.GetCustomInfoForCurrentThread("PXProcessingState") as PXProcessingInfo).Errors == 0)
                {
                    throw new PXRedirectToFileException(fi, true);
                }
            }
            catch (PXRedirectToFileException)
            {
                throw;
            }
            catch (Exception ex)
            {
                PXProcessing.SetError(ex.Message);
            }
            return(adapter.Get());
        }
示例#4
0
        public static void ClearProcessingRows()
        {
            List <SyncCCProcessingInfoEntry> list = PXLongOperation.GetCustomInfoForCurrentThread(processingKey) as List <SyncCCProcessingInfoEntry>;

            list.Clear();
        }
示例#5
0
        protected virtual IEnumerable LumGererateYUSENNLFile(PXAdapter adapter, [PXDate] DateTime?shipDate, [PXInt] int?siteID, [SOOperation.List] string operation)
        {
            using (PXTransactionScope sc = new PXTransactionScope())
            {
                try
                {
                    // variable
                    var shipmentList    = new List <SOShipment>();
                    var soList          = adapter.Get <SOOrder>().ToList();
                    var soListwithoutFM = new List <object>();
                    soListwithoutFM.AddRange(soList.Where(x => x.OrderType != "FM"));
                    var graph = PXGraph.CreateInstance <SOShipmentEntry>();

                    // Find soOrder type != FM
                    var newAdapter = new PXAdapter(new LumShipmentDocView(Base, adapter.View.BqlSelect, soListwithoutFM));
                    newAdapter.MassProcess = true;
                    newAdapter.Arguments   = adapter.Arguments;
                    // Create SOShipment Graph
                    Base.CreateShipmentIssue(newAdapter, shipDate, siteID);
                    if ((PXLongOperation.GetCustomInfoForCurrentThread("PXProcessingState") as PXProcessingInfo).Errors != 0)
                    {
                        return(adapter.Get());
                    }

                    // Get Shipments
                    foreach (var order in soList.Where(x => x.OrderType != "FM"))
                    {
                        var soOrderShipment = SelectFrom <SOOrderShipment> .Where <SOOrderShipment.orderNbr.IsEqual <P.AsString>
                                                                                   .And <SOOrderShipment.orderType.IsEqual <P.AsString> > >
                                              .View.Select(Base, order.OrderNbr, order.OrderType).RowCast <SOOrderShipment>().FirstOrDefault();

                        var shipment = SelectFrom <SOShipment> .Where <SOShipment.shipmentNbr.IsEqual <P.AsString> >
                                       .View.Select(Base, soOrderShipment.ShipmentNbr).RowCast <SOShipment>().FirstOrDefault();

                        // update field
                        shipment.GetExtension <SOShipmentExt>().UsrSendToWareHouse = true;
                        graph.Document.Update(shipment);

                        // Remove Hold (Shipments)
                        var shipAdapter = new PXAdapter(graph.Document)
                        {
                            Searches = new Object[] { shipment.ShipmentNbr }
                        };
                        graph.releaseFromHold.PressButton(shipAdapter);
                        if ((PXLongOperation.GetCustomInfoForCurrentThread("PXProcessingState") as PXProcessingInfo).Errors != 0)
                        {
                            return(adapter.Get());
                        }

                        shipmentList.Add(shipment);
                    }
                    // Generate NL File, Success will throw PXRedirectToFileException
                    int           totalLine = 1;
                    StringBuilder sb        = new StringBuilder();
                    string        line      = string.Empty;

                    #region FileHeader - HDR

                    sb = graph.GetExtension <SOShipmentEntryExt>().CombineYusenHedaer(sb);

                    #endregion

                    // General Detail
                    var result = graph.GetExtension <SOShipmentEntryExt>().CombineYusenDetail(sb, shipmentList, totalLine);
                    sb = result.sb;

                    // FBM Yuesn Detail
                    result = graph.GetExtension <SOShipmentEntryExt>().CombineYusenDetailForFBM(sb, soList.Where(x => x.OrderType == "FM").ToList(), result.totalLine);
                    sb     = result.sb;

                    #region Filetrailer – TRL

                    sb = graph.GetExtension <SOShipmentEntryExt>().CombineYusenFooter(sb, result.totalLine);

                    #endregion

                    // Create SM.FileInfo
                    var      fileName = $"Yusen-{DateTime.Now.ToString("yyyyMMddHHmmss")}.csv";
                    var      data     = new UTF8Encoding(true).GetBytes(sb.ToString());
                    FileInfo fi       = new FileInfo(fileName, null, data);

                    // DownLoad File
                    if ((PXLongOperation.GetCustomInfoForCurrentThread("PXProcessingState") as PXProcessingInfo).Errors == 0)
                    {
                        throw new PXRedirectToFileException(fi, true);
                    }
                }
                // Success
                catch (PXRedirectToFileException)
                {
                    sc.Complete();
                    throw;
                }
                catch (Exception ex)
                {
                    PXProcessing.SetError(ex.Message);
                }
            }

            return(adapter.Get());
        }