コード例 #1
0
        public HttpResponseMessage ActivitiesAndGroups(DateTimeOffset? fromTime, DateTimeOffset? toTime)
        {
            var timeline = new TimelineDto();

            if (fromTime.HasValue && toTime.HasValue && fromTime < toTime)
            {
                var group = new GroupDto();
                group.Color = HelperFunctions.GetRandomColor();
                group.DisplayName = "My Group";
                group.DisplayKey = "MyGroup";
                group.GroupId = "1";

                var activity = new ActivityDto();
                activity.StartTime = new DateTimeOffset(fromTime.Value.Year, fromTime.Value.Month, fromTime.Value.Day, 12, 0, 0, fromTime.Value.Offset);
                activity.EndTime = activity.StartTime.AddHours(1);
                activity.DisplayName = "My activity";
                activity.GroupId = group.GroupId;

                timeline.Activities = new[] { activity };
                timeline.Groups = new[] { group };
                timeline.Color = HelperFunctions.GetRandomColor();
            }

            return new HttpResponseMessage()
            {
                Content = new StringContent(HelperFunctions.ToXml(timeline), Encoding.UTF8, "application/xml")
            };
        }
コード例 #2
0
        public HttpResponseMessage OnlyTimes(DateTimeOffset? fromTime, DateTimeOffset? toTime)
        {
            var timeline = new TimelineDto();

            if (fromTime.HasValue && toTime.HasValue && fromTime < toTime)
            {
                var activity = new ActivityDto();
                activity.StartTime = new DateTimeOffset(fromTime.Value.Year, fromTime.Value.Month, fromTime.Value.Day, 12, 0, 0, fromTime.Value.Offset);
                activity.EndTime = activity.StartTime.AddHours(1);

                timeline.Activities = new[] { activity };
            }

            return new HttpResponseMessage()
            {
                Content = new StringContent(HelperFunctions.ToXml(timeline), Encoding.UTF8, "application/xml")
            };
        }