public ActionResult Appliances_Create([DataSourceRequest]DataSourceRequest request, AdministerApplianceViewModel appliance) { var newId = 0; if (ModelState.IsValid) { var entity = new Appliance { Name = appliance.Name, Type = appliance.Type, Power = appliance.Power, Input = appliance.Input, Output = appliance.Output, ManufacturerId = this.User.Identity.GetUserId() }; this.appliances.Add(entity); this.appliances.SaveChanges(); newId = entity.Id; } var applianceToDisplay = this.appliances .All() .To<AdministerApplianceViewModel>() .FirstOrDefault(x => x.Id == newId); return Json(new[] { applianceToDisplay }.ToDataSourceResult(request, ModelState)); }
public void SelectAppliance(ApplianceID id) { applianceSelectPanel.gameObject.SetActive(false); applianceMenu.gameObject.SetActive(true); selectedAppliance = GameGlobal.Appliances[id]; applianceNameText.text = selectedAppliance.name; UpdateApplianceMenu(); }
public void SetUp() { ApplianceModel = new ApplianceModel("A/C", "BrandNameA", "A/C A") { Id = 1, PossibleSettings = new Dictionary<string, string[]> { ["FunctionA"] = new[] { "FunctionADefaultChoice", "FunctionAChoice2", "FunctionAChoice3" }, ["FunctionB"] = new[] { "FunctionBDefaultChoice", "FunctionBChoice2", "FunctionBChoice3" } } }; Appliance = new Appliance { Id = 1, Name = "Appliance1", Model = ApplianceModel, }; }
public void SetUp() { var appl1 = new Appliance { Id = 1, Name = "Appliance1", Model = new ApplianceModel(), }; var appl2 = new Appliance { Id = 2, Name = "Appliance2", Model = new ApplianceModel(), }; var appl3 = new Appliance { Id = 3, Name = "Appliance3", Model = new ApplianceModel(), }; MockedAppliancesList = new List<Appliance> { appl1, appl2, appl3 }.AsQueryable(); MockedZonesList = new List<Zone> { new Zone { Id = 1, Name = "Bed Room", Appliances = new List<Appliance> { appl1, appl2 } }, new Zone { Id = 2, Name = "Kitchen", Appliances = new List<Appliance> { appl3 } }, }.AsQueryable(); MockedZonesDbSet = MockedZonesList.GetQueryableMockDbSet(); MockedAppliancesDbSet = MockedAppliancesList.GetQueryableMockDbSet(); MockedContext = new Mock<IApplicationDbContext>(); MockedContext.Setup(c => c.Zones).Returns(MockedZonesDbSet.Object); MockedContext.Setup(c => c.Appliances).Returns(MockedAppliancesDbSet.Object); MockedRepository = new EfApplicationRepository { Context = MockedContext.Object }; }
public async Task <ActionResult> Create([Bind(Include = "Id,ApplianceTypeId,Power")] Appliance appliance) { if (ModelState.IsValid) { db.Appliances.Add(appliance); await db.SaveChangesAsync(); string comment = $"Id: {appliance.Id} ApplianceTypeId: {appliance.ApplianceTypeId} Power: {appliance.Power.ToString()}"; SystemLog.New("ApplianceCreate", comment, null, false); return(RedirectToAction("Index")); } IList <ApplianceType> appliancetypes = db.ApplianceTypes .Where(a => true) .ToList(); appliancetypes = appliancetypes .OrderBy(a => a.Name) .ToList(); ViewBag.ApplianceTypeId = new SelectList(appliancetypes, "Id", "Name", appliance.ApplianceTypeId); return(View(appliance)); }
public void SetCurrentAppliance(Appliance a) { if (_currentAppliance != null) { Controls.Remove(_currentAppliance.GetUIGenerator()); _currentAppliance.GetMenuItem().Checked = false; } else { disconnectItem.Enabled = true; } HideLogPanel(); _currentAppliance = a; _currentAppliance.GetMenuItem().Checked = true; Controls.Add(_currentAppliance.GetUIGenerator()); _currentAppliance.GetUIGenerator().Visible = true; _currentAppliance.GetUIGenerator().BringToFront(); _currentAppliance.GetUIGenerator().Focus(); this.Text = Globals.GetVersionString() + " - " + a.Name; setActionItemName(); }
private void Update() { // Check if user clicked on a appliance if so interact with it if (Input.GetMouseButtonDown(0)) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(new Vector2(mousePos.x, mousePos.y), Vector2.zero); if (hit.collider != null) // Something was clicked { Appliance appliance = hit.collider.GetComponent <Appliance>(); if (GameManager.gameRunning) { if (appliance.canInteractOnPlay) { appliance.InteractOnPlay(); } } } } }
public async Task <ActionResult> AddAppliance(Appliance model, string UserName, string indexConsumptionId) { var appliance = new Appliance { ApplianceType = model.ApplianceType, nrWatts = model.nrWatts, hh = model.hh, mm = model.mm, }; int hhTOmm = _applianceRepository.ConvertHHToMM(appliance.hh); int total_mm = hhTOmm + appliance.mm; int mmTOss = _applianceRepository.ConvertMMToSS(total_mm); float wTokw = _applianceRepository.ConvertWattsToKw(appliance.nrWatts); appliance.kwMonth = _applianceRepository.GetKwMonth(wTokw, mmTOss); appliance.Id = Guid.NewGuid().ToString(); appliance.SmallUserId = _userRepository.GetIdByName(UserName); //appliance.IndexConsumptionId = _userRepository.GetIdConsumptionByName(UserName); appliance.IndexConsumptionId = indexConsumptionId; float priceKw = _applianceRepository.GetPriceKw(appliance.IndexConsumptionId); appliance.priceMonth = _applianceRepository.GetPriceMonth(appliance.kwMonth, priceKw); await _consumptionContext.Appliances.AddAsync(appliance); await _consumptionContext.SaveChangesAsync(); ICollection <Appliance> allAppliances = new List <Appliance>(); string userId = _userRepository.GetIdByName(UserName); allAppliances = _consumptionContext.Appliances.Where(x => x.SmallUserId.Equals(userId)).Where(x => x.IndexConsumptionId.Equals(indexConsumptionId)).OrderBy(x => x.ApplianceType).ToList(); return(Ok(allAppliances)); }
protected int searchHelper(GroupNode g, bool listBelow, Appliance a) { if (g.IsObject()) { return(0); } BranchGroupNode bg = (BranchGroupNode)g; if (bg.Count == 0) { return(0); } ListDecision d = null; if (bg.IsList()) { d = new ListDecision(!listBelow); bg.Decorations[ListDecision.DECISION_KEY] = d; } int dim = 0; for (int i = 0; i < bg.Children.Count; i++) { dim = Math.Max(dim, searchHelper((GroupNode)bg.Children[i], d != null, a)); } if (d != null) { return(d.Dimensions = dim + 1); } return(dim); }
private List <Appliance> GetApplianceList(XmlNodeList nodeList) { try { List <Appliance> appliance = new List <Appliance>(); foreach (XmlNode client in nodeList) { Appliance a = new Appliance(); a.ApplianceId = ""; a.ApplianceName = client["ApplianceName"].InnerText; a.IpAddress = client["IPAddress"].InnerText; a.DisplayName = client["DisplayName"].InnerText; appliance.Add(a); } return(appliance); } catch (Exception ex) { Log.WriteLine("ERROR : " + ex.Message); throw ex; } }
public IActionResult Add([FromBody] AddRequestModel requestModel, [FromHeader] string displayLanguage) { var responseModel = new ApiResponseModel <Appliance>(); responseModel.DisplayLanguage = displayLanguage; try { var record = new Appliance(); record.Name = requestModel.Name; record.Barcode = requestModel.Barcode; var dbResult = _applianceService.Add(record); if (dbResult > 0) { responseModel.Data = record; // oluşturulan entity bilgisinde id kolonu atanmış olur ve entity geri gönderiliyor responseModel.ResultStatusCode = ResultStatusCodeStatic.Success; responseModel.ResultStatusMessage = "Success"; return(Ok(responseModel)); } else { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = "Could Not Be Saved"; responseModel.Data = null; return(StatusCode(StatusCodes.Status500InternalServerError, responseModel)); } } catch (Exception ex) { responseModel.ResultStatusCode = ResultStatusCodeStatic.Error; responseModel.ResultStatusMessage = ex.Message; responseModel.Data = null; return(StatusCode(StatusCodes.Status500InternalServerError, responseModel)); } }
/** * @param sourceAppliance */ public AttributeChangeEvent(Appliance sourceAppliance) : base(sourceAppliance) { //super(sourceAppliance); }
/** * @param sourceAppliance */ public StateChangeEvent(Appliance sourceAppliance) : base(sourceAppliance) { //super(sourceAppliance); }
public override void ModifyAppliance(Appliance appliance) { throw new NotImplementedException(); }
public ApiResponseModel <Appliance> Edit(string userToken, string displayLanguage, Appliance appliance) { ApiResponseModel <Appliance> result = new ApiResponseModel <Appliance>(); using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(ConfigHelper.ApiUrl); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userToken); httpClient.DefaultRequestHeaders.Add("DisplayLanguage", displayLanguage); var portalApiRequestModel = new AddRequestModel(); portalApiRequestModel.Id = appliance.Id; portalApiRequestModel.Name = appliance.Name; portalApiRequestModel.Barcode = appliance.Barcode; HttpResponseMessage response = httpClient.PutAsJsonAsync(string.Format("v1/Appliance/" + portalApiRequestModel.Id), portalApiRequestModel).Result; result = response.Content.ReadAsJsonAsync <ApiResponseModel <Appliance> >().Result; } return(result); }
public void Produce(Appliance appliance, ProduceMethod method) { GameGlobal.Player.IsWorking = true; var parameter = new Dictionary<byte, object> { { (byte)ProduceParameterItem.ApplianceID, appliance.id }, { (byte)ProduceParameterItem.ProduceMethodID, method.id } }; peer.OpCustom((byte)OperationType.Produce, parameter, true, 0, true); }
public ApplianceBuilder() { _appliance = new Appliance(TestName, TestDescription, TestDefaultPowerConsumption, TestDefaultStartupPowerConsumption); }
public ActionResult DeleteAppliance(Appliance appliance) { db.Appliances.Remove(db.Appliances.Where(p => p.Id == appliance.Id).First()); db.SaveChanges(); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public void AddAppliance(Appliance appliance) { _unitOfWork.ApplianceRepository.Add(appliance); _unitOfWork.Save(); }
public abstract void ModifyAppliance(Appliance appliance);
public void DeleteAppliance(Appliance appliance) { _unitOfWork.ApplianceRepository.Delete(appliance); _unitOfWork.Save(); }
public void EditAppliance(Appliance appliance) { _unitOfWork.ApplianceRepository.Edit(appliance); _unitOfWork.Save(); }
/// <summary> /// Updates the specified model. /// </summary> /// <param name="model">The model.</param> /// <param name="isPolling">if set to <c>true</c> [is polling].</param> /// <exception cref="System.Exception"></exception> public void Sync(Appliance model, bool isPolling) { try { HWLogger.Service.Debug($"Start UpdateAppliance. [isPolling:{isPolling}]"); var devices = MGroup.Instance.EntityObjects.GetObjectReader <MonitoringObject>(ApplianceClass, ObjectQueryOptions.Default).ToList(); var exsitAppliance = devices.FirstOrDefault(); if (exsitAppliance == null) { throw new Exception($"Can not find the Appliance "); } var discoveryData = new IncrementalDiscoveryData(); this.UpdateAppliance(model, exsitAppliance); discoveryData.Add(exsitAppliance); #region EnclosureCollection var enclosureCollections = exsitAppliance.GetRelatedMonitoringObjects(this.EnclosureCollectionClass); if (enclosureCollections.Any()) { var exsit = enclosureCollections.First(); this.UpdateEnclosureCollection(model.EnclosureCollection, exsit); discoveryData.Add(exsit); } else { var enclosureCollection = this.CreateEnclosureCollection(model.EnclosureCollection); discoveryData.Add(enclosureCollection); } #endregion #region ServerCollection var serverCollections = exsitAppliance.GetRelatedMonitoringObjects(this.ServerCollectionClass); if (serverCollections.Any()) { var exsit = serverCollections.First(); this.UpdateServerCollection(model.ServerCollection, exsit); discoveryData.Add(exsit); } else { var serverCollection = this.CreateServerCollection(model.ServerCollection); discoveryData.Add(serverCollection); } #endregion #region EventCollection var eventCollections = exsitAppliance.GetRelatedMonitoringObjects(this.EventCollectionClass); if (eventCollections.Any()) { var exsit = eventCollections.First(); this.UpdateEventCollection(model.EventCollection, exsit); discoveryData.Add(exsit); } else { var eventCollection = this.CreateEventCollection(model.EventCollection); discoveryData.Add(eventCollection); } #endregion #region PerformanceCollection var performanceCollections = exsitAppliance.GetRelatedMonitoringObjects(this.PerformanceCollectionClass); if (performanceCollections.Any()) { var exsit = performanceCollections.First(); this.UpdatePerformanceCollection(model.PerformanceCollection, exsit); discoveryData.Add(exsit); } else { var performanceCollection = this.CreatePerformanceCollection(model.PerformanceCollection); discoveryData.Add(performanceCollection); } #endregion #region FusionDirectorCollection var fusionDirectorCollections = exsitAppliance.GetRelatedMonitoringObjects(this.FusionDirectorCollectionClass); if (fusionDirectorCollections.Any()) { var exsit = fusionDirectorCollections.First(); this.UpdateFusionDirectorCollection(model.FusionDirectorCollection, exsit); discoveryData.Add(exsit); } else { var fusionDirectorCollection = this.CreateFusionDirectorCollection(model.FusionDirectorCollection); discoveryData.Add(fusionDirectorCollection); } #endregion discoveryData.Overwrite(this.MontioringConnector); HWLogger.Service.Info($"UpdateAppliance finish."); } catch (Exception e) { HWLogger.Service.Error(e, $"Update Appliance Error. [isPolling:{isPolling}]"); } }
/** * @param sourceAppliance */ public LowBateryAlarm(Appliance sourceAppliance) : base(sourceAppliance) { //super(sourceAppliance); }
protected AbstractCommand(Appliance appliance) { this.receiverAppliance = appliance; this.snapshots = createSnapshots(); }
protected AbstractCommand(Appliance appliance) { this.receiverAppliance = appliance; this.snapshots = createSnapshots(); }
/* * Constants */ /* * Process Method */ public override void Process(Appliance a) { // start searching for units searchHelper(a.GetRoot(), a); }
/** * @param receiverAppliance */ public TurnOffAppliance(Appliance receiverAppliance) : base(receiverAppliance) { //super(receiverAppliance); }
/** * @param receiverAppliance */ public TurnOffAppliance(Appliance receiverAppliance) : base(receiverAppliance) { //super(receiverAppliance); }
public ActionResult AddAppliance(Appliance appliance) { db.Appliances.Add(appliance); db.SaveChanges(); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public void Init(Appliance appliance) { this.Appliance = appliance; }
/** * @param sourceAppliance */ public Alarm(Appliance sourceAppliance) : base(sourceAppliance) { //super(sourceAppliance); }
/** * @param appliance */ public TurnOnApplianceCommand(Appliance appliance) : base(appliance) { //super(appliance); }
/** * @param appliance */ public StartApplianceCommand(Appliance appliance) : base(appliance) { //super(appliance); }
/** * @param sourceAppliance */ public LowBateryAlarm(Appliance sourceAppliance) : base(sourceAppliance) { //super(sourceAppliance); }
public ActionResult Appliances_Destroy([DataSourceRequest]DataSourceRequest request, Appliance appliance) { this.appliances.Delete(appliance.Id); this.appliances.SaveChanges(); return Json(new[] { appliance }.ToDataSourceResult(request, ModelState)); }
/* * Member Variables */ /* * Constructor */ /* * Process Rule Method */ public abstract void Process(Appliance a);
public void AddPassiveAppliance(Appliance appliance, int passiveEnergy) { appliances.Add(appliance); passiveEnergys += passiveEnergy; }
/** * @param appliance */ public StartApplianceCommand(Appliance appliance) : base(appliance) { //super(appliance); }
/* * Process Method */ public override void Process(Appliance a) { generateOrganization(a.GetRoot(), a.GetDependedObjects()); }
/** * @param sourceAppliance */ public TemperatureAlarm(Appliance sourceAppliance) : base(sourceAppliance) { //super(sourceAppliance); }
private void HandleExistingAppliance(Appliance appliance) { OldDataSheet = appliance.DataSheet.MakeCopy() as DataSheet; OnDataSheetChanged(NewAppliance.DataSheet); }
/** * @param sourceAppliance */ public HumidityAlarm(Appliance sourceAppliance) : base(sourceAppliance) { //super(sourceAppliance); }
/** * @param sourceAppliance */ public Alarm(Appliance sourceAppliance) : base(sourceAppliance) { //super(sourceAppliance); }
public Appliance Insert(Appliance appliance) { return(repoAppliance.Insert(appliance)); }
public void SetAppliance(Appliance appliance) { this.appliance = appliance; }
public Appliance Update(Appliance appliance) { return(repoAppliance.Update(appliance)); }