Beispiel #1
0
        public virtual IEnumerable uploadData(PXAdapter adapter)
        {
            //Rastrea la consulta genérica, si existe forma la estrucutra de la tabla
            GIDesign design = PXSelectReadonly <GIDesign, Where <GIDesign.designID, Equal <Required <GIDesign.designID> > > > .Select(this, Filter.Current.GenericInq);

            if (design != null)
            {
                var start = Filter.Current.StartDate;
                var end   = Filter.Current.EndDate;

                string name = design.Name + ".csv";// "orders.csv";

                PXLongOperation.StartOperation(this, delegate()
                {
                    //Obtiene la estructura de la tabla
                    DataTable tableGI = CreateTableStructure(design);

                    //Si existe más de una columna significa que recupero la estructura de la consulta generica
                    if (tableGI.Columns.Count > 1)
                    {
                        //Llena la columna con los registros de la consulta generica
                        Dictionary <string, DateTime?> parameters = new Dictionary <string, DateTime?>()
                        {
                            { "StartDate", Filter.Current.StartDate },
                            { "EndDate", Filter.Current.EndDate }
                        };
                        tableGI = LoadRowsToTable(design, tableGI, parameters);
                    }

                    //Obtiene el csv
                    SendData(DatatableToCsv(tableGI), name);
                });
            }

            return(adapter.Get());
        }
        public virtual IEnumerable Close1099Year(PXAdapter adapter)
        {
            int?[] childBranches = BranchMaint.GetChildBranches(this, Year_Header.Current.BranchID)
                                   .Select(branch => branch.BranchID)
                                   .ToArray();

            PXCache           cache = Year_Header.Cache;
            List <AP1099Year> list  = adapter.Get().Cast <AP1099Year>().ToList();

            foreach (AP1099Year year in list
                     .Where(year => !string.IsNullOrEmpty(year.FinYear) &&
                            year.Status == AP1099Year.status.Open &&
                            childBranches.Contains(year.BranchID)))
            {
                year.Status = AP1099Year.status.Closed;
                cache.Update(year);
            }
            if (cache.IsInsertedUpdatedDeleted)
            {
                Actions.PressSave();
                PXLongOperation.StartOperation(this, delegate {});
            }
            return(list);
        }
Beispiel #3
0
        public virtual IEnumerable Release(PXAdapter adapter)
        {
            PXCache cache             = Document.Cache;
            List <TaxAdjustment> list = new List <TaxAdjustment>();

            foreach (TaxAdjustment doc in adapter.Get())
            {
                if (doc.Hold != true && doc.Released != true)
                {
                    cache.Update(doc);
                    list.Add(doc);
                }
            }
            if (list.Count == 0)
            {
                throw new PXException(Messages.Document_Status_Invalid);
            }
            Save.Press();
            if (list.Count > 0)
            {
                PXLongOperation.StartOperation(this, () => ReportTaxReview.ReleaseDoc(list));
            }
            return(list);
        }
        public virtual IEnumerable export(PXAdapter adapter)
        {
            if (PXLongOperation.Exists(UID))
            {
                throw new ApplicationException(GL.Messages.PrevOperationNotCompleteYet);
            }
            CABatch document = this.Document.Current;

            if (document != null && document.Released == true && document.Hold == false)
            {
                PXResult <PaymentMethod, SYMapping> res = (PXResult <PaymentMethod, SYMapping>) PXSelectJoin <PaymentMethod,
                                                                                                              LeftJoin <SYMapping, On <SYMapping.mappingID, Equal <PaymentMethod.aPBatchExportSYMappingID> > >,
                                                                                                              Where <PaymentMethod.paymentMethodID, Equal <Optional <CABatch.paymentMethodID> > > > .Select(this, document.PaymentMethodID);

                PaymentMethod pt  = res;
                SYMapping     map = res;
                if (pt != null && pt.APCreateBatchPayment == true && pt.APBatchExportSYMappingID != null && map != null)
                {
                    string defaultFileName = this.GenerateFileName(document);
                    PXLongOperation.StartOperation(this, delegate()
                    {
                        PX.Api.SYExportProcess.RunScenario(map.Name,
                                                           SYMapping.RepeatingOption.All,
                                                           true,
                                                           true,
                                                           new PX.Api.PXSYParameter(ExportProviderParams.FileName, defaultFileName),
                                                           new PX.Api.PXSYParameter(ExportProviderParams.BatchNbr, document.BatchNbr));
                    });
                }
                else
                {
                    throw new PXException(Messages.CABatchExportProviderIsNotConfigured);
                }
            }
            return(adapter.Get());
        }
