0

我正在尝试使用 Microsoft Commerce Server 服务器端代码检索折扣的开始和结束日期。如何做到这一点?我唯一坚持的数据是促销代码“TEST”。关于如何创建 Discount 对象或 CampaignItem 对象并设置促销代码以检索其属性的代码示例并不多。请帮忙。

4

1 回答 1

1

以下代码片段演示了如何获取Commerce Server的StartDate和。这假定您使用的是 Commerce Server 2007 API,并且您知道要从中获得日期的折扣的 ID。EndDateDiscount

//The discount id we want to get dates from.
var discountId = 12;//Set to your ID.

//Configure the Commerce Server site name.
var siteName = "StarterSite";

//We need a MarketingContext instance so we can access the marketing API. 
var mc = MarketingContext.Create(siteName, null, AuthorizationMode.NoAuthorization);

//Get our discount.
var discount = (Discount)mc.CampaignItems.GetCampaignItem(discountId);

//Voila.  Start and End dates.
var startDate = discount.StartDate;
var endDate = discount.EndDate;

注意:MarketingContext.Create重载,返回一个在本地模式下MarketingContext使用营销系统管理 API 的实例。有关这些模式的更多信息,请参阅了解不同类型的 Commerce Server API

于 2013-07-23T20:43:47.343 回答