public static void PopulateDayTypeProperties(DayType dt, ResourceDescription rd) { if ((dt != null) && (rd != null)) { IES1Converter.PopulateIdentifiedObjectProperties(dt, rd); } }
public double GenerateDayType() { day_type = DayType.Poor; double N = rand.NextDouble(); double cumulative = 0; cumulative += P_Days[0]; if (N <= cumulative) { day_type = DayType.Good; return(N); } cumulative += P_Days[1]; if (N <= cumulative) { day_type = DayType.Fair; return(N); } cumulative += P_Days[2]; if (N <= cumulative) { day_type = DayType.Poor; return(N); } return(N); }
public List <(DateTime, DayType, TimeSpan)> Get_DayTypeInYear(int year) { List <(DateTime, DayType, TimeSpan)> list1 = new List <(DateTime, DayType, TimeSpan)>(); List <List <string> > list2 = GetAllRowFromTable("holi"); list2.ForEach(x => { DateTime day = new DateTime(Convert.ToInt64(x[0])).ToLocalTime(); TimeSpan ts = new TimeSpan(0, Convert.ToInt32(x[2]), 0); DayType dayType = new DayType(); if (Convert.ToInt32(x[1]) == 0) { dayType = DayType.FreeDay; } else if (Convert.ToInt32(x[1]) == 1) { dayType = DayType.FullDay; } else if (Convert.ToInt32(x[1]) == 2) { dayType = DayType.ShortDay; } if (day.Year == year) { list1.Add((day, dayType, ts)); } }); return(list1); }
private void ClearProperties() { SDStackPanelVis = false; TheSpecialDay = new SpecialDay(); TheMonth = new TimePeriod(); TheDayType = new DayType(); }
/// <summary> /// Sets the type of the day (used for user input). /// </summary> /// <param name="date">The date.</param> /// <param name="dayType">Type of the day.</param> /// /// <returns>Function doesn't return anything, but it saves daytype in user-defined calendar.</returns> public static void SetDayType(DateTime date, DayType dayType) { Day temp = new Day(date, dayType); HolidaysCalendar.Add(temp); return; }
public static Color GetDayTypeForeColor(DayType dayType) { lock (m_syncRoot) { if (dayType.IsWorkDay) return Color.Black; else if (dayType.IsWeekend) return Color.MidnightBlue; else if (dayType.IsExecutiveOrder) return Color.DarkCyan; else if (dayType.IsFlexDay) return Color.DarkGreen; else if (dayType.IsVacationDay) return Color.DarkGoldenrod; else if (dayType.IsSickDay) return Color.MediumVioletRed; else if (dayType.IsHalfDay) return ColorTranslator.FromHtml("#666666"); else if (dayType.IsOther) return Color.Indigo; else if (dayType.IsNA) return Color.Indigo; else { MessageBox.Show(string.Format("DayTypes.{0} is unhandled in GetDayTypeForeColor(); using default ForeColor.", dayType.Name), "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return Color.FromKnownColor(KnownColor.ControlText); } } }
private bool CheckValidation(DayType dt) { string MessageError = null; using (SalDbContext _db = new SalDbContext()) { var checkedwage = _db.DayTypes.FirstOrDefault(p => p.NameDayType == dt.NameDayType); if (checkedwage != null) { MessageError += "Елемент вже є в базі"; return(false); } else { if (string.IsNullOrWhiteSpace(dt.NameDayType.ToString())) { MessageError += "Поле не може бути пустим"; } } } if (string.IsNullOrEmpty(MessageError)) { return(true); } else { MessageBox.Show("Mistake {0}", MessageError.ToString()); return(false); } }
public IEnumerable <DatesRange> this[DayType dayType] { get { return(Ranges.Where(d => d.Key == dayType).SelectMany(d => d.Value)); } }
private DayType calculateDayType(DateTime dt, DayOfWeek dayOfWeek, GermanSpecialDays specialDays, out GermanSpecialDay foundSpecialDay) { foundSpecialDay = null; if (specialDays != null) { specialDays.TryGetValue(dt, out foundSpecialDay); } if (foundSpecialDay != null) { return(DayType.Holiday); } DayType ret = DayType.Unknown; switch (dayOfWeek) { case DayOfWeek.Monday: case DayOfWeek.Tuesday: case DayOfWeek.Wednesday: case DayOfWeek.Thursday: case DayOfWeek.Friday: ret = DayType.Working; break; case DayOfWeek.Saturday: case DayOfWeek.Sunday: ret = DayType.Weekend; break; } // TODO: more calculations required... return(ret); }
public Answer this[DayType dayType] { get { return(Answers.Where(d => d.DayType == dayType).FirstOrDefault()); } }
public JsonResult DeleteDayType(DayType dayType) { var isSuccess = true; var message = string.Empty; const string url = "/DayType/Index"; permission = (RoleSubModuleItem)cacheProvider.Get(cacheKey) ?? roleSubModuleItemService.GetRoleSubModuleItemBySubModuleIdandRole(url, Helpers.UserSession.GetUserFromSession().RoleId); if (permission.DeleteOperation == true) { isSuccess = this.dayTypeService.DeleteDayType(dayType.Id); if (isSuccess) { message = Resources.ResourceDayType.MsgDayTypeDeleteSuccessful; } else { message = Resources.ResourceDayType.MsgDayTypeDeleteFailed; } } else { message = Resources.ResourceCommon.MsgNoPermissionToDelete; } return(Json(new { isSuccess = isSuccess, message = message }, JsonRequestBehavior.AllowGet)); }
public RelativeTimeInterval(int leadDays, DayType dayType, DateTime from, DateTime to) { this.LeadDays = leadDays; this.LeadDayType = dayType; this.From = from; this.To = to; }
/** * Switch backward. */ public void SwitchBackward() { DayType previousDayType; switch (currentDayType) { case DayType.DayAfterTomorrow: previousDayType = DayType.Tomorrow; break; case DayType.Tomorrow: case DayType.Today: default: previousDayType = DayType.Today; break; } // fetch new data if necessary if (previousDayType != currentDayType) { callback(previousDayType); currentDayType = previousDayType; UpdateButtons(); } }
public double GenerateDayType() { day_type = DayType.Poor; double N = rand.NextDouble(); double cumulative = 0; cumulative += P_Days[0]; if (N <= cumulative) { day_type = DayType.Good; return N; } cumulative += P_Days[1]; if (N <= cumulative) { day_type = DayType.Fair; return N; } cumulative += P_Days[2]; if (N <= cumulative) { day_type = DayType.Poor; return N; } return N; }
/// <summary> /// Returns the localiztion text of a specified week day type /// </summary> public static int GetText(DayType dayType) { switch (dayType) { case DayType.FirstWorkingDay: return(GetText(GetDayByIndex(0))); case DayType.LastWorkingDay: return(GetText(GetDayByIndex(4))); case DayType.FirstWeekendDay: return(GetText(FirstWeekendDay)); case DayType.LastWeekendDay: return(GetText(SecondWeekendDay)); case DayType.WorkingDays: return(680); case DayType.Record_WorkingDays: return(672); case DayType.WeekendDays: return(1050); case DayType.Record_WeekendDays: return(1051); default: return(-1); } }
public static SelectList ToSelectList(this DayType selectedValueOutput) { var values = from DayType e in Enum.GetValues(typeof(DayType)) select new { Id = (int)e, Name = e.GetDescription() }; return(new SelectList(values, "Id", "Name", selectedValueOutput)); }
private void RefreshBackground() { var now = DateTime.Now; var notes = Notes.Current.Items; var dayNotes = notes.Where(a => !a.IsMonthDay && MonthDayHelper.IsSameMonthDay(Convert.ToDateTime(a.Date), Day)) .Select(a => a.Name).ToList(); var monthDayNotes = notes.Where(a => a.IsMonthDay && MonthDayHelper.IsSameMonthMonthMonthDay(Convert.ToDateTime(a.Date), Day)) .Select(a => a.Name);; dayNotes.AddRange(monthDayNotes); if (dayNotes.Count > 0) { DayType = DayType.Note; NoteText = string.Join("\r\n", dayNotes); } else if (Day.Year == now.Year && Day.Month == now.Month && Day.Day == now.Day) { DayType = DayType.Today; NoteText = "今天"; } else if (Day.Year == AppModel.Current.Year && Day.Month == AppModel.Current.Month) { DayType = DayType.Normal; } else { DayType = DayType.OtherMonth; } }
public virtual List<LineNameInfo> GetLineIdsFromNumber(int number, DayType daytype) { var instance = DBModel.GetInstance(); Dictionary<string, Line> tempLineCollection = instance.Lines.GetDataFromDayType(daytype); var temp = (from t in tempLineCollection where t.Value.Number == number select new LineNameInfo { Number = t.Value.Number, Id = t.Key, Name = t.Value.Name }).ToList(); return temp; }
public virtual List<LineNameInfo> GetLinesKeyFromName(string name, DayType daytype) { var instance = DBModel.GetInstance(); Dictionary<string, Line> tempLineCollection = instance.Lines.GetDataFromDayType(daytype); var temp = (from t in tempLineCollection where t.Value.Name.Contains(name) select new LineNameInfo() { Id = t.Key, Number = t.Value.Number, Name = t.Value.Name }).ToList(); return temp; }
/** * Switch forward. */ public void SwitchForward() { DayType nextDayType; switch (currentDayType) { case DayType.Today: nextDayType = DayType.Tomorrow; break; //case DayType.Tomorrow: //case DayType.DayAfterTomorrow: default: nextDayType = DayType.DayAfterTomorrow; break; } // fetch new data if necessary if (nextDayType != currentDayType) { callback(nextDayType); currentDayType = nextDayType; UpdateButtons(); } }
public EmployeeTimeModel() { HourTypes = new Dictionary <string, decimal>(); for (DayType d = DayType.Workday; d <= DayType.Other; d++) { HourTypes.Add(d.ToString(), 0); } }
public HourAndMinuteGridView(Dictionary <int, List <int> > minuteDictionary, DayType dayType) { InitializeComponent(); var vb = new ViewBuilder(); Content = vb.Build(minuteDictionary, dayType); }
private List <CalendarDay> GetDaysByType(DayType dayType) { var days = new List <CalendarDay>(); days.AddRange(GetAllDaysCollection <CalendarDay>().Where(calendarDay => calendarDay.Type == dayType)); return(days); }
private void SetAddingProperties() { TheMonth = new TimePeriod(); TheSpecialDay = new SpecialDay(); TheDayType = new DayType(); SDStackPanelVis = true; UpdateSDVis = false; }
private static DayTypeModel PrepareDayTypeModel(DayType dayType) { DayTypeModel dayTypeTemp = new DayTypeModel(); dayTypeTemp.Id = dayType.Id; dayTypeTemp.DayType = dayType.DayType1; return(dayTypeTemp); }
public static void Collect(ExcelWorksheet rawData, UnitOfWork unit) { Console.Write("Calendar: "); DayType workDay = new DayType { Name = "workday" }; DayType holiday = new DayType { Name = "holiday" }; DayType business = new DayType { Name = "business" }; DayType religious = new DayType { Name = "religious" }; DayType sick = new DayType { Name = "sick" }; DayType vacation = new DayType { Name = "vacation" }; DayType other = new DayType { Name = "other" }; unit.DayTypes.Insert(workDay); unit.DayTypes.Insert(holiday); unit.DayTypes.Insert(business); unit.DayTypes.Insert(religious); unit.DayTypes.Insert(sick); unit.DayTypes.Insert(vacation); unit.DayTypes.Insert(other); unit.Save(); int N = 0; for (int row = 2; row <= rawData.Dimension.Rows; row++) { int oldId = rawData.ReadInteger(row, 1); Day d = new Day { Employee = unit.Employees.Get(Utility.dicEmpl[rawData.ReadInteger(row, 2)]), DayType = unit.DayTypes.Get(rawData.ReadInteger(row, 3)), Date = rawData.ReadDate(row, 4) }; unit.Calendar.Insert(d); unit.Save(); Utility.dicDays.Add(oldId, d.Id); N++; if (N % 100 == 0) { Console.Write($"{N}"); } } Console.WriteLine(N); }
public IEnumerable <ScheduleLine> GetSchedule(string typeOfLine, string typeOfDay, string Number) { if (typeOfLine == null || typeOfDay == null || Number == null) { //return BadRequest(); } RouteType type = Enums.RouteType.Town; if (typeOfLine == "Town") { type = Enums.RouteType.Town; } else if (typeOfLine == "Suburban") { type = Enums.RouteType.Suburban; } DayType day = DayType.Workday; if (typeOfDay == "Work day") { day = Enums.DayType.Workday; } else if (typeOfDay == "Suburban") { day = Enums.DayType.Weekend; } List <ScheduleLine> schedule = new List <ScheduleLine>(); var lines = db.Lines.GetAll(); foreach (var line in lines) { if (line.Number == Number) { foreach (var dep in line.Schadules) { ScheduleLine sl = new ScheduleLine(); sl.Number = line.Number; sl.Time = DateTime.Parse(dep.DepartureTime); if (dep.Day == DayType.Weekend) { sl.Day = "Weekend"; } else if (true) { sl.Day = "Work day"; } sl.IDDay = dep.IdSchadule; schedule.Add(sl); } } } return(schedule); }
IEnumerator DayRoutin() { WaitForSeconds waitForSeconds = new WaitForSeconds(0.4f); while (true) { if (dayType == DayType.Morning) { // daytime -= Time.deltaTime; // SeaMorningPanel(); EnemyMorning(); if (daytime <= 0) { daytime = 300f; dayType = DayType.NightGo; } yield return(null); } else if (dayType == DayType.MorningGo) { daylight.intensity += 0.05f; if (daylight.intensity >= 2f) { dayType = DayType.Morning; } yield return(waitForSeconds); } else if (dayType == DayType.Night) { // daytime -= Time.deltaTime; // SeaNightPanel(); EnemyNight(); if (daytime <= 0) { daytime = 300f; dayType = DayType.MorningGo; } yield return(null); } else if (dayType == DayType.NightGo) { daylight.intensity -= 0.05f; if (daylight.intensity <= 0.5f) { dayType = DayType.Night; } yield return(waitForSeconds); } } }
public void StringContainsDayOffInfoWithDateTime([Values] DayType dayType) { var dateTime = 04.08.Of(2020); var dayOffInfo = new DayOffDateTime(dateTime, dayType); var dayOffInfoAsString = dayOffInfo.ToString(); Assert.That(dayOffInfoAsString, Is.EqualTo($"{dateTime:d} ({dayType:G})")); }
public static DateTypeViewData Create(DayType section) { return(new DateTypeViewData { Id = section.Id, SchoolYearId = section.SchoolYearRef, Name = section.Name, Number = section.Number }); }
public ActionResult Edit([Bind(Include = "DayTypeID,DayTypeName,SymbolName,SymbolNameLatin,WorkHours")] DayType dayType) { if (ModelState.IsValid) { db.Entry(dayType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dayType)); }
public SpecialDayViewModel() { _specLogic = new SpecialDayLogic(); TheSpecialDay = new SpecialDay(); TheMonth = new TimePeriod(); TheDayType = new DayType(); SpecialDayCollection = new ObservableCollection <SpecialDay>(_specLogic.GetSP()); DayTypeCollection = new ObservableCollection <DayType>(_specLogic.GetDT()); PeriodCollection = new ObservableCollection <TimePeriod>(_specLogic.GetPC()); }
public Tax ( TaxType taxType, DayType dayType, decimal value ) { TaxType = taxType; DayType = dayType; Value = value; }
private ListViewItem CreateDayTypesListViewItem(DayType dayType) { ListViewItem listViewItem = new ListViewItem(dayType.Name); listViewItem.ImageIndex = 0; listViewItem.SubItems.Add(dayType.Description); listViewItem.Tag = dayType; return(listViewItem); }
public static Color GetDayTypeForeColor(DayType dayType, decimal hours) { lock (m_syncRoot) { if (dayType.IsWorkDay) { // If it is a work day and no hours are allotted, this should be flagged. return (hours == 0.00m) ? ColorTranslator.FromHtml("#990000") : GetDayTypeForeColor(dayType); } else { // If it is NOT a work day and hours ARE allotted, this should be flagged. return (hours == 0.00m) ? GetDayTypeForeColor(dayType) : ColorTranslator.FromHtml("#990000"); } } }
internal static void SetColorByDayType(this DataGridViewCell cell, DayType dayType) { switch (dayType) { case DayType.WeekEnd: cell.Style.BackColor = CellsPalette.WeekEnd; break; case DayType.Holiday: case DayType.Vacations: cell.Style.BackColor = CellsPalette.FreeDay; break; } }
public virtual LineInfoResult GetDetailsData(string id, DayType daytype) { var instance = DBModel.GetInstance(); Dictionary<string, Line> tempLineCollection = instance.Lines.GetDataFromDayType(daytype); if (!tempLineCollection.ContainsKey(id)) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } var tempLine = tempLineCollection[id]; var result = new LineInfoResult() { LineId = id, LineNumber = tempLine.Number, LineName = tempLine.Name, Buses = tempLine.Buses, Stations = (from sta in tempLine.Stations let staTemp = instance.Stations[sta] select new StationIdNamePair() { Id = sta, Name = staTemp.Name, Yomi = staTemp.Yomi }).ToList() }; return result; }
/// <summary> /// Create n-monthly repeating date generator. /// </summary> /// <param name="wday">Day of week</param> /// <param name="week">1=first, 2=second, 3=third, 4=fourth, 5=last</param> /// <param name="nMonths">how many months between events</param> public MonthlyRelativeGenerator(WDay wday, int week, int nMonths) { DayId = wday; switch (wday) { case WDay.Any: _DayType = DayType.EveryDay; break; case WDay.WeekDay: _DayType = DayType.WeekDay; break; case WDay.WeekendDay: _DayType = DayType.WeekendDay; break; default: _DayType = DayType.Specific; _DayOfWeek = (wday == WDay.Sun) ? DayOfWeek.Sunday : (DayOfWeek) (wday - 2); break; } _WeekInMonth = week; _M = nMonths; }
public Dictionary<string, Line> GetDataFromDayType(DayType dayType) { switch (dayType) { case DayType.saturday: return this.Saturday; case DayType.holiday: return this.Holiday; default: return this.Weekday; } }
public static bool HasCurrentDayFlag(DayType type) { return (type & DayType.CurrentDay) > 0; }
public virtual RouteSearchResult SearchRoute(string from, string to, DayType daytype,RouteSeachMethod method = RouteSeachMethod.DepartureBase, string queryTime = null, int count = 5) { var instance = DBModel.GetInstance(); // deptがnullなら現在時刻 TimeSpan baseTime = DateTime.Now.TimeOfDay; if (queryTime != null && queryTime != String.Empty) { baseTime = Commons.ConvertToTimeSpan(queryTime); if (baseTime == TimeSpan.Zero) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest)); } } else { method = RouteSeachMethod.DepartureBase; } var fromStation = instance.Stations.Where(c => c.Key == from).Select(c => c.Value).SingleOrDefault(); var toStation = instance.Stations.Where(c => c.Key == to).Select(c => c.Value).SingleOrDefault(); if (fromStation == null || toStation == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } var result = new RouteSearchResult() { FromStation = new StationIdNamePair() { Id = from, Name = fromStation.Name, Yomi = fromStation.Yomi }, ToStation = new StationIdNamePair() { Id = to, Name = toStation.Name, Yomi = toStation.Yomi }, QueryDayType = daytype, QueryMethod = method, QueryTime = Commons.ConvertToString(baseTime) }; IEnumerable<Tuple<BusDeptTimeInfo, BusDeptTimeInfo>> tempSource = null; if (method == RouteSeachMethod.DepartureBase) { // 発検索 -> fromの発車時刻がクエリとして与えられた時刻よりも新しい tempSource = fromStation.Buses.Where(c => c.DayType == daytype && Commons.ConvertToTimeSpan(c.DeptTime) >= baseTime) .Join(toStation.Buses, f => f.BusId, t => t.BusId, (f, t) => new Tuple<BusDeptTimeInfo, BusDeptTimeInfo>(f, t)); } else { // 着検索 -> toの発車時刻がクエリとして与えられた時刻よりも古い tempSource = toStation.Buses.Where(c => c.DayType == daytype && Commons.ConvertToTimeSpan(c.DeptTime) <= baseTime) .Join(fromStation.Buses, t => t.BusId, f => f.BusId, (t, f) => new Tuple<BusDeptTimeInfo, BusDeptTimeInfo>(f, t)); } // 発と着の順番を考慮 var tempRoute = (from busSet in tempSource let bus = instance.Buses[busSet.Item1.BusId] let line = instance.Lines.GetDataFromDayType(daytype)[bus.LineId] where line.Stations.IndexOf(@from) < line.Stations.LastIndexOf(to) select new Tuple<BusDeptTimeInfo,BusDeptTimeInfo,Bus,Line>(busSet.Item1,busSet.Item2, bus, line)); // -> 最初から見つかったもの と 最後に見つかったものを比較すれば、最低でも行けることは保証(最短かどうかは除いて) *1 // 提案コスト検索 IEnumerable<Route> tempResult = null; if (method == RouteSeachMethod.DepartureBase) { tempResult = (from route in tempRoute let deptTime = Commons.ConvertToTimeSpan(route.Item1.DeptTime) let arrTime = Commons.ConvertToTimeSpan(route.Item2.DeptTime) where deptTime <= arrTime // *1の個所では最初と最後をとったが、このDeptInfoが必ず順序が保証されているとは限らない(*1は路線情報で判断) let costTime = Commons.DiffTimespan(deptTime, arrTime) orderby costTime descending // 2番目のクエリ:所要時間 (3番目のクエリ:TransferCount) orderby deptTime ascending // 1番目のクエリ:到着時間が近い順 let costTimeStr = Commons.ConvertToString(costTime) select new Route() { Pathes = new List<Path>() { new Path() { DeptNode = new Node() { Station = result.FromStation, Time = route.Item1.DeptTime }, ArrNode = new Node() { Station = result.ToStation, Time = route.Item2.DeptTime }, Method = TransferMethod.Bus, Line = new LineNameInfo() { Id = route.Item3.LineId, Name = route.Item4.Name, Number = route.Item4.Number }, BusId = route.Item1.BusId, Time = costTimeStr } }, Rank = 1.0, TotalDeptTime = route.Item1.DeptTime, TotalArrTime = route.Item2.DeptTime, TransferCount = 0, TotalTime = costTimeStr }).Select((n, ind) => { n.Rank = ind; return n; }); } else { tempResult = (from route in tempRoute let deptTime = Commons.ConvertToTimeSpan(route.Item1.DeptTime) let arrTime = Commons.ConvertToTimeSpan(route.Item2.DeptTime) where deptTime <= arrTime // *1の個所では最初と最後をとったが、このDeptInfoが必ず順序が保証されているとは限らない(*1は路線情報で判断) let costTime = Commons.DiffTimespan(deptTime, arrTime) orderby costTime descending // 2番目のクエリ:所要時間 (3番目のクエリ:TransferCount) orderby deptTime descending // 1番目のクエリ:到着時間が近い順 let costTimeStr = Commons.ConvertToString(costTime) select new Route() { Pathes = new List<Path>() { new Path() { DeptNode = new Node() { Station = result.FromStation, Time = route.Item1.DeptTime }, ArrNode = new Node() { Station = result.ToStation, Time = route.Item2.DeptTime }, Method = TransferMethod.Bus, Line = new LineNameInfo() { Id = route.Item3.LineId, Name = route.Item4.Name, Number = route.Item4.Number }, BusId = route.Item1.BusId, Time = costTimeStr } }, Rank = 1.0, TotalDeptTime = route.Item1.DeptTime, TotalArrTime = route.Item2.DeptTime, TransferCount = 0, TotalTime = costTimeStr }).Select((n, ind) => { n.Rank = ind; return n; }); } if (count == -1 || count <= 0) { result.Routes = tempResult.ToList(); } else { result.Routes = tempResult.Take(count).ToList(); } return result; }
public virtual RouteSearchResult SearchRoute(string from, string to, DayType daytype) { var instance = DBModel.GetInstance(); var fromStation = instance.Stations.Where(c => c.Key == from).Select(c => c.Value).SingleOrDefault(); var toStation = instance.Stations.Where(c => c.Key == to).Select(c => c.Value).SingleOrDefault(); if (fromStation == null || toStation == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } var result = new RouteSearchResult() { FromStation = new StationIdNamePair() { Id = from, Name = fromStation.Name, Yomi = fromStation.Yomi }, ToStation = new StationIdNamePair() { Id = to, Name = toStation.Name, Yomi = toStation.Yomi }, QueryDayType = daytype }; result.Routes = (from busSet in fromStation.Buses.Where(c => c.DayType == daytype) .Join(toStation.Buses, f => f.BusId, t => t.BusId, (f, t) => new { From = f, To = t }) let bus = instance.Buses[busSet.From.BusId] let line = instance.Lines.GetDataFromDayType(daytype)[bus.LineId] where line.Stations.IndexOf(@from) < line.Stations.LastIndexOf(to) let dept = Commons.ConvertToTimeSpan(busSet.From.DeptTime) let arr = Commons.ConvertToTimeSpan(busSet.To.DeptTime) where dept <= arr let time = Commons.ConvertToString(Commons.DiffTimespan(dept, arr)) select new Route() { Pathes = new List<Path>() { new Path() { DeptNode = new Node() { Station = result.FromStation, Time = busSet.From.DeptTime }, ArrNode = new Node() { Station = result.ToStation, Time = busSet.To.DeptTime }, Method = TransferMethod.Bus, Line = new LineNameInfo() { Id = bus.LineId, Name = line.Name, Number = line.Number }, BusId = busSet.From.BusId, Time = time } }, Rank = 1.0, TotalDeptTime = busSet.From.DeptTime, TotalArrTime = busSet.To.DeptTime, TransferCount = 0, TotalTime = time }).ToList(); return result; }
/// <summary> /// Returns the localiztion text of a specified week day type /// </summary> public static int GetText(DayType dayType) { switch (dayType) { case DayType.FirstWorkingDay: return GetText(GetDayByIndex(0)); case DayType.LastWorkingDay: return GetText(GetDayByIndex(4)); case DayType.FirstWeekendDay: return GetText(FirstWeekendDay); case DayType.LastWeekendDay: return GetText(SecondWeekendDay); case DayType.WorkingDays: return 680; case DayType.Record_WorkingDays: return 672; case DayType.WeekendDays: return 1050; case DayType.Record_WeekendDays: return 1051; default: return -1; } }