Beispiel #5
0
        public virtual IEnumerable release(PXAdapter adapter)
        {
            PXCache cache = Caches[typeof(GLVoucherBatch)];
            List <GLVoucherBatch> list = new List <GLVoucherBatch>();

            foreach (GLVoucherBatch batch in VoucherBatches.Select())
            {
                if (batch.Released != true && batch.Selected == true)
                {
                    list.Add(batch);
                }
            }
            if (list.Count == 0)
            {
                throw new PXException(Messages.NoBatchesIsSelectedForRelease);
            }
            if (list.Count > 0)
            {
                PXLongOperation.ClearStatus(this.UID);
                PXLongOperation.StartOperation(this, delegate() { ReleaseBatch(list); });
                VoucherBatches.View.RequestRefresh();
            }
            return(adapter.Get());
        }
        public virtual IEnumerable release(PXAdapter adapter)
        {
            PXCache cache = Caches[typeof(CATransfer)];

            if (PXLongOperation.Exists(UID))
            {
                throw new ApplicationException(GL.Messages.PrevOperationNotCompleteYet);
            }
            Save.Press();
            CATransfer        transfer = Transfer.Current;
            List <CARegister> list     = new List <CARegister>();
            CATran            tran     = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATransfer.tranIn> > > > .Select(this, transfer.TranIDIn);

            if (tran != null)
            {
                list.Add(CATrxRelease.CARegister(transfer, tran));
            }
            else
            {
                throw new PXException(Messages.TransactionNotFound);
            }

            tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATransfer.tranIn> > > > .Select(this, transfer.TranIDOut);

            if (tran == null)
            {
                throw new PXException(Messages.TransactionNotFound);
            }

            PXLongOperation.StartOperation(this, delegate() { CATrxRelease.GroupRelease(list, false); });

            List <CATransfer> ret = new List <CATransfer>();

            ret.Add(transfer);
            return(ret);
        }
        public virtual IEnumerable runNow(PXAdapter adapter)
        {
            this.Save.Press();

            Schedule schedule = Schedule_Header.Current;

            if (schedule.NextRunDate > Accessinfo.BusinessDate)
            {
                throw new PXException(Messages.SheduleNextExecutionDateExceeded);
            }
            else
            {
                if (schedule.NoRunLimit == false && schedule.RunCntr >= schedule.RunLimit)
                {
                    throw new PXException(Messages.SheduleExecutionLimitExceeded);
                }
                else
                {
                    if (schedule.NoEndDate == false && schedule.EndDate < Accessinfo.BusinessDate)
                    {
                        throw new PXException(Messages.SheduleHasExpired);
                    }
                    else
                    {
                        PXLongOperation.StartOperation(this,
                                                       delegate()
                        {
                            ARScheduleProcess sp = PXGraph.CreateInstance <ARScheduleProcess>();
                            sp.GenerateProc(schedule);
                        }
                                                       );
                    }
                }
            }
            yield return(schedule);
        }
        public override void clearAll()
        {
            var graphGenerationLogError = PXGraph.CreateInstance <GenerationLogErrorMaint>();

            PXResultset <FSGenerationLogError> bqlResultSet = PXSelect <FSGenerationLogError,
                                                                        Where <
                                                                            FSGenerationLogError.ignore, Equal <False>,
                                                                            And <FSGenerationLogError.processType, Equal <Required <FSGenerationLogError.processType> > > > >
                                                              .Select(this, ID.RecordType_ServiceContract.ROUTE_SERVICE_CONTRACT);

            PXLongOperation.StartOperation(
                this,
                delegate
            {
                foreach (FSGenerationLogError fsGenerationLogErrorRow in bqlResultSet)
                {
                    graphGenerationLogError.Clear();
                    graphGenerationLogError.LogErrorMessageRecords.Current = graphGenerationLogError.LogErrorMessageRecords.Search <FSGenerationLogError.logID>(fsGenerationLogErrorRow.LogID);
                    fsGenerationLogErrorRow.Ignore = true;
                    graphGenerationLogError.LogErrorMessageRecords.Update(fsGenerationLogErrorRow);
                    graphGenerationLogError.Save.Press();
                }
            });
        }
Beispiel #9
0
 public void longrunAction()
 {
     PXLongOperation.StartOperation(UID, BackgroundOperation);
 }
