コード例 #1
0
        /// <summary>
        /// This method is used to command the SmartBlue application to set the date of an editable control to the specified value.
        /// </summary>
        /// <param name="id">
        /// The ID of the item, whose value shall be set.
        /// </param>
        /// <param name="value">New value</param>
        public void SetDateValue(string id, string value)
        {
            // method entry log message
            // this.log.Trace("SetDateValue(...) - running...");

            // start stop watch for execution time measurement
            var executionTimeStopWatch = new Stopwatch();

            executionTimeStopWatch.Start();

            // create uri
            var uri = this.uriCreator.GetAppComInterfaceUri();

            // create message
            DateTime dateTimeValue;
            var      isSucceed = DateTime.TryParseExact(value, DateFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeValue);

            if (isSucceed)
            {
                var appComMessage = RequestCreator.CreateSetDateValueRequest(id, dateTimeValue);

                // send message
                this.appComProtocolLayer.Post(uri.ToString(), appComMessage);
            }
            else
            {
                var errorMessage = string.Format("Cannot parse date string '{0}'. Check format.", value);
                // this.log.Error("SetDateValue(...) - {0}", errorMessage);
                throw new TDDException(errorMessage);
            }

            // method exit log message
            // this.log.Debug("SetDateValue(...) - duration = {0} ms", executionTimeStopWatch.ElapsedMilliseconds);
            // this.log.Trace("SetDateValue(...) - done");
        }