public void AssignOrder(RSSVWorkOrder order, bool isMassProcess = false) { WorkOrders.Current = order; //If the assignee is not specified, specify the default employee. if (order.Assignee == null) { //Retrieve the record with the default setting RSSVSetup setupRecord = AutoNumSetup.Current; order.Assignee = setupRecord.DefaultEmployee; } //Change the status of the work order. order.Status = WorkOrderStatusConstants.Assigned; //Update the work order in the cache. order = WorkOrders.Update(order); //Modify the number of assigned orders for the employee. RSSVEmployeeWorkOrderQty employeeNbrOfOrders = new RSSVEmployeeWorkOrderQty(); employeeNbrOfOrders.Userid = order.Assignee; employeeNbrOfOrders.NbrOfAssignedOrders = 1; Quantity.Insert(employeeNbrOfOrders); // Trigger the Save action to save the changes to the database Actions.PressSave(); //Display the message to indicate successful processing. if (isMassProcess) { PXProcessing.SetInfo(string.Format(Messages.WorkOrderAssigned, order.OrderNbr)); } }
// public static void Process(POReceipt doc) // { // List<POReceipt> list = new List<POReceipt>(); // // list.Add(doc); // Process(list, false); // } public static void Process(List <POOrder> list, bool isMassProcess) { POOrderEntry rg = PXGraph.CreateInstance <POOrderEntry>(); for (int i = 0; i < list.Count; i++) { try { rg.Clear(); rg.Document.Current = PXSelect <POOrder, Where <POOrder.orderType, Equal <Required <POOrder.orderType> >, And <POOrder.orderNbr, Equal <Required <POOrder.orderNbr> > > > > .Select(rg, list[i].OrderType, list[i].OrderNbr); rg.CalculateExternalTax(rg.Document.Current); PXProcessing <POOrder> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { if (isMassProcess) { PXProcessing <POOrder> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } else { throw new PXMassProcessException(i, e); } } } }
public static void Process(List <FSAppointment> list, bool isMassProcess) { AppointmentEntry appointmentEntryGraph = PXGraph.CreateInstance <AppointmentEntry>(); for (int i = 0; i < list.Count; i++) { try { appointmentEntryGraph.Clear(); appointmentEntryGraph.AppointmentRecords.Current = PXSelect <FSAppointment, Where <FSAppointment.srvOrdType, Equal <Required <FSAppointment.srvOrdType> >, And <FSAppointment.refNbr, Equal <Required <FSAppointment.refNbr> > > > > .Select(appointmentEntryGraph, list[i].SrvOrdType, list[i].RefNbr); appointmentEntryGraph.CalculateExternalTax(appointmentEntryGraph.AppointmentRecords.Current); PXProcessing <FSAppointment> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { if (isMassProcess) { PXProcessing <FSAppointment> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } else { throw new PXMassProcessException(i, e); } } } }
public ConvertItemsToEquipmentProcess() { SMEquipmentMaint graphSMEquipmentMaint; InventoryItems.SetProcessDelegate( delegate(List <SoldInventoryItem> inventoryItemRows) { graphSMEquipmentMaint = CreateInstance <SMEquipmentMaint>(); bool error = false; for (int i = 0; i < inventoryItemRows.Count; i++) { SoldInventoryItem soldInventoryItemRow = inventoryItemRows[i]; error = false; try { for (int j = 0; j < soldInventoryItemRow.ShippedQty; j++) { SharedFunctions.CreateSoldEquipment(graphSMEquipmentMaint, soldInventoryItemRow, null, null, null, null); } } catch (Exception e) { error = true; PXProcessing <SoldInventoryItem> .SetError(i, e.Message); } if (error == false) { PXProcessing <SoldInventoryItem> .SetInfo(i, TX.Messages.RECORD_PROCESSED_SUCCESSFULLY); } } }); }
public StaffContractScheduleProcess() { StaffContractScheduleProcess processor = null; StaffSchedules.SetProcessDelegate( delegate(List <FSStaffSchedule> fsScheduleRowList) { processor = PXGraph.CreateInstance <StaffContractScheduleProcess>(); int index = 0; foreach (FSStaffSchedule fsScheduleRow in fsScheduleRowList) { try { DateTime?fromDate = fsScheduleRow.LastGeneratedElementDate ?? fsScheduleRow.StartDate; processor.processStaffSchedule(Filter.Cache, processor, fsScheduleRow, fromDate, Filter.Current.ToDate); PXProcessing <FSStaffSchedule> .SetInfo(index, TX.Messages.RECORD_PROCESSED_SUCCESSFULLY); } catch (Exception e) { PXProcessing <FSStaffSchedule> .SetError(index, e); } index++; } }); }
public RouteScheduleProcess() { RouteScheduleProcess processor = null; RouteContractSchedules.SetProcessDelegate( delegate(List <FSRouteContractScheduleFSServiceContract> fsScheduleRowList) { processor = PXGraph.CreateInstance <RouteScheduleProcess>(); int index = 0; foreach (FSRouteContractScheduleFSServiceContract fsScheduleRow in fsScheduleRowList) { try { processor.processServiceContract(Filter.Cache, fsScheduleRow, Filter.Current.FromDate, Filter.Current.ToDate); PXProcessing <FSRouteContractScheduleFSServiceContract> .SetInfo(index, TX.Messages.RECORD_PROCESSED_SUCCESSFULLY); } catch (Exception e) { PXProcessing <FSRouteContractScheduleFSServiceContract> .SetError(index, e); } index++; } updateRoutes(processor.nextGenerationID); }); }
public static void Process(IList <KCStore> stores) { logger.SetRequestId(GetRequestId()); for (int i = 0; i < stores.Count; i++) { var tokenSource = new CancellationTokenSource(); try { ProcessStore(stores[i], tokenSource.Token); PXProcessing <KCStore> .SetInfo(i, KCMessages.BulkUploadSuccess(stores[i].SiteMasterCD)); } catch (Exception exception) { string log = KCMessages.ProcessException(stores[i].SiteMasterCD, exception.Message, exception.StackTrace); PXTrace.WriteError(exception); logger.ClearLoggingIds(); logger.Error(log); PXProcessing <KCStore> .SetError(i, new Exception(log)); } finally { tokenSource.Cancel(true); tokenSource.Dispose(); } } }
public static void ProcessSurvey(List <SurveyCollector> recs, SurveyFilter filter) { var collGraph = CreateInstance <SurveyCollectorMaint>(); var action = filter.Action; if (string.IsNullOrEmpty(action)) { throw new PXException(Messages.SurveyActionNotRecognised); } SurveyProcess surveyProcessGraph = PXGraph.CreateInstance <SurveyProcess>(); surveyProcessGraph.Filter.Insert(filter); var collCache = collGraph.Collector.Cache; var errorOccurred = false; var docCount = 0; foreach (var rec in recs) { var row = (SurveyCollector)collCache.CreateCopy(rec); collGraph.Collector.Current = row; try { PXProcessing <SurveyCollector> .SetCurrentItem(rec); switch (action) { case SurveyAction.SendNew: collGraph.DoSendNewNotification(row); break; case SurveyAction.RemindOnly: collGraph.DoSendReminder(row, filter.DurationTimeSpan); break; case SurveyAction.ExpireOnly: row.Status = CollectorStatus.Expired; row.Message = null; collGraph.Collector.Update(row); break; } if (++docCount % 10 == 0) { surveyProcessGraph.Actions.PressSave(); } PXProcessing <SurveyCollector> .SetInfo(recs.IndexOf(rec), string.Format("The survey collector {0} has been updated", rec.CollectorID)); PXProcessing <SurveyCollector> .SetProcessed(); } catch (Exception ex) { row.Status = CollectorStatus.Error; row.Message = ex.Message; surveyProcessGraph.Documents.Update(row); surveyProcessGraph.Actions.PressSave(); PXTrace.WriteError(ex); string errorMessage = ex.Message + ": "; if (ex is PXOuterException pex && pex.InnerMessages != null) { foreach (string message in pex.InnerMessages) { errorMessage += message + ", "; } }
public static void Release(List <EPTimeCardRow> timeCards) { TimeCardMaint timeCardMaint = PXGraph.CreateInstance <TimeCardMaint>(); for (int i = 0; i < timeCards.Count; i++) { timeCardMaint.Clear(); timeCardMaint.Document.Current = timeCardMaint.Document.Search <EPTimeCard.timeCardCD>(timeCards[i].TimeCardCD); if (timeCardMaint.Document.Current == null) { PXProcessing <EPTimeCardRow> .SetError(i, Messages.TimecardCannotBeReleased_NoRights); } else { try { timeCardMaint.release.Press(); PXProcessing <EPTimeCardRow> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { PXProcessing <EPTimeCardRow> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } } } }
public static void Process(List <PMProforma> list, bool isMassProcess) { Stopwatch sw = new Stopwatch(); ProformaEntry rg = PXGraph.CreateInstance <ProformaEntry>(); rg.SuppressRowSeleted = true; for (int i = 0; i < list.Count; i++) { try { rg.Document.Current = PXSelect <PMProforma, Where <PMProforma.refNbr, Equal <Required <PMProforma.refNbr> > > > .Select(rg, list[i].RefNbr); rg.CalculateAvalaraTax(rg.Document.Current); PXProcessing <PMProforma> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { if (isMassProcess) { PXProcessing <PMProforma> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } else { throw new PXMassProcessException(i, e); } } } }
public static void ReleaseDoc(List <POLandedCostDoc> list, bool aIsMassProcess) { var docgraph = PXGraph.CreateInstance <POLandedCostDocEntry>(); int iRow = 0; bool failed = false; foreach (POLandedCostDoc doc in list) { try { docgraph.ReleaseDoc(doc); PXProcessing <POLandedCostDoc> .SetInfo(iRow, ActionsMessages.RecordProcessed); } catch (Exception e) { if (aIsMassProcess) { PXProcessing <POLandedCostDoc> .SetError(iRow, e); failed = true; } else { throw; } } iRow++; } if (failed) { throw new PXException(Messages.LandedCostProcessingForOneOrMorePOReceiptsFailed); } }
public static List <ARCashSale> Process(List <ARCashSale> list, bool isMassProcess) { List <ARCashSale> listWithTax = new List <ARCashSale>(list.Count); ARCashSaleEntry rg = PXGraph.CreateInstance <ARCashSaleEntry>(); for (int i = 0; i < list.Count; i++) { try { rg.Clear(); rg.Document.Current = PXSelect <ARCashSale, Where <ARCashSale.docType, Equal <Required <ARCashSale.docType> >, And <ARCashSale.refNbr, Equal <Required <ARCashSale.refNbr> > > > > .Select(rg, list[i].DocType, list[i].RefNbr); listWithTax.Add(rg.CalculateExternalTax(rg.Document.Current)); PXProcessing <ARCashSale> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { if (isMassProcess) { PXProcessing <ARCashSale> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } else { throw new PXMassProcessException(i, e); } } } return(listWithTax); }
public static void Process(List <CROpportunity> list, bool isMassProcess) { OpportunityMaint rg = PXGraph.CreateInstance <OpportunityMaint>(); for (int i = 0; i < list.Count; i++) { try { rg.Clear(); rg.Opportunity.Current = PXSelect <CROpportunity, Where <CROpportunity.opportunityID, Equal <Required <CROpportunity.opportunityID> > > > .Select(rg, list[i].OpportunityID); CalculateAvalaraTax(rg, rg.Opportunity.Current); PXProcessing <CROpportunity> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { if (isMassProcess) { PXProcessing <CROpportunity> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } else { throw new PXMassProcessException(i, e); } } } }
public static List <CAAdj> Process(List <CAAdj> list, bool isMassProcess) { List <CAAdj> listWithTax = new List <CAAdj>(list.Count); CATranEntry rg = PXGraph.CreateInstance <CATranEntry>(); for (int i = 0; i < list.Count; i++) { try { rg.Clear(); rg.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.adjRefNbr, Equal <Required <CAAdj.adjRefNbr> > > > .Select(rg, list[i].AdjRefNbr); listWithTax.Add(rg.CalculateAvalaraTax(rg.CAAdjRecords.Current)); PXProcessing <CAAdj> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { if (isMassProcess) { PXProcessing <CAAdj> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } else { throw new PXMassProcessException(i, e); } } } return(listWithTax); }
public virtual void RevalueInventory(INUpdateStdCostRecord itemsite) { using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { if (je.adjustment.Current == null) { je.adjustment.Cache.Insert(); } foreach ( PXResult <INCostStatus, InventoryItem, INSite, INPostClass, INItemSite> res in incoststatus.View.SelectMultiBound(new object[] { itemsite })) { INCostStatus layer = res; INSite site = res; INTran tran = new INTran(); if (((INCostStatus)res).LayerType == INLayerType.Oversold) { tran.TranType = INTranType.NegativeCostAdjustment; } else { tran.TranType = INTranType.StandardCostAdjustment; } tran.BranchID = site.BranchID; tran.InvtAcctID = layer.AccountID; tran.InvtSubID = layer.SubID; tran.AcctID = INReleaseProcess.GetAccountDefaults <INPostClass.stdCstRevAcctID> (je, (InventoryItem)res, (INSite)res, (INPostClass)res); tran.SubID = INReleaseProcess.GetAccountDefaults <INPostClass.stdCstRevSubID> (je, (InventoryItem)res, (INSite)res, (INPostClass)res); tran.InventoryID = layer.InventoryID; tran.SubItemID = layer.CostSubItemID; tran.SiteID = layer.CostSiteID; tran.Qty = 0m; tran.TranCost = PXDBCurrencyAttribute.BaseRound(this, (decimal)(layer.QtyOnHand * itemsite.StdCost)) - layer.TotalCost; je.transactions.Insert(tran); } if (je.transactions.Select().Count == 0) { je.Clear(); } else { je.Save.Press(); PXProcessing <INUpdateStdCostRecord> .SetInfo(string.Format(Messages.AdjstmentCreated, je.adjustment.Current.RefNbr)); } ts.Complete(); } } }
public static void ProcessSurveyResponse(List <CRCaseSurveySetup> setup) { var graph = PXGraph.CreateInstance <CaseSurveyResponseEngine>(); var setupRecord = graph.SetupRecord.SelectSingle(); var setupRecordExt = graph.SetupRecord.Cache.GetExtension <CRSetupExt>(setupRecord); var fromDate = setupRecordExt.UsrLastSurveySyncDate; var toDate = DateTime.UtcNow; var dataReader = new PX.SurveyMonkeyReader.SurveyMonkeyReader(setupRecordExt.UsrSurveyID, setupRecordExt.UsrAccessToken); List <SurveyResponse> surveyResponses; try { surveyResponses = dataReader.GetSurveyResponsesByDateRange(fromDate, toDate); } catch (Exception ex) { throw new PXException(ex.Message); } foreach (var surveyResponse in surveyResponses) { graph.Cases.Current = (CRCase)graph.Cases.Search <CRCase.caseCD>(surveyResponse.CaseCD); if (graph.Cases.Current == null) { continue; } // Surveys can technically be answered by more than one person; if responses exist already just skip over the response since // the integration doesn't handle multiple responses per case. if (graph.CaseSurveyResponses.SelectSingle() != null) { continue; } var caseExt = PXCache <CRCase> .GetExtension <CRCaseExt>(graph.Cases.Current); caseExt.UsrResponseID = surveyResponse.ResponseID; caseExt.UsrResponseDate = surveyResponse.ResponseDate; graph.Cases.Current = graph.Cases.Update(graph.Cases.Current); foreach (var question in surveyResponse.Questions) { graph.SetQuestionAnswer(dataReader, question); } graph.Actions.PressSave(); } setupRecordExt.UsrLastSurveySyncDate = toDate; graph.SetupRecord.Update(setupRecord); graph.Actions.PressSave(); PXProcessing <CRCaseSurveySetup> .SetInfo("Successfully synched"); }
public ServiceOrderProcess() { ServiceOrderProcess graphServiceOrderProcess; ServiceOrderRecords.SetProcessDelegate( delegate(List <FSServiceOrder> fsServiceOrderRowList) { graphServiceOrderProcess = PXGraph.CreateInstance <ServiceOrderProcess>(); ServiceOrderEntry graphServiceOrderEntry = PXGraph.CreateInstance <ServiceOrderEntry>(); int index = 0; foreach (FSServiceOrder fsServiceOrderRow in fsServiceOrderRowList) { try { graphServiceOrderEntry.ServiceOrderRecords.Current = graphServiceOrderEntry.ServiceOrderRecords .Search <FSServiceOrder.refNbr>(fsServiceOrderRow.RefNbr, fsServiceOrderRow.SrvOrdType); switch (Filter.Current.SOAction) { case ID.ServiceOrder_Action_Filter.COMPLETE: graphServiceOrderEntry.CompleteOrder(); break; case ID.ServiceOrder_Action_Filter.CANCEL: graphServiceOrderEntry.CancelOrder(); break; case ID.ServiceOrder_Action_Filter.REOPEN: graphServiceOrderEntry.ReopenOrder(); break; case ID.ServiceOrder_Action_Filter.CLOSE: graphServiceOrderEntry.CloseOrder(); break; case ID.ServiceOrder_Action_Filter.UNCLOSE: graphServiceOrderEntry.UncloseOrderWithOptions(false); break; case ID.ServiceOrder_Action_Filter.ALLOWINVOICE: graphServiceOrderEntry.AllowInvoice(); break; } PXProcessing <FSServiceOrder> .SetInfo(index, TX.Messages.RECORD_PROCESSED_SUCCESSFULLY); } catch (Exception e) { PXProcessing <FSServiceOrder> .SetError(index, e); } index++; } }); }
private const bool AutoReleaseDebitAdjustments = true; //TODO: now (26.10.2017) we can't apply nonreleased debit adjustment public static APInvoice CreateAndReleasePPDDebitAdj(APInvoiceEntry ie, APPPDDebitAdjParameters filter, List <PendingPPDDebitAdjApp> list, bool autoReleaseDebitAdjustments) { APInvoice invDebitAdj; try { ie.Clear(PXClearOption.ClearAll); PXUIFieldAttribute.SetError(ie.Document.Cache, null, null, null); using (var ts = new PXTransactionScope()) { invDebitAdj = ie.CreatePPDDebitAdj(filter, list); if (invDebitAdj != null) { if (autoReleaseDebitAdjustments == true) { using (new PXTimeStampScope(null)) { APDocumentRelease.ReleaseDoc(new List <APRegister> { invDebitAdj }, false); APPaymentEntry paymentEntry = PXGraph.CreateInstance <APPaymentEntry>(); APPayment debitAdj = PXSelect <APPayment, Where <APPayment.docType, Equal <Required <APPayment.docType> >, And <APPayment.refNbr, Equal <Required <APPayment.refNbr> > > > > .Select(paymentEntry, invDebitAdj.DocType, invDebitAdj.RefNbr) .First(); paymentEntry.Document.Current = debitAdj; paymentEntry.SelectTimeStamp(); CreatePPDApplications(paymentEntry, list, debitAdj); paymentEntry.Persist(); APDocumentRelease.ReleaseDoc(new List <APRegister> { invDebitAdj }, false); // It needs to release applications } } foreach (PendingPPDDebitAdjApp adj in list) { PXProcessing <PendingPPDDebitAdjApp> .SetInfo(adj.Index, ActionsMessages.RecordProcessed); } } ts.Complete(); } } catch (Exception e) { foreach (PendingPPDDebitAdjApp adj in list) { PXProcessing <PendingPPDDebitAdjApp> .SetError(adj.Index, e); } invDebitAdj = null; } return(invDebitAdj); }
private static void Process(List <KCPriceAndInventoryMessage> messages) { logger.SetRequestId(GetRequestId()); messages = messages.OrderBy(x => x.CreatedDateTime).ToList(); bool ftp = messages.Count >= GetThresholdValue(); if (ftp && messages.Count > 0) { var tokenSource = new CancellationTokenSource(); try { var reversed = new List <KCPriceAndInventoryMessage>(messages); reversed.Reverse(); new KCMSMQDataHelper(logger.LoggerProperties).ProcessMessageFTP(reversed, tokenSource.Token); logger.ClearLoggingIds(); logger.Information(KCMessages.MSMQSyncFTP(messages.Count)); foreach (KCPriceAndInventoryMessage msg in reversed) { PXProcessing <KCPriceAndInventoryMessage> .SetInfo(messages.IndexOf(msg), $"Data Exchange for {msg.Message} has been processed successfully"); } } catch (Exception exception) { PXProcessing <KCPriceAndInventoryMessage> .SetError(new Exception(exception.Message)); logger.ClearLoggingIds(); logger.Error(exception.Message); } finally { tokenSource.Cancel(true); tokenSource.Dispose(); } } else if (messages.Count > 0) { int index = 0; try { foreach (KCPriceAndInventoryMessage msg in messages) { index = messages.IndexOf(msg); new KCMSMQDataHelper(logger.LoggerProperties).ProcessMessageAPI(msg); PXProcessing <KCPriceAndInventoryMessage> .SetInfo(index, $"Data Exchange for {msg.Message} has been processed successfully"); } } catch (Exception exception) { PXProcessing <KCPriceAndInventoryMessage> .SetError(index, new Exception(exception.Message)); logger.ClearLoggingIds(); logger.Error(exception.Message); } } }
public static void ReleaseDoc(List <POReceipt> list, bool aIsMassProcess) { POReceiptEntry docgraph = PXGraph.CreateInstance <POReceiptEntry>(); DocumentList <INRegister> created = new DocumentList <INRegister>(docgraph); DocumentList <APInvoice> invoicesCreated = new DocumentList <APInvoice>(docgraph); INReceiptEntry iRe = null; INIssueEntry iIe = null; AP.APInvoiceEntry apInvoiceGraph = PXGraph.CreateInstance <APInvoiceEntry>(); int iRow = 0; bool failed = false; foreach (POReceipt order in list) { try { switch (order.ReceiptType) { case POReceiptType.POReceipt: case POReceiptType.TransferReceipt: if (iRe == null) { iRe = docgraph.CreateReceiptEntry(); } docgraph.ReleaseReceipt(iRe, apInvoiceGraph, order, created, invoicesCreated, aIsMassProcess); break; case POReceiptType.POReturn: if (iIe == null) { iIe = docgraph.CreateIssueEntry(); } docgraph.ReleaseReturn(iIe, apInvoiceGraph, order, created, invoicesCreated, aIsMassProcess); break; } PXProcessing <POReceipt> .SetInfo(iRow, ActionsMessages.RecordProcessed); } catch (Exception e) { if (aIsMassProcess) { PXProcessing <POReceipt> .SetError(iRow, e); failed = true; } else { throw; } } iRow++; } if (failed) { throw new PXException(Messages.ReleaseOfOneOrMoreReceiptsHasFailed); } }
public static void CreateSalesOrderandPayments(PrepareAndImportOrdersParams objParams) { try { using (PXTransactionScope ts = new PXTransactionScope()) { if (objParams.objliUsrMapping.Where(X => X.IntegrationID == objParams.objSOProcessOrderRecord.IntegrationID).Count() == 0) { objParams.objliUsrMapping.Clear(); objParams.objliUsrMapping = SOHelper.GetUsrFieldMapping(objParams.objSOOrderEntry, objParams.objSOProcessOrderRecord.IntegrationID); } if (objParams.objliUsrMapping.Count > 0) { CreateSO objCreateSO = new CreateSO(); objCreateSO.SetSOHeaderObjectsData(objParams); objCreateSO.SetSOLineObjectsData(objParams); objCreateSO.SetBillingContactObjectsData(objParams); objCreateSO.SetBillingAddressobjectsData(objParams); objCreateSO.SetFinancialInformationobjectsData(objParams); objCreateSO.SetShippingContactObjectsData(objParams); objCreateSO.SetShippingAddressObjectsData(objParams); objCreateSO.SetFreightData(objParams); objCreateSO.SetDocumentLevelDiscountandTaxData(objParams); //Validate order total - decimal dAmazonTotal = 0; Decimal.TryParse(objParams.ObjCurrentOrder.OrderTotal.Amount, out dAmazonTotal); if (dAmazonTotal != objParams.objSOOrderEntry.Document.Current.CuryOrderTotal.GetValueOrDefault(0)) { throw new PXException(SOMessages.ErrorOrderTotalNotMatch); } objParams.objSOOrderEntry.Actions.PressSave(); objCreateSO.CreatePaymentProcess(objParams); if (objParams.objSOOrderEntry.Document.Current != null && !string.IsNullOrEmpty(objParams.objSOOrderEntry.Document.Current.OrderNbr)) { ts.Complete(); SOLogService.LogImportStatus(objParams, true, SOMessages.sucess); PXProcessing <SOProcessOrder> .SetInfo(objParams.CurrentOrderIndex, SOMessages.sucess); } } else { throw new PXException(SOMessages.FieldMappingEmptyErrMsg); } } } catch (Exception ex) { throw ex; } }
public static void SetProcessDelegate <ProcessGraph>(PXGraph graph, ScheduleRun.Parameters filter, PXProcessing <Schedule> view) where ProcessGraph : PXGraph <ProcessGraph>, IScheduleProcessing, new() { if (filter == null) { return; } short times = filter.LimitTypeSel == ScheduleRunLimitType.StopAfterNumberOfExecutions ? filter.RunLimit ?? 1 : short.MaxValue; DateTime executionDate = filter.LimitTypeSel == ScheduleRunLimitType.StopOnExecutionDate ? filter.ExecutionDate ?? graph.Accessinfo.BusinessDate.Value : DateTime.MaxValue; Dictionary <string, string> parametersErrors = PXUIFieldAttribute.GetErrors( graph.Caches[typeof(ScheduleRun.Parameters)], filter); view.SetProcessDelegate(schedules => { if (parametersErrors.Any()) { throw new PXException(parametersErrors.First().Value); } ProcessGraph processGraph = PXGraph.CreateInstance <ProcessGraph>(); bool failed = false; foreach (Schedule schedule in schedules) { try { PXProcessing <Schedule> .SetCurrentItem(schedule); processGraph.Clear(); processGraph.GenerateProc(schedule, times, executionDate); PXProcessing <Schedule> .SetInfo(ActionsMessages.RecordProcessed); } catch (Exception e) { failed = true; PXProcessing <Schedule> .SetError(e); } } if (failed) { //Clean current to prevent set exception to the last item PXProcessing <Schedule> .SetCurrentItem(null); throw new PXException(AR.Messages.OneOrMoreItemsAreNotProcessed); } }); }
protected static void ProcessSchedules(ServiceContractInq processor, FSContractSchedule fsScheduleRow, ServiceContractFilter Filter) { try { DateTime?fromDate = fsScheduleRow.NextExecutionDate ?? fsScheduleRow.StartDate; processor.processServiceContract(processor.Filter.Cache, fsScheduleRow, fromDate, Filter.ToDate); PXProcessing <FSContractSchedule> .SetInfo(TX.Messages.RECORD_PROCESSED_SUCCESSFULLY); } catch (Exception e) { PXProcessing <FSContractSchedule> .SetError(e); } }
public static void ReleaseDoc(List <POReceiptLCInfo> list) { LandedCostProcess lcGraph = PXGraph.CreateInstance <LandedCostProcess>(); PXSelectBase <LandedCostTran> select = new PXSelect <LandedCostTran, Where <LandedCostTran.source, Equal <LandedCostTranSource.fromPO>, And <LandedCostTran.processed, Equal <False>, And <LandedCostTran.pOReceiptNbr, Equal <Required <LandedCostTran.pOReceiptNbr> > > > > >(lcGraph); DocumentList <INRegister> inList = new DocumentList <INRegister>(lcGraph); DocumentList <APInvoice> apList = new DocumentList <APInvoice>(lcGraph); bool failed = false; int index = 0; foreach (POReceiptLCInfo iRct in list) { if ((iRct.Selected ?? false)) { List <LandedCostTran> trans = new List <LandedCostTran>(); foreach (LandedCostTran itr in select.Select(iRct.ReceiptNbr)) { trans.Add(itr); } try { lcGraph.Clear(); lcGraph.ReleaseLCTrans(trans, inList, apList); PXProcessing <APRegister> .SetInfo(index, ActionsMessages.RecordProcessed); } catch (LandedCostProcess.NoApplicableSourceException) { PXProcessing <APRegister> .SetInfo(index, Messages.NoApplicableLinesForLCTransOnlyAPDocumentIsCreated); } catch (Exception e) { PXProcessing <POReceiptLCInfo> .SetError(index, e); failed = true; } } index++; } if (failed) { throw new PXException(Messages.LandedCostProcessingForOneOrMorePOReceiptsFailed); } }
public static void Process(List <SlackMessage> list, bool isMassProcess) { string errorMessage = string.Empty; bool erroroccurred = false; SlackSetupMaint setupGraph = PXGraph.CreateInstance <SlackSetupMaint>(); SlackMessageMaint graph = PXGraph.CreateInstance <SlackMessageMaint>(); SlackSetup setup = setupGraph.SetupRecord.SelectSingle(); foreach (SlackMessage message in list) { try { if ((bool)message.IsSimple) { var msg = createSimpleMessage(message); WebRequest.postRequest(setup.SlackURL, msg); } else { //var msg = createDetailMessage(message); var msg = createDetailMessageWithFields(setup.AcumaticaURL, message); WebRequest.postRequest(setup.SlackURL, msg); } message.Released = true; graph.Messages.Update(message); graph.Save.Press(); PXProcessing <SlackMessage> .SetInfo(list.IndexOf(message), "Processed."); } catch (Exception ex) { errorMessage = ex.Message; erroroccurred = true; PXProcessing <SlackMessage> .SetError(list.IndexOf(message), String.Format("{0}", ex.Message)); } } if (erroroccurred && isMassProcess) { throw new PXException("A least one Transaction hasn't been processed."); } if (erroroccurred && !isMassProcess) { throw new PXException(errorMessage); } }
public virtual void RefreshRates(RefreshFilter filter, List <RefreshRate> list) { DateTime date = GetUtcSyncDate(filter.CuryEffDate.Value); Dictionary <string, decimal> rates = GetRatesFromService(filter, list, date); CuryRateMaint graph = PXGraph.CreateInstance <CuryRateMaint>(); graph.Filter.Current.ToCurrency = filter.CuryID; graph.Filter.Current.EffDate = date; bool hasError = false; for (int i = 0; i < list.Count; i++) { RefreshRate rr = list[i]; if (rates.ContainsKey(rr.FromCuryID)) { CurrencyRate curyRate = (CurrencyRate)graph.CuryRateRecordsEntry.Insert(); curyRate.FromCuryID = rr.FromCuryID; curyRate.ToCuryID = filter.CuryID; curyRate.CuryRateType = rr.CuryRateType; curyRate.CuryRate = rates[rr.FromCuryID] * (1 + rr.OnlineRateAdjustment.GetValueOrDefault(0) / 100); curyRate.CuryMultDiv = CuryMultDivType.Div; rr.CuryRate = curyRate.CuryRate; graph.CuryRateRecordsEntry.Update(curyRate); PXProcessing <RefreshRate> .SetInfo(i, ActionsMessages.RecordProcessed); } else { PXProcessing <RefreshRate> .SetError(i, PXMessages.LocalizeFormatNoPrefixNLA(Messages.NoOnlyRatesFoundForCurrency, rr.FromCuryID)); hasError = true; } } graph.Actions.PressSave(); if (hasError) { throw new PXOperationCompletedException(Messages.CurrencyRateFailedToRefresh); } }
public void ApproveOrder(SalesOrder order, bool isMassProcess = false) { Orders.Current = order; if (order.Status == OrderStatus.Hold) { throw new PXException(String.Format("Order {0} is On Hold and cannot be approved.", order.OrderNbr)); } else if (order.Status != OrderStatus.Open) { throw new PXException(String.Format("Order {0} is already approved.", order.OrderNbr)); } order.Status = OrderStatus.Approved; Orders.Update(order); Persist(); if (isMassProcess) { PXProcessing.SetInfo(String.Format("Order {0} has been successfully approved.", order.OrderNbr)); } }
public void ImportClearLogAmazonRecords(SOImportClearLog graph, List <SOOrderProcessLog> listOfImportLog) { foreach (SOOrderProcessLog lg in listOfImportLog) { try { if (lg.Selected == true) { graph.Log.Cache.Delete(lg); PXProcessing <SOOrderProcessLog> .SetInfo(listOfImportLog.IndexOf(lg), SOMessages.logRecordDeleted); } } catch (Exception ex) { PXProcessing <SOOrderProcessLog> .SetError(listOfImportLog.IndexOf(lg), ex.Message); } } graph.Actions.PressSave(); }
public static void Release(List <Document> list) { ExternalTaxPostProcess rg = PXGraph.CreateInstance <ExternalTaxPostProcess>(); for (int i = 0; i < list.Count; i++) { Document doc = list[i]; try { rg.Clear(); rg.Post(doc); PXProcessing <Document> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { PXProcessing <Document> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } } }
private static void DoImportCards(List <CCSynchronizeCard> items) { int index = 0; string procCenterId = procCenterId = items.First()?.CCProcessingCenterID; CCSynchronizeCards graph = PXGraph.CreateInstance <CCSynchronizeCards>(); foreach (CCSynchronizeCard item in items) { if (graph.ValidateImportCard(item, index) && !graph.CheckCustomerPaymentProfileExists(item, index)) { using (PXTransactionScope scope = new PXTransactionScope()) { graph.CreateCustomerPaymentMethodRecord(item); graph.UpdateCCProcessingSyncronizeCardRecord(item); scope.Complete(); PXProcessing <CCSynchronizeCard> .SetInfo(index, Messages.Completed); } } index++; } }