/// <summary>
        /// Adds a new DateTime value to the list of query parameters.
        /// </summary>
        /// <param name="key">The parameter name.</param>
        /// <param name="value">The parameter value.</param>
        /// <returns>The statement builder, for chaining method calls.</returns>
        public StatementBuilder AddValue(string key, DateTime value)
        {
            DateTimeValue queryValue = new DateTimeValue();

            queryValue.value = value;
            return(AddValue(key, queryValue));
        }
 /// <summary>
 /// Converts a System.DateTime object to a date object.
 /// </summary>
 /// <param name="dateTime">The DateTime object.</param>
 /// <returns>A Dfp Datetime object.</returns>
 public static DfpDateTime FromDateTime(System.DateTime dateTime) {
   DfpDateTime retval = new DfpDateTime();
   retval.date = new Date();
   retval.date.year = dateTime.Year;
   retval.date.month = dateTime.Month;
   retval.date.day = dateTime.Day;
   retval.hour = dateTime.Hour;
   retval.minute = dateTime.Minute;
   retval.second = dateTime.Second;
   return retval;
 }
Пример #3
0
        private static bool DateTimeValuesAreEqual(Value value1, Value value2)
        {
            DateTime dateTime1 = (value1 as DateTimeValue).value;
            DateTime dateTime2 = (value2 as DateTimeValue).value;

            return(DatesAreEqual(dateTime1.date, dateTime2.date) &&
                   dateTime1.hour == dateTime2.hour &&
                   dateTime1.minute == dateTime2.minute &&
                   dateTime1.second == dateTime2.second &&
                   String.Equals(dateTime1.timeZoneID, dateTime2.timeZoneID));
        }
        /// <summary>
        /// Converts a System.DateTime object to a date object.
        /// </summary>
        /// <param name="dateTime">The DateTime object.</param>
        /// <returns>A Dfp Datetime object.</returns>
        public static DfpDateTime FromDateTime(System.DateTime dateTime)
        {
            DfpDateTime retval = new DfpDateTime();

            retval.date       = new Date();
            retval.date.year  = dateTime.Year;
            retval.date.month = dateTime.Month;
            retval.date.day   = dateTime.Day;
            retval.hour       = dateTime.Hour;
            retval.minute     = dateTime.Minute;
            retval.second     = dateTime.Second;
            return(retval);
        }
Пример #5
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the OrderService.
            LineItemService lineItemService = (LineItemService)user.GetService(
                DfpService.v201405.LineItemService);

            long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));

            // Create statement to only select line items for the given order that
            // have been modified in the last 3 days.
            DateTime         threeDaysAgo     = DateTimeUtilities.FromDateTime(System.DateTime.Now.AddDays(-3));
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .Where("lastModifiedDateTime >= :lastModifiedDateTime AND orderId = :orderId")
                                                .OrderBy("id ASC")
                                                .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
                                                .AddValue("lastModifiedDateTime", threeDaysAgo)
                                                .AddValue("orderId", orderId);

            // Set default for page.
            LineItemPage page = new LineItemPage();

            try {
                do
                {
                    // Get line items by statement.
                    page = lineItemService.getLineItemsByStatement(statementBuilder.ToStatement());

                    // Display results.
                    if (page != null && page.results != null)
                    {
                        foreach (LineItem lineItem in page.results)
                        {
                            Console.WriteLine("Line item with id \"{0}\", belonging to order id \"{1}\" and " +
                                              "named \"{2}\" was found.", lineItem.id, lineItem.orderId, lineItem.name);
                        }
                    }
                    statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
                } while(statementBuilder.GetOffset() < page.totalResultSetSize);

                Console.WriteLine("Number of results found: {1}.", page.totalResultSetSize);
            } catch (Exception ex) {
                Console.WriteLine("Failed to get line items. Exception says \"{0}\"", ex.Message);
            }
        }
 /// <summary>
 /// Adds a new DateTime value to the list of query parameters.
 /// </summary>
 /// <param name="key">The parameter name.</param>
 /// <param name="value">The parameter value.</param>
 /// <returns>The statement builder, for chaining method calls.</returns>
 public StatementBuilder AddValue(string key, DateTime value) {
   DateTimeValue queryValue = new DateTimeValue();
   queryValue.value = value;
   return AddValue(key, queryValue);
 }