2015-08-13 58 views
0

我在SO303000中定制了操作版本。这里是我从SOInvoiceEntry和我添加的代码复制的代码:页面在完成和操作时不会重新加载

[PXUIField(DisplayName = "Release", Visible = false)] 
    [PXButton()] 
    public IEnumerable Release(PXAdapter adapter) 
    { 
     List<ARRegister> list = new List<ARRegister>(); 
     foreach (ARInvoice ardoc in adapter.Get<ARInvoice>()) 
     { 
      if (Base.Document.Cache.GetStatus(ardoc) == PXEntryStatus.Notchanged) Base.Document.Cache.SetStatus(ardoc, PXEntryStatus.Updated); 
      list.Add(ardoc); 
     } 

     // skipAvalaraCallOnSave = true; 
     Base.Save.Press(); 

     PXLongOperation.StartOperation(this, delegate() 
     { 
      PXTimeStampScope.SetRecordComesFirst(typeof(ARInvoice), true); 

      List<ARRegister> listWithTax = new List<ARRegister>(); 
      foreach (ARInvoice ardoc in list) 
      { 
       if (ardoc.IsTaxValid != true && AvalaraMaint.IsExternalTax(Base, ardoc.TaxZoneID)) 
       { 
        ARInvoice doc = new ARInvoice(); 
        doc.DocType = ardoc.DocType; 
        doc.RefNbr = ardoc.RefNbr; 
        doc.OrigModule = ardoc.OrigModule; 
        doc.ApplyPaymentWhenTaxAvailable = ardoc.ApplyPaymentWhenTaxAvailable; 
        listWithTax.Add(ARExternalTaxCalc.Process(doc)); 
       } 
       else 
       { 
        listWithTax.Add(ardoc); 
       } 
      } 

      SOInvoiceEntry ie = PXGraph.CreateInstance<SOInvoiceEntry>(); 
      SOOrderShipmentProcess docgraph = PXGraph.CreateInstance<SOOrderShipmentProcess>(); 
      HashSet<object> processed = new HashSet<object>(); 

      ARDocumentRelease.ReleaseDoc(listWithTax, adapter.MassProcess, null, delegate(ARRegister ardoc, bool isAborted) 
      { 
       List<object> items = new List<object>(); 
       items.Add(ardoc); 
       PXAutomation.RemovePersisted(ie, typeof(ARInvoice), items); 

       docgraph.Clear(); 
       foreach (PXResult<SOOrderShipment, SOOrder> ordershipment in docgraph.Items.View.SelectMultiBound(new object[] { ardoc })) 
       { 
        SOOrderShipment copy = PXCache<SOOrderShipment>.CreateCopy(ordershipment); 
        SOOrder order = ordershipment; 
        copy.InvoiceReleased = true; 
        docgraph.Items.Update(copy); 

        if (order.Completed == true && order.BilledCntr <= 1 && order.ShipmentCntr <= order.BilledCntr + order.ReleasedCntr) 
        { 
         foreach (SOAdjust adj in docgraph.Adjustments.Select(order.OrderType, order.OrderNbr)) 
         { 
          SOAdjust adjcopy = PXCache<SOAdjust>.CreateCopy(adj); 
          adjcopy.CuryAdjdAmt = 0m; 
          adjcopy.CuryAdjgAmt = 0m; 
          adjcopy.AdjAmt = 0m; 
          docgraph.Adjustments.Update(adjcopy); 
         } 
        } 
        processed.Add(ardoc); 
       } 
       docgraph.Save.Press(); 
      }); 
      PXAutomation.StorePersisted(ie, typeof(ARInvoice), new List<object>(processed)); 
      foreach (ARInvoice ardoc in list) 
      { 
       PXDatabase.Execute("pp_DMS_SO_Invoice_InsertSettleDate", 
      new PXSPInParameter("@CompanyID", PXContext.GetSlot<int?>("singleCompanyID")), 
      new PXSPInParameter("@InvoiceType", ardoc.DocType), 
      new PXSPInParameter("@InvoiceNBR", ardoc.RefNbr)); 
       createARDocument(ardoc); 
      } 

     }); 

     return list; 
     } 
    } 

当我发布文档时,必须手动重新加载页面。我不知道它为什么不自动重新加载。 我调试了,我发现发生错误“在mscorlib.dll中发生了'System.Reflection.TargetInvocationException'类型的未处理异常”我认为它不能反映下一个操作的对象,因此它不会重新加载缓存。 感谢您的支持。

回答

0

我是不确定您的具体问题,因为它需要进一步验证发生了什么。但作为一个解决这个问题的方法,如果你只是想从代码重新加载屏幕,你可以抛出一个重定向所需的异常

所有操作完成后,创建一个发票条目的实例,通过搜索确切的文档,然后重定向到该图表。

如代码:

PX.Objects.SO.SOInvoiceEntry invGraph = new PX.Objects.SO.SOInvoiceEntry(); 
invGraph.Document.Current = invGraph .Document.Search<PX.Objects.AR.ARInvoice>(<YOUR INVOICE NUMBER>); 
throw new PXRedirectRequiredException(invGraph, "Reloading invoice"); 
相关问题