internal override bool GetIsFirstItemInScope(int index)
        {
            var pIsFirstItemInScope = false;

            if (index == 0)
            {
                pIsFirstItemInScope = true;
            }
            else
            {
                DateTime date = default;
                int      year = 0;

                date = GetDateAt((uint)index);
                var pCalendar = GetCalendar();
                pCalendar.SetDateTime(date);
                year = pCalendar.Year;

                pIsFirstItemInScope = year % s_decade == 0;

                // "Decade" is a virtual scope which should be less than Era and greater than Year.
                // So a decade scope should not cross Eras.
                // When this year is the first year of this Era, we still look it
                // as the first item in the scope.
                if (!pIsFirstItemInScope)
                {
                    int firstYearInThisEra = 0;
                    firstYearInThisEra  = pCalendar.FirstYearInThisEra;
                    pIsFirstItemInScope = year == firstYearInThisEra;
                }
            }

            return(pIsFirstItemInScope);
        }
        public async Task <bool> SendForProcessing(string cartId, System.DateTimeOffset PurchasedOn, CancellationToken cancellationToken)
        {
            PurchaseItineraryMessage purchaseItineraryMessage = new PurchaseItineraryMessage()
            {
                CartId = cartId, PurchasedOn = PurchasedOn
            };

            List <EventGridEvent> events = new List <EventGridEvent>();

            events.Add(new EventGridEvent()
            {
                Id        = Guid.NewGuid().ToString(),
                EventType = "ContosoTravel.Web.Application.Messages.PurchaseItineraryMessage",
                Data      = new PurchaseItineraryMessage()
                {
                    CartId = cartId
                },
                EventTime   = DateTime.UtcNow,
                Subject     = "PurchaseItinerary",
                DataVersion = "1.0"
            });

            var client = await _eventGridClient;
            await client.PublishEventsAsync(TopicHostName, events, cancellationToken);

            return(true);
        }
        public static int Compare(System.DateTimeOffset first, System.DateTimeOffset second)
        {
            Contract.Ensures(-1 <= Contract.Result <int>());
            Contract.Ensures(Contract.Result <int>() <= 1);

            return(default(int));
        }
Example #4
0
        public void Configure(EntityTypeBuilder <ServiceProduct> builder)
        {
            builder.Property(m => m.Description)
            .HasColumnName("Description")
            .HasMaxLength(2000)
            .IsRequired();

            builder.Property(m => m.LongDescription)
            .HasMaxLength(2000)
            .IsRequired(false);

            builder.Property(m => m.UnitType)
            .IsRequired()
            .HasColumnName("UnitType")
            .HasConversion <byte>();

            builder.Property(m => m.CategoryId)
            .HasColumnName("CategoryId")
            .IsRequired();

            builder.HasOne(m => m.Category)
            .WithMany(m => m.Products)
            .HasForeignKey(m => m.CategoryId)
            .IsRequired();

            var datatime = new System.DateTimeOffset(2020, 10, 18, 13, 36, 00, TimeSpan.FromHours(3));

            builder.HasData(
                new { ProductType = 2, Id = 5, Name = "Azure E03 Virtual Machine", CategoryId = 9, Description = "4VCPU, 8GB Ram Description", LongDescription = "4VCPU, 8GB Ram Long Description", UnitPrice = 0.90, UnitType = ServiceUnitType.Hour, VendorId = 1, CreatedAt = datatime, CreatedBy = -1, ModifiedAt = datatime, ModifiedBy = -1 },
                new { ProductType = 2, Id = 6, Name = "Oracle Cloud V05 Virtual Machine", CategoryId = 9, Description = "4VCPU, 8GB Ram Description", LongDescription = "4VCPU, 8GB Ram Long Description", UnitPrice = 0.85, UnitType = ServiceUnitType.Hour, VendorId = 2, CreatedAt = datatime, CreatedBy = -1, ModifiedAt = datatime, ModifiedBy = -1 },
                new { ProductType = 2, Id = 7, Name = "Body Guard Service", CategoryId = 10, Description = "Body Guard Service Description", LongDescription = "Body Guard Service Long Description", UnitPrice = 150.00, UnitType = ServiceUnitType.Hour, VendorId = 8, CreatedAt = datatime, CreatedBy = -1, ModifiedAt = datatime, ModifiedBy = -1 }
                );
        }
