public static void Main(string[] args) { var trung = new Student() { Name = "Trung", ID = 5 }; var c1203l = new Class() { ID = 1, Name = "C1203L", Teacher = "NhatNK" }; var lab1 = new Room() { Name = "Lab1" }; var late = new TimeSlot() { StartTime = DateTime.MinValue.AddDays(4).AddHours(17).AddMinutes(30), EndTime = DateTime.MinValue.AddDays(4).AddHours(19).AddMinutes(30) }; var m = new Manager(); m.Students.Add(trung); m.Classes.Add(c1203l); m.TimeSlots.Add(late); m.Rooms.Add(lab1); m.RegisterStudentWithClass(trung, c1203l); m.RegisterClassRoomTimeSlot(c1203l, lab1, late); foreach (var a in m.Allocation) { Console.WriteLine("{0} {1} {2}", a.Item1.Name, a.Item2.Name, a.Item3.StartTime.DayOfWeek); } }
/// <summary> /// 计算每个时隙的负载(百分比) /// 当前小区用于DPA的发射功率除以当前小区用于HSDPA总功率 /// </summary> private void CalculateLoadAndPowerInSlot(TimeSlot ts) { ts.HSDPALoad = (float)(UnitTrans.dBmTomw(ts.HSDPAConsumedPower) / (UnitTrans.dBmTomw(ts.HSDPARemainPower) + UnitTrans.dBmTomw(ts.HSDPAConsumedPower))); }
public TypicalDay(string name) { this.name = name; timeSlots = new TimeSlot[24]; for (int i = 0; i < timeSlots.Length; i++) { timeSlots[i] = new TimeSlot(i, i + 1, false); } }
public void MyTestInitialize() { TDSimCell cell = null; TimeSlot[] slots = new TimeSlot[7]; m_TDSimUser = MockTDSimUser.CreatTDSimUser_PSUL(); cell = MockTDSimCell.CreatTDSimCell(); m_TDSimUser.ServiceCell = cell; slots = MockTDSlots.CreatSlots(); cell.Slots = slots; }
//=============================================================================== // Public Methods //=============================================================================== public bool AddBooking(Booking newBooking, TimeSlot timeSlot) { if (CheckBooking(timeSlot)) { return false; } else { timeBooking_[(int)timeSlot] = newBooking; return true; } }
public void HARQ_Test() { IGetLinkloss linkloss = new MockIGetLinkloss(); ICalcInterfere interfere = null; TDCalcCommonParam param = new TDCalcCommonParam(); TDLinkLossCalc TDLinkLoss = new TDLinkLossCalc(linkloss); ISimUser simUser = new MockISimUserBase(); ISimCellBase cellBase = new MockISimCellBase(); TDLinkLoss.GetDLTotalLoss(simUser, cellBase); HSDPABearerManagement retainGain = new HSDPABearerManagement(NetWorkType.TDSCDMA); HARQ m_Harq = new HARQ(interfere, linkloss, retainGain); m_Harq.CalcInterfere = new MockICalcInterfere(); TimeSlot slot1 = new TimeSlot(); TimeSlot slot2 = new TimeSlot(); List<TDSimCell> cellList = new List<TDSimCell>(); TDSimCell cell1; cell1 = MockTDSimCell.CreatTDSimCell(); //cell1.NeCell = new TDSCDMACarrier(); TDSimCell cell2; cell2 = MockTDSimCell.CreatTDSimCell(); //cell2.NeCell = new TDSCDMACarrier(); TDSimUser user1; user1 = MockTDSimUser.CreatTDSimUser_CS(); TDSimUser user2; user2 = MockTDSimUser.CreatTDSimUser_CS(); user2.IsHSDPARetransmited = true; user2.HSDPARetransCount = 1; TDSimUser user3; user3 = MockTDSimUser.CreatTDSimUser_CS(); user3.IsHSDPARetransmited = true; user3.HSDPARetransCount = 2; slot1.HSDPAScheduledUsers.Add(user1); slot2.HSDPAScheduledUsers.Add(user2); slot2.HSDPAScheduledUsers.Add(user3); cell1.HSDPATimeslot.Add(slot1); cell1.HSDPATimeslot.Add(slot2); cellList.Add(cell1); cellList.Add(cell2); m_Harq.Run(cellList); Assert.AreEqual(cellList[0].HSDPAAccessedUsers.Count, 0); }
public static List<TimeSlot> GetTimeSlotFromBand(int bandID) { List<TimeSlot> times = new List<TimeSlot>(); try { // Get data DbParameter param = Database.AddParameter("@bandid", bandID); DbDataReader reader = Database.GetData("SELECT * FROM timeslot WHERE BandID = @bandID ORDER BY startdate", param); foreach (DbDataRecord record in reader) { // Create new TimeSlot TimeSlot time = new TimeSlot(); // Get ID if (DBNull.Value.Equals(record["ID"])) time.ID = -1; else time.ID = Convert.ToInt32(record["ID"]); // Get BandID if (DBNull.Value.Equals(record["BandID"])) time.BandID = -1; else time.BandID = Convert.ToInt32(record["BandID"]); // Get StageID if (DBNull.Value.Equals(record["StageID"])) time.StageID = -1; else time.StageID = Convert.ToInt32(record["StageID"]); // Get StartDate if (DBNull.Value.Equals(record["StartDate"])) time.StartDate = new DateTime(); else time.StartDate = Convert.ToDateTime(record["StartDate"]); // Get EndDate if (DBNull.Value.Equals(record["EndDate"])) time.EndDate = new DateTime(); else time.EndDate = Convert.ToDateTime(record["EndDate"]); time.Stage = StageSQLRepository.GetStage(time.StageID); // Add TimeSlot times.Add(time); } reader.Close(); return times; } // Fail catch (Exception ex) { Console.WriteLine(ex.Message); } return null; }
public static TimeSlot[] CreateTS() { TimeSlot[] slots = new TimeSlot[7]; TS tsnum = TS.TS0; for (int i = 0; i < slots.Length; i++) { slots[i].TsNum = tsnum++; //初始化UPA的字段 slots[i].HSUPAConsumedCode = 0; slots[i].HSUPARot = 0; slots[i].HSUPATotalCode = 10; slots[i].HSUPATotalPower = 0; slots[i].HSUPATSUElist.Clear(); slots[i].LinkDirection = LinkType.Uplink; } return slots; }
static void Main(string[] args) { TimeSlotCollection slots = new TimeSlotCollection(); slots.Add(new TimeSlot(new DateTime(2015, 1, 1, 9, 0, 0), new DateTime(2015, 1, 1, 10, 0, 0))); slots.Add(new TimeSlot(new DateTime(2015, 1, 1, 10, 0, 0), new DateTime(2015, 1, 1, 12, 0, 0))); slots.Add(new TimeSlot(new DateTime(2015, 1, 1, 14, 0, 0), new DateTime(2015, 1, 1, 15, 0, 0))); slots.Add(new TimeSlot(new DateTime(2015, 1, 1, 16, 0, 0), new DateTime(2015, 1, 1, 16, 30, 0))); TimeSlot withIn = new TimeSlot(new DateTime(2015, 1, 1, 8, 0, 0), new DateTime(2015, 1, 1, 18, 0, 0)); TimeSpan slotLength = TimeSpan.FromMinutes(60); TimeSlotCollection availableTimes = slots.FindAvailableSlots(slotLength, withIn); if (availableTimes != null) { foreach (var item in availableTimes) { Console.WriteLine(item); } } Console.WriteLine("Done!"); Console.ReadLine(); }
public bool RemoveClassRoomTimeSlot(Class cl, Room r, TimeSlot t) { return this.allocation.Remove(new Tuple<Class, Room, TimeSlot>(cl, r, t)); }
private void ButtonSave_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; if (daysListBox.SelectedItem == null) { MessageBox.Show("Please Enter Required Fields", "Validation Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { WorkHours workHours = cntrl.GetWorkHoursByDay(daysListBox.SelectedItem.ToString()); DateTime startTime = DateTime.Parse(workHours.GetStart_Time()); DateTime endTime = DateTime.Parse(workHours.GetEnd_Time()); TimeSlot timeSlots = new TimeSlot(); timeSlots.SetDay_of_the_Week(daysListBox.SelectedItem.ToString()); timeSlots.SetStart_Time(startTimePicker.Value.ToLongTimeString()); if (radioButtonThirtyMinutes.Checked == true) { timeSlots.SetEnd_Time(startTimePicker.Value.AddMinutes(30).ToLongTimeString()); } else if (radioButtonOneHour.Checked == true) { timeSlots.SetEnd_Time(startTimePicker.Value.AddHours(1).ToLongTimeString()); } if (radioButtonLunchBreak.Checked == true) { timeSlots.SetSlotType(radioButtonLunchBreak.Text.ToString()); } else if (radioButtonWorkTime.Checked == true) { timeSlots.SetSlotType(radioButtonWorkTime.Text.ToString()); } DateTime timeslot_startTime = DateTime.Parse(timeSlots.GetStart_Time()); DateTime timeslot_endTime = DateTime.Parse(timeSlots.GetEnd_Time()); bool status; if (startTime.Hour < timeslot_startTime.Hour && endTime.Hour > timeslot_endTime.Hour) { status = true; } else if ((startTime.Hour == timeslot_startTime.Hour && endTime.Hour > timeslot_endTime.Hour) && startTime.Minute <= timeslot_startTime.Minute) { status = true; } else if ((startTime.Hour < timeslot_startTime.Hour && endTime.Hour == timeslot_endTime.Hour) && endTime.Minute >= timeslot_endTime.Minute) { status = true; } else if ((startTime.Hour == timeslot_startTime.Hour && endTime.Hour == timeslot_endTime.Hour) && (startTime.Minute <= timeslot_startTime.Minute && endTime.Minute >= timeslot_endTime.Minute)) { status = true; } else { status = false; } if (status) { int count = cntrl.SaveTimeSlot(timeSlots); Cursor.Current = Cursors.Default; if (count >= 1) { MessageBox.Show("TimeSlot Saved SuccessFully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (count == 0) { MessageBox.Show("TimeSlot Already Added", "TimeSlot Exist", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (count == -1) { MessageBox.Show("Error Occurred", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (count == -2) { MessageBox.Show("Cannot add another Lunch Break for " + timeSlots.GetDay_of_the_Week() + "!!", "Duplicate Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Cursor.Current = Cursors.WaitCursor; LoadData(); Cursor.Current = Cursors.Default; } else { MessageBox.Show("Please Enter Valid Time-Slot", "Invalid Time-Slot", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
/* Creates a TimeSlot using a list of activeplayers * Assigns players on Courts based on wait-time(primary factor) and level of player * Time of arrival is automatically taken care of * Algorithm: * 1.Get a players with the highest wait-time * 2.Get players with the same level as the player in 1. * 3.Assign the players to a court * 4.If not enough players in that player's level or the wait-time difference is greater than 2, * find players with the highest wait-time in other levels * 5.Repeat 1-4 until all courts are filled * 6.Update the players on the court to "on court" and reset their wait-time to zero * 7.Increment the wait-time of the off court players by 1 * The ActivePlayersTable is updated afterwards */ public static void MakeTimeSlot(TimeSlot ts, List <Player> players, BadmintonContext context) { Random random = new Random(); int numOfCourts = TimeSlot.getNumOfCourts(); List <List <Player> > playergrid = new List <List <Player> >(); List <int> onCourtIDs = new List <int>(); int numOfLevels = 5; int count; int lvl; for (int i = 0; i < numOfLevels; i++) { playergrid.Add(new List <Player>()); } for (int j = 0; j < players.Count; j++) { playergrid[players.ElementAt(j).Level - 1].Add(players.ElementAt(j)); } for (int i = 0; i < numOfCourts; i++) { Court court = new Court(); count = 0; players = players.OrderByDescending(x => x.Waits).ToList(); for (int j = 0; j < players.Count; j++) { if (count >= Court.intGetNumOfPlayersOnCourt()) { break; } lvl = players.ElementAt(j).Level - 1; playergrid[lvl] = playergrid[lvl].OrderByDescending(x => x.Waits).ToList(); for (int k = 0; k < playergrid[lvl].Count; k++) { if (count >= Court.intGetNumOfPlayersOnCourt()) { break; } if (playergrid[lvl][k].OnCourt == false) { PlayerHelper.UpdatePlayerOnCourt(playergrid[lvl][k], context); court.addPlayer(playergrid[lvl][k]); count++; } } if (count < Court.intGetNumOfPlayersOnCourt()) { lvl++; if (lvl < 5) { playergrid[lvl] = playergrid[lvl].OrderByDescending(x => x.Waits).ToList(); for (int k = 0; k < playergrid[lvl].Count; k++) { if (count >= Court.intGetNumOfPlayersOnCourt()) { break; } if (playergrid[lvl][k].OnCourt == false) { PlayerHelper.UpdatePlayerOnCourt(playergrid[lvl][k], context); court.addPlayer(playergrid[lvl][k]); count++; } } } if (count < Court.intGetNumOfPlayersOnCourt()) { lvl = lvl - 2; if (lvl >= 0) { playergrid[lvl] = playergrid[lvl].OrderByDescending(x => x.Waits).ToList(); for (int k = 0; k < playergrid[lvl].Count; k++) { if (count >= Court.intGetNumOfPlayersOnCourt()) { break; } if (playergrid[lvl][k].OnCourt == false) { PlayerHelper.UpdatePlayerOnCourt(playergrid[lvl][k], context); court.addPlayer(playergrid[lvl][k]); count++; } } } } } } ts.addCourt(court); } for (int q = 0; q < playergrid.Count; q++) { for (int p = 0; p < playergrid[q].Count; p++) { if (playergrid[q][p].OnCourt == false) { playergrid[q][p].Waits++; //update every player's wait times } } } foreach (var p in players) { if (p.OnCourt == false) { ActivePlayer updated = context.ActivePlayers.Single(x => x.PlayerID == p.ID); updated.Waits++; context.SaveChanges(); } } }
static WeeklyEventAssignment ParseWeeklyAssignment(TimeTableData appropriateData, XElement elem, Event ev, int week) { if (elem != null) { var weekTag = string.Empty; switch (week) { case 1: weekTag = "FirstWeek"; break; case 2: weekTag = "SecondWeek"; break; default: throw new ArgumentException("week"); } var weekNode = elem.Elements(weekTag).FirstOrDefault(); if (weekNode == null) return null; var room = appropriateData.Rooms.FirstOrDefault(r => r.Id == int.Parse(weekNode.Attribute("room").Value)); var timeSlot = new TimeSlot(int.Parse(weekNode.Attribute("day").Value), int.Parse(weekNode.Attribute("slot").Value)); return new WeeklyEventAssignment(ev, room, timeSlot, week); } return null; }
/// <summary> /// Get location string for the confirmation email /// </summary> /// <param name="tSlot"></param> /// <returns></returns> private string GetInterviewLocation(TimeSlot tSlot) { var template = ""; if (File.Exists(HttpContext.Current.Server.MapPath("/_templates/" + "InterviewLocation.html"))) { template = File.ReadAllText(HttpContext.Current.Server.MapPath("/_templates/" + "InterviewLocation.html")); // location header template = template.Replace("#Location#", tSlot.Location.Location); // location address var address = ""; if (!string.IsNullOrEmpty(tSlot.Location.LocationAddress)) address += tSlot.Location.LocationAddress; // location post code if (!string.IsNullOrEmpty(tSlot.Location.Postcode)) address += !string.IsNullOrEmpty(tSlot.Location.LocationAddress) ? ", " + tSlot.Location.Postcode : tSlot.Location.Postcode; template = template.Replace("#LocationAddress#", address); // directions var directions = ""; if (!string.IsNullOrEmpty(tSlot.Location.Directions)) { directions = "<p><strong>Directions</strong></p>"; directions += "<p>" + tSlot.Location.Directions + "</p>"; } template = template.Replace("#Directions#", directions); //google map link var googleMapLink = ""; // ReSharper disable once CompareOfFloatsByEqualityOperator if (tSlot.Location.CoY != 0 && tSlot.Location.CoX != 0) { var link = "http://maps.google.com/?q=" + tSlot.Location.CoX + "," + tSlot.Location.CoY; googleMapLink = "<a target='_blank' href='" + link + "'>View on Google Maps</a>"; } template = template.Replace("#GoogleMapLink#", googleMapLink); } return template; }
/// <summary> /// 如果ru足够则返回true,否则返回false /// </summary> /// <param name="slot">需要判断的时隙</param> /// <param name="runum">需要的ru个数</param> /// <returns></returns> private bool JugeRemainRuNumEn(TimeSlot slot, int ruNum) { int remainRU = slot.R4MaxCodeNum - slot.R4ConsumedCodeNum; return remainRU >= ruNum; }
public Reservation(User user, TimeSlot timeSlot) { User = user; TimeSlot = timeSlot; }
public void DateTimeToTimeSlot_ThrowsError_ForDateSmallerThanOrigin() { var dt = new DateTime(2017, 1, 1); Assert.Throws <ValidationException>(() => TimeSlot.DateTimeToTimeSlot(dt)); }
public bool CreateTimeSlot(TimeSlot newTimeSlot) { throw new System.NotImplementedException(); }
public bool UpdateTimeSlot(TimeSlot movie) { throw new System.NotImplementedException(); }
public void DateTimeToTimeSlotWhenEpochStartTimePassedNumberShouldBeZero() { TimeSlot.DateTimeToTimeSlot(TimeSlot.EpochStart).ShouldBe(0); }
public void DateTimeToTimeSlotValidUTCTimePassedNumberReturned() { TimeSlot.DateTimeToTimeSlot(new DateTime(2018, 03, 15, 17, 34, 50, DateTimeKind.Utc)).ShouldBe(637); }
public void DateTimeToTimeSlotWhenTimeBeforeEpochStartPassedToCtorExceptionShouldBeThrown() { Should.Throw <ArgumentOutOfRangeException>(() => TimeSlot.DateTimeToTimeSlot(new DateTime(2000, 1, 1))); }
static void Main() { MainForm view = new MainForm(); view.Visible = false; Module[] module = new Module[16]; XmlTextReader xmlReader = new XmlTextReader("D:" + "\\XMLModule.xml"); string code = ""; string name = ""; string semester = ""; string prerequisite = ""; TimeSlot lecture_Slot = TimeSlot.NULL; TimeSlot tutorial_Slot = TimeSlot.NULL; string info = ""; int count = 0; while (xmlReader.Read()) { //move to fisrt element xmlReader.MoveToElement(); //if element name is <code> if (xmlReader.Name == "Code") { //found the desired element so read the next node xmlReader.Read(); XmlNodeType nType = xmlReader.NodeType; if (nType == XmlNodeType.Text) { code = xmlReader.ReadContentAsString(); } } else if (xmlReader.Name == "Name") { xmlReader.Read(); XmlNodeType nType = xmlReader.NodeType; if (nType == XmlNodeType.Text) { name = xmlReader.ReadContentAsString(); } } else if (xmlReader.Name == "Semester") { xmlReader.Read(); XmlNodeType nType = xmlReader.NodeType; if (nType == XmlNodeType.Text) { semester = xmlReader.ReadContentAsString(); } } else if (xmlReader.Name == "Prerequisite") { xmlReader.Read(); XmlNodeType nType = xmlReader.NodeType; if (nType == XmlNodeType.Text) { prerequisite = xmlReader.ReadContentAsString(); } } else if (xmlReader.Name == "Lecture_Slot") { xmlReader.Read(); XmlNodeType nType = xmlReader.NodeType; if (nType == XmlNodeType.Text) { lecture_Slot = (TimeSlot)xmlReader.ReadContentAsInt(); } } else if (xmlReader.Name == "Tutorial_Slot") { xmlReader.Read(); XmlNodeType nType = xmlReader.NodeType; if (nType == XmlNodeType.Text) { tutorial_Slot = (TimeSlot)xmlReader.ReadContentAsInt(); module[count] = new Module(code, name, semester, prerequisite, lecture_Slot, tutorial_Slot, info); count++; } } else if (xmlReader.Name == "Info") { xmlReader.Read(); XmlNodeType nType = xmlReader.NodeType; if (nType == XmlNodeType.Text) { info = xmlReader.Value; } } } ModuleController moduleController = new ModuleController(view, module); StudentController studentController = new StudentController(view); moduleController.loadView(); view.ShowDialog(); }
/// <summary> /// Crear un nuevo objeto TimeSlot. /// </summary> /// <param name="id">Valor inicial de Id.</param> /// <param name="initialTime">Valor inicial de InitialTime.</param> /// <param name="finalTime">Valor inicial de FinalTime.</param> public static TimeSlot CreateTimeSlot(global::System.Guid id, global::System.TimeSpan initialTime, global::System.TimeSpan finalTime) { TimeSlot timeSlot = new TimeSlot(); timeSlot.Id = id; timeSlot.InitialTime = initialTime; timeSlot.FinalTime = finalTime; return timeSlot; }
public object TryReserve(int min) { if (min <= 0) { return(BadRequest(new { message = "Minutos deben ser positivos" })); } var timenow = DateTime.UtcNow.AddHours(1); bool tomorrow = false; if (timenow.Hour >= 20) { //return BadRequest(new { message = "La biblioteca está cerrada." }); tomorrow = true; timenow = new DateTime(timenow.Year, timenow.Month, timenow.Day, TimeSlot.HourStart, 0, 0); } int startindex = (timenow.Hour - TimeSlot.HourStart) * 2 + (timenow.Minute >= 30 ? 1 : 0); int steps = (int)Math.Ceiling(min / 30f); var bib = CacheService.Biblioteca; int minstart = int.MaxValue; int minsala = -1; var candidates = new List <object>(); for (int i = 0; i < bib.Salas.Count; i++) { var sala = bib.Salas[i]; int needed = steps; for (int j = startindex; j < sala.OccupiedMap.Length; j++) { if (!sala.OccupiedMap[j]) { needed--; } else { needed = steps; } if (needed == 0) { int start = j - (steps - 1); candidates.Add(new { sala = i + 1, start = TimeSlot.IndexToTime(start), end = TimeSlot.IndexToTime(start + steps), }); // Queremos la sala con el inicio menor. if (start < minstart) { minstart = start; minsala = i; } break; } } } if (minsala == -1) { return(NotFound(new { found = false })); } return(Ok(new { found = true, sala = minsala + 1, start = TimeSlot.IndexToTime(minstart), end = TimeSlot.IndexToTime(minstart + steps), tomorrow = tomorrow, options = candidates, })); }
public void AddTest() { var first = new TimeSlot(); Assert.Equal(0, first.Duration); Assert.Equal(0, first.TaskCount); Assert.Null(first.Next); var next = first.AddTask(50); Assert.Equal(50, first.Duration); Assert.Equal(1, first.TaskCount); Assert.Equal(next, first.Next); Assert.Equal(10.0, first.GetTaskProgress(10)); Assert.Equal(0, next.Duration); Assert.Equal(0, next.TaskCount); Assert.Null(next.Next); var next2 = first.AddTask(50); Assert.Equal(50, first.Duration); Assert.Equal(2, first.TaskCount); Assert.Equal(next2, first.Next); Assert.Equal(next, first.Next); Assert.Equal(20.0, first.GetTaskProgress(40)); Assert.Equal(0, next2.Duration); Assert.Equal(0, next2.TaskCount); Assert.Null(next2.Next); var next3 = first.AddTask(30); Assert.Equal(30, first.Duration); Assert.Equal(3, first.TaskCount); Assert.Equal(next3, first.Next); Assert.Equal(3.0, first.GetTaskProgress(9)); Assert.Equal(20, next3.Duration); Assert.Equal(2, next3.TaskCount); Assert.Equal(next2, next3.Next); Assert.Equal(next, next3.Next); Assert.Equal(10.0 + 5, first.GetTaskProgress(40)); Assert.Equal(0, next2.Duration); Assert.Equal(0, next2.TaskCount); Assert.Null(next2.Next); var next4 = first.AddTask(75); Assert.Equal(25, next2.Duration); Assert.Equal(1, next2.TaskCount); Assert.Equal(next4, next2.Next); Assert.Equal((30.0 / 4) + (20.0 / 3) + 20, first.GetTaskProgress(70)); Assert.Equal(0, next4.Duration); Assert.Equal(0, next4.TaskCount); Assert.Null(next4.Next); }
/// <summary> /// 初始化LinkSet /// </summary> /// <param name="user"></param> /// <param name="slot"></param> /// <param name="tsRes"></param> private static void InitTSLinkParam(TDSimUser user, TimeSlot slot, TSResource tsRes) { TSLinkParam link = new TSLinkParam(); link.CodeRU = tsRes.RuNum; link.CodeNum = tsRes.PhCodeNum; link.TxPower = float.NegativeInfinity; user.LinkSet.Add(slot.TsNum, link); slot.AccessedUsers.Add(user); }
protected override void OnMouseMove(MouseEventArgs e) { ClearToolTopState(); TimeFrameObject tfo = GetTimeFrameObject(e); if (e.Button == MouseButtons.Left) { if (tfo is Cell) { Cell cellNewSelected = (Cell)tfo; if (tfoLastSelected is Cell) { Cell cellLastSelected = (Cell)tfoLastSelected; if (cellLastSelected != cellNewSelected) { SelectCellBlock(cellLastSelected, cellNewSelected); } } } else if (tfo is TimeSlot) { TimeSlot tsNewSelected = (TimeSlot)tfo; if (tfoLastSelected is TimeSlot) { TimeSlot tsLastSelected = (TimeSlot)tfoLastSelected; if (tsLastSelected != tsNewSelected) { if (tsNewSelected.Column > tsLastSelected.Column) { for (int j = tsLastSelected.Column; j < tsNewSelected.Column; ++j) { TimeSlots[j].Selected = tsLastSelected.Selected; } } else if (tsNewSelected.Column < tsLastSelected.Column) { for (int j = tsNewSelected.Column; j < tsLastSelected.Column; ++j) { TimeSlots[j].Selected = tsLastSelected.Selected; } } } } } else if (tfo is _Day) { _Day dNewSelected = (_Day)tfo; if (tfoLastSelected is _Day) { _Day dLastSelected = (_Day)tfoLastSelected; if (dLastSelected != dNewSelected) { if (dNewSelected.Row > dLastSelected.Row) { for (int i = dLastSelected.Row; i < dNewSelected.Row; ++i) { Days[i].Selected = dLastSelected.Selected; } } else if (dNewSelected.Row < dLastSelected.Row) { for (int i = dNewSelected.Row; i < dLastSelected.Row; ++i) { Days[i].Selected = dLastSelected.Selected; } } } } } } if (tfoLastHighlighted != null) { tfoLastHighlighted.Highlighted = false; } if (tfo != null) { tfo.Highlighted = true; tfoLastHighlighted = tfo; } if (e.Button == MouseButtons.None) { if (Grid.Contains(e.X, e.Y)) { LastMouseHover = e; HoverTimerStart.Start(); } } this.Invalidate(true); }
public void AddTimeSlot(TimeSlot timeSlot) { if(TimeSlots.Contains(timeSlot)) throw new Exception(""); TimeSlots.Add(timeSlot); }
public ActionResult Edit(TimeSlotViewModel model) { if (Session["CurrentSchedule"] == null) { return RedirectToAction("Index", "Schedule"); } var schedule = (Schedule)Session["CurrentSchedule"]; int days = DateTime.DaysInMonth(schedule.Year, schedule.Month); model.CurrentSchedule = schedule; model.Offices = new OfficeAppService().GetOfficesByEmployeeId(schedule.EmployeeId); model.DaysInMonth = days; ; DateTime parsedDate1 = DateTime.ParseExact(model.StartTimeText, "H:mm", System.Globalization.CultureInfo.InvariantCulture); DateTime parsedDat2 = DateTime.ParseExact(model.EndTimeText, "H:mm", System.Globalization.CultureInfo.InvariantCulture); try { var svc = new TimeSlotAppService(); var o = new TimeSlot { TimeSlotId= model.TimeSlotId, ScheduleId = schedule.ScheduleId, Day = model.Day, StartTime = parsedDate1, EndTime = parsedDat2, OfficeId = model.OfficeId, }; if (model.Action == "-1") { var exist = svc.GetTimeSlot(model.TimeSlotId)!=null; if (!exist) { svc.AddTimeSlot(o); ViewBag.Feed = 0; } else { model.Action = "-1"; ViewBag.Feed = 3; return View(model); } } else { o.TimeSlotId= model.TimeSlotId; if (model.IsDeleteAction == 0) { svc.SaveTimeSlot(o); } else { svc.RemoveTimeSlot(model.TimeSlotId); } ViewBag.Feed = 0; } } catch (Exception) { ViewBag.Feed = 1; } return View(model); }
/// <summary> /// Get Interviewrs string for the confirmation email /// </summary> /// <param name="tSlot"></param> /// <returns></returns> private string GetInterviewers(TimeSlot tSlot) { var template = ""; if (File.Exists(HttpContext.Current.Server.MapPath("/_templates/" + "Interviewers.html"))) { template = File.ReadAllText(HttpContext.Current.Server.MapPath("/_templates/" + "Interviewers.html")); var interviwersText = tSlot.Interviewers .Aggregate("", (current, interviewer) => current + (interviewer.Forename + " " + interviewer.Surname + "<br />")); template = template.Replace("#Interviewers#", interviwersText); } return template; }
public static TimeSlot Parse(Parser parser, int startindent) { var timeslot = new TimeSlot(); if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line in TimeSlots"); timeslot.Description = parser.GetLine(); if (parser.curr.indent <= startindent) return timeslot; var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.Time: timeslot.Time = parser.GetTime(); break; case Parser.RegKeywords.DayOfWeek: timeslot.DayOfWeek = parser.GetInt(); break; case Parser.RegKeywords.Limit: timeslot.Limit = parser.GetInt(); break; default: throw parser.GetException("unexpected line in TimeSlot"); } } return timeslot; }
public WeeklyEventAssignment(Event e, Room r, TimeSlot slot, int week) { Event = e; Room = r; TimeSlot = slot; Week = week; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { TimeSlot timeslot = new TimeSlot(); Configuration.GetSection("TimeSlot").Bind(timeslot); ConfigVars.NewInstance.slots = timeslot; services.AddDbContext <OneDirectContext>(options => options.UseNpgsql(ConfigVars.NewInstance.ConnectionString) ); //set form options services.Configure <FormOptions>(options => { options.ValueCountLimit = 500; //default 1024 options.ValueLengthLimit = int.MaxValue; //not recommended value options.MultipartBodyLengthLimit = long.MaxValue; //not recommended value }); // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); //Hangfire configuration services.AddHangfire(configuration => { }); services.AddMvc(); //services.AddMemoryCache(); services.AddDistributedMemoryCache(); services.AddSession(options => { // Set a short timeout for easy testing. options.IdleTimeout = TimeSpan.FromMinutes(Convert.ToInt32(ConfigVars.NewInstance.servertimeout)); options.Cookie.HttpOnly = true; }); services.AddMvc().AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); //to run video in iframe //services.AddAntiforgery(o => o.SuppressXFrameOptionsHeader = true); services.AddAntiforgery(o => o.SuppressXFrameOptionsHeader = true); services.AddNodeServices(); //services.AddTransient<OneDirectContext>(); services.AddScoped <ILibraryInterface, LibraryRepository>(); services.AddScoped <IPatientLibraryInterface, PatientLibraryRepository>(); services.AddScoped <IEquipmentExerciseInterface, EquipmentExerciseRepository>(); services.AddScoped <IPainInterface, PainRepository>(); services.AddScoped <INewPatient, NewPatientRepository>(); services.AddScoped <IPatientRxInterface, PatientRxRepository>(); services.AddScoped <IUserInterface, UserRepository>(); services.AddScoped <IRequestFactory, RequestFactory>(); services.AddScoped <VTransactInterface, VTransactRepository>(); services.AddScoped <IPatient, PatientRepository>(); services.AddScoped <LoginAuthorizeAttribute>(); services.AddScoped <Smtp>(); //Rollbar Configuration services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); ConfigureRollbarSingleton(); services.AddRollbarLogger(loggerOptions => { loggerOptions.Filter = (loggerName, loglevel) => loglevel >= LogLevel.Debug; }); }
private static void GetBandsWithTimeSlot(ref List<Band> bands, bool stage, bool asc) { try { // Get data DbDataReader reader; if (stage) { if (asc) reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description, ts.ID AS TimeSlotID, ts.BandID, ts.StageID, ts.StartDate, ts.EndDate, s.ID AS Stage_ID, s.Name AS StageName FROM band AS b INNER JOIN timeslot AS ts ON b.ID = ts.bandID INNER JOIN stage AS s ON ts.stageID = s.ID ORDER BY StageName ASC, Name ASC, StartDate ASC"); else reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description, ts.ID AS TimeSlotID, ts.BandID, ts.StageID, ts.StartDate, ts.EndDate, s.ID AS Stage_ID, s.Name AS StageName FROM band AS b INNER JOIN timeslot AS ts ON b.ID = ts.bandID INNER JOIN stage AS s ON ts.stageID = s.ID ORDER BY StageName DESC, Name DESC, StartDate DESC"); } else { if (asc) reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description, ts.ID AS TimeSlotID, ts.BandID, ts.StageID, ts.StartDate, ts.EndDate, s.ID AS Stage_ID, s.Name AS StageName FROM band AS b INNER JOIN timeslot AS ts ON b.ID = ts.bandID INNER JOIN stage AS s ON ts.stageID = s.ID ORDER BY StartDate ASC, Name ASC, StageName ASC"); else reader = Database.GetData("SELECT b.ID, b.Name, b.Twitter, b.Facebook, b.Picture, b.Description, ts.ID AS TimeSlotID, ts.BandID, ts.StageID, ts.StartDate, ts.EndDate, s.ID AS Stage_ID, s.Name AS StageName FROM band AS b INNER JOIN timeslot AS ts ON b.ID = ts.bandID INNER JOIN stage AS s ON ts.stageID = s.ID ORDER BY StartDate DESC, Name DESC, StageName DESC"); } foreach (DbDataRecord record in reader) { Band band = new Band(); // Get ID if (DBNull.Value.Equals(record["ID"])) band.ID = -1; else band.ID = Convert.ToInt32(record["ID"]); // Get Name if (DBNull.Value.Equals(record["Name"])) band.Name = ""; else band.Name = record["Name"].ToString(); // Get Twitter if (DBNull.Value.Equals(record["Twitter"])) band.Twitter = ""; else band.Twitter = record["Twitter"].ToString(); // Get Facebook if (DBNull.Value.Equals(record["Facebook"])) band.Facebook = ""; else band.Facebook = record["Facebook"].ToString(); // Get Picture if (DBNull.Value.Equals(record["Picture"])) band.Picture = null; else band.Picture = (byte[])record["Picture"]; // Get Description if (DBNull.Value.Equals(record["Description"])) band.Description = ""; else band.Description = record["Description"].ToString(); // Get Genres band.Genres = GenreSQLRepository.GetGenresFromBand(band.ID); //Get Timeslot TimeSlot ts = new TimeSlot(); // Get TimeSlotID if (DBNull.Value.Equals(record["TimeSlotID"])) ts.ID = -1; else ts.ID = Convert.ToInt32(record["TimeSlotID"]); // Get BandID if (DBNull.Value.Equals(record["BandID"])) ts.BandID = -1; else ts.BandID = Convert.ToInt32(record["BandID"]); // Get StageID if (DBNull.Value.Equals(record["StageID"])) ts.StageID = -1; else ts.StageID = Convert.ToInt32(record["StageID"]); // Get StartDate if (DBNull.Value.Equals(record["StartDate"])) ts.StartDate = new DateTime(); else ts.StartDate = Convert.ToDateTime(record["StartDate"]); // Get EndDate if (DBNull.Value.Equals(record["EndDate"])) ts.EndDate = new DateTime(); else ts.EndDate = Convert.ToDateTime(record["EndDate"]); // Get Stage Stage s = new Stage(); // Get Stage_ID if (DBNull.Value.Equals(record["Stage_ID"])) s.ID = -1; else s.ID = Convert.ToInt32(record["Stage_ID"]); // Get Name if (DBNull.Value.Equals(record["StageName"])) s.Name = ""; else s.Name = record["StageName"].ToString(); ts.Stage = s; band.TimeSlots = new List<TimeSlot>(); band.TimeSlots.Add(ts); bands.Add(band); } reader.Close(); } // Fail catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static TimeSlot CreateTimeSlot(global::System.Guid ID, global::System.DateTime start, global::System.DateTime end) { TimeSlot timeSlot = new TimeSlot(); timeSlot.Id = ID; timeSlot.Start = start; timeSlot.End = end; return timeSlot; }
public Slot(DayOfWeek day, TimeSlot timeSlot) { this.Day = day; this.TimeSlot = timeSlot; this.LastUpdated = DateTime.UtcNow.Ticks.ToString(); this.Movie = null; }
/// <summary> /// 更新一个时隙上的负载 /// </summary> /// <param name="slot"></param> private static void UpdateOneTSLoad(TimeSlot slot,TDSimCell cell) { if (slot.LinkDirection == LinkType.Downlink) { float curPower = (float)UnitTrans.dBmTomw((double)slot.CurPower); float maxPower = (float)UnitTrans.dBmTomw((double)slot.MaxPowerforR4); slot.Load = curPower / maxPower; } else { float curPower = (float)UnitTrans.dBmTomw(slot.CurPower); float backNoise = (float)UnitTrans.dBmTomw(cell.BackNoise_DB); slot.Load = (float)(1 - backNoise / curPower); } }
/// <summary> /// Registers a class with a room-timeslot pair. The class, the room and /// the timeslot should have been registered to the Classes, Rooms and /// TimeSlots properties already. /// </summary> public bool RegisterClassRoomTimeSlot(Class cl, Room r, TimeSlot t) { return Classes.Contains(cl) && Rooms.Contains(r) && TimeSlots.Contains(t) && this.allocation.Add(new Tuple<Class, Room, TimeSlot>(cl, r, t)); }
public static bool IntersectionWithExclusions(TimeSlot slot, List <ExceptionTime> exceptions) { bool retVal = false; foreach (var exception in exceptions) { switch (exception.Recurency) { case Recurency.None: retVal = TimeRangeUtils.PeriodIntersectionsRawDates(slot.PeriodStart, slot.PeriodEnd, exception.PeriodStart, exception.PeriodEnd); break; case Recurency.Daily: DateTime currentDayStart = slot.PeriodStart.Date.Add(exception.PeriodStart.TimeOfDay); DateTime currentDayEnd = slot.PeriodStart.Date.Add(exception.PeriodStart.TimeOfDay); retVal = TimeRangeUtils.PeriodIntersectionsRawDates(slot.PeriodStart, slot.PeriodEnd, currentDayStart, currentDayEnd); break; case Recurency.Weekly: DateTime currentWeekStart = slot.PeriodStart.Date.AddDays((int)(slot.PeriodStart - exception.PeriodStart).TotalDays % 7).Add(exception.PeriodStart.TimeOfDay); DateTime currentWeekEnd = slot.PeriodStart.Date.AddDays((int)(slot.PeriodStart - exception.PeriodEnd).TotalDays % 7).Add(exception.PeriodEnd.TimeOfDay); retVal = TimeRangeUtils.PeriodIntersectionsRawDates(slot.PeriodStart, slot.PeriodEnd, currentWeekStart, currentWeekEnd); break; case Recurency.Monthly: DateTime currentMonthStart; DateTime currentMonthEnd; try { currentMonthStart = new DateTime(slot.PeriodStart.Year, slot.PeriodStart.Month, exception.PeriodStart.Day, exception.PeriodStart.Hour, exception.PeriodStart.Minute, exception.PeriodStart.Second); } catch { currentMonthStart = new DateTime(slot.PeriodStart.Year, slot.PeriodStart.Month, exception.PeriodStart.Day - 1, exception.PeriodStart.Hour, exception.PeriodStart.Minute, exception.PeriodStart.Second); } try { currentMonthEnd = new DateTime(slot.PeriodEnd.Year, slot.PeriodStart.Month, exception.PeriodEnd.Day, exception.PeriodEnd.Hour, exception.PeriodEnd.Minute, exception.PeriodEnd.Second); } catch { currentMonthEnd = new DateTime(slot.PeriodEnd.Year, slot.PeriodStart.Month, exception.PeriodEnd.Day - 1, exception.PeriodEnd.Hour, exception.PeriodEnd.Minute, exception.PeriodEnd.Second); } retVal = TimeRangeUtils.PeriodIntersectionsRawDates(slot.PeriodStart, slot.PeriodEnd, currentMonthStart, currentMonthEnd); break; case Recurency.Yearly: DateTime currentYearStart; DateTime currentYearEnd; try { currentYearStart = new DateTime(slot.PeriodStart.Year, exception.PeriodStart.Month, exception.PeriodStart.Day, exception.PeriodStart.Hour, exception.PeriodStart.Minute, exception.PeriodStart.Second); } catch { currentYearStart = new DateTime(slot.PeriodStart.Year, exception.PeriodStart.Month, exception.PeriodStart.Day - 1, exception.PeriodStart.Hour, exception.PeriodStart.Minute, exception.PeriodStart.Second); } try { currentYearEnd = new DateTime(slot.PeriodEnd.Year, exception.PeriodEnd.Month, exception.PeriodEnd.Day, exception.PeriodEnd.Hour, exception.PeriodEnd.Minute, exception.PeriodEnd.Second); } catch { currentYearEnd = new DateTime(slot.PeriodEnd.Year, exception.PeriodEnd.Month, exception.PeriodEnd.Day - 1, exception.PeriodEnd.Hour, exception.PeriodEnd.Minute, exception.PeriodEnd.Second); } retVal = TimeRangeUtils.PeriodIntersectionsRawDates(slot.PeriodStart, slot.PeriodEnd, currentYearStart, currentYearEnd); break; } if (retVal) { break; } } return(retVal); }
private TimeSlot Read5_TimeSlot(bool isNullable, bool checkType) { XmlQualifiedName xmlQualifiedName = checkType ? base.GetXsiType() : null; bool flag = false; if (isNullable) { flag = base.ReadNull(); } if (checkType && !(xmlQualifiedName == null) && (xmlQualifiedName.Name != this.id6_TimeSlot || xmlQualifiedName.Namespace != this.id2_WorkingHoursxsd)) { throw base.CreateUnknownTypeException(xmlQualifiedName); } if (flag) { return(null); } TimeSlot timeSlot = new TimeSlot(); bool[] array = new bool[2]; while (base.Reader.MoveToNextAttribute()) { if (!base.IsXmlnsAttribute(base.Reader.Name)) { base.UnknownNode(timeSlot); } } base.Reader.MoveToElement(); if (base.Reader.IsEmptyElement) { base.Reader.Skip(); return(timeSlot); } base.Reader.ReadStartElement(); base.Reader.MoveToContent(); int num = 0; int readerCount = base.ReaderCount; while (base.Reader.NodeType != XmlNodeType.EndElement && base.Reader.NodeType != XmlNodeType.None) { if (base.Reader.NodeType == XmlNodeType.Element) { if (!array[0] && base.Reader.LocalName == this.id8_Start && base.Reader.NamespaceURI == this.id2_WorkingHoursxsd) { timeSlot.Start = base.Reader.ReadElementString(); array[0] = true; } else if (!array[1] && base.Reader.LocalName == this.id9_End && base.Reader.NamespaceURI == this.id2_WorkingHoursxsd) { timeSlot.End = base.Reader.ReadElementString(); array[1] = true; } else { base.UnknownNode(timeSlot, "WorkingHours.xsd:Start, WorkingHours.xsd:End"); } } else { base.UnknownNode(timeSlot, "WorkingHours.xsd:Start, WorkingHours.xsd:End"); } base.Reader.MoveToContent(); base.CheckReaderCount(ref num, ref readerCount); } base.ReadEndElement(); return(timeSlot); }
public Booking getBooking(TimeSlot timeSlot) { return timeBooking_[(int)timeSlot]; }
/// <summary> /// No hay ningún comentario para TimeSlot en el esquema. /// </summary> public void AddToTimeSlot(TimeSlot timeSlot) { base.AddObject("TimeSlot", timeSlot); }
/// <summary> /// 初始化opccuiedTS /// </summary> /// <param name="user"></param> /// <param name="slot"></param> /// <param name="remainNeedRU"></param> /// <returns></returns> private static TSResource InitTSResource(TDSimUser user, TimeSlot slot, int remainNeedRU) { TSResource tsRes = new TSResource(); tsRes.RuNum = (byte)remainNeedRU; tsRes.PhCodeNum = (byte)(Math.Ceiling((Double)(remainNeedRU * user.SpreadFactor / TimeSlot.TotalCodeNum))); //user.OccupiedTS.Add(slot.TsNum, tsRes); return tsRes; }
/// <summary> /// Returns a list of time slots available for the given course under the restrictions that it should be a lab room, /// class room, instructional room, etc. /// </summary> /// <param name="course"> /// The course to account for. /// </param> /// <param name="labRoom"> /// Should the room be a lab room? /// </param> /// <param name="classRoom"> /// Should the room be a class room? /// </param> /// <param name="instructRoom"> /// Should the room be an instructional room? /// </param> /// <returns> /// A list of time slots representing available times at what rooms. /// </returns> private List<TimeSlot> RequestAvailableRooms(Course course, bool labRoom, bool classRoom, bool instructRoom, bool library) { List<TimeSlot> availableSlots = new List<TimeSlot>(); foreach (Room room in Program.Database.Rooms) { if ((room.RoomID != "Lib" && library) && (!room.Resource.Cad && course.Requirement.Cad) && (!room.Resource.Program && course.Requirement.Program) && (!room.Resource.Multi && course.Requirement.Multi) && (!room.Resource.Gaming && course.Requirement.Gaming)) continue; if ((labRoom && !room.Resource.Lab) || (classRoom && !room.Resource.Classroom) || (instructRoom && !room.Resource.Instruct) || (library && !room.RoomID.Contains("Lib"))) continue; // Figure out where existing schedule usages are var usages = from schedule in CurrentSchedules where schedule.RoomID == room.RoomID select schedule; // We don't care so much about what's already here, just flag it RangedList<Room> usedSlots = new RangedList<Room>(); usedSlots.Payload = usedSlots.Payload.Distinct().ToList(); foreach (Schedule schedule in usages) { usedSlots.AddRange(schedule.StartTime, schedule.EndTime, room); } // We start on monday and blow through each day of the week, looking in 1-hour increments for available slots DateTime startDate = StartDate(); for (int day = 0; day < 5; day++) { DateTime currentDate = startDate.AddDays(day).AddHours(8.335); DateTime? openStart = currentDate; for (int hour = 0; hour < 8; hour++) { // Is the current date available? RangedList<Room>.PayloadIndex currentSlot = usedSlots.GetIndex(currentDate); if (currentSlot != null) { // We've got to close an availability block if (openStart != null && (DateTime)openStart != currentDate) { DateTime start = (DateTime)openStart; DateTime end = currentDate; // Record our availability range TimeSlot newSlot = new TimeSlot() { Start = start, End = end, TargetRoom = room, }; availableSlots.Add(newSlot); } openStart = null; // Not available, move along to the next hour } else if (openStart == null) openStart = currentDate; currentDate = currentDate.AddHours(1); } // This will happen on our first pass because entire days are still available if (openStart != null && (DateTime)openStart != currentDate) { DateTime start = (DateTime)openStart; DateTime end = currentDate; // Record our availability range TimeSlot newSlot = new TimeSlot() { Start = start, End = end, TargetRoom = room, }; availableSlots.Add(newSlot); } } } List<TimeSlot> result = availableSlots.Distinct().ToList(); return result; }
public int SaveTimeSlot(TimeSlot timeSlots) { int count = 0; try { DBConnection.OpenConnection(); SqlCommand cmd2 = new SqlCommand(CommonConstants.QUERY_GET_TIMESLOT, DBConnection.DatabaseConnection); cmd2.Parameters.AddWithValue(CommonConstants.PARAMETER_DAY_OF_THE_WEEK, timeSlots.GetDay_of_the_Week()); cmd2.Parameters.AddWithValue(CommonConstants.PARAMETER_START_TIME, timeSlots.GetStart_Time()); cmd2.Parameters.AddWithValue(CommonConstants.PARAMETER_END_TIME, timeSlots.GetEnd_Time()); cmd2.Parameters.AddWithValue(CommonConstants.PARAMETER_TYPE, timeSlots.GetSlotType()); SqlDataReader reader = cmd2.ExecuteReader(); if (reader.Read()) { reader.Close(); DBConnection.CloseConnection(); return(0); } reader.Close(); DBConnection.CloseConnection(); if (timeSlots.GetSlotType().Trim() == "Lunch Break") { DBConnection.OpenConnection(); SqlCommand cmd3 = new SqlCommand(CommonConstants.QUERY_GET_LUNCH_BREAK_COUNT_FOR_THE_DAY, DBConnection.DatabaseConnection); cmd3.Parameters.AddWithValue(CommonConstants.PARAMETER_DAY_OF_THE_WEEK, timeSlots.GetDay_of_the_Week()); cmd3.Parameters.AddWithValue(CommonConstants.PARAMETER_TYPE, timeSlots.GetSlotType()); SqlDataReader reader2 = cmd3.ExecuteReader(); reader2.Read(); if (int.Parse(reader2[CommonConstants.COLUMN_BREAK_COUNT].ToString()) >= 1) { reader2.Close(); DBConnection.CloseConnection(); return(-2); } DBConnection.CloseConnection(); } DBConnection.OpenConnection(); SqlCommand cmd = new SqlCommand(CommonConstants.QUERY_SAVE_TIMESLOT, DBConnection.DatabaseConnection); cmd.Parameters.AddWithValue(CommonConstants.PARAMETER_DAY_OF_THE_WEEK, timeSlots.GetDay_of_the_Week()); cmd.Parameters.AddWithValue(CommonConstants.PARAMETER_START_TIME, timeSlots.GetStart_Time()); cmd.Parameters.AddWithValue(CommonConstants.PARAMETER_END_TIME, timeSlots.GetEnd_Time()); cmd.Parameters.AddWithValue(CommonConstants.PARAMETER_TYPE, timeSlots.GetSlotType()); count = cmd.ExecuteNonQuery(); } catch (Exception ex) { try { Console.WriteLine(ex); DBConnection.CloseConnection(); } catch (Exception) { throw; } return(-1); } finally { try { DBConnection.CloseConnection(); } catch (Exception) { throw; } } return(count); }
public bool CheckBooking(TimeSlot timeSlot) { return timeBooking_[(int)timeSlot].IsBooked; }
private List <InstrumentPrice> ReadFromFile(string filePath) { List <InstrumentPrice> dataList = new List <InstrumentPrice>(); var fileStream = new StreamReader(filePath); string line; fileStream.ReadLine(); // Skip first line InstrumentPrice instrumentPrice; decimal price; DateTime date; while ((line = fileStream.ReadLine()) != null) { var properties = line.Split(','); if (Decimal.TryParse(properties[4], out price)) { if (DateTime.TryParseExact(properties[3], _format, CultureInfo.InvariantCulture, DateTimeStyles.None, out date)) { try { instrumentPrice = new InstrumentPrice(properties[0], properties[1], properties[2], date, TimeSlot.DateTimeToTimeSlot(date), price); dataList.Add(instrumentPrice); } catch (Exception e) { _logger.LogInformation(e, ""); continue; } } else { _logger.LogInformation($"Error parsing Date - {properties[3]}"); } } else { _logger.LogInformation($"Error parsing Price - {properties[4]}"); } } return(dataList); }