本文整理汇总了C#中DateRange类的典型用法代码示例。如果您正苦于以下问题:C# DateRange类的具体用法?C# DateRange怎么用?C# DateRange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DateRange类属于命名空间,在下文中一共展示了DateRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DateFilter
public DateFilter(Point point)
{
InitializeComponent();
DateRange = new DateRange();
this.Location = point;
panelDtp.Visible = false;
panelMonth.Visible = false;
cbFromMonth.SelectedIndex = 0;
cbToMonth.SelectedIndex = 0;
for (int i = DateTime.Now.Year - 5; i < DateTime.Now.Year + 5; i++)
{
cbFromYear.Items.Add(i);
cbToYear.Items.Add(i);
}
cbFromYear.SelectedIndex = 0;
cbToYear.SelectedIndex = 0;
cbDateFilterType.SelectedIndex = 0;
cbFromYear.SelectedIndexChanged += new System.EventHandler(cbFromYear_SelectedIndexChanged);
cbToYear.SelectedIndexChanged += new System.EventHandler(cbToYear_SelectedIndexChanged);
this.cbToMonth.SelectedIndexChanged += new System.EventHandler(this.cbToMonth_SelectedIndexChanged);
this.cbFromMonth.SelectedIndexChanged += new System.EventHandler(this.cbFromMonth_SelectedIndexChanged);
}
示例2: GenerateUsageReport
private object GenerateUsageReport(IUnitOfWork uow, DateRange dateRange, int start,
int length, out int count)
{
_dataUrlMappings = new Dictionary<string, string>();
_dataUrlMappings.Add("BookingRequest", "/Dashboard/Index/");
_dataUrlMappings.Add("Email", "/Dashboard/Index/");
_dataUrlMappings.Add("User", "/User/Details?userID=");
var factDO = uow.FactRepository.GetQuery().WhereInDateRange(e => e.CreateDate, dateRange);
count = factDO.Count();
return factDO
.OrderByDescending(e => e.CreateDate)
.Skip(start)
.Take(length)
.AsEnumerable()
.Select(
f => new
{
PrimaryCategory = f.PrimaryCategory,
SecondaryCategory = f.SecondaryCategory,
Activity = f.Activity,
Status = f.Status,
Data = AddClickability(f.Data),
CreateDate = f.CreateDate.ToString(DateStandardFormat),
})
.ToList();
}
示例3: ItemCount
public static double ItemCount(CalendarAppointmentItem currentApp, UIElementCollection children)
{
double count = 0;
foreach (UIElement child in children)
{
if (child is CalendarAppointmentItem)
{
var currentChild = child as CalendarAppointmentItem;
var cStart = currentApp.GetValue(TimeSlotPanel.StartTimeProperty) as DateTime?;
var cEnd = currentApp.GetValue(TimeSlotPanel.EndTimeProperty) as DateTime?;
var toTest = new DateRange(cStart.Value, cEnd.Value);
var aStart = currentChild.GetValue(TimeSlotPanel.StartTimeProperty) as DateTime?;
var aEnd = currentChild.GetValue(TimeSlotPanel.EndTimeProperty) as DateTime?;
var current = new DateRange(aStart.Value, aEnd.Value);
if (toTest.Overlaps(current))
{
count++;
}
}
}
return count;
}
示例4: MyViewModel
public MyViewModel()
{
var date = DateTime.Now;
var ganttAPI = new GanttTask(date, date.AddDays(2), "Design public API") { Description = "Description: Design public API" };
var ganttRendering = new GanttTask(date.AddDays(2).AddHours(8), date.AddDays(4), "Gantt Rendering") { Description = "Description: Gantt Rendering" };
var ganttDemos = new GanttTask(date.AddDays(4.5), date.AddDays(7), "Gantt Demos") { Description = "Description: Gantt Demos" };
var milestone = new GanttTask(date.AddDays(7), date.AddDays(7).AddHours(1), "Review") { Description = "Review", IsMilestone = true };
ganttRendering.Dependencies.Add(new Dependency { FromTask = ganttAPI });
ganttDemos.Dependencies.Add(new Dependency { FromTask = ganttRendering });
var iterationTask = new GanttTask(date, date.AddDays(7), "Iteration 1")
{
Children = { ganttAPI, ganttRendering, ganttDemos, milestone }
};
this.tasks = new ObservableCollection<GanttTask>() { iterationTask };
this.visibleTime = new DateRange(date.AddDays(-1), date.AddDays(9));
this.timeLineDeadlineBehavior = new TimeLineDeadlineBehavior();
this.ProjectDeadline = date.AddDays(8);
}
示例5: StartDateHaveToBeEarlierThanEndDate_ArgumentException
public void StartDateHaveToBeEarlierThanEndDate_ArgumentException()
{
DateTime startDate = DateTime.Now.AddMonths(months: 2);
DateTime endDate = DateTime.Now.AddMonths(months: 1);
DateRange range = new DateRange(startDate, endDate);
}
示例6: ImportConsent
public ImportConsent(Guid notificationId, DateRange consentRange, string conditions, Guid userId)
{
ConsentRange = consentRange;
Conditions = conditions;
UserId = userId;
NotificationId = notificationId;
}
示例7: GetRangeStart
protected DateTime GetRangeStart(DateRange range)
{
switch (range) {
case DateRange.Today:
return DateTime.Now.Date;
case DateRange.Last24Hours:
return DateTime.Now.AddDays(-1);
case DateRange.ThisWeek:
//TODO #################
int diff = DateTime.Now.DayOfWeek - DayOfWeek.Monday;
if (diff < 0){
diff += 7;
}
return DateTime.Now.AddDays(-1 * diff).Date;
case DateRange.Last7Days:
return DateTime.Now.Date.AddDays(-7);
case DateRange.ThisMonth:
return new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
case DateRange.Last30Days:
return new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(-30);
case DateRange.ThisYear:
return new DateTime(DateTime.Now.Year, 1, 1);
case DateRange.LastYear:
return new DateTime(DateTime.Now.Year, 1, 1).AddYears(-1);
case DateRange.All:
return new DateTime(1790, 1, 1);
case DateRange.LastMonth:
return new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(-1);
default:
break;
}
return DateTime.Now;
}
示例8: Generate
public object Generate(IUnitOfWork uow, DateRange dateRange, string type, int start,
int length, out int recordcount)
{
recordcount = 0;
switch (type)
{
case "alllogs":
return ShowAllLogs(uow, dateRange, start,
length, out recordcount);
case "usage":
return GenerateUsageReport(uow, dateRange, start,
length, out recordcount);
case "incident":
return ShowAllIncidents(uow, dateRange, start,
length, out recordcount);
case "fiveRecentIncident":
return ShowMostRecent5Incidents(uow, out recordcount);
case "showBookerThroughput":
return ShowBookerThroughput(uow, dateRange, start,
length, out recordcount);
case "showBRResponsiveness":
return ShowBRResponsiveness(uow, dateRange, start,
length, out recordcount);
}
return this;
}
示例9: Constructor_NullEffectiveDate_Succeeds
public void Constructor_NullEffectiveDate_Succeeds()
{
DateTime? effectiveDate = null;
DateTime expirationDate = new DateTime ( 2000, 1, 1 );
DateRange dateRange = new DateRange ( effectiveDate, expirationDate );
}
示例10: GetRangeEnd
protected DateTime GetRangeEnd(DateRange range)
{
switch (range) {
case DateRange.Today:
return DateTime.Now;
case DateRange.Last24Hours:
return DateTime.Now;
case DateRange.ThisWeek:
return DateTime.Now;
case DateRange.Last7Days:
return DateTime.Now;
case DateRange.ThisMonth:
return DateTime.Now;
case DateRange.Last30Days:
return DateTime.Now;
case DateRange.ThisYear:
return DateTime.Now;
case DateRange.LastYear:
return new DateTime(DateTime.Now.Year, 1, 1);
case DateRange.All:
return new DateTime(2030, 1, 1);
case DateRange.LastMonth:
return new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMinutes(-1);
default:
break;
}
return DateTime.Now;
}
示例11: Constructor_LaterThanExpiration_ThrowsException
public void Constructor_LaterThanExpiration_ThrowsException()
{
DateTime effectiveDate = new DateTime ( 2000, 1, 2 );
DateTime expirationDate = new DateTime ( 2000, 1, 1 );
DateRange dateRange = new DateRange ( effectiveDate, expirationDate );
}
示例12: EqualityTest
public void EqualityTest()
{
DateRange sd = new DateRange(d1, d1);
DateRange sd2 = new DateRange(d1, d1);
Assert.AreEqual(sd, sd2);
sd = new DateRange(d1, d2);
sd2 = new DateRange(d1, d1);
Assert.AreNotEqual(sd, sd2);
sd = new DateRange(null, d1);
sd2 = new DateRange(null, d1);
Assert.AreEqual(sd, sd2);
sd = new DateRange(d1, null);
sd2 = new DateRange(d1, null);
Assert.AreEqual(sd, sd2);
sd = new DateRange(null, d1);
sd2 = new DateRange(d1, null);
Assert.AreNotEqual(sd, sd2);
sd = new DateRange(null, null);
sd2 = new DateRange(d1, null);
Assert.AreNotEqual(sd, sd2);
}
示例13: Map
public void Map()
{
// Arrange
var start = new DateTime(2010, 1, 1);
var end = DateUtility.MaxDate;
var range = new DateRange(start, end);
var id = new MDM.Contracts.NexusId { SystemName = "Test", Identifier = "A" };
var contractDetails = new MDM.Contracts.CurveDetails();
var contract = new MDM.Contracts.Curve
{
Identifiers = new MDM.Contracts.NexusIdList { id },
Details = contractDetails,
Nexus = new MDM.Contracts.SystemData { StartDate = start, EndDate = end }
};
// NB Don't assign validity here, want to prove SUT sets it
var details = new Curve();
var mapping = new CurveMapping();
var mappingEngine = new Mock<IMappingEngine>();
mappingEngine.Setup(x => x.Map<MDM.Contracts.NexusId, CurveMapping>(id)).Returns(mapping);
mappingEngine.Setup(x => x.Map<MDM.Contracts.CurveDetails, Curve>(contractDetails)).Returns(details);
var mapper = new CurveMapper(mappingEngine.Object);
// Act
var candidate = mapper.Map(contract);
// Assert
//Assert.AreEqual(1, candidate.Details.Count, "Detail count differs");
Assert.AreEqual(1, candidate.Mappings.Count, "Mapping count differs");
Check(range, details.Validity, "Validity differs");
}
示例14: Constructor_ValidDateRange_Succeeds
public void Constructor_ValidDateRange_Succeeds()
{
DateTime effectiveDate = new DateTime ( 2000, 1, 1 );
DateTime expirationDate = new DateTime ( 2000, 2, 1 );
DateRange dateRange = new DateRange ( effectiveDate, expirationDate );
}
示例15: Education
/**
* @param validSince `validSince` is a <code>DateTime</code> object, it's the first time Pipl's
* crawlers found this data on the page.
* @param degree degree
* @param school school
* @param dateRange `dateRange` is A <code>DateRange</code> object (Pipl.APIs.Data.Fields.DateRange),
* that's the time the person was studying.
*/
public Education(string degree = null, string school = null, DateRange dateRange = null, DateTime? validSince = null)
: base(validSince)
{
this.Degree = degree;
this.School = school;
this.DateRange = dateRange;
}