Example #5
0
        private async Task <string> getAccessTokenUsingPasswordGrant()
        {
            JObject jResult       = null;
            String  urlParameters = String.Format(
                "grant_type={0}&resource={1}&client_id={2}&username={3}&password={4}",
                grantType,
                resourceId,
                clientId,
                userName,
                password
                );

            HttpClient client     = new HttpClient();
            var        createBody = new StringContent(urlParameters, System.Text.Encoding.UTF8, contentType);

            HttpResponseMessage response = await client.PostAsync(tokenEndpoint, createBody);

            if (response.IsSuccessStatusCode)
            {
                Task <string> responseTask = response.Content.ReadAsStringAsync();
                responseTask.Wait();
                string responseContent = responseTask.Result;
                jResult = JObject.Parse(responseContent);
            }
            accessToken = (string)jResult["access_token"];

            if (!String.IsNullOrEmpty(accessToken))
            {
                //Set AuthenticationHelper values so that the regular MSAL auth flow won't be triggered.
                tokenForUser = accessToken;
                expiration   = DateTimeOffset.UtcNow.AddHours(5);
            }

            return(accessToken);
        }
Example #6
0
        public async Task UserInfo([Summary("The (optional) user to get info for")] IUser user = null)
        {
            var userInfo = user ?? Context.Client.CurrentUser;

            System.DateTimeOffset guildCreatedAt = new System.DateTimeOffset();
            guildCreatedAt = userInfo.CreatedAt;
            string guildcreated = String.Format("{0:dd/MM/yyyy 'at' h:mm tt}", guildCreatedAt);
            var    userimage    = userInfo.GetAvatarUrl();
            var    game         = userInfo.Game;
            string display;

            if (game == null)
            {
                display = "User isn't playing anything";
            }
            else
            {
                display = game.Value.Name;
            }

            var embed = new EmbedBuilder()
                        .WithColor(new Color(color))
                        .AddInlineField("[Username]", userInfo.Username)
                        .AddInlineField("[Account created]", guildcreated)
                        .AddInlineField("[Currently playing]", display)
                        .AddInlineField("[Status]", userInfo.Status)
                        .WithThumbnailUrl(userimage);

            await Context.Channel.SendMessageAsync("", embed : embed);
        }
 private static DateTime ClampDate(
     DateTime date,
     DateTime minDate,
     DateTime maxDate)
 {
     return(date <minDate?minDate : date> maxDate ? maxDate : date);
 }
Example #8
0
 public Person(
     string name,
     System.DateTimeOffset lastSeen)
 {
     Name     = name;
     LastSeen = lastSeen;
 }
Example #9
0
        public JsonResult GetProcessingReport(System.DateTimeOffset startOfReporting, System.DateTimeOffset endOfReporting)
        {
            if (User.Identity.IsAuthenticated)
            {
                int userId = User.Identity.GetUserId <int>();
                if (userId > 0)
                {
                    try
                    {
                        _logger.Info("{0} {1}\n\tReporting Start: {2}\n\tReporting End: {3}", User.Identity.Name, Request.Url.ToString(), startOfReporting, endOfReporting);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex, "Logging error");
                    }

                    var processingReport = _processingR.GetProcessingReportData(startOfReporting, endOfReporting, userId);

                    return(Json(processingReport, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("Unable to find UserId!"));
                }
            }
            else
            {
                return(Json("Unauthenticated user!"));
            }
        }
Example #10
0
        /// <summary>
        /// List the start times of the available aggregated profiles of a profiling group for an aggregation period within the specified time range.
        /// ListProfileTimes /profilingGroups/{profilingGroupName}/profileTimes#endTime&period&startTime
        /// </summary>
        /// <param name="endTime">The end time of the time range from which to list the profiles.</param>
        /// <param name="maxResults">The maximum number of profile time results returned by <code>ListProfileTimes</code> in paginated output. When this parameter is used, <code>ListProfileTimes</code> only returns <code>maxResults</code> results in a single page with a <code>nextToken</code> response element. The remaining results of the initial request can be seen by sending another <code>ListProfileTimes</code> request with the returned <code>nextToken</code> value. </param>
        /// <param name="nextToken"><p>The <code>nextToken</code> value returned from a previous paginated <code>ListProfileTimes</code> request where <code>maxResults</code> was used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the <code>nextToken</code> value. </p> <note> <p>This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.</p> </note></param>
        /// <param name="orderBy">The order (ascending or descending by start time of the profile) to use when listing profiles. Defaults to <code>TIMESTAMP_DESCENDING</code>. </param>
        /// <param name="period">The aggregation period.</param>
        /// <param name="profilingGroupName">The name of the profiling group.</param>
        /// <param name="startTime">The start time of the time range from which to list the profiles.</param>
        /// <returns>Success</returns>
        public async Task <ListProfileTimesResponse> ListProfileTimesAsync(System.DateTimeOffset endTime, int maxResults, string nextToken, OrderBy orderBy, AggregationPeriod period, string profilingGroupName, System.DateTimeOffset startTime, Action <System.Net.Http.Headers.HttpRequestHeaders> handleHeaders = null)
        {
            var requestUri = "/profilingGroups/" + (profilingGroupName == null? "" : Uri.EscapeDataString(profilingGroupName)) + "/profileTimes#endTime&period&startTime?endTime=" + endTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ") + "&maxResults=" + maxResults + "&nextToken=" + (nextToken == null? "" : Uri.EscapeDataString(nextToken)) + "&orderBy=" + orderBy + "&period=" + period + "&startTime=" + startTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");

            using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
            {
                if (handleHeaders != null)
                {
                    handleHeaders(request.Headers);
                }

                var responseMessage = await client.SendAsync(request);

                try
                {
                    responseMessage.EnsureSuccessStatusCodeEx();
                    var stream = await responseMessage.Content.ReadAsStreamAsync();

                    using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream)))
                    {
                        var serializer = new JsonSerializer();
                        return(serializer.Deserialize <ListProfileTimesResponse>(jsonReader));
                    }
                }
                finally
                {
                    responseMessage.Dispose();
                }
            }
        }
