Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从Commerce Server获取折扣开始和结束日期?_C#_Asp.net_E Commerce_Commerce - Fatal编程技术网

C# 如何从Commerce Server获取折扣开始和结束日期?

C# 如何从Commerce Server获取折扣开始和结束日期?,c#,asp.net,e-commerce,commerce,C#,Asp.net,E Commerce,Commerce,我正在尝试使用Microsoft Commerce Server服务器端代码检索折扣的开始和结束日期。如何做到这一点?我唯一的数据就是促销代码“TEST”。关于如何创建折扣对象或活动项目对象并设置促销代码以检索其属性,没有太多代码示例。请提供帮助。下面的代码片段演示了如何为商务服务器折扣获取开始日期和结束日期。这假设您使用的是Commerce Server 2007 API,并且您知道希望从中获取日期的折扣的ID //The discount id we want to get dates fr

我正在尝试使用Microsoft Commerce Server服务器端代码检索折扣的开始和结束日期。如何做到这一点?我唯一的数据就是促销代码“TEST”。关于如何创建折扣对象或活动项目对象并设置促销代码以检索其属性,没有太多代码示例。请提供帮助。

下面的代码片段演示了如何为商务服务器
折扣
获取
开始日期和
结束日期。这假设您使用的是Commerce Server 2007 API,并且您知道希望从中获取日期的折扣的ID

//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
重载,返回在本地模式下使用营销系统管理API的
MarketingContext
实例。有关这些模式的更多信息,请参阅。

您似乎在询问折扣的开始和结束日期,但随后说您无法获得促销代码属性。你能澄清你的问题吗?目标是从Commerce Server获取折扣开始日期和结束日期属性,但要做到这一点,我不确定应该使用什么方法来创建获取这些属性所需的对象OK。您使用的是Commerce Server 2007 API还是Commerce Server 2009?是否有办法通过促销代码名称(即TENOFF)获取折扣?或者它有折扣id吗?你可以通过API来实现,尽管这会很冗长。您喜欢使用直接SQL吗?如果是这样,您可以在这里尝试解决方案