简体   繁体   English

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

[英]How to get Discount Start and End Date from Commerce Server?

I am trying to retrieve the start and end date of a discount using Microsoft Commerce Server, server side code. 我正在尝试使用Microsoft Commerce Server服务器端代码检索折扣的开始和结束日期。 How can this be achieved? 如何做到这一点? The only data I am stuck with is the promo code "TEST". 我遇到的唯一数据是促销代码“ TEST”。 There are not a lot of code samples on how I can just create the Discount object or CampaignItem object and set the promo code to retrieve its properties. 关于如何直接创建Discount对象或CampaignItem对象并设置促销代码以检索其属性的代码示例并不多。 Please help. 请帮忙。

The following code snippet demonstrates how to get the StartDate and EndDate for a Commerce Server Discount . 以下代码段演示了如何获取Commerce Server DiscountStartDateEndDate This assumes you are using the Commerce Server 2007 API and that you know the ID of the discount you want the dates from. 这假定您使用的是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;

Note: The MarketingContext.Create overload, returns a MarketingContext instance that utilises the marketing system management API in local mode . 注意: MarketingContext.Create重载,返回在本地模式下使用营销系统管理API的MarketingContext实例。 For more information on these modes, see Understanding the Different Types of Commerce Server APIs . 有关这些模式的更多信息,请参见了解不同类型的Commerce Server API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在SSRS中获取开始日期和结束日期之间的差的平均值 - How to get the average of the difference between start date and end date in SSRS 如何获取日期时间月份开始和结束日期? - How to get the Date time month start and End Date? 如何使用用户输入的开始日期和结束日期更新结果 - How to update results with start date and end date inputed from user 如何从C#中的日期计算一天的开始和一天的结束 - How to calculate start of day and end of day from a date in c# 从头到尾如何从第 5 次出现“-”中获取所有内容? - From end to start how to get everything from the 5th occurence of "-"? 尝试从Team City Sharp Server获取开始日期 - Trying to get a Start Date from a Team City Sharp Server 如何使用 LIKE % C# 获取开始日期和结束日期 - How can i get the Start Date and End Date with LIKE % C# 如何在C#中获取该年的周开始日期(星期一)和结束日期(星期日)列表 - How to get the list of week start date (Monday) and end date (Sunday) for the year in C# 如何通过指定开始和结束索引从字典中获取一系列项目 - How to get a range of items from dictionary by specifying start and end index 获取给定开始日期,结束日期和星期几的日期 - Get dates given a start date an end date and day of week
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM