2017-12-21 20 views
0

ユーザーが出荷注文を送信すると、「アップロードIN」というアクションを呼び出す必要があります。私はすでに注文を自動的に確認しています。出荷確認後、プログラムでUpdate INを呼び出すにはどうすればよいですか?

public delegate void CreateShipmentDelegate(SOOrder order, int? SiteID, DateTime? ShipDate, bool? useOptimalShipDate, string operation, DocumentList<SOShipment> list); 
    [PXOverride] 
    public virtual void CreateShipment(SOOrder order, int? SiteID, DateTime? ShipDate, bool? useOptimalShipDate, string operation, DocumentList<SOShipment> list, CreateShipmentDelegate baseMethod) 
    { 
     baseMethod(order, SiteID, ShipDate, useOptimalShipDate, operation, list); 

     foreach (var action in (Base.action.GetState(null) as PXButtonState).Menus) 
     { 
      if (action.Command == "Confirm Shipment") 
      { 
       PXAdapter adapter2 = new PXAdapter(new DummyView(Base, Base.Document.View.BqlSelect, new List<object> { Base.Document.Current })); 
       adapter2.Menu = action.Command; 
       Base.action.PressButton(adapter2); 

       TimeSpan timespan; 
       Exception ex; 
       while (PXLongOperation.GetStatus(Base.UID, out timespan, out ex) == PXLongRunStatus.InProcess) 
       { } 
       break; 
      } 
     } 
    } 

私は、foreachループを複製しようとしたが、代わりに「アップロードIN」を探してそれが希望の結果が得られませんでした:ここで別の質問の答えをベースにしています私のコード(Auto confirm shipment when create shipment from Sales Order by Automation Step)がある

 foreach (var action in (Base.action.GetState(null) as PXButtonState).Menus) 
     { 
      if (action.Command == "Update IN") 
      { 

       PXAdapter adapter3 = new PXAdapter(new DummyView(Base, Base.Document.View.BqlSelect, new List<object> { Base.Document.Current })); 
       adapter3.Menu = action.Command; 
       Base.action.PressButton(adapter3); 

       TimeSpan timespan; 
       Exception ex; 
       while (PXLongOperation.GetStatus(Base.UID, out timespan, out ex) == PXLongRunStatus.InProcess) 
       { } 
       break; 
      } 
     } 

Actionを一般的に呼び出す方法はありますか?

私はこの特定の動作に気づいたことの1つは、バージョン6のインスタンスのソースでそのコードを見つけることができないということです。しかし、バージョン2017では、それを独自のアクションとしてVisibility = falseで見つけました。このアクションは2017年に廃止されましたか、または設定でこのアクションを表示/非表示する設定がありますか?

+0

私はアクションが自動化ステップ(v6.x)からv2017の実際のソースコードに移動されたと考えています。その移動中に、フィールド修飾子が保護されているかプライベートになっているため、グラフや何かをその行に沿って拡張すると消えます。新しい2017バージョンにアップグレードするまで、グラフ拡張にそのアクションハンドラを追加することをお勧めします。 –

答えて

0

そのアクションが実際に画面上に表示されていない初期の2017年バージョンの既知のバグがあります:

enter image description here

このバグは、最新の2017のバージョンで修正されなければなりません。その間の回避策は、そのアクションをSOShipmentEntryグラフ拡張で再定義することです。

[PXUIField(DisplayName = "Update IN", Visible = false, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)] 
[PXButton] 
protected virtual IEnumerable updateIN(PXAdapter adapter, List<SOShipment> shipmentList = null) 
{ 
    List<SOShipment> list = new List<SOShipment>(); 
    if (shipmentList == null) 
    { 
     foreach (SOShipment order in adapter.Get<SOShipment>()) 
     { 
      list.Add(order); 
     } 
    } 
    else 
    { 
     list = shipmentList; 
    } 

    if (!Base.UnattendedMode && sosetup.Current.UseShippedNotInvoiced != true && sosetup.Current.UseShipDateForInvoiceDate != true && list.Any(shipment => 
    { 
     IReadOnlyDictionary<string, object> fills = PXAutomation.GetFills(shipment); 
     object fillStatus = null; 
     fills?.TryGetValue(typeof(SOShipment.status).Name, out fillStatus); 
     return shipment.Status != SOShipmentStatus.Completed && fillStatus?.ToString() != SOShipmentStatus.Completed; 
    })) 
    { 
     WebDialogResult result = Base.Document.View.Ask(Base.Document.Current, PX.Objects.GL.Messages.Confirmation, 
      PX.Objects.SO.Messages.ShipNotInvoicedUpdateIN, MessageButtons.YesNo, MessageIcon.Question); 
     if (result != WebDialogResult.Yes) 
      return list; 
    } 

    Base.Save.Press(); 

    PXLongOperation.StartOperation(this, delegate() 
    { 
     INIssueEntry ie = PXGraph.CreateInstance<INIssueEntry>(); 
     SOShipmentEntry docgraph = PXGraph.CreateInstance<SOShipmentEntry>(); 

     docgraph.Caches[typeof(SiteStatus)] = ie.Caches[typeof(SiteStatus)]; 
     docgraph.Caches[typeof(LocationStatus)] = ie.Caches[typeof(LocationStatus)]; 
     docgraph.Caches[typeof(LotSerialStatus)] = ie.Caches[typeof(LotSerialStatus)]; 
     docgraph.Caches[typeof(SiteLotSerial)] = ie.Caches[typeof(SiteLotSerial)]; 
     docgraph.Caches[typeof(ItemLotSerial)] = ie.Caches[typeof(ItemLotSerial)]; 

     docgraph.Views.Caches.Remove(typeof(SiteStatus)); 
     docgraph.Views.Caches.Remove(typeof(LocationStatus)); 
     docgraph.Views.Caches.Remove(typeof(LotSerialStatus)); 
     docgraph.Views.Caches.Remove(typeof(SiteLotSerial)); 
     docgraph.Views.Caches.Remove(typeof(ItemLotSerial)); 

     DocumentList<INRegister> created = new DocumentList<INRegister>(docgraph); 

     foreach (SOShipment order in list) 
     { 
      try 
      { 
       if (adapter.MassProcess) PXProcessing<SOShipment>.SetCurrentItem(order); 
       docgraph.PostShipment(ie, order, created); 
      } 
      catch (Exception ex) 
      { 
       if (!adapter.MassProcess) 
       { 
        throw; 
       } 
       PXProcessing<SOShipment>.SetError(ex); 
      } 
     } 

     if (docgraph.sosetup.Current.AutoReleaseIN == true && created.Count > 0 && created[0].Hold == false) 
     { 
      INDocumentRelease.ReleaseDoc(created, false); 
     } 
    }); 

    return list; 
} 
+0

このバグはv6.xには影響しません。2017バージョンのほんの一部にしか影響せず、バージョンで修正済みとマークされています。 17.203.0011; 17.204.0013.0001; 17.205.0005; 18.091.0009; 18.091.0024 –

+0

これは、2017年の行動を見ていないという質問に答えています。私は彼らが行動を取っているのを見ましたが、visible = falseです。私が知る必要があるのは、そのアクションまたはオートメーション、バージョン6にあるものをどのように呼び出すことができるかです。提案はありますか? –

+0

現在の2017バージョンでは表示できません。問題は可視性ではなくアクセス修飾子です。だからこそ、私の答えで説明したように、アクションハンドラを再定義するのがこの回避策です。その他のオプションは、ダウングレードまたはアップグレードすることです。 –

関連する問題