Example #11
0
 internal News(string topic, date stamp, string sender, string detail) : base(2)
 {
     Topic  = topic;
     Stamp  = stamp;
     Sender = sender ?? "";
     Detail = detail ?? "";
 }
Example #12
0
        public void Overlaps(
            [IncludeDataSources(true, TestProvName.AllOracle /* TestProvName.AllPostgreSQL, ProviderName.DB2 */)] string context)
        {
            // Postgre and DB2 have support but needs to know the type of parameters explicitely,
            // so this test wouldn't work without adding casts at every constant.

            using var db   = GetDataContext(context);
            using var ints = SetupIntsTable(db);

            // OVERLAPS is neither client-evaluated, nor converted in providers without native support.
            // So tests are short because we don't want to test all edge cases of provider implementation.
            // We simply want to check if valid SQL is generated for all basic support types

            ints.Count(i => Row(DT.Parse("2020-10-01"), DT.Parse("2020-10-05"))
                       .Overlaps(Row(DT.Parse("2020-10-03"), DT.Parse("2020-11-09"))))
            .Should().Be(1);

            ints.Count(i => Row(DTO.Parse("2020-10-05"), DTO.Parse("2020-10-01"))
                       .Overlaps(Row(DTO.Parse("2020-10-03"), DTO.Parse("2020-11-09"))))
            .Should().Be(1);

            ints.Count(i => Row(DT.Parse("2020-10-03"), TimeSpan.Parse("6"))
                       .Overlaps(Row(DT.Parse("2020-10-05"), TimeSpan.Parse("1"))))
            .Should().Be(1);

            ints.Count(i => Row(DT.Parse("2020-10-03"), TimeSpan.Parse("6"))
                       .Overlaps(Row(DT.Parse("2020-10-05"), (TimeSpan?)null)))
            .Should().Be(1);
        }
Example #13
0
        /// <summary>
        /// Converts the serializable named value into a normal named value
        /// </summary>
        /// <param name="serializableNamedValue">The serializable named value</param>
        /// <returns>The value, but in types common to the rest of Taupo</returns>
        public NamedValue Convert(SerializableNamedValue serializableNamedValue)
        {
            ExceptionUtilities.CheckArgumentNotNull(serializableNamedValue, "serializableNamedValue");
            var value = serializableNamedValue.Value;

#if WIN8
            var dateTimeOffsetValue = value as Microsoft.Test.Taupo.Astoria.Contracts.WebServices.DataOracleService.Win8.DateTimeOffset;
            if (dateTimeOffsetValue != null)
            {
                value = new System.DateTimeOffset(dateTimeOffsetValue.DateTime.Year,
                                                  dateTimeOffsetValue.DateTime.Month,
                                                  dateTimeOffsetValue.DateTime.Day,
                                                  dateTimeOffsetValue.DateTime.Hour,
                                                  dateTimeOffsetValue.DateTime.Minute,
                                                  dateTimeOffsetValue.DateTime.Second,
                                                  TimeSpan.FromMinutes(dateTimeOffsetValue.OffsetMinutes));
            }
#endif
            var spatialValue = value as SerializableSpatialData;
            if (spatialValue != null)
            {
                ExceptionUtilities.CheckObjectNotNull(this.SpatialFormatter, "Cannot convert spatial data without SpatialFormatter dependency being set");

                var spatialTypeKind = SpatialUtilities.InferSpatialTypeKind(spatialValue.BaseTypeName);
                value = this.SpatialFormatter.Parse(spatialTypeKind, spatialValue.WellKnownTextRepresentation);
            }
            else if (value is SerializableEmptyData)
            {
                value = EmptyData.Value;
            }

            return(new NamedValue(serializableNamedValue.Name, value));
        }
