Пример #1
0
 protected virtual void SOImportFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
 {
     SOImportProcess.SOImportFilter row = e.Row as SOImportProcess.SOImportFilter;
     if (row != null)
     {
         PXUIFieldAttribute.SetEnabled <SOImportProcess.SOImportFilter.lastSyncDate>(sender, row, false);
         PXUIFieldAttribute.SetEnabled <SOImportProcess.SOImportFilter.processAllTypes>(Filter.Cache, null, string.IsNullOrEmpty(row.IntegrationID));
         PXUIFieldAttribute.SetEnabled <SOImportProcess.SOImportFilter.integrationID>(Filter.Cache, null, (row.ProcessAllTypes != null && row.ProcessAllTypes != true));
     }
 }
        public static void LogImportCount(SOImportProcess.SOImportFilter currentimportcount, string integrationId, SOPartialMaint logGraph, int?processId, string screenAction, bool isNoOrdersPrepared)
        {
            SOOrderProcessLog processcount = null;

            switch (screenAction)
            {
            case SOConstants.importorders:
                processcount                      = new SOOrderProcessLog();
                processcount.ProcessDate          = PX.Common.PXTimeZoneInfo.Now;
                processcount.TotalRecordstoImport = isNoOrdersPrepared == true ? 0 : currentimportcount.TotalRecordsToImport;
                processcount.ImportedRecordsCount = currentimportcount.TotalImportedRecords;
                processcount.FailedRecordsCount   = currentimportcount.TotalFailedRecords;
                processcount.IntegrationID        = integrationId;
                processcount.Operation            = SOConstants.btnPrepare;
                logGraph.OrderProcessLog.Insert(processcount);
                logGraph.Actions.PressSave();
                logGraph.OrderProcessLog.Current.ParentProcessID = logGraph.OrderProcessLog.Current.ProcessID;
                logGraph.OrderProcessLog.Update(logGraph.OrderProcessLog.Current);
                logGraph.Actions.PressSave();
                break;

            case SOConstants.scheduleimportorders:
                processcount = PXSelectReadonly <SOOrderProcessLog, Where <SOOrderProcessLog.processID, Equal <Required <SOOrderProcessLog.processID> > > > .Select(logGraph, Convert.ToInt32(processId));

                if (processcount == null)
                {
                    processcount                      = new SOOrderProcessLog();
                    processcount.ProcessDate          = PX.Common.PXTimeZoneInfo.Now;
                    processcount.Operation            = SOConstants.btnPrepareAndImport;
                    processcount.TotalRecordstoImport = isNoOrdersPrepared == true ? 0 : 1;
                    processcount.ImportedRecordsCount = 0;
                    processcount.FailedRecordsCount   = 0;
                    processcount.IntegrationID        = integrationId;
                    logGraph.OrderProcessLog.Insert(processcount);
                    logGraph.Actions.PressSave();
                    logGraph.OrderProcessLog.Current.ParentProcessID = logGraph.OrderProcessLog.Current.ProcessID;
                    logGraph.OrderProcessLog.Update(logGraph.OrderProcessLog.Current);
                    logGraph.Actions.PressSave();
                }
                else
                {
                    processcount.ProcessDate          = PX.Common.PXTimeZoneInfo.Now;
                    processcount.TotalRecordstoImport = processcount.TotalRecordstoImport + 1;
                    logGraph.OrderProcessLog.Update(processcount);
                    logGraph.Actions.PressSave();
                }
                break;
            }
        }
Пример #3
0
        private void LoadIntegrationsToPrepareAndImport(SOImportProcess.SOImportFilter row)
        {
            if (row != null)
            {
                SOOrderProcessLog getProcessId = PXSelectGroupBy <SOOrderProcessLog, Aggregate <Max <SOOrderProcessLog.processID> > > .Select(this);

                PXSelectBase <SOProcessOrder> objMaxOrder = new PXSelectGroupBy <SOProcessOrder, Where <SOProcessOrder.integrationID, Equal <Required <SOProcessOrder.integrationID> > >, Aggregate <Max <SOProcessOrder.synDatetime> > >(this);

                if (row.IntegrationID != null && row.ProcessAllTypes == true && row.LastSyncDate != null)
                {
                    throw new PXException(SOMessages.msgProcessError);
                }
                else
                {
                    SOPrepareAndImport processRecord = new SOPrepareAndImport();
                    prepareAndImport.Cache.Clear();
                    SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>();
                    if (row.IntegrationID != null && row.ProcessAllTypes == false)
                    {
                        foreach (SOProcessOrder objLastOrder in objMaxOrder.Select(row.IntegrationID))
                        {
                            Filter.Cache.SetValue <SOImportProcess.SOImportFilter.lastSyncDate>(row, objLastOrder.SynDatetime ?? GetMaxOrderDate(orderEntry, row.IntegrationID));
                            processRecord.LastSyncDate  = GetMaxOrderDate(orderEntry, row.IntegrationID);
                            processRecord.ToDate        = Filter.Current.TODate;
                            processRecord.IntegrationID = row.IntegrationID;
                            processRecord.ProcessID     = (getProcessId != null && getProcessId.ProcessID != null) ? getProcessId.ProcessID + 1 : 1;
                            prepareAndImport.Cache.Insert(processRecord);
                        }
                    }
                    else if (string.IsNullOrEmpty(row.IntegrationID) && row.ProcessAllTypes == true)
                    {
                        int?processId = (getProcessId != null && getProcessId.ProcessID != null) ? getProcessId.ProcessID + 1 : 1;
                        foreach (SOAmazonSetup integrationrecord in PXSelectReadonly <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True> > > .Select(this))
                        {
                            processRecord.LastSyncDate  = GetMaxOrderDate(orderEntry, integrationrecord.IntegrationID);
                            processRecord.ToDate        = row.TODate;
                            processRecord.IntegrationID = integrationrecord.IntegrationID;
                            processRecord.ProcessID     = processId++;
                            prepareAndImport.Cache.Insert(processRecord);
                        }
                    }
                }
            }
        }