private void btnCreate_Click(object sender, EventArgs e) { btnCreatePerson.Enabled = true; btnDispose.Enabled = true; btnCreate.Enabled = false; Building.AboveFloorCount = int.Parse(txtOverCount.Text); Building.UnderFloorCount = int.Parse(txtUnderCount.Text); ElevatorInfo.ElevatorCount = int.Parse(txtElevatorCount.Text); int floorCount = Building.AllFloorCount; int floorNum = Building.AboveFloorCount; Height = floorCount * ElevatorInfo.ConsoleSize.Height + 150; for (int i = 0; i < floorCount; i++) { controllerList.Add(new FloorController(groupBox1, floorNum, i)); floorNum = floorNum == 1 ? -1 : floorNum - 1; } for (int i = 0; i < ElevatorInfo.ElevatorCount; i++) { displayerList.Add(new Displayer(panel2, i + 1, GetFloorPosition())); int initFloor = Methods.RandomValue(1, Building.AboveFloorCount); displayerList[i].MoveTo(initFloor); displayerList[i].SetFloorNumberAndDirection(new OutsideCall() { Floor = initFloor, Direction = DirectionStyle.None }); ElevatorService.CreateDevice(i + 1, initFloor); } panel2.Width = ElevatorInfo.ElevatorCount * ElevatorInfo.LcdWidth; Width = groupBox1.Width + panel2.Width + 500; SetFormPosition(); }
public static IActionResult AssignElevatorEndpoint([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "Elevator/Assign")] HttpRequest req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request."); // TODO update logging string elevatorNumber = ElevatorService.AssignElevator(); return(new OkObjectResult(elevatorNumber)); }
private void ElevatorService_NoticeEvent(object sender, NoticeEventArgs e) { if (txtLog.InvokeRequired) { Invoke(LocalThreadAction, sender, e); } else { string msg = DateTime.Now.ToString("mm:ss fff "); Displayer lcd = displayerList.Find(x => x.ID == e.ElevatorID); #region 消息判断 msg += e.ElevatorID > 0 ? $"【{e.ElevatorID}】号电梯 " : ""; switch (e.Status) { case StatusStyle.Running: msg += $"运行中({e.Direction})"; lcd.UpdateDockMsg(e.ElevatorID, false); break; case StatusStyle.Arrive: msg += $"到达{e.Floor}层({e.Direction})"; lcd.MoveTo(e.Floor); lcd.SetFloorNumberAndDirection(new OutsideCall { Floor = e.Floor, Direction = e.Direction }); break; case StatusStyle.Opening: SetCallButton(ElevatorService.GetLightUpList().ToArray()); break; case StatusStyle.Closing: lcd.UpdateDockMsg(e.ElevatorID, true); break; case StatusStyle.Call: msg += $"外呼:"; SetCallButton(ElevatorService.GetLightUpList().ToArray()); break; case StatusStyle.PersonIn: lcd.SetPersonCount(ElevatorService.GetPersonCount(e.ElevatorID)); break; case StatusStyle.PersonOut: lcd.SetPersonCount(ElevatorService.GetPersonCount(e.ElevatorID)); break; } #endregion msg += e.Msg; msg += Environment.NewLine;//换行 txtLog.AppendText(msg); } }
public static IActionResult SendNotificationEndpoint([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "Elevator/SendNotification")] HttpRequest req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request."); // TODO update logging // Placeholder - get from query string string elevatorNumber = req.Query["elevatorNumber"]; ElevatorService.SendElevatorNotification(elevatorNumber); return(new OkResult()); }
/// <summary> /// 更新内呼和外呼信息 /// </summary> /// <param name="elevatorID"></param> internal void UpdateDockMsg(int elevatorID, bool isClosing) { if (isClosing || LcdDockFromInside.Text.DeleteBlank() == "停靠") { SetDockFromInside(ElevatorService.GetDockFromInside(elevatorID)); } if (isClosing || LcdDockFromOutside.Text.DeleteBlank() == "外呼") { SetDockFromOutside(ElevatorService.GetDockFromOutside(elevatorID)); } }
private void btnDispose_Click(object sender, EventArgs e) { btnCreatePerson.Enabled = false; btnCreate.Enabled = true; btnDispose.Enabled = false; foreach (var item in controllerList) { item.Dispose(); } controllerList.Clear(); foreach (var item in displayerList) { item.Dispose(); } displayerList.Clear(); ElevatorService.ClearDevice(); MainForm_Shown(null, null); SetFormPosition(); }
private static async Task Run() { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("config.json", optional: true, reloadOnChange: true) .Build(); var connectionString = config.GetConnectionString("SCElevators.Data.ApplicationDbContext"); using (var db = new ApplicationDbContext(connectionString)) { var scraper = new ElevatorsScraper(); var service = new ElevatorService(db); var next = 1; var errors = 0; var threshold = 5; var keepGoing = true; do { try { Console.Write("Getting {0}", next); var elevator = await scraper.GetElevator(next); Console.Write(" {0}", elevator.Number); if (await service.Exists(elevator.Number)) { try { await service.Update(elevator.Number, DateTimeOffset.UtcNow); Console.WriteLine(" Updated!"); } catch (Exception e) { Console.WriteLine(" Unable to update!"); } } else { try { await service.Create(elevator.Number, elevator.OwnerName, elevator.Location, elevator.LocationAddress, elevator.LocationCity, elevator.LocationState, elevator.LocationZip, elevator.County, elevator.Status, elevator.NextInspectionDue, elevator.NextInspectionDueOther, elevator.MachineType, elevator.Manufacturer, elevator.UnitType, DateTimeOffset.UtcNow); Console.WriteLine(" Created!"); } catch (Exception e) { Console.WriteLine(" Unable to create!"); } } next++; errors = 0; Thread.Sleep(250); } catch (Exception e) { Console.WriteLine(" Not found?"); next++; errors++; if (errors >= threshold) { keepGoing = false; } } } while (keepGoing); } }