本文整理汇总了C#中System.DateTime.Count方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.Count方法的具体用法?C# DateTime.Count怎么用?C# DateTime.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.Count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDaysUntil
public void TestDaysUntil()
{
var expected = new List<DateTime>
{
new DateTime(2011, 1, 1),
new DateTime(2011, 1, 2),
new DateTime(2011, 1, 3),
new DateTime(2011, 1, 4),
new DateTime(2011, 1, 5),
new DateTime(2011, 1, 6),
new DateTime(2011, 1, 7),
new DateTime(2011, 1, 8),
new DateTime(2011, 1, 9),
new DateTime(2011, 1, 10),
new DateTime(2011, 1, 11),
new DateTime(2011, 1, 12),
new DateTime(2011, 1, 13),
new DateTime(2011, 1, 14),
new DateTime(2011, 1, 15),
new DateTime(2011, 1, 16),
new DateTime(2011, 1, 17),
new DateTime(2011, 1, 18),
new DateTime(2011, 1, 19),
new DateTime(2011, 1, 20),
};
var results = new DateTime(2011, 1, 1).DaysUntil(new DateTime(2011, 1, 20));
Assert.AreEqual(expected.Count, results.Count());
}
示例2: GetMasterByCheckstateAndDate
public List<V_Satisfactions> GetMasterByCheckstateAndDate(int pageCount, int pageIndex, int pageSize, string checkstate, DateTime[] dateTimes)
{
if(!string.IsNullOrEmpty(checkstate)&&dateTimes.Count()>=2)
{
using (SatisfactionSurveyBll masterBll = new SatisfactionSurveyBll())
{
IQueryable<V_Satisfactions> dataList= masterBll.GetMasterByCheckstateAndDate(pageCount, pageIndex, pageSize, checkstate, dateTimes);
return dataList != null && dataList.Count() > 0 ? dataList.ToList() : null;
}
}
return null;
}
示例3: GetEmployeeSurveyAppByCheckstateAndDate
public List<V_EmployeeSurveyApp> GetEmployeeSurveyAppByCheckstateAndDate(int pageCount, int pageIndex, int pageSize, string checkstate, DateTime[] datetimes)
{
if (datetimes.Count() > 1)
{
IQueryable<V_EmployeeSurveyApp> returnList;
using (EmployeeSurveyAppBll getBll = new EmployeeSurveyAppBll())
{
returnList = getBll.GetEmployeeSurveyAppByCheckstateAndDate(pageCount, pageIndex, pageSize, checkstate, datetimes);
return returnList.Count() > 0 ? returnList.ToList() : null;
}
}
return null;
}
示例4: SetupHeights
public void SetupHeights(DateTime[] dates, double[] heights, double[] NDemands, double[] CanopyWidths, double[] TreeLeafAreas)
{
dgvHeights.Rows.Clear();
for (int i = 0; i < dates.Count(); i++)
{
dgvHeights.Rows.Add(dates[i].ToShortDateString(), heights[i] / 1000,NDemands[i], CanopyWidths[i], TreeLeafAreas[i]);
}
}
示例5: TestMonthsUntilDaysIncorrectlyFormatted
public void TestMonthsUntilDaysIncorrectlyFormatted()
{
var expected = new List<DateTime>
{
new DateTime(2011, 1, 1),
new DateTime(2011, 2, 1),
new DateTime(2011, 3, 1),
new DateTime(2011, 4, 1)
};
var results = new DateTime(2011, 1, 15).MonthsUntil(new DateTime(2011, 4, 23));
Assert.AreEqual(expected.Count, results.Count());
}
示例6: TestMonthsUntilBoundsAreInCorrect
public void TestMonthsUntilBoundsAreInCorrect()
{
var results = new DateTime(2011, 2, 1).MonthsUntil(new DateTime(2011, 1, 1));
Assert.AreEqual(0, results.Count());
}
示例7: TestMonthsUntil
public void TestMonthsUntil()
{
var expected = new List<DateTime>
{
new DateTime(2011, 1, 1),
new DateTime(2011, 2, 1),
new DateTime(2011, 3, 1),
new DateTime(2011, 4, 1)
};
var results = new DateTime(2011, 1, 1).MonthsUntil(new DateTime(2011, 4, 1));
Assert.AreEqual(expected.Count, results.Count());
}
示例8: OrderCard
public string OrderCard(string[] flowArray, DateTime[] windowTime)
{
string orderNo = string.Empty;
for (int i = 0; i < flowArray.Count(); i++)
{
if (windowTime == null || windowTime.Count() == 0)
{
throw new BusinessException("窗口时间不能为空。");
}
IList<KanbanScan> kanbanScanList = genericMgr.FindAll<KanbanScan>("from KanbanScan k where k.IsOrdered = 0 and k.Flow = ?", flowArray[i]);
try
{
if (string.IsNullOrEmpty(orderNo))
{
orderNo = kanbanScanOrderMgr.OrderCard(kanbanScanList, windowTime[i]);
}
else
{
orderNo += "," + kanbanScanOrderMgr.OrderCard(kanbanScanList, windowTime[i]);
}
}
catch (BusinessException ex)
{
genericMgr.CleanSession();
MessageHolder.AddErrorMessage(ex.Message);
}
catch (Exception ex)
{
MessageHolder.AddErrorMessage("路线{0}结转出错,错误信息:{1}", new string[] { flowArray[i], ex.Message });
}
}
return orderNo;
}
示例9: GetHeaderList
//.........这里部分代码省略.........
// hasFamilyName = false,
// }).ToList();
// foreach (PART_NUM_MAP pnfm in partNumFamilyMaps)
// {
// if (myWIP_EVENT.Any(a => a.FamilyName == pnfm.FAMILY))
// {
// List<DriveInfo> driveInfos = myWIP_EVENT.Where(a => a.FamilyName == pnfm.FAMILY).ToList();
// foreach (DriveInfo driveInfo in driveInfos)
// {
// driveInfo.FamilyName = pnfm.DESCRIP;
// driveInfo.hasFamilyName = true;
// }
// }
// }
// foreach (DriveInfo driveInfo in myWIP_EVENT)
// {
// if (!driveInfo.hasFamilyName)
// {
// driveInfo.FamilyName = "NO DESCRIPTION";
// }
// }
// dayInit = myWIP_EVENT.OrderBy(a => a.eventDate).Select(a => a.eventDate).FirstOrDefault();
// int subInvCodeTotals = 0;
// List<string> familyNames = myWIP_EVENT.Select(a => a.FamilyName).Distinct().ToList();
// foreach (string fn in familyNames)
// {
// DriveInOutViewModel diovm = new DriveInOutViewModel();
// diovm.SubInv = wcm.SUB_INV_CODE + "\r\n (" + wcm.DESCRIP + ")";
// //diovm.DESCRIPT = wcm.DESCRIP;
// diovm.FamilyName = fn;
// diovm.CountBackDays = new List<int>();
// int subInvFamilyTotals = 0;
// for (int i = 0; i < sepDateList.Count() - 1; i++)
// {
// int tTotals = CalculateCount(myWIP_EVENT, dayInit, wcm.SUB_INV_CODE, fn, sepDateList[i + 1], sepDateList[i]);
// diovm.CountBackDays.Add(tTotals);
// subInvFamilyTotals += tTotals;
// //subInvCodeTotals += tTotals;
// totals[i] += tTotals;
// }
// diovm.CountBackDays.Add(subInvFamilyTotals);
// subInvCodeTotals += subInvFamilyTotals;
// diovm.CountBackDays.Add(subInvCodeTotals);
// viewModel.Add(diovm);
// }
// }
// DriveInOutViewModel diovm1 = new DriveInOutViewModel();
// diovm1.SubInv = "(SUM)";
// diovm1.CountBackDays = new List<int>();
// int allTotals = 0;
// for (int i = 0; i < sepDateList.Count() - 1; i++)
// {
// diovm1.CountBackDays.Add(totals[i]);
// allTotals += totals[i];
// }
// diovm1.CountBackDays.Add(allTotals);
// diovm1.CountBackDays.Add(allTotals);
// viewModel.Add(diovm1);
// TempData["viewModel"] = viewModel;
// TempData["headers"] = GetHeaderList(sepDateList);
// ViewData["Header"] = GetHeaderList(sepDateList);
// ViewData["TotalPages"] = (int)Math.Ceiling((float)viewModel.Count() / _pageSize);
// if ((int)ViewData["TotalPages"] < currentPage)
// {
// currentPage = 1;
// }
// ViewData["CurrentPage"] = currentPage;
// return View(viewModel);
//}
private static List<string> GetHeaderList(DateTime[] sepDateList, bool showFamilyName)
{
List<string> headers = new List<string>();
headers.Add("No");
headers.Add("SubInv ");
//headers.Add("DESCRIPTION");
if (showFamilyName)
{
headers.Add("FamilyName");
}
else
{
headers.Add("SubInv Description");
}
int dayStart = 0;
for (int i = 0; i < sepDateList.Count()-1; i++)
{
int dayEnd = -30 * (i + 1);
if (i == sepDateList.Count() - 2)
{
headers.Add(" > " + (-dayStart).ToString());
}
else
{
headers.Add((-dayStart).ToString() + " ~ " + (-dayEnd).ToString());
}
dayStart = dayEnd - 1;
}
headers.Add("TOTAL");
return headers;
}
示例10: Index
public ActionResult Index(string sort, int? page, string curSubInvCode, string curFamilyName, bool? showFamilyName)
{
var currentPage = page ?? 1;
ViewData["SortItem"] = sort;
sort = sort ?? "No";
ViewData["PageSize"] = _pageSize;
bool curShowFamilyName = showFamilyName ?? false;
List<DriveInOutViewModel> viewModel = new List<DriveInOutViewModel>();
if (curFamilyName == null)
{
curFamilyName = "All";
}
ViewData["curFamilyName"] = curFamilyName;
string[] ValidSICs = { "TLS", "FW", "ECP", "EJQ", "SGN", "FQT", "SEC" };
List<WIP_CODE_MAP_org> SICs = _entities.WIP_CODE_MAP_org.Where(a => a.AREA_CODE == "default" && ValidSICs.Contains(a.SUB_INV_CODE)).OrderBy(a => a.SUB_INV_CODE).ToList();
ViewData["SUB_INV_CODEs"] = SICs.Select(a => a.SUB_INV_CODE).ToList();
if (curSubInvCode == null)
{
curSubInvCode = "All";
}
ViewData["curSubInvCode"] = curSubInvCode;
var myWIP_EVENT = (from r in _entities.WIP_STATE
join h in _entities.WIP_EVENT on r.SERIAL_NUM equals h.SERIAL_NUM
where (ValidSICs.Contains(r.SUB_INV_CODE) && curSubInvCode == "All" || r.SUB_INV_CODE == curSubInvCode)
orderby r.SERIAL_NUM
select new
{
r.SERIAL_NUM,
r.SUB_INV_CODE,
FamilyName = r.PART_NUM.Substring(0, 3), // b.FAMILY,
h.EVENT_DATE
} into t1
group t1 by t1.SERIAL_NUM into tempDB
select new DriveInfo
{
eventDate = tempDB.OrderBy(a => a.EVENT_DATE).Select(a => a.EVENT_DATE).FirstOrDefault(),
serialNo = tempDB.FirstOrDefault().SERIAL_NUM,
subInv = tempDB.FirstOrDefault().SUB_INV_CODE,
FamilyName = tempDB.FirstOrDefault().FamilyName,
hasFamilyName = false,
}).OrderBy(a=>a.subInv).ToList();
List<PART_NUM_MAP> partNumFamilyMaps = (from r in _entities.PART_NUM_MAP
where r.PART_NUM.Substring(3, 7) == "000-000"
select r).Distinct().ToList();
foreach (PART_NUM_MAP pnfm in partNumFamilyMaps)
{
if (myWIP_EVENT.Any(a => a.FamilyName == pnfm.FAMILY))
{
List<DriveInfo> driveInfos = myWIP_EVENT.Where(a => a.FamilyName == pnfm.FAMILY).ToList();
foreach (DriveInfo driveInfo in driveInfos)
{
driveInfo.FamilyName = pnfm.DESCRIP;
driveInfo.hasFamilyName = true;
}
}
}
foreach (DriveInfo driveInfo in myWIP_EVENT)
{
if (!driveInfo.hasFamilyName)
{
driveInfo.FamilyName = "NO DESCRIPTION";
}
}
myWIP_EVENT = (from r in myWIP_EVENT where (r.FamilyName == curFamilyName || curFamilyName == "All") && (r.subInv == curSubInvCode || curSubInvCode == "All") orderby r.subInv, r.FamilyName select r).ToList();
ViewData["FamilyNames"] = myWIP_EVENT.Select(a=>a.FamilyName).Distinct().ToList();
DateTime dayInit = new DateTime(2010, 1, 1);
DateTime[] sepDateList = new DateTime[14] {
DateTime.Today,
DateTime.Today.AddDays(-30),
DateTime.Today.AddDays(-60),
DateTime.Today.AddDays(-90),
DateTime.Today.AddDays(-120),
DateTime.Today.AddDays(-150),
DateTime.Today.AddDays(-180),
DateTime.Today.AddDays(-210),
DateTime.Today.AddDays(-240),
DateTime.Today.AddDays(-270),
DateTime.Today.AddDays(-300),
DateTime.Today.AddDays(-330),
DateTime.Today.AddDays(-360),
dayInit };
dayInit = myWIP_EVENT.OrderBy(a => a.eventDate).Select(a => a.eventDate).FirstOrDefault();
int subInvSUM = myWIP_EVENT.Select(a=>a.subInv).Distinct().Count();
int[,] totals = new int[subInvSUM+1, sepDateList.Count()];
int subInvIndex = 0;
int count = 0;
//.........这里部分代码省略.........
示例11: SetupHeights
public void SetupHeights(DateTime[] dates, double[] heights)
{
for (int i = 0; i < dates.Count(); i++)
{
dgvHeights.Rows.Add(dates[i].ToShortDateString(), heights[i] / 1000);
}
}
示例12: render_line
public ActionResult render_line(int symposium_id)
{
if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated == true)
{
int[] int_arry = new int[4] { 1, 7, 7000, 10000 };
Symposium found_symposium = db.Symposiums.Find(symposium_id);
int vote_count = 0;
foreach (var item in found_symposium.Projects)
{
vote_count = vote_count + item.Votes.Count();
}
Vote[] found_symposium_votes = new Vote[vote_count];
int q = 0;
foreach (var item in found_symposium.Projects)
{
foreach (var vote in item.Votes)
{
found_symposium_votes[q] = vote;
q++;
}
}
var all_votes = found_symposium_votes.OrderBy(v => v.created_at).ToList();
DateTime[] times = new DateTime[all_votes.Count()];
int i = 0;
foreach (var timestamp in all_votes)
{
times[i] = Convert.ToDateTime(timestamp.created_at);
i++;
}
ViewBag.Votes = all_votes;
Symposium symposium = db.Symposiums.Find(symposium_id);
var array = times.GroupBy(y => (int)(y.Ticks / TimeSpan.TicksPerMinute / 10)).Select(g => new { Value = g.Key, Count = g.Count() }).OrderBy(x => x.Value);
if (array.FirstOrDefault() != null && array.Count() > 1)
{
String[] x_axis = new String[times.Count()];
int iterator = 0;
foreach (var item in array)
{
long new_tick = convert_interval(item.Value);
DateTime myDate = new DateTime(new_tick);
int minutes = myDate.Minute;
String vote_date = myDate.ToString("hh:mm" + "-" + (minutes + 10));
x_axis[iterator] = vote_date;
iterator++;
}
DateTime am_or_pm;
if (array.FirstOrDefault() != null)
{
am_or_pm = new DateTime(convert_interval(array.First().Value));
string tt = am_or_pm.ToString("tt");
ViewBag.Morning_or_Evening = tt;
}
int[] counts = new int[array.Count()];
int r = 0;
foreach (var item in array)
{
counts[r] = item.Count;
r++;
}
ViewBag.Counts = counts;
var vote_intervals = x_axis.Where(x => !string.IsNullOrEmpty(x)).ToArray();
ViewBag.line_x_axis = vote_intervals;
return View(symposium);
}
else
{
return RedirectToAction("no_information", "Reports");
}
}
else
{
return RedirectToAction("desktop_vote", "Projects");
}
}