ListAttribute.GetLocalizedLabel関数を使用して文字列リストからテキストラベルを返す際に、「指定されたキーが辞書に存在しませんでした」というエラーが発生しています。興味深いのは、エラーはたぶん1/5の時間に起こるだけで、それは2回おきに動作するということです。Acumatica GetLocalizedLabelメソッドがキーに実行されていることがある
添付のスクリーンショットに見られるように、コードでエラーがスローされましたが、非常に同じコードがウォッチウィンドウで完全に正常に動作することがわかります。
リスト属性のスニペット: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を実行するか、他の方法で行ってもかまいません。
迅速な対応と、より良いデバッグに役立つ情報をお寄せいただきありがとうございます。 pxStringListAttribute.ValueLabelDicは0のカウントを返していますが、許可されたラベルにはすべてのラベルが含まれているようです。現在のキーは、リスト属性の100%の値です。リストアトリビュートがValueLabelDicに項目を持たない理由についての他のアイデアはありますか?他のコードと同じように、ほとんどの場合動作し、いくつかの試行の後にのみ壊れます。私の説明では説明されていないことは、この関数が長時間実行されている操作から呼び出されていることです。 – Chris
失敗した場所で許可されている値をチェックしてください:foreach(新しいPCMConstants.DeliveryStatus.ListAttribute()。GetAllowedValues(sender)の文字列値)PXTrace.WriteInformation(value); –
私はまた、[PXDBString]属性の長さも指定します。通常、すべてのキーは同じ長さです。 –