2017-08-04 1 views
0

ListAttribute.GetLocalizedLabel関数を使用して文字列リストからテキストラベルを返す際に、「指定されたキーが辞書に存在しませんでした」というエラーが発生しています。興味深いのは、エラーはたぶん1/5の時間に起こるだけで、それは2回おきに動作するということです。Acumatica GetLocalizedLabelメソッドがキーに実行されていることがある

添付のスクリーンショットに見られるように、コードでエラーがスローされましたが、非常に同じコードがウォッチウィンドウで完全に正常に動作することがわかります。

enter image description here

リスト属性のスニペット:DACフィールドの

public partial class DeliveryStatus 
    { 

     public class ListAttribute : PXStringListAttribute 
     { 
      public ListAttribute() 
       : base(
       new string[] { PendingSchedule, Scheduled, Invoiced, Paid, AddressingInProgress, PrintingInProgress, Delivered, AwaitingMailInstructions, Canceled, Stalled, MergeProofInProgress, MergeProofReceived, MergeProofApproval, ReadyToMail, MailingChangesNeeded, PendingDelivery, MergeProofNeedsChanges, PendingSupervisorApproval, PreMailing, PendingXMPieConfig, PendingMergeProofQual, ScheduledWithChanges, PendingXXXing, PreparingShipment, PreparingPickup, PendingRecyle, InvoicedOkToCharge, PendingAutoProcess, PendingEnvelopeAddressing }, 
       new string[] { PendingScheduleLabel, ScheduledLabel, InvoicedLabel, PaidLabel, AddressingInProgressLabel, PrintingInProgressLabel, DeliveredLabel, AwaitingMailInstructionsLabel, CanceledLabel, StalledLabel, MergeProofInProgressLabel, MergeProofReceivedLabel, MergeProofApprovalLabel, ReadyToMailLabel, MailingChangesNeededLabel, PendingDeliveryLabel, MergeProofNeedsChangesLabel, PendingSupervisorApprovalLabel, PreMailingLabel, PendingXMPieConfigLabel, PendingMergeProofQualLabel, ScheduledWithChangesLabel, PendingXXXingLabel, PreparingShipmentLabel, PreparingPickupLabel, PendingRecyleLabel, InvoicedOkToChargeLabel, PendingAutoProcessLabel, PendingEnvelopeAddressingLabel }) { } 
     } 

スニペット:

#region Status   
    [PXDBString] 
    [PCMConstants.DeliveryStatus.List()] 
    [PXDefault(PCMConstants.DeliveryStatus.PendingSchedule, PersistingCheck = PXPersistingCheck.Nothing)] 
    [PXUIField(DisplayName = "Status")] 
    public string Status { get; set; } 
    public class status : IBqlField { } 
    #endregion 

UPDATE:HB_ACUMATICAで働いた後、私は、コード当社ことを決定することができました私たちのニーズには過労です。文字列リスト内の特定のキーのテキストラベルが何であるかを把握するだけでした。 DictionaryLabelDic = new PCMConstants.DeliveryStatus.ListAttribute()。ValueLabelDic;を使用してキャッシュを使用せずにこれを実現できます。 TryGetValueを実行するか、他の方法で行ってもかまいません。

答えて

0

同じコードGetLocalizedLabelが実行でしょう使用して、それをデバッグしよう:

protected virtual void UsrDeliveryRequest_RowSelected(PXCache sender, PXRowSelectedEventArgs e) 
{ 
    if (e.Row == null) return; 

    PXStringListAttribute pxStringListAttribute = sender.GetAttributesReadonly<UsrDeliveryRequest.status>(e.Row).OfType<PXStringListAttribute>().Single(); 
    string key = (string)sender.GetValue<UsrDeliveryRequest.status>(e.Row); 

    if (pxStringListAttribute.ValueLabelDic.ContainsKey(key)) 
     PXTrace.WriteInformation(PXMessages.LocalizeNoPrefix(pxStringListAttribute.ValueLabelDic[key])); 
    else 
     PXTrace.WriteInformation("Missing Key, if current UsrDeliveryRequest.Status is valid it should be included in ValueLabelDic."); 
} 

私の推測では、それがクラッシュしたときUsrDeliveryRequest.Statusが含まれていない値を持っていることである。

new string[] { PendingSchedule, Scheduled, Invoiced, Paid, AddressingInProgress, PrintingInProgress, Delivered, AwaitingMailInstructions, Canceled, Stalled, MergeProofInProgress, MergeProofReceived, MergeProofApproval, ReadyToMail, MailingChangesNeeded, PendingDelivery, MergeProofNeedsChanges, PendingSupervisorApproval, PreMailing, PendingXMPieConfig, PendingMergeProofQual, ScheduledWithChanges, PendingXXXing, PreparingShipment, PreparingPickup, PendingRecyle, InvoicedOkToCharge, PendingAutoProcess, PendingEnvelopeAddressing } 

あなたはStatus値が許可されたキーリストにない場合、ラベルを取得するのを避けるべきです。 SetListを使用してリストに追加するか、nullなどの特別な場合には無視します。

+0

迅速な対応と、より良いデバッグに役立つ情報をお寄せいただきありがとうございます。 pxStringListAttribute.ValueLabelDicは0のカウントを返していますが、許可されたラベルにはすべてのラベルが含まれているようです。現在のキーは、リスト属性の100%の値です。リストアトリビュートがValueLabelDicに項目を持たない理由についての他のアイデアはありますか?他のコードと同じように、ほとんどの場合動作し、いくつかの試行の後にのみ壊れます。私の説明では説明されていないことは、この関数が長時間実行されている操作から呼び出されていることです。 – Chris

+0

失敗した場所で許可されている値をチェックしてください:foreach(新しいPCMConstants.DeliveryStatus.ListAttribute()。GetAllowedValues(sender)の文字列値)PXTrace.WriteInformation(value); –

+0

私はまた、[PXDBString]属性の長さも指定します。通常、すべてのキーは同じ長さです。 –

関連する問題