private static House Initialization() { House house = new House("Дом1"); house.AddRoom(new Room("Зал")); house.AddRoom(new Room("Кухня")); house.AddDevice("Зал", new ClimatControl("Климат")); HouseCinema cinema = new HouseCinema("Кинотеатр"); Tv tv = new Tv("TV1"); tv.Connection(cinema); DVDPlayer dvd = new DVDPlayer("DVD"); dvd.Connection(cinema); house.AddDevice("Зал", cinema); house.AddDevice("Зал", new DVDPlayer("DVD")); house.AddDevice("Зал", new Tv("TV1")); house.AddDevice("Зал", new Tv("TV2")); house.AddDevice("Зал", new Lamp("Лампа1")); house.AddDevice("Зал", new Lamp("Лампа2")); house.AddDevice("Кухня", new Tv("TV")); house.AddDevice("Кухня", new Heating("Heating")); house.AddDevice("Кухня", new Conditioner("Condition")); house.AddDevice("Кухня", new Lamp("Лампа1")); house.AddDevice("Кухня", new Lamp("Лампа2")); return house; }
public ActionResult AddTools() { house = Session["home"] as House; Response.Cookies.Add(new HttpCookie("view", "~/Views/Home/AddTools.cshtml")); return View(house); }
public ActionResult Index() { _house = ReadHouse(); if (Request.IsAjaxRequest()) return PartialView(_house); else return View(_house); }
public ActionResult AddRoom() { _house = ReadHouse(); _house.Remote.Reader.RoomData = Request.Params["addRoom[Room]"]; _house.Remote.Reader.CommandData = Request.Params["addRoom[Command]"]; _house.Remote.PushButton(); SaveHouse(); return PartialView("Device/Room", _house.GetRoom(_house.Remote.Reader.RoomData)); }
public string Delete([FromBody]DataToJson value) { _house = ReadHouse(); _house.Remote.Reader.RoomData = value.Room; _house.Remote.Reader.DeviceData = value.Device; _house.Remote.Reader.CommandData = value.Command; _house.Remote.PushButton(); SaveHouse(); return "ok"; }
protected void Page_Init(object sender, EventArgs e) { Home = SerDesHouse.Read(); WebReader wbReader = new WebReader(Home); Home.Remote = new RemoteControl(wbReader, new List<IWriter> { this }); Home.Remote.AddCommand(new SetLightCommand()); IsRedact = false; RunSensor(); }
public ActionResult DelRoom() { house = Session["home"] as House; GetView(); house.Remote.Reader.RoomData = Request.Params["list_room"]; house.Remote.Reader.CommandData = "delRom"; house.Remote.PushButton(); SaveHouse(); return View(view, house); }
public static void Save(House house) { BinaryFormatter binFormat = new BinaryFormatter(); try { using (Stream fStream = new FileStream(pathFile, FileMode.Create, FileAccess.Write, FileShare.None)) { binFormat.Serialize(fStream, house); } } catch (Exception e) { } }
public ActionResult AddDevice() { house = Session["home"] as House; GetView(); house.Remote.Reader.RoomData = Request.Params["list_room"]; house.Remote.Reader.DeviceData = Request.Params["addDevice"]; house.Remote.Reader.CommandData = house.Remote.Commands.Values. Where(c => c.Inform.Contains("Добавить " + Request.Params["list_device"])). Select(c=>c.Name).First(); house.Remote.PushButton(); SaveHouse(); return View(view, house); }
public ActionResult LigthSelect(string room, string device, string command) { house = Session["home"] as House; ILight light = house.GetDevice(room, device) as ILight; if (light != null) { light.Brightness = (LightsState)Enum.Parse(typeof(LightsState), command); } house.Remote.PushButton(); Session["home"] = house; SaveHouse(); GetView(); return View(view, house); }
protected void Page_Load(object sender, EventArgs e) { btnRedactDev.Click += btnRedactDev_Click; _house = Master.Home; if (!IsPostBack) { ddlRedactRoom.DataSource = _house.Rooms.Values.Select(c => c.Name); ddlRedactRoom.DataBind(); ddlRoom.DataSource = _house.Rooms.Values.Select(c => c.Name); ddlRoom.DataBind(); ddlDevice.DataSource = _house.GetRoom(ddlRoom.SelectedValue).Devices.Values.Select(c => c.Name); ddlDevice.DataBind(); } }
public ActionResult Command(string room, string device, string command) { house = Session["home"] as House; if (command.Contains("_plus")) command = command.Replace("_plus", "+"); house.Remote.Reader.RoomData = room; house.Remote.Reader.DeviceData = device; house.Remote.Reader.CommandData = command; house.Remote.PushButton(); Session["home"] = house; SaveHouse(); GetView(); return View(view, house); }
public string Put([FromBody]DataToJson value) { _house = ReadHouse(); if (value.Device == "") { if (!_house.HasRoom(value.Room)) { _house.ChangeNameRoom(value.Value, value.Room); SaveHouse(); if (_house.GetRoom(value.Room) != null) { return "ok"; } } else { return "Комната \"" + value.Room + "\" уже существует"; } } else { if (!_house.HasDevice(value.Room, value.Device)) { _house.ChangeNameDevice(value.Room, value.Value, value.Device); SaveHouse(); if (_house.GetDevice(value.Room, value.Device) != null) { return "ok"; } } else { return "Устройство \"" + value.Device + "\" в комнате \" " + value.Room + " \" уже существует"; } } return "Изменение не произошло!!!"; }
public ActionResult AddDevice() { _house = ReadHouse(); _house.Remote.Reader.RoomData = Request.Params["addDevice[Room]"]; _house.Remote.Reader.DeviceData = Request.Params["addDevice[Device]"]; _house.Remote.Reader.CommandData = Request.Params["addDevice[Command]"]; _house.Remote.Reader.CommandData = _house.Remote.Commands.Values. Where(c => c.Inform.Contains("Добавить " + Request.Params["addDevice[Command]"])). Select(c => c.Name).First(); _house.Remote.PushButton(); SaveHouse(); Device device = _house.GetDevice(_house.Remote.Reader.RoomData, _house.Remote.Reader.DeviceData); ViewBag.room = Request.Params["addDevice[Room]"].ToLower(); if (device != null) { if (device is Lamp) { return PartialView("Device/Lamp", device as Lamp); } if (device is ClimatControl) { return PartialView("Device/ClimatControl", device as ClimatControl); } if (device is Tv) { return PartialView("Device/Tv", device as Tv); } } return new EmptyResult(); }
public DataForControl(House house, Room room, Device device) { _device = device; _house = house; _room = room; }
public ActionResult RedactRoom() { house = Session["home"] as House; GetView(); house.ChangeNameRoom(Request.Params["list_room"], Request.Params["redactRoom"]); SaveHouse(); return View(view, house); }
public ActionResult Devices(string id) { house = Session["home"] as House; if (house == null) return Redirect("/Home/Index"); ViewBag.RoomName = house.GetRoom(id).Name; ViewBag.Devices = new SelectList(house.GetRoom(id).Devices.Values, "Name", "Name"); GetView(); return View(view, house); }
public ActionResult RedactTools() { _house = ReadHouse(); return PartialView(_house); }
public IEnumerable<string> Post([FromBody]DataToJson value) { _house = ReadHouse(); return _house.GetRoom(value.Room).Devices.Values.Select(c => c.Name); }
private void ReadHouse() { house = db.Houses.FirstOrDefault(); if (house != null) { if (house.Remote == null) { house.Remote = new RemoteControl(new WebReader(house), null); } } }
public RunHouse(House house, RemoteControl remote) { Home = house; Home.Remote = remote; }
public RoomControl(House house, Room room) { _room = room; _house = house; _panel = new Panel(); }
public WebReader(House home) : base(home) { }
protected void Page_Load(object sender, EventArgs e) { _house = Master.Home; }