Beispiel #10
0
 private void SyncUsers()
 {
     PXLongOperation.StartOperation(this, () => Console.WriteLine("Synced"));
 }
        public virtual IEnumerable ConvertToOpportunity(PXAdapter adapter)
        {
            Save.Press();
            bool           isOpportunityAutoNumberOn = this.IsNumberingAutonumbered(Setup.Current.OpportunityNumberingID);
            List <Contact> contacts = new List <Contact>(adapter.Get().Cast <Contact>());

            foreach (Contact l in contacts)
            {
                OpportunityMaint opportunityMaint = CreateInstance <OpportunityMaint>();
                CROpportunity    opportunity      = (CROpportunity)opportunityMaint.Opportunity.Cache.Insert();

                if (!isOpportunityAutoNumberOn)
                {
                    if (OpportunityInfo.AskExt() != WebDialogResult.OK || !OpportunityInfo.VerifyRequired())
                    {
                        return(contacts);
                    }
                    CROpportunity existing = PXSelect <CROpportunity, Where <CROpportunity.opportunityID, Equal <Required <CROpportunity.opportunityID> > > > .SelectSingleBound(this, null, OpportunityInfo.Current.OpportunityID);

                    if (existing != null)
                    {
                        OpportunityInfo.Cache.RaiseExceptionHandling <OpportunityFilter.opportunityID>(OpportunityInfo.Current, OpportunityInfo.Current.OpportunityID, new PXSetPropertyException(Messages.OpportunityAlreadyExists, OpportunityInfo.Current.OpportunityID));
                        return(contacts);
                    }

                    object cd = OpportunityInfo.Current.OpportunityID;
                    opportunityMaint.Opportunity.Cache.RaiseFieldUpdating <CROpportunity.opportunityID>(null, ref cd);
                    opportunity.OpportunityID = (string)cd;
                }
                Contact lead = l;
                PXLongOperation.StartOperation(this, delegate()
                {
                    CRContactClass cls = PXSelect <CRContactClass, Where <CRContactClass.classID, Equal <Current <Contact.classID> > > > .SelectSingleBound(this, new object[] { lead });
                    if (cls != null && cls.OwnerToOpportunity == true)
                    {
                        opportunity.WorkgroupID = lead.WorkgroupID;
                        opportunity.OwnerID     = lead.OwnerID;
                    }
                    if (cls != null && cls.TargetOpportunityClassID != null)
                    {
                        opportunity.CROpportunityClassID = cls.TargetOpportunityClassID;
                    }

                    if (lead.BAccountID != null)
                    {
                        opportunity.BAccountID = lead.BAccountID;
                    }

                    if (lead.ParentBAccountID != null)
                    {
                        opportunity.ParentBAccountID = lead.ParentBAccountID;
                    }

                    if (lead.CampaignID != null)
                    {
                        opportunity.CampaignSourceID = lead.CampaignID;
                    }
                    opportunity.ContactID       = lead.ContactID;
                    opportunity.ConvertedLeadID = lead.ContactID;
                    opportunity.OpportunityName = string.IsNullOrEmpty(lead.FullName) ? lead.DisplayName : lead.FullName;
                    opportunity = (CROpportunity)opportunityMaint.Opportunity.Cache.Update(opportunity);

                    ContactMaint contactGraph = CreateInstance <ContactMaint>();
                    lead.ContactType          = ContactTypesAttribute.Person;
                    lead.QualificationDate    = PXTimeZoneInfo.Now;
                    lead.ConvertedBy          = Accessinfo.UserID;
                    lead = contactGraph.Contact.Update(lead);

                    opportunityMaint.Opportunity.Search <CROpportunity.opportunityID>(opportunity.OpportunityID);
                    lead = opportunityMaint.Leads.Update(lead);

                    // Copy Note text and Files references
                    CRSetup setup = PXSetupOptional <CRSetup> .Select(opportunityMaint);
                    PXNoteAttribute.CopyNoteAndFiles(opportunityMaint.Leads.Cache, lead, opportunityMaint.OpportunityCurrent.Cache, opportunity, setup);

                    throw new PXRedirectRequiredException(opportunityMaint, "Opportunity", true);
                });
            }
            return(contacts);
        }
Beispiel #12
0
 public IEnumerable users()
 {
     PXLongOperation.StartOperation(this, () => SyncUsers());
     return(new PXSelect <PX.SM.Users>(this).Select());
 }
Beispiel #13
0
 public virtual IEnumerable delete(PXAdapter adapter)
 {
     PXLongOperation.StartOperation(this, () => DeleteMessage(SelectedList().RowCast <SMEmail>()));
     return(adapter.Get());
 }
