使用我嘗試使用client.create
貨幣的ExchangeRateServiceClient
每次貨幣代碼對我得到一個異常如何更新現有的匯率
無法建立匯率貨幣對(ExchangeRateCurrencyPair)的記錄。從貨幣:美元,歐元。記錄已經存在。
System.Exception的{} System.ServiceModel.FaultException
我全新的AX API ...我使用C#
AXDev09.ExchangeRateServiceCreateRequest request =
new AXDev09.ExchangeRateServiceCreateRequest();
AXDev09.ExchangeRateServiceClient client = new AXDev09.ExchangeRateServiceClient();
request.CallContext = new AXDev09.CallContext();
request.CallContext.Language = "en-us";
request.CallContext.Company = "T51";
request.CallContext.MessageId = Guid.NewGuid().ToString();
AXDev09.AxdEntity_CurrencyPair[] myPair = new AXDev09.AxdEntity_CurrencyPair[1];
myPair[0] = new AXDev09.AxdEntity_CurrencyPair();
myPair[0].ToCurrencyCode = "EUR";
myPair[0].FromCurrencyCode = "USD";
AXDev09.AxdEntity_ExchangeRate[] myExchange = new AXDev09.AxdEntity_ExchangeRate[1];
myExchange[0] = new AXDev09.AxdEntity_ExchangeRate();
myExchange[0].ExchangeRate = Convert.ToDecimal("0.708");
myExchange[0].ExchangeRateSpecified = true;
myPair[0].ExchangeRate = myExchange;
myPair[0].ExchangeRateDisplayFactor = AXDev09.AxdEnum_ExchangeRateDisplayFactor.One;
myPair[0].ExchangeRateType = "Average";
AxdType_DateTime myFromDate = new AxdType_DateTime();
myFromDate.localDateTime = DateTime.Now.ToUniversalTime();
myFromDate.timezone = AxdEnum_Timezone.GMTMINUS0600CENTRALTIME;
myFromDate.Value = myFromDate.localDateTime;
AxdType_DateTime myToDate = new AxdType_DateTime();
myToDate.localDateTime = DateTime.Now.ToUniversalTime();
myToDate.timezone = AxdEnum_Timezone.GMTMINUS0600CENTRALTIME;
myToDate.Value = myToDate.localDateTime;
request.LedgerExchangeRate = new AXDev09.AxdLedgerExchangeRate();
request.LedgerExchangeRate.CurrencyPair = myPair;
request.LedgerExchangeRate.ValidFromDateTime = myFromDate;
request.LedgerExchangeRate.ValidToDateTime = myToDate;
client.Open();
client.create(request.CallContext, request.LedgerExchangeRate);
client.Close();
謝謝你的回答...我想要做的是用新的匯率(0.708)更新現有的ExchangeRateCurrencyPair ... – user3109074
顯示你的代碼。 –
這是爲我們公司使用AX類庫的摘要而創建的類,所以我不認爲我們可以直接實例化它們......我在TechNet上查看AX庫,並且有Update方法。所以我需要那個?我認爲你可以創建一個新的交換對與一個不同的從到日期對,所以這就是爲什麼我想創建。 – user3109074