public void Can_use_Today_class_with_seconds() { var time = Today.At(09, 01, 05); Assert.That(time, Is.EqualTo(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 09, 01, 05))); }
public static void PrintDate() => WriteLine(Today.ToLongDateString());
private void OnDoCommence(object sender, CommenceArgs e) { if (DoInitialSummary != null) { DoInitialSummary.Invoke(this, args); } if (StartOfSimulation != null) { StartOfSimulation.Invoke(this, args); } if (CLEMInitialiseResource != null) { CLEMInitialiseResource.Invoke(this, args); } if (CLEMInitialiseActivity != null) { CLEMInitialiseActivity.Invoke(this, args); } if (CLEMValidate != null) { CLEMValidate.Invoke(this, args); } while (Today <= EndDate && !e.CancelToken.IsCancellationRequested) { if (DoWeather != null) { DoWeather.Invoke(this, args); } if (DoDailyInitialisation != null) { DoDailyInitialisation.Invoke(this, args); } if (StartOfDay != null) { StartOfDay.Invoke(this, args); } if (Today.Day == 1 && StartOfMonth != null) { StartOfMonth.Invoke(this, args); } if (Today.DayOfYear == 1 && StartOfYear != null) { StartOfYear.Invoke(this, args); } if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null) { StartOfWeek.Invoke(this, args); } if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null) { EndOfWeek.Invoke(this, args); } if (DoManagement != null) { DoManagement.Invoke(this, args); } if (DoEnergyArbitration != null) { DoEnergyArbitration.Invoke(this, args); } if (DoSoilWaterMovement != null) { DoSoilWaterMovement.Invoke(this, args); } if (DoSoilTemperature != null) { DoSoilTemperature.Invoke(this, args); } if (DoSoilOrganicMatter != null) { DoSoilOrganicMatter.Invoke(this, args); } if (DoSurfaceOrganicMatterDecomposition != null) { DoSurfaceOrganicMatterDecomposition.Invoke(this, args); } if (DoUpdateWaterDemand != null) { DoUpdateWaterDemand.Invoke(this, args); } if (DoWaterArbitration != null) { DoWaterArbitration.Invoke(this, args); } if (PrePhenology != null) { PrePhenology.Invoke(this, args); } if (DoPhenology != null) { DoPhenology.Invoke(this, args); } if (DoPotentialPlantGrowth != null) { DoPotentialPlantGrowth.Invoke(this, args); } if (DoPotentialPlantPartioning != null) { DoPotentialPlantPartioning.Invoke(this, args); } if (DoNutrientArbitration != null) { DoNutrientArbitration.Invoke(this, args); } if (DoActualPlantPartioning != null) { DoActualPlantPartioning.Invoke(this, args); } if (DoActualPlantGrowth != null) { DoActualPlantGrowth.Invoke(this, args); } if (DoUpdate != null) { DoUpdate.Invoke(this, args); } if (DoManagementCalculations != null) { DoManagementCalculations.Invoke(this, args); } if (DoStock != null) { DoStock.Invoke(this, args); } if (DoLifecycle != null) { DoLifecycle.Invoke(this, args); } if (DoReportCalculations != null) { DoReportCalculations.Invoke(this, args); } if (Today == EndDate && EndOfSimulation != null) { EndOfSimulation.Invoke(this, args); } if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null) { EndOfYear.Invoke(this, args); } if (Today.AddDays(1).Day == 1 && EndOfMonth != null) // is tomorrow the start of a new month? { // CLEM events performed before APSIM EndOfMonth if (CLEMStartOfTimeStep != null) { CLEMStartOfTimeStep.Invoke(this, args); } if (CLEMUpdateLabourAvailability != null) { CLEMUpdateLabourAvailability.Invoke(this, args); } if (CLEMUpdatePasture != null) { CLEMUpdatePasture.Invoke(this, args); } if (CLEMPastureReady != null) { CLEMPastureReady.Invoke(this, args); } if (CLEMDoCutAndCarry != null) { CLEMDoCutAndCarry.Invoke(this, args); } if (CLEMAnimalBreeding != null) { CLEMAnimalBreeding.Invoke(this, args); } if (CLEMAnimalMilkProduction != null) { CLEMAnimalMilkProduction.Invoke(this, args); } if (CLEMPotentialIntake != null) { CLEMPotentialIntake.Invoke(this, args); } if (CLEMGetResourcesRequired != null) { CLEMGetResourcesRequired.Invoke(this, args); } if (CLEMAnimalWeightGain != null) { CLEMAnimalWeightGain.Invoke(this, args); } if (CLEMCalculateManure != null) { CLEMCalculateManure.Invoke(this, args); } if (CLEMCollectManure != null) { CLEMCollectManure.Invoke(this, args); } if (CLEMAnimalDeath != null) { CLEMAnimalDeath.Invoke(this, args); } if (CLEMAnimalMilking != null) { CLEMAnimalMilking.Invoke(this, args); } if (CLEMCalculateEcologicalState != null) { CLEMCalculateEcologicalState.Invoke(this, args); } if (CLEMAnimalManage != null) { CLEMAnimalManage.Invoke(this, args); } if (CLEMAnimalStock != null) { CLEMAnimalStock.Invoke(this, args); } if (CLEMAnimalSell != null) { CLEMAnimalSell.Invoke(this, args); } if (CLEMDetachPasture != null) { CLEMDetachPasture.Invoke(this, args); } if (CLEMHerdSummary != null) { CLEMHerdSummary.Invoke(this, args); } if (CLEMAgeResources != null) { CLEMAgeResources.Invoke(this, args); } if (CLEMAnimalBuy != null) { CLEMAnimalBuy.Invoke(this, args); } if (CLEMEndOfTimeStep != null) { CLEMEndOfTimeStep.Invoke(this, args); } EndOfMonth.Invoke(this, args); } if (EndOfDay != null) { EndOfDay.Invoke(this, args); } if (DoReport != null) { DoReport.Invoke(this, args); } Today = Today.AddDays(1); } Today = EndDate; Summary.WriteMessage(this, "Simulation terminated normally"); }
public void Should_succeed_when_asserting_datetime_is_on_or_after_the_same_datetime() { Today.Should().BeOnOrAfter(Today); }
public BuiltInFunctions() { // Text Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); Functions["exact"] = new Exact(); Functions["find"] = new Find(); Functions["proper"] = new Proper(); Functions["text"] = new Text.Text(); Functions["t"] = new T(); // Numbers Functions["int"] = new CInt(); // Math Functions["abs"] = new Abs(); Functions["cos"] = new Cos(); Functions["cosh"] = new Cosh(); Functions["power"] = new Power(); Functions["sign"] = new Sign(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["countif"] = new CountIf(); Functions["fact"] = new Fact(); Functions["floor"] = new Floor(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["sumproduct"] = new SumProduct(); Functions["sumsq"] = new Sumsq(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["stdev.s"] = new Stdev(); Functions["stdev.p"] = new StdevP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["ln"] = new Ln(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["min"] = new Min(); Functions["mod"] = new Mod(); Functions["average"] = new Average(); Functions["averagea"] = new AverageA(); Functions["averageif"] = new AverageIf(); Functions["round"] = new Round(); Functions["rounddown"] = new Rounddown(); Functions["roundup"] = new Roundup(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["quotient"] = new Quotient(); Functions["trunc"] = new Trunc(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["atan"] = new Atan(); Functions["atan2"] = new Atan2(); Functions["var"] = new Var(); Functions["varp"] = new VarP(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["iserror"] = new IsError(); Functions["iserr"] = new IsErr(); Functions["iseven"] = new IsEven(); Functions["isodd"] = new IsOdd(); Functions["islogical"] = new IsLogical(); Functions["isna"] = new IsNa(); Functions["na"] = new Na(); Functions["n"] = new N(); // Logical Functions["if"] = new If(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row(); Functions["rows"] = new Rows() { SkipArgumentEvaluation = true }; Functions["column"] = new Column(); Functions["columns"] = new Columns() { SkipArgumentEvaluation = true }; Functions["choose"] = new Choose(); Functions["index"] = new Index(); Functions["indirect"] = new Indirect(); // Date Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); Functions["weeknum"] = new Weeknum(); Functions["weekday"] = new Weekday(); Functions["days360"] = new Days360(); Functions["yearfrac"] = new Yearfrac(); Functions["edate"] = new Edate(); Functions["eomonth"] = new Eomonth(); Functions["isoweeknum"] = new IsoWeekNum(); Functions["workday"] = new Workday(); }
public void Should_succeed_when_asserting_datetime_is_on_or_before_later_datetime() { Today.Should().BeOnOrBefore(Tomorrow); }
public void Should_fail_when_asserting_datetime_is_on_or_before_earlier_datetime() { Action act = () => Today.Should().BeOnOrBefore(Yesterday); act.ShouldThrow <AssertFailedException>(); }
public Month(Today parent) { _parent = parent; }
public void Using_Today() { var date = Today.At(09, 00); Assert.That(date, Is.EqualTo(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 09, 00, 00))); }
protected void ddlDuration_SelectedIndexChanged(object sender, EventArgs e) { //date between you should use date first and earlier date lateafter string Today, Yesterday, ThisYear; Today = Convert.ToString(System.DateTime.Today.ToShortDateString()); Yesterday = Convert.ToString(System.DateTime.Today.AddDays(-1).ToShortDateString()); ThisYear = Convert.ToString(System.DateTime.Today.Year.ToString()); //-------------------this week start............... DateTime d1, d2, d3, d4, d5, d6, d7; DateTime weekstart, weekend; d1 = Convert.ToDateTime(System.DateTime.Today.ToShortDateString()); d2 = Convert.ToDateTime(System.DateTime.Today.AddDays(-1).ToShortDateString()); d3 = Convert.ToDateTime(System.DateTime.Today.AddDays(-2).ToShortDateString()); d4 = Convert.ToDateTime(System.DateTime.Today.AddDays(-3).ToShortDateString()); d5 = Convert.ToDateTime(System.DateTime.Today.AddDays(-4).ToShortDateString()); d6 = Convert.ToDateTime(System.DateTime.Today.AddDays(-5).ToShortDateString()); d7 = Convert.ToDateTime(System.DateTime.Today.AddDays(-6).ToShortDateString()); string ThisWeek = (System.DateTime.Today.DayOfWeek.ToString()); if (ThisWeek.ToString() == "Monday") { weekstart = d1; weekend = weekstart.Date.AddDays(+6); } else if (Convert.ToString(ThisWeek) == "Tuesday") { weekstart = d2; weekend = weekstart.Date.AddDays(+6); } else if (ThisWeek.ToString() == "Wednesday") { weekstart = d3; weekend = weekstart.Date.AddDays(+6); } else if (ThisWeek.ToString() == "Thursday") { weekstart = d4; weekend = weekstart.Date.AddDays(+6); } else if (ThisWeek.ToString() == "Friday") { weekstart = d5; weekend = weekstart.Date.AddDays(+6); } else if (ThisWeek.ToString() == "Saturday") { weekstart = d6; weekend = weekstart.Date.AddDays(+6); } else { weekstart = d7; weekend = weekstart.Date.AddDays(+6); } string thisweekstart = weekstart.ToShortDateString(); string thisweekend = weekend.ToShortDateString(); //.................this week duration end..................... ///--------------------last week duration .... DateTime d17, d8, d9, d10, d11, d12, d13; DateTime lastweekstart, lastweekend; d17 = Convert.ToDateTime(System.DateTime.Today.AddDays(-7).ToShortDateString()); d8 = Convert.ToDateTime(System.DateTime.Today.AddDays(-8).ToShortDateString()); d9 = Convert.ToDateTime(System.DateTime.Today.AddDays(-9).ToShortDateString()); d10 = Convert.ToDateTime(System.DateTime.Today.AddDays(-10).ToShortDateString()); d11 = Convert.ToDateTime(System.DateTime.Today.AddDays(-11).ToShortDateString()); d12 = Convert.ToDateTime(System.DateTime.Today.AddDays(-12).ToShortDateString()); d13 = Convert.ToDateTime(System.DateTime.Today.AddDays(-13).ToShortDateString()); string thisday = (System.DateTime.Today.DayOfWeek.ToString()); if (thisday.ToString() == "Monday") { lastweekstart = d17; lastweekend = lastweekstart.Date.AddDays(+6); } else if (Convert.ToString(thisday) == "Tuesday") { lastweekstart = d8; lastweekend = lastweekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Wednesday") { lastweekstart = d9; lastweekend = lastweekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Thursday") { lastweekstart = d10; lastweekend = lastweekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Friday") { lastweekstart = d11; lastweekend = lastweekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Saturday") { lastweekstart = d12; lastweekend = lastweekstart.Date.AddDays(+6); } else { lastweekstart = d13; lastweekend = lastweekstart.Date.AddDays(+6); } string lastweekstartdate = lastweekstart.ToShortDateString(); string lastweekenddate = lastweekend.ToString(); //---------------lastweek duration end................. // Today //2 Yesterday //3 ThisWeek //4 LastWeek //5 ThisMonth //6 LastMonth //7 ThisQuarter //8 LastQuarter //9 ThisYear //10Last Year //------------------this month period----------------- DateTime thismonthstart = Convert.ToDateTime(System.DateTime.Now.Month.ToString() + "/1/" + System.DateTime.Now.Year.ToString()); string thismonthstartdate = thismonthstart.ToShortDateString(); string thismonthenddate = Today.ToString(); //------------------this month period end................ //-----------------last month period start --------------- int lastmonthno = Convert.ToInt32(thismonthstart.Month.ToString()) - 1; string lastmonthNumber = Convert.ToString(lastmonthno.ToString()); DateTime lastmonth = Convert.ToDateTime(lastmonthNumber.ToString() + "/1/" + ThisYear.ToString()); string lastmonthstart = lastmonth.ToShortDateString(); string lastmonthend = ""; if (lastmonthNumber == "1" || lastmonthNumber == "3" || lastmonthNumber == "5" || lastmonthNumber == "7" || lastmonthNumber == "9" || lastmonthNumber == "11") { lastmonthend = lastmonthNumber + "/31/" + ThisYear.ToString(); } else if (lastmonthNumber == "4" || lastmonthNumber == "6" || lastmonthNumber == "8" || lastmonthNumber == "10" || lastmonthNumber == "12") { lastmonthend = lastmonthNumber + "/30/" + ThisYear.ToString(); } else { if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString()))) { lastmonthend = lastmonthNumber + "/29/" + ThisYear.ToString(); } else { lastmonthend = lastmonthNumber + "/28/" + ThisYear.ToString(); } } string lastmonthstartdate = lastmonthstart.ToString(); string lastmonthenddate = lastmonthend.ToString(); //-----------------last month period end ----------------------- //--------------------this quater period start ---------------- int thisqtr = Convert.ToInt32(thismonthstart.AddMonths(-2).Month.ToString()); string thisqtrNumber = Convert.ToString(thisqtr.ToString()); DateTime thisquater = Convert.ToDateTime(thisqtrNumber.ToString() + "/1/" + ThisYear.ToString()); string thisquaterstart = thisquater.ToShortDateString(); string thisquaterend = ""; if (thisqtrNumber == "1" || thisqtrNumber == "3" || thisqtrNumber == "5" || thisqtrNumber == "7" || thisqtrNumber == "9" || thisqtrNumber == "11") { thisquaterend = thisqtrNumber + "/31/" + ThisYear.ToString(); } else if (thisqtrNumber == "4" || thisqtrNumber == "6" || thisqtrNumber == "8" || thisqtrNumber == "10" || thisqtrNumber == "12") { thisquaterend = thisqtrNumber + "/30/" + ThisYear.ToString(); } else { if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString()))) { thisquaterend = thisqtrNumber + "/29/" + ThisYear.ToString(); } else { thisquaterend = thisqtrNumber + "/28/" + ThisYear.ToString(); } } string thisquaterstartdate = thisquaterstart.ToString(); string thisquaterenddate = thisquaterend.ToString(); // --------------this quater period end ------------------------ // --------------last quater period start---------------------- int lastqtr = Convert.ToInt32(thismonthstart.AddMonths(-5).Month.ToString());// -5; string lastqtrNumber = Convert.ToString(lastqtr.ToString()); int lastqater3 = Convert.ToInt32(thismonthstart.AddMonths(-3).Month.ToString()); //DateTime lastqater3 = Convert.ToDateTime(System.DateTime.Now.AddMonths(-3).Month.ToString()); string lasterquater3 = lastqater3.ToString(); DateTime lastquater = Convert.ToDateTime(lastqtrNumber.ToString() + "/1/" + ThisYear.ToString()); string lastquaterstart = lastquater.ToShortDateString(); string lastquaterend = ""; if (lastqtrNumber == "1" || lastqtrNumber == "3" || lastqtrNumber == "5" || lastqtrNumber == "7" || lastqtrNumber == "9" || lastqtrNumber == "11") { lastquaterend = lasterquater3 + "/31/" + ThisYear.ToString(); } else if (lastqtrNumber == "4" || lastqtrNumber == "6" || lastqtrNumber == "8" || lastqtrNumber == "10" || lastqtrNumber == "12") { lastquaterend = lasterquater3 + "/30/" + ThisYear.ToString(); } else { if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString()))) { lastquaterend = lasterquater3 + "/29/" + ThisYear.ToString(); } else { lastquaterend = lasterquater3 + "/28/" + ThisYear.ToString(); } } string lastquaterstartdate = lastquaterstart.ToString(); string lastquaterenddate = lastquaterend.ToString(); //--------------last quater period end------------------------- //--------------this year period start---------------------- DateTime thisyearstart = Convert.ToDateTime("1/1/" + ThisYear.ToString()); DateTime thisyearend = Convert.ToDateTime("12/31/" + ThisYear.ToString()); string thisyearstartdate = thisyearstart.ToShortDateString(); string thisyearenddate = thisyearend.ToShortDateString(); //---------------this year period end------------------- //--------------this year period start---------------------- DateTime lastyearstart = Convert.ToDateTime("1/1/" + System.DateTime.Today.AddYears(-1).Year.ToString()); DateTime lastyearend = Convert.ToDateTime("12/31/" + System.DateTime.Today.AddYears(-1).Year.ToString()); string lastyearstartdate = lastyearstart.ToShortDateString(); string lastyearenddate = lastyearend.ToShortDateString(); //---------------this year period end------------------- string periodstartdate = ""; string periodenddate = ""; if (ddlDuration.SelectedItem.Text == "Today") { periodstartdate = Today.ToString(); periodenddate = Today.ToString(); } else if (ddlDuration.SelectedItem.Text == "Yesterday") { periodstartdate = Yesterday.ToString(); periodenddate = Yesterday.ToString(); } else if (ddlDuration.SelectedItem.Text == "This Week") { periodstartdate = thisweekstart.ToString(); periodenddate = thisweekend.ToString(); } else if (ddlDuration.SelectedItem.Text == "Last Week") { periodstartdate = lastweekstartdate.ToString(); periodenddate = Today.ToString(); } else if (ddlDuration.SelectedItem.Text == "This Month") { periodstartdate = thismonthstart.ToShortDateString(); periodenddate = Today.ToString(); } else if (ddlDuration.SelectedItem.Text == "Last Month") { periodstartdate = lastmonthstartdate.ToString(); periodenddate = lastmonthenddate.ToString(); } else if (ddlDuration.SelectedItem.Text == "This Quarter") { periodstartdate = thisquaterstartdate.ToString(); periodenddate = thisquaterenddate.ToString(); } else if (ddlDuration.SelectedItem.Text == "Last Quarter") { periodstartdate = lastquaterstartdate.ToString(); periodenddate = lastquaterenddate.ToString(); } else if (ddlDuration.SelectedItem.Text == "This Year") { periodstartdate = thisyearstartdate.ToString(); periodenddate = thisyearenddate.ToString(); } else if (ddlDuration.SelectedItem.Text == "Last Year") { periodstartdate = lastyearstartdate.ToString(); periodenddate = lastyearenddate.ToString(); } else { periodstartdate = "1/1/1900"; periodenddate = Today.ToString(); } if (periodstartdate.Length > 0) { txtfrom.Text = periodstartdate; txtto.Text = periodenddate; // periodstartdate; // Session["MFDate"] = txtFromDate.Text; // Session["MTDate"] = txtToDate.Text; // txtFromDate.Text; // DropDownList1_SelectedIndexChanged(sender, e); } }
protected override void RunJournalCommand() { if (Last) { var journal = OpenJournal(); var lastEntry = journal.CreateIndex <JournalEntryFile>().SelectMany(x => x.Entries).OrderByDescending(x => x.EntryDate).FirstOrDefault(); if (lastEntry == null) { throw new PSInvalidOperationException("No entries found!"); } SystemProcess.Start(lastEntry.FilePath); return; } var fileSystem = new FileSystem(); var journalWriter = new JournalWriter(fileSystem, Location); string path; LocalDate entryDate; switch (ParameterSetName) { case "Name": { entryDate = EntryName.EndsWith(".md") ? Journal.FileNameWithExtensionPattern.Parse(EntryName).Value : Journal.FileNamePattern.Parse(EntryName).Value; path = journalWriter.GetJournalEntryFilePath(entryDate); break; } case "Date": { entryDate = LocalDate.FromDateTime(Date); path = journalWriter.GetJournalEntryFilePath(entryDate); break; } case "DateOffset": { entryDate = Today.PlusDays(DateOffset); path = journalWriter.GetJournalEntryFilePath(entryDate); break; } case "Entry": { entryDate = Journal.FileNamePattern.Parse(Entry.EntryName).Value; path = journalWriter.GetJournalEntryFilePath(entryDate); break; } default: throw new NotSupportedException(); } if (!fileSystem.File.Exists(path)) { throw new PSInvalidOperationException($"An entry does not exist for '{entryDate}'."); } Commit(GitCommitType.PreOpenJournalEntry); SystemProcess.Start(path); if (Wait) { var result = Choice($"Reading entry for {entryDate}", "Continue on to next entry?", 0, "&Continue", "&Quit"); Commit(GitCommitType.PostOpenJournalEntry); if (result == 1) { ThrowTerminatingError("Pipeline terminated at user's request.", ErrorCategory.NotSpecified); } } }
public BuiltInFunctions() { // Text Functions["text"] = new CStr(); Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); // Numbers Functions["int"] = new CInt(); // Math Functions["cos"] = new Cos(); Functions["cosh"] = new Cosh(); Functions["power"] = new Power(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["floor"] = new Floor(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["min"] = new Min(); Functions["mod"] = new Mod(); Functions["average"] = new Average(); Functions["round"] = new Round(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["var"] = new Var(); Functions["varp"] = new VarP(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["iserror"] = new IsError(); // Logical Functions["if"] = new If(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row(); Functions["rows"] = new Rows(); Functions["column"] = new Column(); Functions["columns"] = new Columns(); Functions["choose"] = new Choose(); // Date Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); }
public string TodayAsString() => Today.ToString("dd/MM/yyyy");
public JsonResult groupbyAttendanceList(DateTime date, string param) { var employees = db.Employee.GetAllWithRelatedData(x => x.IsActive == true && x.IsDeleted == false).ToList(); var vm = new List <vmGroupbyAttendance>(); switch (param) { case "department": foreach (var item in employees.GroupBy(g => g.DepartmentId)) { var name = ""; var total = 0; var absent = 0; var present = 0; var late = 0; var business = 0; var leave = 0; name = item.Select(x => x.Department.Name).FirstOrDefault(); total = item.Select(x => x.Id).Count(); foreach (var employee in item) { //check leave var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isLeaveExists != null) { leave += 1; continue; } //check business var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isBusinessExists != null) { business += 1; continue; } //check late var lateCount = db.SystemPreference.GetFirstOrDefault().LateCount; var shift = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault(); var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay); var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount); var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1); if (punch.Count() == 0) { absent += 1; continue; } else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow) { late += 1; present += 1; continue; } else { present += 1; continue; } } vm.Add(new vmGroupbyAttendance { Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total }); } break; case "designation": foreach (var item in employees.GroupBy(g => g.DesignationId)) { var name = ""; var total = 0; var absent = 0; var present = 0; var late = 0; var business = 0; var leave = 0; name = item.Select(x => x.Designation.Name).FirstOrDefault(); total = item.Select(x => x.Id).Count(); foreach (var employee in item) { //check leave var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isLeaveExists != null) { leave += 1; continue; } //check business var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isBusinessExists != null) { business += 1; continue; } //check late var lateCount = db.SystemPreference.GetFirstOrDefault().LateCount; var shift = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault(); var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay); var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount); var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1); if (punch.Count() == 0) { absent += 1; continue; } else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow) { late += 1; present += 1; continue; } else { present += 1; continue; } } vm.Add(new vmGroupbyAttendance { Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total }); } break; case "shift": foreach (var item in employees.GroupBy(g => g.ShiftId)) { var name = ""; var total = 0; var absent = 0; var present = 0; var late = 0; var business = 0; var leave = 0; name = item.Select(x => x.Shift.Name).FirstOrDefault(); total = item.Select(x => x.Id).Count(); foreach (var employee in item) { //check leave var isLeaveExists = db.LeaveApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isLeaveExists != null) { leave += 1; continue; } //check business var isBusinessExists = db.BusinessApplication.GetFirstOrDefault(x => x.EmployeeId == employee.Id && x.FromDate.Date == Today && x.Status == ApplicationStatus.Pending || x.Status == ApplicationStatus.Approved); if (isBusinessExists != null) { business += 1; continue; } //check late var lateCount = db.SystemPreference.GetFirstOrDefault().LateCount; var shift = employee.Shift.ShiftDetailsList.Where(x => x.DayName == Today.ToString("dddd")).FirstOrDefault(); var officeStart = Today.Add(DateTime.Parse(shift.OfficeStartTime).TimeOfDay); var officeStart_with_lateAllow = officeStart.AddMinutes(lateCount); var punch = db.AttendanceMachineDataFiltered.GetAllAsQueryable().Where(x => x.EmployeeId == employee.Id && x.TransactionTime.Date == Today).OrderBy(o => o.TransactionTime).ToList().Take(1); if (punch.Count() == 0) { absent += 1; continue; } else if (punch.FirstOrDefault().TransactionTime > officeStart_with_lateAllow) { late += 1; present += 1; continue; } else { present += 1; continue; } } vm.Add(new vmGroupbyAttendance { Absent = absent, Business = business, Late = late, Leave = leave, Present = present, Name = name, Total = total }); } break; } return(Json(vm)); }
public static void PrintData() => WriteLine(Today.ToShortDateString());
public List <RawDailySalesItem> GetDailyHistory(DateTime?When) { List <RawDailySalesItem> Results = new List <RawDailySalesItem>(); DateTime Today; if (When.HasValue) { Today = When.Value.Date; } else { Today = DateTime.Now.Date.AddDays(-1); } DateTime Tomorrow = Today.AddDays(1); InitializeConnection(); // need to resolve any merchant sequence number issues // now get the details var DailyHistories = from h in GiftEntity.Histories where h.WhenHappened > Today && h.WhenHappened < Tomorrow && h.ErrorCode == "APP " && h.TransType != "DYRP" && // keep the daily report out of this h.TransType != "SHIP" // keep the card shipments out of the report orderby h.ID //c.Card2 == WhichCard.ID select new { ID = h.ID, CardGUID = h.CardGUID, TransType = h.TransType, When = h.WhenHappened, Amount = h.Amount, PointsGranted = 0, MerchWhere = h.WhichMerchantGUID, Clrk = h.Clerk, Text = h.TransactionText, CardGUID2 = h.CardGUID2, CouponUsed = "", CouponIssued = "", PrizeAwardedGUID = "", InvoiceNumber = h.InvoiceNumber }; foreach (var his in DailyHistories) { RawDailySalesItem nHistory = new RawDailySalesItem(); nHistory.ID = his.ID; nHistory.CardNumber = (from c in GiftEntity.Cards where c.CardGUID == his.CardGUID select c.CardNumLast4).FirstOrDefault(); nHistory.Amount = his.Amount; Merchant tMerchant = (from m in GiftEntity.Merchants where m.MerchantGUID == his.MerchWhere select m).FirstOrDefault(); if (tMerchant != null) { nHistory.MerchantID = tMerchant.MerchantID; } nHistory.TransType = his.TransType; nHistory.WhenHappened = his.When; Results.Add(nHistory); } return(Results); }
public void InitializeTest() { Today = DateTime.Today; Yesterday = Today.AddDays(-1); Tomorrow = Today.AddDays(1); }
public bool ValidateTeamRecord(TeamProxy savedVersion) { bool staffChanged = true; bool roleChanged = true; bool startChanged = true; bool amendment = false; ProjectTeams predecessor = Predecessor(); if (savedVersion == null) { savedVersion = new TeamProxy(); } // Prevents having to check for null each time else { amendment = true; staffChanged = (savedVersion.StaffID != StaffID); roleChanged = (savedVersion.RoleCode != RoleCode); startChanged = (savedVersion.FromDate != FromDate); } try { string errorMessage = ""; if (StaffMember == null) { errorMessage = "Please choose a staff member from the list, or use the 'Search' function.|No Staff Member"; } else if (ProjectRole == null) { errorMessage = "Please select a project role for the staff member.|No Role Selected"; } else if (FromDate == null) { errorMessage = "Please enter a date from which this user is (or was) part of the team.|No Start Date"; } else if (EffectiveTo < FromDate) { errorMessage = "The 'To' date cannot be after the 'From' date.|Invalid Dates"; } else if (amendment && (staffChanged || roleChanged) && savedVersion.IsHistoric) { errorMessage = "Past team members cannot be amended, except to change their dates.|Historic Record"; } else if (!StaffMember.Active && FromDate <= Today && EffectiveTo > Today) { errorMessage = StaffMember.StaffName + " is inactive and cannot be part of the current project team now, but can be added for a future date.|Inactive User"; } else if (IsDuplicate()) { errorMessage = StaffMember.StaffName + " already has the same role in the project during this period. Please check the existing record.|Duplicate Record"; } else if (HasKeyRole && predecessor == null && FromDate > Project.StartDate) { errorMessage = ProjectRole.RoleDescription + " is a key role, and is not covered at the start of the project. Please adjust the 'from' date, then (if appropriate) " + "add an initial " + ProjectRole.RoleDescription + " afterwards; the date of this record will then be adjusted automatically.|Key Role Not Covered"; } else if (HasKeyRole && Successor() == null & ToDate != null) { errorMessage = ProjectRole.RoleDescription + " is a key role, and must always have a current record. Please leave the 'to' date blank, then (if appropriate) " + "add a subsequent " + ProjectRole.RoleDescription + " afterwards; the date of this record will then be adjusted automatically.|Key Role Not Covered"; } else if (amendment && roleChanged && savedVersion.HasKeyRole) { errorMessage = "The existing role (" + savedVersion.ProjectRole.RoleDescription + ") is a key role, and must always be filled during the project. Please ensure " + "continuity in that role (e.g. by selecting an alternative staff member for this record) before changing/adding this user's new project role.|Key Role Not Covered"; } if (errorMessage != "") { MessageFunctions.SplitInvalid(errorMessage); return(false); } } catch (Exception generalException) { MessageFunctions.Error("Error validating project team details", generalException); return(false); } try { MessageFunctions.ClearQuery(); if (AlreadyOnProject()) { MessageFunctions.AddQuery(StaffMember.StaffName + " is already a project team member in a different capacity, or at a different time."); } if (amendment && (staffChanged || roleChanged) && Project.StartDate < Today.AddMonths(-1)) { MessageFunctions.AddQuery("This change is more than a month after the start of the project, which suggests an addition rather than amendment is required."); } if ((staffChanged || roleChanged) && IsUnusualRole()) { MessageFunctions.AddQuery("The role of " + ProjectRole.RoleDescription + " appears unusual for this user, given their main job role."); } if (startChanged && FromDate < Project.StartDate) { MessageFunctions.AddQuery("This role starts before the project's official start date (which may be correct if involved in initialising the project)."); } if (startChanged && FromDate > Today.AddYears(1)) { MessageFunctions.AddQuery("This role starts more than a year in the future."); } if (HasKeyRole) { if (predecessor != null && ((FromDate != null && (predecessor.FromDate == null || predecessor.FromDate < FromDate))) && ((ToDate != null && (predecessor.ToDate == null || predecessor.ToDate > ToDate))) ) { MessageFunctions.AddQuery("Projects can only have one internal " + ProjectRole.RoleDescription + " at a time, and this project already has another " + ProjectRole.RoleDescription + " throughout this period. The existing record will automatically be split into 'before' and 'after' sections."); } else if (ProjectFunctions.SubsumesStaff(this)) // Opposite scenario of above { MessageFunctions.AddQuery("Projects can only have one internal " + ProjectRole.RoleDescription + " at a time, and this period entirely covers an existing " + ProjectRole.RoleDescription + " record. That record will therefore be automatically deleted, and other existing records' dates adjusted to avoid overlaps."); } else if (RoleOverlap()) // Only if not throwing above - i.e. there is at least one overlap, but no complete replacement or split { MessageFunctions.AddQuery("Projects can only have one internal " + ProjectRole.RoleDescription + " at a time, and this project already has another " + ProjectRole.RoleDescription + " during part of this period. Existing records' dates will be automatically adjusted to avoid overlaps."); } if (predecessor != null && predecessor.ToDate != null && EffectiveFrom.AddDays(-1) > predecessor.ToDate) { MessageFunctions.AddQuery(ProjectRole.RoleDescription + " is a key role, but this leaves a gap after the previous incumbent, so that record will be extended automatically. " + "If that is not correct please adjust the 'from' date, or (after saving) add another interim record in between; existing dates will be adjusted to fit."); } if (Successor() != null && Successor().FromDate != null && EffectiveTo.AddDays(1) < Successor().FromDate) { MessageFunctions.AddQuery(ProjectRole.RoleDescription + " is a key role, but this leaves a gap to the next incumbent, so that record will be extended automatically. " + "If that is not correct please adjust the 'to' date, or (after saving) add another interim record in between; existing dates will be adjusted to fit."); } } return(MessageFunctions.AskQuery("")); } catch (Exception generalException) { MessageFunctions.Error("Error validating project team details", generalException); return(false); } finally { MessageFunctions.ClearQuery(); } }
public void Should_succeed_when_asserting_datetime_is_on_or_before_the_same_datetime() { Today.Should().BeOnOrBefore(Today); }
public static void PrintDate() => Console.WriteLine(Today.ToShortDateString());
public void Should_succeed_when_asserting_datetime_is_on_or_after_earlier_datetime() { Today.Should().BeOnOrAfter(Yesterday); }
public void Text18__GetValue(object sender, Stimulsoft.Report.Events.StiGetValueEventArgs e) { e.Value = this.Text18.TextFormat.Format(CheckExcelValue(sender, "Date: " + Today.ToString("Y"))); }
public void Should_fail_when_asserting_datetime_is_on_or_after_later_datetime() { Action act = () => Today.Should().BeOnOrAfter(Tomorrow); act.ShouldThrow <AssertFailedException>(); }
protected void filldatebyperiod() { string Today, Yesterday, ThisYear; Today = Convert.ToString(System.DateTime.Today.ToShortDateString()); Yesterday = Convert.ToString(System.DateTime.Today.AddDays(-1).ToShortDateString()); ThisYear = Convert.ToString(System.DateTime.Today.Year.ToString()); DateTime d1, d2, d3, d4, d5, d6, d7; DateTime weekstart, weekend; d1 = Convert.ToDateTime(System.DateTime.Today.ToShortDateString()); d2 = Convert.ToDateTime(System.DateTime.Today.AddDays(-1).ToShortDateString()); d3 = Convert.ToDateTime(System.DateTime.Today.AddDays(-2).ToShortDateString()); d4 = Convert.ToDateTime(System.DateTime.Today.AddDays(-3).ToShortDateString()); d5 = Convert.ToDateTime(System.DateTime.Today.AddDays(-4).ToShortDateString()); d6 = Convert.ToDateTime(System.DateTime.Today.AddDays(-5).ToShortDateString()); d7 = Convert.ToDateTime(System.DateTime.Today.AddDays(-6).ToShortDateString()); string ThisWeek = (System.DateTime.Today.DayOfWeek.ToString()); if (ThisWeek.ToString() == "Monday") { weekstart = d1; weekend = weekstart.Date.AddDays(+6); } else if (Convert.ToString(ThisWeek) == "Tuesday") { weekstart = d2; weekend = weekstart.Date.AddDays(+6); } else if (ThisWeek.ToString() == "Wednesday") { weekstart = d3; weekend = weekstart.Date.AddDays(+6); } else if (ThisWeek.ToString() == "Thursday") { weekstart = d4; weekend = weekstart.Date.AddDays(+6); } else if (ThisWeek.ToString() == "Friday") { weekstart = d5; weekend = weekstart.Date.AddDays(+6); } else if (ThisWeek.ToString() == "Saturday") { weekstart = d6; weekend = weekstart.Date.AddDays(+6); } else { weekstart = d7; weekend = weekstart.Date.AddDays(+6); } string thisweekstart = weekstart.ToShortDateString(); ViewState["thisweekstart"] = thisweekstart; string thisweekend = weekend.ToShortDateString(); ViewState["thisweekend"] = thisweekend; //.................this week ..................... DateTime d17, d8, d9, d10, d11, d12, d13; DateTime lastweekstart, lastweekend; d17 = Convert.ToDateTime(System.DateTime.Today.AddDays(-7).ToShortDateString()); d8 = Convert.ToDateTime(System.DateTime.Today.AddDays(-8).ToShortDateString()); d9 = Convert.ToDateTime(System.DateTime.Today.AddDays(-9).ToShortDateString()); d10 = Convert.ToDateTime(System.DateTime.Today.AddDays(-10).ToShortDateString()); d11 = Convert.ToDateTime(System.DateTime.Today.AddDays(-11).ToShortDateString()); d12 = Convert.ToDateTime(System.DateTime.Today.AddDays(-12).ToShortDateString()); d13 = Convert.ToDateTime(System.DateTime.Today.AddDays(-13).ToShortDateString()); string thisday = (System.DateTime.Today.DayOfWeek.ToString()); if (thisday.ToString() == "Monday") { lastweekstart = d17; lastweekend = lastweekstart.Date.AddDays(+6); } else if (Convert.ToString(thisday) == "Tuesday") { lastweekstart = d8; lastweekend = lastweekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Wednesday") { lastweekstart = d9; lastweekend = lastweekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Thursday") { lastweekstart = d10; lastweekend = lastweekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Friday") { lastweekstart = d11; lastweekend = lastweekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Saturday") { lastweekstart = d12; lastweekend = lastweekstart.Date.AddDays(+6); } else { lastweekstart = d13; lastweekend = lastweekstart.Date.AddDays(+6); } string lastweekstartdate = lastweekstart.ToShortDateString(); ViewState["lastweekstart"] = lastweekstartdate; string lastweekenddate = lastweekend.ToShortDateString(); ViewState["lastweekend"] = lastweekenddate; //.................last week ..................... DateTime d14, d15, d16, d171, d18, d19, d20; DateTime last2weekstart, last2weekend; d14 = Convert.ToDateTime(System.DateTime.Today.AddDays(-14).ToShortDateString()); d15 = Convert.ToDateTime(System.DateTime.Today.AddDays(-15).ToShortDateString()); d16 = Convert.ToDateTime(System.DateTime.Today.AddDays(-16).ToShortDateString()); d171 = Convert.ToDateTime(System.DateTime.Today.AddDays(-17).ToShortDateString()); d18 = Convert.ToDateTime(System.DateTime.Today.AddDays(-18).ToShortDateString()); d19 = Convert.ToDateTime(System.DateTime.Today.AddDays(-19).ToShortDateString()); d20 = Convert.ToDateTime(System.DateTime.Today.AddDays(-20).ToShortDateString()); //string thisday = (System.DateTime.Today.DayOfWeek.ToString()); if (thisday.ToString() == "Monday") { last2weekstart = d14; last2weekend = last2weekstart.Date.AddDays(+6); } else if (Convert.ToString(thisday) == "Tuesday") { last2weekstart = d15; last2weekend = last2weekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Wednesday") { last2weekstart = d16; last2weekend = last2weekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Thursday") { last2weekstart = d171; last2weekend = last2weekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Friday") { last2weekstart = d18; last2weekend = last2weekstart.Date.AddDays(+6); } else if (thisday.ToString() == "Saturday") { last2weekstart = d19; last2weekend = last2weekstart.Date.AddDays(+6); } else { last2weekstart = d20; last2weekend = last2weekstart.Date.AddDays(+6); } string last2weekstartdate = last2weekstart.ToShortDateString(); ViewState["last2weekstart"] = last2weekstartdate; //string last2weekenddate = last2weekend.ToShortDateString(); //ViewState["last2week"] = last2weekenddate; //------------------this month period----------------- DateTime thismonthstart = Convert.ToDateTime(System.DateTime.Now.Month.ToString() + "/1/" + System.DateTime.Now.Year.ToString()); string thismonthstartdate = thismonthstart.ToShortDateString(); ViewState["thismonthstartdate"] = thismonthstartdate; string thismonthenddate = Today.ToString(); ViewState["thismonthenddate"] = thismonthenddate; //------------------this month period end................ //-----------------last month period start --------------- // int last2monthno = Convert.ToInt32(thismonthstart.Month.ToString()) - 2; int lastmonthno = Convert.ToInt32(thismonthstart.Month.ToString()) - 1; string lastmonthNumber = Convert.ToString(lastmonthno.ToString()); DateTime lastmonth = Convert.ToDateTime(lastmonthNumber.ToString() + "/1/" + ThisYear.ToString()); string lastmonthstart = lastmonth.ToShortDateString(); string lastmonthend = ""; if (lastmonthNumber == "1" || lastmonthNumber == "3" || lastmonthNumber == "5" || lastmonthNumber == "7" || lastmonthNumber == "8" || lastmonthNumber == "10" || lastmonthNumber == "12") { lastmonthend = lastmonthNumber + "/31/" + ThisYear.ToString(); } else if (lastmonthNumber == "4" || lastmonthNumber == "6" || lastmonthNumber == "9" || lastmonthNumber == "11") { lastmonthend = lastmonthNumber + "/30/" + ThisYear.ToString(); } else { if (System.DateTime.IsLeapYear(Convert.ToInt32(ThisYear.ToString()))) { lastmonthend = lastmonthNumber + "/29/" + ThisYear.ToString(); } else { lastmonthend = lastmonthNumber + "/28/" + ThisYear.ToString(); } } string lastmonthstartdate = lastmonthstart.ToString(); ViewState["lastmonthstartdate"] = lastmonthstartdate; string lastmonthenddate = lastmonthend.ToString(); ViewState["lastmonthenddate"] = lastmonthenddate; //-----------------last month period end ----------------------- int last2monthno = Convert.ToInt32(thismonthstart.Month.ToString()) - 2; string last2monthNumber = Convert.ToString(last2monthno.ToString()); DateTime last2month = Convert.ToDateTime(last2monthNumber.ToString() + "/1/" + ThisYear.ToString()); string last2monthstart = last2month.ToShortDateString(); ViewState["last2monthstart"] = last2monthstart; //-----------------last 2 month period end ----------------------- //--------------this year period start---------------------- DateTime thisyearstart = Convert.ToDateTime("1/1/" + ThisYear.ToString()); DateTime thisyearend = Convert.ToDateTime("12/31/" + ThisYear.ToString()); string thisyearstartdate = thisyearstart.ToShortDateString(); ViewState["thisyearstartdate"] = thisyearstartdate; string thisyearenddate = thisyearend.ToShortDateString(); ViewState["thisyearenddate"] = thisyearenddate; //---------------this year period end------------------- //--------------last year period start---------------------- DateTime lastyearstart = Convert.ToDateTime("1/1/" + System.DateTime.Today.AddYears(-1).Year.ToString()); DateTime lastyearend = Convert.ToDateTime("12/31/" + System.DateTime.Today.AddYears(-1).Year.ToString()); string lastyearstartdate = lastyearstart.ToShortDateString(); ViewState["lastyearstartdate"] = lastyearstartdate; string lastyearenddate = lastyearend.ToShortDateString(); ViewState["lastyearenddate"] = lastyearenddate; //---------------last year period end------------------- DateTime last2yearstart = Convert.ToDateTime("1/1/" + System.DateTime.Today.AddYears(-2).Year.ToString()); string last2yearstartdate = last2yearstart.ToShortDateString(); ViewState["last2yearstartdate"] = last2yearstartdate; //---------------last 2 year period ------------------- }
protected void btnOk_Click(object sender, EventArgs e) { if (txtDiscountCode.Text.Trim().Length == 0) { spanErrorMsg.InnerText = "Discount Code cannot be empty."; spanErrorMsg.Visible = true; return; } //Validate the Discount Code. DiscountCode discountCode = GetBL <FinanceBL>().GetDiscountCode(txtDiscountCode.Text.Trim()); if (discountCode == null) { //Invalid Discount Code. spanErrorMsg.InnerText = "Invalid Discount Code."; spanErrorMsg.Visible = true; return; } if (discountCode.ExpireDate.Date < Today) { //If it is expired spanErrorMsg.InnerText = "Discount Code has expired."; spanErrorMsg.Visible = true; return; } //If the usage limit has exceeded. var dicountCodeUsageList = GetBL <FinanceBL>().GetDiscountCodeUsages(discountCode.DiscountCodeID, true); if (dicountCodeUsageList.Count() == discountCode.InstanceCount) { spanErrorMsg.InnerText = "This Discount code has reached its maximum instance count."; spanErrorMsg.Visible = true; return; } //if the new discount code is already being used if (dicountCodeUsageList.Where(dcu => dcu.CompanyId == CompanyId).FirstOrDefault() != null) { spanErrorMsg.InnerText = "Discount Code has already been used by this company."; spanErrorMsg.Visible = true; return; } spanErrorMsg.Visible = false; DiscountCodeUsage newDiscountCodeUsage = new DiscountCodeUsage(); newDiscountCodeUsage.DiscountCodeId = discountCode.DiscountCodeID; newDiscountCodeUsage.CreatedDate = newDiscountCodeUsage.LastUpdatedDate = Now; newDiscountCodeUsage.StartDate = Today; newDiscountCodeUsage.EndDate = Today.AddDays(discountCode.Duration * 7); newDiscountCodeUsage.CreatedByUserId = newDiscountCodeUsage.LastUpdatedByUserId = UserID; newDiscountCodeUsage.CompanyId = CompanyId; newDiscountCodeUsage.IsAdminApplied = true; newDiscountCodeUsage.IsActive = true; GetBL <FinanceBL>().AddDiscountCodeUsageBySBAdmin(newDiscountCodeUsage, UserID); popupManageDiscount.HidePopup(); LoadDiscountCodes(); }
public BuiltInFunctions() { // Text Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["rept"] = new Rept(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); Functions["concat"] = new Concat(); Functions["textjoin"] = new Textjoin(); Functions["char"] = new CharFunction(); Functions["exact"] = new Exact(); Functions["find"] = new Find(); Functions["fixed"] = new Fixed(); Functions["proper"] = new Proper(); Functions["search"] = new Search(); Functions["text"] = new Text.Text(); Functions["t"] = new T(); Functions["hyperlink"] = new Hyperlink(); Functions["value"] = new Value(CultureInfo.CurrentCulture); Functions["trim"] = new Trim(); Functions["clean"] = new Clean(); Functions["unicode"] = new Unicode(); Functions["unichar"] = new Unichar(); Functions["numbervalue"] = new NumberValue(); // Numbers Functions["int"] = new CInt(); // Math Functions["abs"] = new Abs(); Functions["asin"] = new Asin(); Functions["asinh"] = new Asinh(); Functions["acot"] = new Acot(); Functions["acoth"] = new Acoth(); Functions["cos"] = new Cos(); Functions["cot"] = new Cot(); Functions["coth"] = new Coth(); Functions["cosh"] = new Cosh(); Functions["csc"] = new Csc(); Functions["csch"] = new Csch(); Functions["power"] = new Power(); Functions["gcd"] = new Gcd(); Functions["lcm"] = new Lcm(); Functions["sec"] = new Sec(); Functions["sech"] = new SecH(); Functions["sign"] = new Sign(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["ceiling.precise"] = new CeilingPrecise(); Functions["ceiling.math"] = new CeilingMath(); Functions["iso.ceiling"] = new IsoCeiling(); Functions["combin"] = new Combin(); Functions["combina"] = new Combina(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["countblank"] = new CountBlank(); Functions["countif"] = new CountIf(); Functions["countifs"] = new CountIfs(); Functions["fact"] = new Fact(); Functions["factdouble"] = new FactDouble(); Functions["floor"] = new Floor(); Functions["floor.precise"] = new FloorPrecise(); Functions["floor.math"] = new FloorMath(); Functions["radians"] = new Radians(); Functions["roman"] = new Roman(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["sumifs"] = new SumIfs(); Functions["sumproduct"] = new SumProduct(); Functions["sumsq"] = new Sumsq(); Functions["sumxmy2"] = new Sumxmy2(); Functions["sumx2my2"] = new SumX2mY2(); Functions["sumx2py2"] = new SumX2pY2(); Functions["seriessum"] = new Seriessum(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["stdev.s"] = new StdevDotS(); Functions["stdev.p"] = new StdevDotP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["ln"] = new Ln(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["median"] = new Median(); Functions["min"] = new Min(); Functions["mina"] = new Mina(); Functions["mod"] = new Mod(); Functions["mode"] = new Mode(); Functions["mode.sngl"] = new ModeSngl(); Functions["mround"] = new Mround(); Functions["average"] = new Average(); Functions["averagea"] = new AverageA(); Functions["averageif"] = new AverageIf(); Functions["averageifs"] = new AverageIfs(); Functions["round"] = new Round(); Functions["rounddown"] = new Rounddown(); Functions["roundup"] = new Roundup(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["rank"] = new Rank(); Functions["rank.eq"] = new RankEq(); Functions["rank.avg"] = new RankAvg(); Functions["percentile"] = new Percentile(); Functions["percentile.inc"] = new PercentileInc(); Functions["percentrank"] = new Percentrank(); Functions["percentrank.inc"] = new PercentrankInc(); Functions["quotient"] = new Quotient(); Functions["trunc"] = new Trunc(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["atan"] = new Atan(); Functions["atan2"] = new Atan2(); Functions["atanh"] = new Atanh(); Functions["acos"] = new Acos(); Functions["acosh"] = new Acosh(); Functions["var"] = new Var(); Functions["var.s"] = new VarDotS(); Functions["varp"] = new VarP(); Functions["var.p"] = new VarDotP(); Functions["large"] = new Large(); Functions["small"] = new Small(); Functions["degrees"] = new Degrees(); Functions["odd"] = new Odd(); Functions["even"] = new Even(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["isnontext"] = new IsNonText(); Functions["iserror"] = new IsError(); Functions["iserr"] = new IsErr(); Functions["error.type"] = new ErrorType(); Functions["iseven"] = new IsEven(); Functions["isodd"] = new IsOdd(); Functions["islogical"] = new IsLogical(); Functions["isna"] = new IsNa(); Functions["na"] = new Na(); Functions["n"] = new N(); Functions["type"] = new TypeFunction(); // Logical Functions["if"] = new If(); Functions["ifs"] = new Ifs(); Functions["maxifs"] = new MaxIfs(); Functions["minifs"] = new MinIfs(); Functions["iferror"] = new IfError(); Functions["ifna"] = new IfNa(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); Functions["false"] = new False(); Functions["switch"] = new Switch(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row(); Functions["rows"] = new Rows(); Functions["column"] = new Column(); Functions["columns"] = new Columns(); Functions["choose"] = new Choose(); Functions["index"] = new RefAndLookup.Index(); Functions["indirect"] = new Indirect(); Functions["offset"] = new Offset(); // Date Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); Functions["weeknum"] = new Weeknum(); Functions["weekday"] = new Weekday(); Functions["days"] = new Days(); Functions["days360"] = new Days360(); Functions["yearfrac"] = new Yearfrac(); Functions["edate"] = new Edate(); Functions["eomonth"] = new Eomonth(); Functions["isoweeknum"] = new IsoWeekNum(); Functions["workday"] = new Workday(); Functions["workday.intl"] = new WorkdayIntl(); Functions["networkdays"] = new Networkdays(); Functions["networkdays.intl"] = new NetworkdaysIntl(); Functions["datevalue"] = new DateValue(); Functions["timevalue"] = new TimeValue(); // Database Functions["dget"] = new Dget(); Functions["dcount"] = new Dcount(); Functions["dcounta"] = new DcountA(); Functions["dmax"] = new Dmax(); Functions["dmin"] = new Dmin(); Functions["dsum"] = new Dsum(); Functions["daverage"] = new Daverage(); Functions["dvar"] = new Dvar(); Functions["dvarp"] = new Dvarp(); //Finance Functions["cumipmt"] = new Cumipmt(); Functions["cumprinc"] = new Cumprinc(); Functions["ddb"] = new Ddb(); Functions["effect"] = new Effect(); Functions["fvschedule"] = new FvSchedule(); Functions["pduration"] = new Pduration(); Functions["rri"] = new Rri(); Functions["pmt"] = new Pmt(); Functions["ppmt"] = new Ppmt(); Functions["ipmt"] = new Ipmt(); Functions["ispmt"] = new IsPmt(); Functions["pv"] = new Pv(); Functions["fv"] = new Fv(); Functions["npv"] = new Npv(); Functions["rate"] = new Rate(); Functions["nper"] = new Nper(); Functions["nominal"] = new Nominal(); Functions["irr"] = new Irr(); Functions["mirr"] = new Mirr(); Functions["xirr"] = new Xirr(); Functions["sln"] = new Sln(); Functions["syd"] = new Syd(); Functions["xnpv"] = new Xnpv(); Functions["coupdays"] = new Coupdays(); Functions["coupdaysnc"] = new Coupdaysnc(); Functions["coupdaybs"] = new Coupdaybs(); Functions["coupnum"] = new Coupnum(); Functions["coupncd"] = new Coupncd(); Functions["couppcd"] = new Couppcd(); Functions["price"] = new Price(); Functions["yield"] = new Yield(); Functions["duration"] = new Duration(); Functions["disc"] = new Disc(); //Engineering Functions["bitand"] = new BitAnd(); Functions["bitor"] = new BitOr(); Functions["bitxor"] = new BitXor(); Functions["bitlshift"] = new BitLshift(); Functions["bitrshift"] = new BitRshift(); Functions["convert"] = new ConvertFunction(); Functions["bin2dec"] = new Bin2Dec(); Functions["bin2hex"] = new Bin2Hex(); Functions["bin2oct"] = new Bin2Oct(); Functions["dec2bin"] = new Dec2Bin(); Functions["dec2hex"] = new Dec2Hex(); Functions["dec2oct"] = new Dec2Oct(); Functions["hex2bin"] = new Hex2Bin(); Functions["hex2dec"] = new Hex2Dec(); Functions["hex2oct"] = new Hex2Oct(); Functions["oct2bin"] = new Oct2Bin(); Functions["oct2dec"] = new Oct2Dec(); Functions["oct2hex"] = new Oct2Hex(); Functions["delta"] = new Delta(); Functions["erf"] = new Erf(); Functions["erf.precise"] = new ErfPrecise(); Functions["erfc"] = new Erfc(); Functions["erfc.precise"] = new ErfcPrecise(); Functions["besseli"] = new BesselI(); Functions["besselj"] = new BesselJ(); Functions["besselk"] = new BesselK(); Functions["bessely"] = new BesselY(); }
/** * @see https://www.openoffice.org/sc/excelfileformat.pdf */ private static Function[] ProduceFunctions() { Function[] retval = new Function[368]; retval[0] = new Count(); // COUNT retval[FunctionID.IF] = new IfFunc(); //nominally 1 retval[2] = LogicalFunction.ISNA; // IsNA retval[3] = LogicalFunction.ISERROR; // IsERROR retval[FunctionID.SUM] = AggregateFunction.SUM; //nominally 4 retval[5] = AggregateFunction.AVERAGE; // AVERAGE retval[6] = AggregateFunction.MIN; // MIN retval[7] = AggregateFunction.MAX; // MAX retval[8] = new Row(); // ROW retval[9] = new Column(); // COLUMN retval[10] = new Na(); // NA retval[11] = new Npv(); // NPV retval[12] = AggregateFunction.STDEV; // STDEV retval[13] = NumericFunction.DOLLAR; // DOLLAR retval[14] = new Fixed(); // FIXED retval[15] = NumericFunction.SIN; // SIN retval[16] = NumericFunction.COS; // COS retval[17] = NumericFunction.TAN; // TAN retval[18] = NumericFunction.ATAN; // ATAN retval[19] = new Pi(); // PI retval[20] = NumericFunction.SQRT; // SQRT retval[21] = NumericFunction.EXP; // EXP retval[22] = NumericFunction.LN; // LN retval[23] = NumericFunction.LOG10; // LOG10 retval[24] = NumericFunction.ABS; // ABS retval[25] = NumericFunction.INT; // INT retval[26] = NumericFunction.SIGN; // SIGN retval[27] = NumericFunction.ROUND; // ROUND retval[28] = new Lookup(); // LOOKUP retval[29] = new Index(); // INDEX retval[30] = new Rept(); // REPT retval[31] = TextFunction.MID; // MID retval[32] = TextFunction.LEN; // LEN retval[33] = new Value(); // VALUE retval[34] = new True(); // TRUE retval[35] = new False(); // FALSE retval[36] = new And(); // AND retval[37] = new Or(); // OR retval[38] = new Not(); // NOT retval[39] = NumericFunction.MOD; // MOD retval[40] = new NotImplementedFunction("DCOUNT"); // DCOUNT retval[41] = new NotImplementedFunction("DSUM"); // DSUM retval[42] = new NotImplementedFunction("DAVERAGE"); // DAVERAGE retval[43] = new DStarRunner(DStarRunner.DStarAlgorithmEnum.DMIN); // DMIN retval[44] = new NotImplementedFunction("DMAX"); // DMAX retval[45] = new NotImplementedFunction("DSTDEV"); // DSTDEV retval[46] = AggregateFunction.VAR; // VAR retval[47] = new NotImplementedFunction("DVAR"); // DVAR retval[48] = TextFunction.TEXT; // TEXT retval[49] = new NotImplementedFunction("LINEST"); // LINEST retval[50] = new NotImplementedFunction("TREND"); // TREND retval[51] = new NotImplementedFunction("LOGEST"); // LOGEST retval[52] = new NotImplementedFunction("GROWTH"); // GROWTH retval[53] = new NotImplementedFunction("GOTO"); // GOTO retval[54] = new NotImplementedFunction("HALT"); // HALT retval[56] = FinanceFunction.PV; // PV retval[57] = FinanceFunction.FV; // FV retval[58] = FinanceFunction.NPER; // NPER retval[59] = FinanceFunction.PMT; // PMT retval[60] = new Rate(); // RATE retval[61] = new Mirr(); // MIRR retval[62] = new Irr(); // IRR retval[63] = new Rand(); // RAND retval[64] = new Match(); // MATCH retval[65] = DateFunc.instance; // DATE retval[66] = new TimeFunc(); // TIME retval[67] = CalendarFieldFunction.DAY; // DAY retval[68] = CalendarFieldFunction.MONTH; // MONTH retval[69] = CalendarFieldFunction.YEAR; // YEAR retval[70] = WeekdayFunc.instance; // WEEKDAY retval[71] = CalendarFieldFunction.HOUR; retval[72] = CalendarFieldFunction.MINUTE; retval[73] = CalendarFieldFunction.SECOND; retval[74] = new Now(); retval[75] = new NotImplementedFunction("AREAS"); // AREAS retval[76] = new Rows(); // ROWS retval[77] = new Columns(); // COLUMNS retval[FunctionID.OFFSET] = new Offset(); //nominally 78 retval[79] = new NotImplementedFunction("ABSREF"); // ABSREF retval[80] = new NotImplementedFunction("RELREF"); // RELREF retval[81] = new NotImplementedFunction("ARGUMENT"); // ARGUMENT retval[82] = TextFunction.SEARCH; retval[83] = new NotImplementedFunction("TRANSPOSE"); // TRANSPOSE retval[84] = new NotImplementedFunction("ERROR"); // ERROR retval[85] = new NotImplementedFunction("STEP"); // STEP retval[86] = new NotImplementedFunction("TYPE"); // TYPE retval[87] = new NotImplementedFunction("ECHO"); // ECHO retval[88] = new NotImplementedFunction("SetNAME"); // SetNAME retval[89] = new NotImplementedFunction("CALLER"); // CALLER retval[90] = new NotImplementedFunction("DEREF"); // DEREF retval[91] = new NotImplementedFunction("WINDOWS"); // WINDOWS retval[92] = new NotImplementedFunction("SERIES"); // SERIES retval[93] = new NotImplementedFunction("DOCUMENTS"); // DOCUMENTS retval[94] = new NotImplementedFunction("ACTIVECELL"); // ACTIVECELL retval[95] = new NotImplementedFunction("SELECTION"); // SELECTION retval[96] = new NotImplementedFunction("RESULT"); // RESULT retval[97] = NumericFunction.ATAN2; // ATAN2 retval[98] = NumericFunction.ASIN; // ASIN retval[99] = NumericFunction.ACOS; // ACOS retval[FunctionID.CHOOSE] = new Choose(); //nominally 100 retval[101] = new Hlookup(); // HLOOKUP retval[102] = new Vlookup(); // VLOOKUP retval[103] = new NotImplementedFunction("LINKS"); // LINKS retval[104] = new NotImplementedFunction("INPUT"); // INPUT retval[105] = LogicalFunction.ISREF; // IsREF retval[106] = new NotImplementedFunction("GetFORMULA"); // GetFORMULA retval[107] = new NotImplementedFunction("GetNAME"); // GetNAME retval[108] = new NotImplementedFunction("SetVALUE"); // SetVALUE retval[109] = NumericFunction.LOG; // LOG retval[110] = new NotImplementedFunction("EXEC"); // EXEC retval[111] = TextFunction.CHAR; // CHAR retval[112] = TextFunction.LOWER; // LOWER retval[113] = TextFunction.UPPER; // UPPER retval[114] = TextFunction.PROPER; // PROPER retval[115] = TextFunction.LEFT; // LEFT retval[116] = TextFunction.RIGHT; // RIGHT retval[117] = TextFunction.EXACT; // EXACT retval[118] = TextFunction.TRIM; // TRIM retval[119] = new Replace(); // Replace retval[120] = new Substitute(); // SUBSTITUTE retval[121] = new Code(); // CODE retval[122] = new NotImplementedFunction("NAMES"); // NAMES retval[123] = new NotImplementedFunction("DIRECTORY"); // DIRECTORY retval[124] = TextFunction.FIND; // Find retval[125] = new NotImplementedFunction("CELL"); // CELL retval[126] = LogicalFunction.ISERR; // IsERR retval[127] = LogicalFunction.ISTEXT; // IsTEXT retval[128] = LogicalFunction.ISNUMBER; // IsNUMBER retval[129] = LogicalFunction.ISBLANK; // IsBLANK retval[130] = new T(); // T retval[131] = new NotImplementedFunction("N"); // N retval[132] = new NotImplementedFunction("FOPEN"); // FOPEN retval[133] = new NotImplementedFunction("FCLOSE"); // FCLOSE retval[134] = new NotImplementedFunction("FSIZE"); // FSIZE retval[135] = new NotImplementedFunction("FReadLN"); // FReadLN retval[136] = new NotImplementedFunction("FRead"); // FRead retval[137] = new NotImplementedFunction("FWriteLN"); // FWriteLN retval[138] = new NotImplementedFunction("FWrite"); // FWrite retval[139] = new NotImplementedFunction("FPOS"); // FPOS retval[140] = new NotImplementedFunction("DATEVALUE"); // DATEVALUE retval[141] = new NotImplementedFunction("TIMEVALUE"); // TIMEVALUE retval[142] = new NotImplementedFunction("SLN"); // SLN retval[143] = new NotImplementedFunction("SYD"); // SYD retval[144] = new NotImplementedFunction("DDB"); // DDB retval[145] = new NotImplementedFunction("GetDEF"); // GetDEF retval[146] = new NotImplementedFunction("REFTEXT"); // REFTEXT retval[147] = new NotImplementedFunction("TEXTREF"); // TEXTREF retval[FunctionID.INDIRECT] = null; // Indirect.Evaluate has different signature retval[149] = new NotImplementedFunction("REGISTER"); // REGISTER retval[150] = new NotImplementedFunction("CALL"); // CALL retval[151] = new NotImplementedFunction("AddBAR"); // AddBAR retval[152] = new NotImplementedFunction("AddMENU"); // AddMENU retval[153] = new NotImplementedFunction("AddCOMMAND"); // AddCOMMAND retval[154] = new NotImplementedFunction("ENABLECOMMAND"); // ENABLECOMMAND retval[155] = new NotImplementedFunction("CHECKCOMMAND"); // CHECKCOMMAND retval[156] = new NotImplementedFunction("RenameCOMMAND"); // RenameCOMMAND retval[157] = new NotImplementedFunction("SHOWBAR"); // SHOWBAR retval[158] = new NotImplementedFunction("DELETEMENU"); // DELETEMENU retval[159] = new NotImplementedFunction("DELETECOMMAND"); // DELETECOMMAND retval[160] = new NotImplementedFunction("GetCHARTITEM"); // GetCHARTITEM retval[161] = new NotImplementedFunction("DIALOGBOX"); // DIALOGBOX retval[162] = TextFunction.CLEAN; // CLEAN retval[163] = new NotImplementedFunction("MDETERM"); // MDETERM retval[164] = new NotImplementedFunction("MINVERSE"); // MINVERSE retval[165] = new NotImplementedFunction("MMULT"); // MMULT retval[166] = new NotImplementedFunction("FILES"); // FILES retval[167] = new IPMT(); retval[168] = new PPMT(); retval[169] = new Counta(); // COUNTA retval[170] = new NotImplementedFunction("CANCELKEY"); // CANCELKEY retval[175] = new NotImplementedFunction("INITIATE"); // INITIATE retval[176] = new NotImplementedFunction("REQUEST"); // REQUEST retval[177] = new NotImplementedFunction("POKE"); // POKE retval[178] = new NotImplementedFunction("EXECUTE"); // EXECUTE retval[179] = new NotImplementedFunction("TERMINATE"); // TERMINATE retval[180] = new NotImplementedFunction("RESTART"); // RESTART retval[181] = new NotImplementedFunction("HELP"); // HELP retval[182] = new NotImplementedFunction("GetBAR"); // GetBAR retval[183] = AggregateFunction.PRODUCT; // PRODUCT retval[184] = NumericFunction.FACT; // FACT retval[185] = new NotImplementedFunction("GetCELL"); // GetCELL retval[186] = new NotImplementedFunction("GetWORKSPACE"); // GetWORKSPACE retval[187] = new NotImplementedFunction("GetWINDOW"); // GetWINDOW retval[188] = new NotImplementedFunction("GetDOCUMENT"); // GetDOCUMENT retval[189] = new NotImplementedFunction("DPRODUCT"); // DPRODUCT retval[190] = LogicalFunction.ISNONTEXT; // IsNONTEXT retval[191] = new NotImplementedFunction("GetNOTE"); // GetNOTE retval[192] = new NotImplementedFunction("NOTE"); // NOTE retval[193] = new NotImplementedFunction("STDEVP"); // STDEVP retval[194] = AggregateFunction.VARP; // VARP retval[195] = new NotImplementedFunction("DSTDEVP"); // DSTDEVP retval[196] = new NotImplementedFunction("DVARP"); // DVARP retval[197] = NumericFunction.TRUNC; // TRUNC retval[198] = LogicalFunction.ISLOGICAL; // IsLOGICAL retval[199] = new NotImplementedFunction("DCOUNTA"); // DCOUNTA retval[200] = new NotImplementedFunction("DELETEBAR"); // DELETEBAR retval[201] = new NotImplementedFunction("UNREGISTER"); // UNREGISTER retval[204] = new NotImplementedFunction("USDOLLAR"); // USDOLLAR retval[205] = new NotImplementedFunction("FindB"); // FindB retval[206] = new NotImplementedFunction("SEARCHB"); // SEARCHB retval[207] = new NotImplementedFunction("ReplaceB"); // ReplaceB retval[208] = new NotImplementedFunction("LEFTB"); // LEFTB retval[209] = new NotImplementedFunction("RIGHTB"); // RIGHTB retval[210] = new NotImplementedFunction("MIDB"); // MIDB retval[211] = new NotImplementedFunction("LENB"); // LENB retval[212] = NumericFunction.ROUNDUP; // ROUNDUP retval[213] = NumericFunction.ROUNDDOWN; // ROUNDDOWN retval[214] = new NotImplementedFunction("ASC"); // ASC retval[215] = new NotImplementedFunction("DBCS"); // DBCS retval[216] = new Rank(); // RANK retval[219] = new Address(); // AddRESS retval[220] = new Days360(); // DAYS360 retval[221] = new Today(); // TODAY retval[222] = new NotImplementedFunction("VDB"); // VDB retval[227] = AggregateFunction.MEDIAN; // MEDIAN retval[228] = new Sumproduct(); // SUMPRODUCT retval[229] = NumericFunction.SINH; // SINH retval[230] = NumericFunction.COSH; // COSH retval[231] = NumericFunction.TANH; // TANH retval[232] = NumericFunction.ASINH; // ASINH retval[233] = NumericFunction.ACOSH; // ACOSH retval[234] = NumericFunction.ATANH; // ATANH retval[235] = new DStarRunner(DStarRunner.DStarAlgorithmEnum.DGET); // DGet retval[236] = new NotImplementedFunction("CreateOBJECT"); // CreateOBJECT retval[237] = new NotImplementedFunction("VOLATILE"); // VOLATILE retval[238] = new NotImplementedFunction("LASTERROR"); // LASTERROR retval[239] = new NotImplementedFunction("CUSTOMUNDO"); // CUSTOMUNDO retval[240] = new NotImplementedFunction("CUSTOMREPEAT"); // CUSTOMREPEAT retval[241] = new NotImplementedFunction("FORMULAConvert"); // FORMULAConvert retval[242] = new NotImplementedFunction("GetLINKINFO"); // GetLINKINFO retval[243] = new NotImplementedFunction("TEXTBOX"); // TEXTBOX retval[244] = new NotImplementedFunction("INFO"); // INFO retval[245] = new NotImplementedFunction("GROUP"); // GROUP retval[246] = new NotImplementedFunction("GetOBJECT"); // GetOBJECT retval[247] = new NotImplementedFunction("DB"); // DB retval[248] = new NotImplementedFunction("PAUSE"); // PAUSE retval[250] = new NotImplementedFunction("RESUME"); // RESUME retval[252] = new NotImplementedFunction("FREQUENCY"); // FREQUENCY retval[253] = new NotImplementedFunction("AddTOOLBAR"); // AddTOOLBAR retval[254] = new NotImplementedFunction("DELETETOOLBAR"); // DELETETOOLBAR retval[FunctionID.EXTERNAL_FUNC] = null; // ExternalFunction is a FreeREfFunction retval[256] = new NotImplementedFunction("RESetTOOLBAR"); // RESetTOOLBAR retval[257] = new NotImplementedFunction("EVALUATE"); // EVALUATE retval[258] = new NotImplementedFunction("GetTOOLBAR"); // GetTOOLBAR retval[259] = new NotImplementedFunction("GetTOOL"); // GetTOOL retval[260] = new NotImplementedFunction("SPELLINGCHECK"); // SPELLINGCHECK retval[261] = new Errortype(); // ERRORTYPE retval[262] = new NotImplementedFunction("APPTITLE"); // APPTITLE retval[263] = new NotImplementedFunction("WINDOWTITLE"); // WINDOWTITLE retval[264] = new NotImplementedFunction("SAVETOOLBAR"); // SAVETOOLBAR retval[265] = new NotImplementedFunction("ENABLETOOL"); // ENABLETOOL retval[266] = new NotImplementedFunction("PRESSTOOL"); // PRESSTOOL retval[267] = new NotImplementedFunction("REGISTERID"); // REGISTERID retval[268] = new NotImplementedFunction("GetWORKBOOK"); // GetWORKBOOK retval[269] = AggregateFunction.AVEDEV; // AVEDEV retval[270] = new NotImplementedFunction("BETADIST"); // BETADIST retval[271] = new NotImplementedFunction("GAMMALN"); // GAMMALN retval[272] = new NotImplementedFunction("BETAINV"); // BETAINV retval[273] = new NotImplementedFunction("BINOMDIST"); // BINOMDIST retval[274] = new NotImplementedFunction("CHIDIST"); // CHIDIST retval[275] = new NotImplementedFunction("CHIINV"); // CHIINV retval[276] = NumericFunction.COMBIN; // COMBIN retval[277] = new NotImplementedFunction("CONFIDENCE"); // CONFIDENCE retval[278] = new NotImplementedFunction("CRITBINOM"); // CRITBINOM retval[279] = new Even(); // EVEN retval[280] = new NotImplementedFunction("EXPONDIST"); // EXPONDIST retval[281] = new NotImplementedFunction("FDIST"); // FDIST retval[282] = new NotImplementedFunction("FINV"); // FINV retval[283] = new NotImplementedFunction("FISHER"); // FISHER retval[284] = new NotImplementedFunction("FISHERINV"); // FISHERINV retval[285] = NumericFunction.FLOOR; // FLOOR retval[286] = new NotImplementedFunction("GAMMADIST"); // GAMMADIST retval[287] = new NotImplementedFunction("GAMMAINV"); // GAMMAINV retval[288] = NumericFunction.CEILING; // CEILING retval[289] = new NotImplementedFunction("HYPGEOMDIST"); // HYPGEOMDIST retval[290] = new NotImplementedFunction("LOGNORMDIST"); // LOGNORMDIST retval[291] = new NotImplementedFunction("LOGINV"); // LOGINV retval[292] = new NotImplementedFunction("NEGBINOMDIST"); // NEGBINOMDIST retval[293] = new NotImplementedFunction("NORMDIST"); // NORMDIST retval[294] = new NotImplementedFunction("NORMSDIST"); // NORMSDIST retval[295] = new NotImplementedFunction("NORMINV"); // NORMINV retval[296] = new NotImplementedFunction("NORMSINV"); // NORMSINV retval[297] = new NotImplementedFunction("STANDARDIZE"); // STANDARDIZE retval[298] = new Odd(); // ODD retval[299] = new NotImplementedFunction("PERMUT"); // PERMUT retval[300] = NumericFunction.POISSON; // POISSON retval[301] = new NotImplementedFunction("TDIST"); // TDIST retval[302] = new NotImplementedFunction("WEIBULL"); // WEIBULL retval[303] = new Sumxmy2(); // SUMXMY2 retval[304] = new Sumx2my2(); // SUMX2MY2 retval[305] = new Sumx2py2(); // SUMX2PY2 retval[306] = new NotImplementedFunction("CHITEST"); // CHITEST retval[307] = new NotImplementedFunction("CORREL"); // CORREL retval[308] = new NotImplementedFunction("COVAR"); // COVAR retval[309] = new NotImplementedFunction("FORECAST"); // FORECAST retval[310] = new NotImplementedFunction("FTEST"); // FTEST retval[311] = new Intercept(); // INTERCEPT retval[312] = new NotImplementedFunction("PEARSON"); // PEARSON retval[313] = new NotImplementedFunction("RSQ"); // RSQ retval[314] = new NotImplementedFunction("STEYX"); // STEYX retval[315] = new Slope(); // SLOPE retval[316] = new NotImplementedFunction("TTEST"); // TTEST retval[317] = new NotImplementedFunction("PROB"); // PROB retval[318] = AggregateFunction.DEVSQ; // DEVSQ retval[319] = new NotImplementedFunction("GEOMEAN"); // GEOMEAN retval[320] = new NotImplementedFunction("HARMEAN"); // HARMEAN retval[321] = AggregateFunction.SUMSQ; // SUMSQ retval[322] = new NotImplementedFunction("KURT"); // KURT retval[323] = new NotImplementedFunction("SKEW"); // SKEW retval[324] = new NotImplementedFunction("ZTEST"); // ZTEST retval[325] = AggregateFunction.LARGE; // LARGE retval[326] = AggregateFunction.SMALL; // SMALL retval[327] = new NotImplementedFunction("QUARTILE"); // QUARTILE retval[328] = AggregateFunction.PERCENTILE; // PERCENTILE retval[329] = new NotImplementedFunction("PERCENTRANK"); // PERCENTRANK retval[330] = new Mode(); // MODE retval[331] = new NotImplementedFunction("TRIMMEAN"); // TRIMMEAN retval[332] = new NotImplementedFunction("TINV"); // TINV retval[334] = new NotImplementedFunction("MOVIECOMMAND"); // MOVIECOMMAND retval[335] = new NotImplementedFunction("GetMOVIE"); // GetMOVIE retval[336] = TextFunction.CONCATENATE; // CONCATENATE retval[337] = NumericFunction.POWER; // POWER retval[338] = new NotImplementedFunction("PIVOTAddDATA"); // PIVOTAddDATA retval[339] = new NotImplementedFunction("GetPIVOTTABLE"); // GetPIVOTTABLE retval[340] = new NotImplementedFunction("GetPIVOTFIELD"); // GetPIVOTFIELD retval[341] = new NotImplementedFunction("GetPIVOTITEM"); // GetPIVOTITEM retval[342] = NumericFunction.RADIANS; ; // RADIANS retval[343] = NumericFunction.DEGREES; // DEGREES retval[344] = new Subtotal(); // SUBTOTAL retval[345] = new Sumif(); // SUMIF retval[346] = new Countif(); // COUNTIF retval[347] = new Countblank(); // COUNTBLANK retval[348] = new NotImplementedFunction("SCENARIOGet"); // SCENARIOGet retval[349] = new NotImplementedFunction("OPTIONSLISTSGet"); // OPTIONSLISTSGet retval[350] = new NotImplementedFunction("IsPMT"); // IsPMT retval[351] = new NotImplementedFunction("DATEDIF"); // DATEDIF retval[352] = new NotImplementedFunction("DATESTRING"); // DATESTRING retval[353] = new NotImplementedFunction("NUMBERSTRING"); // NUMBERSTRING retval[354] = new Roman(); // ROMAN retval[355] = new NotImplementedFunction("OPENDIALOG"); // OPENDIALOG retval[356] = new NotImplementedFunction("SAVEDIALOG"); // SAVEDIALOG retval[357] = new NotImplementedFunction("VIEWGet"); // VIEWGet retval[358] = new NotImplementedFunction("GetPIVOTDATA"); // GetPIVOTDATA retval[359] = new Hyperlink(); // HYPERLINK retval[360] = new NotImplementedFunction("PHONETIC"); // PHONETIC retval[361] = new NotImplementedFunction("AVERAGEA"); // AVERAGEA retval[362] = MinaMaxa.MAXA; // MAXA retval[363] = MinaMaxa.MINA; // MINA retval[364] = new NotImplementedFunction("STDEVPA"); // STDEVPA retval[365] = new NotImplementedFunction("VARPA"); // VARPA retval[366] = new NotImplementedFunction("STDEVA"); // STDEVA retval[367] = new NotImplementedFunction("VARA"); // VARA return(retval); }
private void DateExpression() { switch (Peek(1).Kind) { case TokenKind.TODAY: _dateRange.AddDate(Today); Load(); break; case TokenKind.TOMORROW: _dateRange.AddDate(Today.AddDays(1)); Load(); break; case TokenKind.YESTERDAY: _dateRange.AddDate(Today.AddDays(-1)); Load(); break; case TokenKind.DAY_IDENTIFIER: DayDateIdent(Peek(1).Text, TokenKind.DAY); Load(); break; case TokenKind.NUMBER: var num = int.Parse(Peek(1).Text); Load(); switch (Peek(1).Kind) { case TokenKind.DAY: case TokenKind.WEEK: case TokenKind.MONTH: case TokenKind.YEAR: NumQuickDateIdent(num); break; case TokenKind.MONTH_MODIFIER: Load(); MonthDateIdent(num); break; } break; case TokenKind.NEXT: Load(); NumQuickDateIdent(1); break; case TokenKind.PREVIOUS: Load(); NumQuickDateIdent(-1); break; } //Get Or Time Year switch (Peek(1).Kind) { case TokenKind.NUMBER: Year(); Load(); if (Peek(1).Kind == TokenKind.AT) { Time(); } break; case TokenKind.AT: Time(); break; } Load(); }
public BuiltInFunctions() { // Text Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["rept"] = new Rept(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); Functions["char"] = new CharFunction(); Functions["exact"] = new Exact(); Functions["find"] = new Find(); Functions["fixed"] = new Fixed(); Functions["proper"] = new Proper(); Functions["search"] = new Search(); Functions["text"] = new Text.Text(); Functions["t"] = new T(); Functions["hyperlink"] = new Hyperlink(); Functions["value"] = new Value(); // Numbers Functions["int"] = new CInt(); // Math Functions["abs"] = new Abs(); Functions["asin"] = new Asin(); Functions["asinh"] = new Asinh(); Functions["cos"] = new Cos(); Functions["cosh"] = new Cosh(); Functions["power"] = new Power(); Functions["sign"] = new Sign(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["countblank"] = new CountBlank(); Functions["countif"] = new CountIf(); Functions["countifs"] = new CountIfs(); Functions["fact"] = new Fact(); Functions["floor"] = new Floor(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["sumifs"] = new SumIfs(); Functions["sumproduct"] = new SumProduct(); Functions["sumsq"] = new Sumsq(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["stdev.s"] = new Stdev(); Functions["stdev.p"] = new StdevP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["ln"] = new Ln(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["median"] = new Median(); Functions["min"] = new Min(); Functions["mina"] = new Mina(); Functions["mod"] = new Mod(); Functions["average"] = new Average(); Functions["averagea"] = new AverageA(); Functions["averageif"] = new AverageIf(); Functions["averageifs"] = new AverageIfs(); Functions["round"] = new Round(); Functions["rounddown"] = new Rounddown(); Functions["roundup"] = new Roundup(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["rank"] = new Rank(); Functions["rank.eq"] = new Rank(); Functions["rank.avg"] = new Rank(true); Functions["quotient"] = new Quotient(); Functions["trunc"] = new Trunc(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["atan"] = new Atan(); Functions["atan2"] = new Atan2(); Functions["atanh"] = new Atanh(); Functions["acos"] = new Acos(); Functions["acosh"] = new Acosh(); Functions["var"] = new Var(); Functions["varp"] = new VarP(); Functions["large"] = new Large(); Functions["small"] = new Small(); Functions["degrees"] = new Degrees(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["isnontext"] = new IsNonText(); Functions["iserror"] = new IsError(); Functions["iserr"] = new IsErr(); Functions["error.type"] = new ErrorType(); Functions["iseven"] = new IsEven(); Functions["isodd"] = new IsOdd(); Functions["islogical"] = new IsLogical(); Functions["isna"] = new IsNa(); Functions["na"] = new Na(); Functions["n"] = new N(); // Logical Functions["if"] = new If(); Functions["iferror"] = new IfError(); Functions["ifna"] = new IfNa(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); Functions["false"] = new False(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row() { SkipArgumentEvaluation = true }; Functions["rows"] = new Rows() { SkipArgumentEvaluation = true }; Functions["column"] = new Column() { SkipArgumentEvaluation = true }; Functions["columns"] = new Columns() { SkipArgumentEvaluation = true }; Functions["choose"] = new Choose(); Functions["index"] = new Index(); Functions["indirect"] = new Indirect(); Functions["offset"] = new Offset() { SkipArgumentEvaluation = true }; // Date Functions["DATEDIF"] = new DATEDIF(); Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); Functions["weeknum"] = new Weeknum(); Functions["weekday"] = new Weekday(); Functions["days360"] = new Days360(); Functions["yearfrac"] = new Yearfrac(); Functions["edate"] = new Edate(); Functions["eomonth"] = new Eomonth(); Functions["isoweeknum"] = new IsoWeekNum(); Functions["workday"] = new Workday(); Functions["networkdays"] = new Networkdays(); Functions["networkdays.intl"] = new NetworkdaysIntl(); Functions["datevalue"] = new DateValue(); Functions["timevalue"] = new TimeValue(); // Database Functions["dget"] = new Dget(); Functions["dcount"] = new Dcount(); Functions["dcounta"] = new DcountA(); Functions["dmax"] = new Dmax(); Functions["dmin"] = new Dmin(); Functions["dsum"] = new Dsum(); Functions["daverage"] = new Daverage(); Functions["dvar"] = new Dvar(); Functions["dvarp"] = new Dvarp(); //Financial Functions["Pmt"] = new PMT(); Functions["Rate"] = new Rate(); }
public void Today_Time_can_be_specified_with_At() { Assert.That(Today.At(14), Is.EqualTo(8.May(2011).At(14))); Assert.That(Today.At(14, 30), Is.EqualTo(8.May(2011).At(14, 30))); Assert.That(Today.At(14, 30, 26), Is.EqualTo(8.May(2011).At(14, 30, 26))); }