Beispiel #14
0
 protected virtual void _(Events.RowDeleting <SOInvoice> e)
 {
     PXLongOperation.StartOperation(this, null);
 }
        public virtual IEnumerable Clone(PXAdapter adapter)
        {
            if (this.Filter.Current.ScheduledEndTime == null)
            {
                Filter.Cache.RaiseExceptionHandling <FSCloneAppointmentFilter.scheduledEndTime>(
                    Filter.Current,
                    null,
                    new PXSetPropertyException(
                        PXMessages.LocalizeFormat(
                            TX.Error.FIELD_MAY_NOT_BE_EMPTY,
                            PXUIFieldAttribute.GetDisplayName <FSCloneAppointmentFilter.scheduledEndTime>(Filter.Cache)),
                        PXErrorLevel.Error));

                return(adapter.Get());
            }

            if (this.Filter.Current.CloningType == ID.CloningType_CloneAppointment.MULTIPLE)
            {
                if (this.Filter.Current.ScheduledFromDate == null)
                {
                    Filter.Cache.RaiseExceptionHandling <FSCloneAppointmentFilter.scheduledFromDate>(
                        Filter.Current,
                        null,
                        new PXSetPropertyException(
                            PXMessages.LocalizeFormat(
                                TX.Error.FIELD_MAY_NOT_BE_EMPTY,
                                PXUIFieldAttribute.GetDisplayName <FSCloneAppointmentFilter.scheduledFromDate>(Filter.Cache)),
                            PXErrorLevel.Error));

                    return(adapter.Get());
                }

                if (this.Filter.Current.ScheduledToDate == null)
                {
                    Filter.Cache.RaiseExceptionHandling <FSCloneAppointmentFilter.scheduledToDate>(
                        Filter.Current,
                        null,
                        new PXSetPropertyException(
                            PXMessages.LocalizeFormat(
                                TX.Error.FIELD_MAY_NOT_BE_EMPTY,
                                PXUIFieldAttribute.GetDisplayName <FSCloneAppointmentFilter.scheduledToDate>(Filter.Cache)),
                            PXErrorLevel.Error));

                    return(adapter.Get());
                }
            }

            FSServiceOrder fsServiceOrderRow = PXSelectJoin <FSServiceOrder,
                                                             InnerJoin <
                                                                 FSAppointment, On <FSAppointment.sOID, Equal <FSServiceOrder.sOID> > >,
                                                             Where <
                                                                 FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > >
                                               .Select(this, this.Filter.Current.AppointmentID);

            if (fsServiceOrderRow != null &&
                fsServiceOrderRow.Status == ID.Status_ServiceOrder.COMPLETED)
            {
                throw new PXException(TX.Error.CANNOT_CLONE_APPOINMENT_SERVICE_ORDER_COMPLETED);
            }

            CloneAppointmentProcess graphCloneAppointmentProcess = PXGraph.CreateInstance <CloneAppointmentProcess>();

            graphCloneAppointmentProcess.Filter.Current.SrvOrdType         = this.Filter.Current.SrvOrdType;
            graphCloneAppointmentProcess.Filter.Current.RefNbr             = this.Filter.Current.RefNbr;
            graphCloneAppointmentProcess.Filter.Current.KeepTimeDuration   = this.Filter.Current.KeepTimeDuration;
            graphCloneAppointmentProcess.Filter.Current.ScheduledDate      = this.Filter.Current.ScheduledDate;
            graphCloneAppointmentProcess.Filter.Current.ScheduledStartTime = this.Filter.Current.ScheduledStartTime;
            graphCloneAppointmentProcess.Filter.Current.ScheduledEndTime   = this.Filter.Current.ScheduledEndTime;

            graphCloneAppointmentProcess.Filter.Current.ScheduledFromDate = this.Filter.Current.ScheduledFromDate;
            graphCloneAppointmentProcess.Filter.Current.ScheduledToDate   = this.Filter.Current.ScheduledToDate;
            graphCloneAppointmentProcess.Filter.Current.ActiveOnMonday    = this.Filter.Current.ActiveOnMonday;
            graphCloneAppointmentProcess.Filter.Current.ActiveOnThursday  = this.Filter.Current.ActiveOnThursday;
            graphCloneAppointmentProcess.Filter.Current.ActiveOnWednesday = this.Filter.Current.ActiveOnWednesday;
            graphCloneAppointmentProcess.Filter.Current.ActiveOnTuesday   = this.Filter.Current.ActiveOnTuesday;
            graphCloneAppointmentProcess.Filter.Current.ActiveOnFriday    = this.Filter.Current.ActiveOnFriday;
            graphCloneAppointmentProcess.Filter.Current.ActiveOnSaturday  = this.Filter.Current.ActiveOnSaturday;
            graphCloneAppointmentProcess.Filter.Current.ActiveOnSunday    = this.Filter.Current.ActiveOnSunday;

            graphCloneAppointmentProcess.AppointmentSelected.Current = this.AppointmentSelected.Current;

            PXLongOperation.StartOperation(
                this,
                delegate
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    if (this.Filter.Current.CloningType == ID.CloningType_CloneAppointment.SINGLE)
                    {
                        AppointmentEntry graphOriginalAppointment = PXGraph.CreateInstance <AppointmentEntry>();

                        graphOriginalAppointment.AppointmentSelected.Current = graphOriginalAppointment.AppointmentRecords.Search <FSAppointment.appointmentID>
                                                                                   (AppointmentSelected.Current.AppointmentID, AppointmentSelected.Current.SrvOrdType);

                        graphCloneAppointmentProcess.CloneAppointment(graphOriginalAppointment, PXGraph.CreateInstance <AppointmentEntry>());
                    }

                    if (this.Filter.Current.CloningType == ID.CloningType_CloneAppointment.MULTIPLE)
                    {
                        graphCloneAppointmentProcess.CloneMultipleAppointments(graphCloneAppointmentProcess);
                    }

                    ts.Complete();
                }
            });

            return(adapter.Get());
        }
        protected virtual void DoTransfer(TransferFilter filter, List <FixedAsset> list)
        {
            DocumentList <FARegister> created = new DocumentList <FARegister>(this);

            foreach (FixedAsset asset in list)
            {
                FADetails det = PXSelect <FADetails, Where <FADetails.assetID, Equal <Current <FixedAsset.assetID> > > > .SelectSingleBound(this, new object[] { asset });

                FALocationHistory location = PXSelect <FALocationHistory, Where <FALocationHistory.assetID, Equal <Current <FADetails.assetID> >, And <FALocationHistory.revisionID, Equal <Current <FADetails.locationRevID> > > > > .SelectSingleBound(this, new object[] { det });

                int?   destClassID  = filter.ClassTo ?? asset.ClassID;
                int?   destBranchID = filter.BranchTo ?? location.LocationID;
                string destDeptID   = string.IsNullOrEmpty(filter.DepartmentTo) ? location.Department : filter.DepartmentTo;

                if (location.LocationID != destBranchID || location.Department != destDeptID || asset.ClassID != destClassID)
                {
                    FADetails         copy_det = (FADetails)Details.Cache.CreateCopy(det);
                    FALocationHistory copy_loc = (FALocationHistory)Lochist.Cache.CreateCopy(location);
                    copy_loc.RevisionID      = ++copy_det.LocationRevID;
                    copy_loc.LocationID      = destBranchID;
                    copy_loc.Department      = destDeptID;
                    copy_loc.PeriodID        = filter.PeriodID;
                    copy_loc.TransactionDate = filter.TransferDate;
                    copy_loc.Reason          = filter.Reason;

                    TransactionEntry.SegregateRegister(this, (int)destBranchID, FARegister.origin.Transfer, null, filter.TransferDate, "", created);

                    Details.Update(copy_det);
                    location = Lochist.Insert(copy_loc);

                    if (asset.ClassID != destClassID)
                    {
                        asset.ClassID = destClassID;
                        AssetSelect.Cache.Update(asset);
                    }

                    FARegister reg = Register.Current;
                    AssetProcess.TransferAsset(this, asset, location, ref reg);
                }
            }
            if (Register.Current != null && created.Find(Register.Current) == null)
            {
                created.Add(Register.Current);
            }
            Actions.PressSave();
            if (fasetup.Current.AutoReleaseTransfer == true)
            {
                SelectTimeStamp();
                PXLongOperation.StartOperation(this, delegate { AssetTranRelease.ReleaseDoc(created, false); });
            }
            else if (created.Count > 0)
            {
                AssetTranRelease graph = CreateInstance <AssetTranRelease>();
                AssetTranRelease.ReleaseFilter fltr = (AssetTranRelease.ReleaseFilter)graph.Filter.Cache.CreateCopy(graph.Filter.Current);
                fltr.Origin = FARegister.origin.Transfer;
                graph.Filter.Update(fltr);
                graph.SelectTimeStamp();

                Dictionary <string, string> parameters = new Dictionary <string, string>();

                for (int i = 0; i < created.Count; ++i)
                {
                    FARegister reg = created[i];
                    reg.Selected = true;
                    graph.FADocumentList.Update(reg);
                    graph.FADocumentList.Cache.SetStatus(reg, PXEntryStatus.Updated);
                    graph.FADocumentList.Cache.IsDirty = false;

                    parameters["FARegister.RefNbr" + i] = reg.RefNbr;
                }

                parameters["PeriodFrom"] = FinPeriodIDFormattingAttribute.FormatForDisplay(filter.PeriodID);
                parameters["PeriodTo"]   = FinPeriodIDFormattingAttribute.FormatForDisplay(filter.PeriodID);
                parameters["Mode"]       = "U";

                PXReportRequiredException reportex = new PXReportRequiredException(parameters, "FA642000", "Preview");
                throw new PXRedirectWithReportException(graph, reportex, "Release FA Transaction");
            }
        }