Example #14
0
 public void Set <T>(string key, T data, System.DateTimeOffset absoluteExpiration, params string[] dependentFiles)
 {
     if (this.RegisterMoniter(key, dependentFiles))
     {
         this.Set <T>(key, data, absoluteExpiration);
     }
 }
Example #15
0
        protected override void OnConfirmed()
        {
            DateTime oldDateTime = default;
            DateTime newDateTime = default;

            //DatePickedEventArgs spArgs;
            //DependencyObject spBoxedDateTime;
            //DateTime spBoxedDtAsReference;

            oldDateTime = Date;
            newDateTime = _tpPresenter.GetDate();
            Date        = newDateTime;
            //Private.ValueBoxer.CreateDateTime(newDateTime, &spBoxedDateTime);
            //spBoxedDateTime.As(spBoxedDtAsReference);
            _asyncOperationManager.Complete(newDateTime);
            //wrl.MakeAndInitialize<xaml_controls.DatePickedEventArgs>(spArgs);
            //spArgs.OldDate = oldDateTime;
            //spArgs.NewDate = newDateTime;
            //m_DatePickedEventSource.InvokeAll(this, spArgs);
            //DatePickerFlyoutGenerated.OnConfirmedImpl();
            // Cleanup
            // return hr;

            _datePicked?.Invoke(this, new DatePickedEventArgs(newDateTime, oldDateTime));

            Close();
        }
Example #16
0
        public void Set <T>(string key, T data, System.DateTimeOffset absoluteExpiration, string regionName = null)
        {
            CacheItem       item   = new CacheItem(key, data, regionName);
            CacheItemPolicy policy = new CacheItemPolicy();

            policy.AbsoluteExpiration = absoluteExpiration;
            Set(item, policy);
        }
Example #17
0
 public TodoItem(string title, string description, DateTimeOffset datetime)
 {
     this.id          = Guid.NewGuid().ToString();
     this.title       = title;
     this.description = description;
     this.completed   = false;
     this.datetime    = datetime;
 }
Example #18
0
        public object AddOrGetExisting(string key, object value, System.DateTimeOffset absoluteExpiration, string regionName = null)
        {
            CacheItem       item   = new CacheItem(key, value, regionName);
            CacheItemPolicy policy = new CacheItemPolicy();

            policy.AbsoluteExpiration = absoluteExpiration;
            return(AddOrGetExisting(item, policy));
        }
Example #19
0
        public async Task <bool> SendForProcessing(string cartId, System.DateTimeOffset PurchasedOn, CancellationToken cancellationToken)
        {
            await Task.Delay(_random.Next(0, 30) * 1000);

            string recordId = await _fulfillmentService.Purchase(cartId, PurchasedOn, cancellationToken);

            return(!string.IsNullOrEmpty(recordId));
        }
        public static RangeDateTime SinceLocalMidnight()
        {
            var localnow      = System.DateTime.Now;
            var localmidnight = new System.DateTime(localnow.Year, localnow.Month, localnow.Day);
            var lower         = new System.DateTimeOffset(localmidnight);

            return(new RangeDateTime(lower, null));
        }
        public static bool TryParse(string input, out System.DateTimeOffset result)
        {
            Contract.Ensures(false);

            result = default(System.DateTimeOffset);

            return(default(bool));
        }
Example #22
0
        private CalendarViewDayItem GetContainerByDate(
            DateTime datetime)
        {
            CalendarViewDayItem ppItem = null;

            var pMonthpanel = m_tpMonthViewItemHost.Panel;

            if (pMonthpanel is {})
        public void GetFromTimeToTime_Test()
        {
            var returnList = new List <DotNetMetric>();

            mock.Setup(repository => repository.GetFromTimeToTime(It.IsAny <DateTimeOffset>().ToUnixTimeSeconds(), It.IsAny <DateTimeOffset>().ToUnixTimeSeconds())).Returns(returnList);
            IActionResult result = controller.GetFromTimeToTime(DateTimeOffset.FromUnixTimeSeconds(10), DateTimeOffset.FromUnixTimeSeconds(20));

            mock.Verify(repository => repository.GetFromTimeToTime(10, 20), Times.AtLeastOnce());
        }
Example #24
0
 // 添加了形参 System.DateTimeOffset set_day,用来表示用户设置的时间
 public TodoItem(string title, string description, System.DateTimeOffset set_day)
 {
     this.id          = Guid.NewGuid().ToString();
     this.title       = title;
     this.description = description;
     this.completed   = false; //默认为未完成
     this.day         = set_day;
     this.date        = set_day.ToString();
 }
        public override System.Web.Mvc.ActionResult GetAppointmentsForBol(System.DateTimeOffset start, System.DateTimeOffset end)
        {
            var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.GetAppointmentsForBol);

            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "start", start);
            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "end", end);
            GetAppointmentsForBolOverride(callInfo, start, end);
            return(callInfo);
        }
        public override void Append(DateTime item)
        {
            RaiseCollectionChanging(CollectionChanging.ItemInserting, item);

            m_addedDates.Add(item);

            base.Append(item);
            return;
        }