Beispiel #17
0
 protected virtual void _(Events.FieldVerifying <SOInvoice.refNbr> e)
 {
     PXLongOperation.StartOperation(this, null);
 }
 public virtual IEnumerable markAsUnread(PXAdapter adapter)
 {
     PXLongOperation.StartOperation(this, () => MarkAs(adapter, EPViewStatusAttribute.NOTVIEWED, SelectedList()));
     return(adapter.Get());
 }
Beispiel #19
0
 protected virtual void _(Events.RowPersisted <SOInvoice> e)
 {
     PXLongOperation.StartOperation(this, null);
 }
        protected virtual void prepareRecords()
        {
            List <string>  importedRecords = new List <string>();
            SOImportFilter currentFilter   = Filter.Current;

            PXLongOperation.StartOperation(this, delegate()
            {
                SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>();
                SOImportProcess graph   = PXGraph.CreateInstance <SOImportProcess>();
                SOPartialMaint logGraph = PXGraph.CreateInstance <SOPartialMaint>();
                if (currentFilter != null)
                {
                    if ((string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == false) || (!string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == true))
                    {
                        throw new PXException(SOMessages.validationIntegrationIdandprocessall);
                    }
                    if (currentFilter.TODate.Value.Date > graph.Accessinfo.BusinessDate.Value.Date)
                    {
                        throw new PXException(SOMessages.validationTodateandBusinessDate);
                    }
                    if (currentFilter.LastSyncDate > currentFilter.TODate)
                    {
                        throw new PXException(SOMessages.validationFromandTodate);
                    }
                    try
                    {
                        orderEntry.Clear();
                        SOSetupAmazonExt objSOOSetupext = orderEntry.sosetup.Current.GetExtension <SOSetupAmazonExt>();
                        if (SOHelper.IsSOPreferencesDetailsExist(orderEntry, objSOOSetupext))
                        {
                            SOAmazonSetup objSOAmazonSetupDetails = null;
                            objOrdersParameters          = new OrdersParameters();
                            SOProcessOrder processrecord = null;
                            int?processedCount           = 0;
                            bool isValidConfiguration    = SOHelper.MarketplaceConfigurations(graph, currentFilter.IntegrationID, out objSOAmazonSetupDetails);

                            // To Get the Max date & time if the same date is processed again
                            //Dhiren-4/11/2019 - We need to revisit date range Delta logic.
                            //SOProcessOrder objProcessOrder = new PXSelect<SOProcessOrder, Where<SOProcessOrder.integrationID, Equal<Required<SOProcessOrder.integrationID>>,
                            //                                                             And<SOProcessOrder.amazonOrderDate, Between<Required<SOProcessOrder.amazonOrderDate>, Required<SOProcessOrder.amazonOrderDate>>>>,
                            //                                                             OrderBy<Desc<SOProcessOrder.amazonOrderDate>>>(graph).SelectSingle(currentFilter.IntegrationID, currentFilter.LastSyncDate, currentFilter.TODate);

                            //currentFilter.FromDate = objProcessOrder != null && objProcessOrder.AmazonOrderDate.HasValue ? objProcessOrder.AmazonOrderDate : currentFilter.LastSyncDate;
                            currentFilter.FromDate = currentFilter.LastSyncDate;
                            Filter.Cache.Update(currentFilter);
                            if (currentFilter.IntegrationID != null && currentFilter.ProcessAllTypes == false)
                            {
                                if (isValidConfiguration)
                                {
                                    int?processId = SOHelper.GetProcessID(graph);
                                    PrepareAllRecords(graph, importedRecords, currentFilter, out processrecord, objSOAmazonSetupDetails, processId, out processedCount, logGraph);
                                    if (processedCount > 0)
                                    {
                                        LogProcessCount(processedCount, currentFilter.IntegrationID, logGraph);
                                    }
                                    graph.Actions.PressSave();
                                }
                                else
                                {
                                    throw new PXException(SOMessages.apidetailsMissing);
                                }
                            }
                            else if (string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == true)
                            {
                                ImportOrderList.Cache.Clear();
                                int?processId = SOHelper.GetProcessID(graph);
                                foreach (SOAmazonSetup objSOAmazonSetup in PXSelectReadonly <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True> > > .Select(graph))
                                {
                                    try
                                    {
                                        PrepareAllRecords(graph, importedRecords, currentFilter, out processrecord, objSOAmazonSetup, processId, out processedCount, logGraph);
                                        if (processedCount > 0)
                                        {
                                            LogProcessCount(processedCount, objSOAmazonSetup.IntegrationID, logGraph);
                                        }
                                        processId++;
                                        graph.Actions.PressSave();
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                                              ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                                                    : SOConstants.exceptionIsEmpty);
                                    }
                                }
                            }
                        }
                        else
                        {
                            throw new PXException(SOMessages.configMissing);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                              ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                            : SOConstants.exceptionIsEmpty);
                    }
                }
            });
        }
Beispiel #21
0
 private void StartLongOperation()
 {
     PXLongOperation.StartOperation(this, () => Console.WriteLine("Long Operation has been started"));
 }
 public virtual IEnumerable resubmit(PXAdapter adapter)
 {
     PXLongOperation.StartOperation(this, delegate() { ResubmitMessages(SelectedList().RowCast <CRSMEmail>().ToList()); });
     return(adapter.Get());
 }
Beispiel #23
0
 protected override void StartClosePeriod(List <FinPeriod> list)
 {
     PXLongOperation.StartOperation(this, delegate() { ClosePeriod(list); });
 }
Beispiel #24
0
 protected virtual void release()
 {
     PXLongOperation.StartOperation(this, null);
 }
Beispiel #25
0
 public virtual IEnumerable archive(PXAdapter adapter)
 {
     PXLongOperation.StartOperation(this, () => ArchiveMessages(SelectedList().RowCast <CRSMEmail>()));
     return(adapter.Get());
 }
Beispiel #26
0
 protected virtual void receiveAll()
 {
     PXLongOperation.StartOperation(this, delegate() { LongProcessReceive(); });
 }
        public static IEnumerable users()
        {
            PXLongOperation.StartOperation(new PX.Data.PXGraph(), () => SyncUsers());

            return(new PXSelect <PX.SM.Users>(new PX.Data.PXGraph()).Select());
        }