Example #27
0
        /// <summary>
        /// Represents a column in the select statement.
        /// </summary>
        /// <param name="arg">Is a value.</param>
        public Column(System.DateTimeOffset arg)
            : base(arg)
        {
            Build = (buildContext, buildArgs) =>
            {
                return(BuildClr(arg, buildContext));
            };

            SetArgType(arg);
        }
Example #28
0
        internal ScalarArgument(System.DateTimeOffset arg)
            : base(arg)
        {
            Build = (buildContext, buildArgs) =>
            {
                return(BuildClr(arg, buildContext));
            };

            SetArgType(arg);
        }
Example #29
0
 public void Set <T>(string key, T data)
 {
     System.DateTimeOffset absoluteExpiration = DateTimeOffset.Now.AddMonths(1);
     //Set(key, data, absoluteExpiration);
     //if (data != null)
     if (!Equals(data, default(T)))
     {
         Set <T>(key, data, absoluteExpiration);
     }
 }
        public override void InsertAt(uint index, DateTime item)
        {
            RaiseCollectionChanging(CollectionChanging.ItemInserting, item);

            m_addedDates.Add(item);

            base.InsertAt(index, item);

            return;
        }
        public void ThenTheScheduleShouldBeInvokedOnlyOnAt(string date, string time)
        {
            var cronExpression = ScenarioContext.Current.Get<CronExpression>("cronExpression");

            var target = System.DateTimeOffset.Parse(time + " " + date);

            var dt = new System.DateTimeOffset(2000, 1, 1, 0, 0, 0, 0, new TimeSpan(0));
            var next = cronExpression.GetNextValidTimeAfter(dt);

            // ReSharper disable PossibleInvalidOperationException
            Assert.True(next.HasValue);
            Assert.Equal(target, next);
            next = cronExpression.GetNextValidTimeAfter(next.Value);
            // ReSharper restore PossibleInvalidOperationException
            Assert.Null(next);
        }
        /// <summary>
        /// Converts the serializable named value into a normal named value
        /// </summary>
        /// <param name="serializableNamedValue">The serializable named value</param>
        /// <returns>The value, but in types common to the rest of Taupo</returns>
        public NamedValue Convert(SerializableNamedValue serializableNamedValue)
        {
            ExceptionUtilities.CheckArgumentNotNull(serializableNamedValue, "serializableNamedValue");
            var value = serializableNamedValue.Value;
#if WIN8
            var dateTimeOffsetValue = value as Microsoft.Test.Taupo.Astoria.Contracts.WebServices.DataOracleService.Win8.DateTimeOffset;
            if (dateTimeOffsetValue != null)
            {
                value = new System.DateTimeOffset(dateTimeOffsetValue.DateTime.Year,
                    dateTimeOffsetValue.DateTime.Month,
                    dateTimeOffsetValue.DateTime.Day,
                    dateTimeOffsetValue.DateTime.Hour,
                    dateTimeOffsetValue.DateTime.Minute,
                    dateTimeOffsetValue.DateTime.Second,
                    TimeSpan.FromMinutes(dateTimeOffsetValue.OffsetMinutes));
            }
#endif
            var spatialValue = value as SerializableSpatialData;
            if (spatialValue != null)
            {
                ExceptionUtilities.CheckObjectNotNull(this.SpatialFormatter, "Cannot convert spatial data without SpatialFormatter dependency being set");

                var spatialTypeKind = SpatialUtilities.InferSpatialTypeKind(spatialValue.BaseTypeName);
                value = this.SpatialFormatter.Parse(spatialTypeKind, spatialValue.WellKnownTextRepresentation);
            }
            else if (value is SerializableEmptyData)
            {
                value = EmptyData.Value;
            }

            return new NamedValue(serializableNamedValue.Name, value);
        }