Beispiel #28
0
 public void syncUsers()
 {
     PXLongOperation.StartOperation(UID, SyncUsersLongOperation);
 }
        public virtual IEnumerable GenerateProjection(PXAdapter adapter)
        {
            if (RouteAppointmentForecastingFilter.Current != null &&
                RouteAppointmentForecastingFilter.Current.DateBegin != null &&
                RouteAppointmentForecastingFilter.Current.DateEnd != null &&
                RouteAppointmentForecastingFilter.Current.DateBegin < RouteAppointmentForecastingFilter.Current.DateEnd)
            {
                DateTime beginFromFilter = RouteAppointmentForecastingFilter.Current.DateBegin.Value;
                DateTime endToFilter     = RouteAppointmentForecastingFilter.Current.DateEnd.Value;
                string   recordType      = ID.RecordType_ServiceContract.ROUTE_SERVICE_CONTRACT;

                int?serviceID          = RouteAppointmentForecastingFilter.Current.ServiceID;
                int?customerID         = RouteAppointmentForecastingFilter.Current.CustomerID;
                int?customerLocationID = RouteAppointmentForecastingFilter.Current.CustomerLocationID;
                int?routeID            = RouteAppointmentForecastingFilter.Current.RouteID;

                PXLongOperation.StartOperation(
                    this,
                    delegate
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        if (beginFromFilter != null && endToFilter != null)
                        {
                            DateHandler requestDate = new DateHandler(endToFilter);

                            var period = new Period((DateTime)beginFromFilter, (DateTime)endToFilter);

                            List <Scheduler.Schedule> scheduleListToProcess = new List <Scheduler.Schedule>();
                            var generator = new TimeSlotGenerator();

                            var fsRouteContractScheduleRecords =
                                PXSelectJoinGroupBy <FSRouteContractSchedule,
                                                     InnerJoin <FSServiceContract,
                                                                On <FSServiceContract.serviceContractID, Equal <FSRouteContractSchedule.entityID> >,
                                                                InnerJoin <FSScheduleRoute,
                                                                           On <FSScheduleRoute.scheduleID, Equal <FSRouteContractSchedule.scheduleID> >,
                                                                           InnerJoin <FSScheduleDet,
                                                                                      On <FSScheduleDet.scheduleID, Equal <FSRouteContractSchedule.scheduleID> > > > >,
                                                     Where <
                                                         FSRouteContractSchedule.entityType, Equal <FSSchedule.entityType.Contract>,
                                                         And <FSServiceContract.recordType, Equal <FSServiceContract.recordType.RouteServiceContract>,
                                                              And <FSRouteContractSchedule.active, Equal <True>,
                                                                   And <FSServiceContract.status, Equal <FSServiceContract.status.Active>,
                                                                        And <FSRouteContractSchedule.startDate, LessEqual <Required <FSRouteContractSchedule.startDate> >,
                                                                             And2 <
                                                                                 Where <
                                                                                     Required <FSScheduleDet.inventoryID>, IsNull,
                                                                                     Or <FSScheduleDet.inventoryID, Equal <Required <FSScheduleDet.inventoryID> > > >,
                                                                                 And2 <
                                                                                     Where <
                                                                                         Required <FSRouteContractSchedule.customerID>, IsNull,
                                                                                         Or <FSRouteContractSchedule.customerID, Equal <Required <FSRouteContractSchedule.customerID> > > >,
                                                                                     And2 <
                                                                                         Where <
                                                                                             Required <FSRouteContractSchedule.customerLocationID>, IsNull,
                                                                                             Or <FSRouteContractSchedule.customerLocationID, Equal <Required <FSRouteContractSchedule.customerLocationID> > > >,
                                                                                         And2 <
                                                                                             Where <
                                                                                                 Required <FSScheduleRoute.dfltRouteID>, IsNull,
                                                                                                 Or <FSScheduleRoute.dfltRouteID, Equal <Required <FSScheduleRoute.dfltRouteID> > > >,
                                                                                             And <
                                                                                                 Where <FSRouteContractSchedule.endDate, IsNull,
                                                                                                        Or <FSRouteContractSchedule.endDate, GreaterEqual <Required <FSRouteContractSchedule.startDate> > > > > > > > > > > > > >,
                                                     Aggregate <
                                                         GroupBy <FSRouteContractSchedule.scheduleID> > >
                                .Select(this, beginFromFilter, serviceID, serviceID, customerID, customerID, customerLocationID, customerLocationID, routeID, routeID, endToFilter);

                            foreach (FSRouteContractSchedule fsRouteContractScheduleRecord in fsRouteContractScheduleRecords)
                            {
                                List <Scheduler.Schedule> mapScheduleResults = MapFSScheduleToSchedule.convertFSScheduleToSchedule(RouteAppointmentForecastingFilter.Cache, fsRouteContractScheduleRecord, endToFilter, recordType);

                                foreach (Scheduler.Schedule mapSchedule in mapScheduleResults)
                                {
                                    scheduleListToProcess.Add(mapSchedule);
                                }
                            }

                            if (recordType == ID.RecordType_ServiceContract.ROUTE_SERVICE_CONTRACT)
                            {
                                foreach (Scheduler.Schedule schedule in scheduleListToProcess)
                                {
                                    schedule.Priority      = (int?)RouteScheduleProcess.SetSchedulePriority(schedule, this);
                                    schedule.RouteInfoList = RouteScheduleProcess.getRouteListFromSchedule(schedule, this);
                                }
                            }

                            List <TimeSlot> timeSlots = generator.GenerateCalendar(period, scheduleListToProcess);

                            var fsRouteAppointmentForecastingRecords =
                                PXSelect <FSRouteAppointmentForecasting,
                                          Where <
                                              FSRouteAppointmentForecasting.startDate, GreaterEqual <Required <FSRouteAppointmentForecasting.startDate> >,
                                              And <
                                                  FSRouteAppointmentForecasting.startDate, LessEqual <Required <FSRouteAppointmentForecasting.startDate> > > > >
                                .Select(this, beginFromFilter, endToFilter);

                            PXCache <FSRouteAppointmentForecasting> cacheRouteForecasting = new PXCache <FSRouteAppointmentForecasting>(this);

                            foreach (FSRouteAppointmentForecasting fsRouteAppointmentDetailProjectionRecord in fsRouteAppointmentForecastingRecords)
                            {
                                cacheRouteForecasting.PersistDeleted(fsRouteAppointmentDetailProjectionRecord);
                            }

                            foreach (TimeSlot timeSlot in timeSlots)
                            {
                                requestDate.setDate(timeSlot.DateTimeBegin);

                                FSSchedule fsScheduleRow = ScheduleSelected.Select(timeSlot.ScheduleID);

                                FSScheduleRoute fsScheduleRouteRow = ScheduleRouteSelected.Select(fsScheduleRow.ScheduleID);

                                FSServiceContract fsServiceContractRow = ServiceContractSelected.Select(fsScheduleRow.EntityID);

                                FSRouteAppointmentForecasting fsRouteAppointmentForecastingRow = new FSRouteAppointmentForecasting();

                                fsRouteAppointmentForecastingRow.RouteID            = fsScheduleRouteRow.DfltRouteID;
                                fsRouteAppointmentForecastingRow.StartDate          = requestDate.StartOfDay();
                                fsRouteAppointmentForecastingRow.ScheduleID         = fsScheduleRow.ScheduleID;
                                fsRouteAppointmentForecastingRow.ServiceContractID  = fsServiceContractRow.ServiceContractID;
                                fsRouteAppointmentForecastingRow.CustomerLocationID = fsServiceContractRow.CustomerLocationID;
                                fsRouteAppointmentForecastingRow.CustomerID         = fsServiceContractRow.CustomerID;
                                fsRouteAppointmentForecastingRow.SequenceOrder      = int.Parse(fsScheduleRouteRow.GlobalSequence);

                                cacheRouteForecasting.PersistInserted(fsRouteAppointmentForecastingRow);
                            }
                        }

                        ts.Complete();
                    }
                });
            }

            return(adapter.Get());
        }
Beispiel #30
0
        protected void createICPOAction()
        {
            Base.Save.Press();

            var curCompanyID = PXInstanceHelper.CurrentCompany;
            var curUserName  = PXLogin.ExtractUsername(PXContext.PXIdentity.IdentityName);

            //A.By using LMICCustomer table to identify the destination tenant of PO need to be created
            var curSOOrder      = (SOOrder)Base.Caches[typeof(SOOrder)].Current;
            var curLMICCustomer = PXSelect <LMICCustomer, Where <LMICCustomer.customerID, Equal <Required <LMICCustomer.customerID> > > > .Select(Base, curSOOrder.CustomerID).TopFirst;

            //B.Go to the destination tenant, and ensure vendor is defined in LMICVendor.If not, throw error message “The vendor is not defined in destination tenant”.
            var curCompanyName = PXLogin.ExtractCompany(PXContext.PXIdentity.IdentityName);
            var curLMICVendor  = new LMICVendor();

            try
            {
                using (PXLoginScope pXLoginScope = new PXLoginScope($"{curUserName}@{curLMICCustomer.LoginName}"))
                {
                    curLMICVendor = PXSelect <LMICVendor, Where <LMICVendor.tenantID, Equal <Required <LMICVendor.tenantID> > > > .Select(PXGraph.CreateInstance <POOrderEntry>(), curCompanyID).TopFirst;
                }
            }
            catch (Exception)
            {
                throw new PXException("Please try again.");
            }

            /*Get InventoryCD in each line*/
            var inventoryCDList = new List <string>();

            foreach (SOLine line in Base.Transactions.Cache.Cached)
            {
                inventoryCDList.Add(PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, line.InventoryID).TopFirst?.InventoryCD);
            }

            if (curLMICCustomer != null)
            {
                if (curLMICVendor != null)
                {
                    try
                    {
                        PXLongOperation.StartOperation(Base, () =>
                        {
                            var SOOrderCustomerOrderNbr = string.Empty;


                            //C.Create a purchase order in destination tenant by uing the following mapping.
                            using (PXLoginScope pXLoginScope = new PXLoginScope($"{curUserName}@{curLMICCustomer.LoginName}"))
                            {
                                POOrderEntry pOOrderEntry = PXGraph.CreateInstance <POOrderEntry>();
                                /* PO Header */
                                POOrder pOOrder = new POOrder();
                                pOOrder         = pOOrderEntry.Document.Insert(pOOrder);

                                pOOrder.BranchID = curLMICVendor.BranchID;
                                pOOrder.VendorID = curLMICVendor.VendorID;

                                pOOrderEntry.Document.Cache.RaiseFieldUpdated <POOrder.vendorID>(pOOrder, pOOrder.VendorID);

                                pOOrder.VendorRefNbr = curSOOrder.OrderNbr;
                                pOOrder.OrderDate    = curSOOrder.OrderDate;
                                pOOrder.OrderDesc    = "IC PO | " + curCompanyName + " | " + curSOOrder.OrderNbr;

                                /* PO Line */
                                int i = 0;
                                foreach (SOLine line in Base.Transactions.Cache.Cached)
                                {
                                    POLine pOLine       = new POLine();
                                    var tempInventoryID = PXSelect <InventoryItem, Where <InventoryItem.inventoryCD, Equal <Required <InventoryItem.inventoryCD> > > > .Select(pOOrderEntry, inventoryCDList[i])?.TopFirst?.InventoryID;
                                    pOLine.InventoryID  =
                                        tempInventoryID == null ?
                                        PXSelect <INItemXRef, Where <INItemXRef.alternateID, Equal <Required <INItemXRef.alternateID> > > > .Select(pOOrderEntry, inventoryCDList[i])?.TopFirst?.InventoryID : tempInventoryID;
                                    pOLine.OrderQty = line.OrderQty;
                                    pOLine          = pOOrderEntry.Transactions.Insert(pOLine);

                                    pOLine.CuryUnitCost = line.CuryUnitPrice;
                                    pOLine = pOOrderEntry.Transactions.Update(pOLine);

                                    i++;
                                }

                                //D.If the PO is saved successfully, please update the following fields
                                // - POOrder, ICSOCreated = true
                                POOrderExt pOOrderExt     = pOOrder.GetExtension <POOrderExt>();
                                pOOrderExt.UsrICSOCreated = true;
                                pOOrderEntry.Document.Update(pOOrder);
                                pOOrderEntry.Actions.PressSave();

                                SOOrderCustomerOrderNbr = pOOrder.OrderNbr;
                            }

                            //D.If the PO is saved successfully, please update the following fields
                            // - SOOrder, ICPOCreated = true; Customer Order Nbr = POOrder.OrderNbr
                            SOOrderExt sOOrderExt       = curSOOrder.GetExtension <SOOrderExt>();
                            sOOrderExt.UsrICPOCreated   = true;
                            curSOOrder.CustomerOrderNbr = SOOrderCustomerOrderNbr;
                            Base.Document.Update(curSOOrder);
                            Base.Save.Press();
                        });
                    }
                    catch (Exception)
                    {
                        throw new PXException("Please try again.");
                    }
                }
                else
                {
                    throw new PXException("The vendor is not defined in destination tenant");
                }
            }
        }