public IActionResult DevicePhotoGalary(int id, IFormFile file) // IFormFile for one Photo and IFormCollection for Multi Photo { var device = repo.GetById(id); if (device == null) { return(NotFound()); } var uploadFolderPath = Path.Combine(host.WebRootPath, "device"); if (!Directory.Exists(uploadFolderPath)) { Directory.CreateDirectory(uploadFolderPath); } var fileName = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); var filePath = Path.Combine(uploadFolderPath, fileName); using (var stream = new FileStream(filePath, FileMode.Create)) { file.CopyTo(stream); } var photo = new DevicesModel { FileName = fileName }; // subDepartment.Photos.Add(photo); device.FileName = photo.FileName; uow.Save(); var result = mapper.Map <DevicesModel, DevicesResource>(photo); return(Ok(result)); }
/// <summary> /// Udate existing Device in client model session /// </summary> /// <param name="model">Existing device instance to update</param> /// <returns>Returns true if updating was succesfull. Otherwise false.</returns> public bool UpdateDeviceToClientModelSession(DevicesModel model) { ClientFullModel fullModel = GetFullModelFromClientModel(); if (fullModel != null) { var record = fullModel.Naprave.Where(n => n.idNaprava == model.idNaprava).FirstOrDefault(); if (record != null) { int index = fullModel.Naprave.IndexOf(record); if (index != -1) { fullModel.Naprave[index] = model; } else { return(false); } } else { return(false); } AddValueToSession(Enums.ClientSession.ClientModel, fullModel); return(true); } return(false); }
public async Task GetDevices(IHttpContext context) { Authenticator.VerifyAuth(context); var devices = await Dispatcher.RunOnMainThread(() => DevicesModel.GetDevices()); await context.SendResponse(HttpStatusCode.OK, devices); }
private DevicesView CreateDevicesView() { IDevicesModel model = new DevicesModel(); IDevicesView view = new DevicesView(); IDevicesPresenter presenter = SimpleResolver.Instance.Get <IDevicesPresenter>( new object[] { model, view } ); view.ShowView(); return(view as DevicesView); }
public JsonResult GetAllDevices() { try { /*db.Configuration.ProxyCreationEnabled = false;*/ int length = int.Parse(Request.Query["length"]); int start = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(int.Parse(Request.Query["start"]) / length))) + 1; string searchValue = Request.Query["search[value]"]; string sortColumnName = Request.Query["columns[" + Request.Query["order[0][column]"] + "][name]"]; string sortDirection = Request.Query["order[0][dir]"]; /*int length = 10; * int start = 1; * string searchValue = ""; * string sortColumnName = "ID"; * string sortDirection = "asc";*/ DevicesPaging apg = new DevicesPaging(); apg.data = new List <DevicesModel>(); start = (start - 1) * length; List <Device> listDevice = _context.Devices.ToList <Device>(); apg.recordsTotal = listDevice.Count; //filter if (!string.IsNullOrEmpty(searchValue)) { listDevice = listDevice.Where(x => x.Name.ToLower().Contains(searchValue.ToLower())).ToList <Device>(); } apg.recordsFiltered = listDevice.Count; //paging listDevice = listDevice.Skip(start).Take(length).ToList <Device>(); foreach (var i in listDevice) { DevicesModel rm = new DevicesModel { Name = i.Name, NameShow = i.NameShow, BranchOrProtocol = i.BranchOrProtocol, Actions = "" }; apg.data.Add(rm); } apg.draw = int.Parse(Request.Query["draw"]); return(Json(apg)); /*return Json(apg, JsonRequestBehavior.AllowGet);*/ } catch (Exception ex) { return(null); } }
public async Task PostDevice(IHttpContext context, long referenceId, JObject body) { Authenticator.VerifyAuth(context); var response = await Dispatcher.RunOnMainThread(() => DevicesModel.UpdateDevice(referenceId, body)); if (response == null) { throw new NotFoundException("Device Not Found."); } await context.SendResponse(HttpStatusCode.OK, response); }
public async Task GetDevice(IHttpContext context, long referenceId) { Authenticator.VerifyAuth(context); var device = await Dispatcher.RunOnMainThread(() => DevicesModel.GetDevice(referenceId)); if (device == null) { throw new NotFoundException("Device not found."); } await context.SendResponse(HttpStatusCode.OK, device); }
/// <summary> /// Add new Device instance to client model session /// </summary> /// <param name="model">New device instance to add</param> /// <returns>Returns true if adding was succesfull. Otherwise false.</returns> public bool AddDeviceToClientModelSession(DevicesModel model) { ClientFullModel fullModel = GetFullModelFromClientModel(); if (fullModel != null) { fullModel.Naprave.Add(model); AddValueToSession(Enums.ClientSession.ClientModel, fullModel); return(true); } return(false); }
/// <summary> /// Delete Device instance from client model session and add new data to session. /// </summary> /// <param name="planID">Device ID</param> /// <param name="clientID">Client ID</param> /// <returns>Return true if delete is succesfull. Otherwise false.</returns> public bool DeleteDeviceFromClientModelSession(int deviceID, int clientID) { DevicesModel model = GetDeviceFromClientModelSession(deviceID, clientID); ClientFullModel tmp = GetFullModelFromClientModel(); if (model != null && tmp != null) { bool isDeleted = tmp.Naprave.Remove(model); AddValueToSession(Enums.ClientSession.ClientModel, tmp); return(isDeleted); } return(false); }
public void Action(DevicesModel model) { if (!model.Shot) { var sequncises = Regex.Match(model.ActivePattern.Name, @"\d+").Value; int pattern = int.Parse(sequncises); buffer[model.StartAddress + 4] = (byte)Math.Round((decimal)(2 + pattern * 2.55), 0); // shot buffer[model.StartAddress + 2] = 255; } else { buffer[model.StartAddress + 2] = 0; } }
public WebResponseContentModel <DevicesModel> SaveDeviceChanges(DevicesModel newData) { WebResponseContentModel <DevicesModel> model = new WebResponseContentModel <DevicesModel>(); try { model.Content = newData; model = PostWebRequestData <WebResponseContentModel <DevicesModel> >(WebServiceHelper.SaveDeviceChanges(), "post", model); } catch (Exception ex) { model.ValidationErrorAppSide = ConcatenateExceptionMessage(ex); } return(model); }
public async Task InitializeAsync() { try { await _userInterfaceService.ShowBusyIndicatorAsync(); Model = await _restService.GetAsync <DevicesModel>(new Uri("api/devicemanager/devices", UriKind.Relative)); var sortedModel = new DevicesModel(); BuildHierarchy(Model, sortedModel, Model.DeviceList.Where(d => d.ParentID == null).Select(d => d.ID).FirstOrDefault(), 0); Model = sortedModel; await _userInterfaceService.HideBusyIndicatorAsync(); } catch (Exception ex) { await _userInterfaceService.ShowFeedbackAsync(ex); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //ComboBoxKategorije.DataBind(); if (action == (int)Enums.UserAction.Edit || action == (int)Enums.UserAction.Delete) { if (deviceID > 0 && SessionHasValue(Enums.ClientSession.ClientModel)) { model = GetClientDataProviderInstance().GetDeviceFromClientModelSession(deviceID, clientID); FillForm(); } } else if (action == (int)Enums.UserAction.Add)//acion ADD { txtIdStranke.Text = clientID.ToString(); // ComboBoxKategorije.SelectedIndex = 0; } UserActionConfirmBtnUpdate(btnConfirmPopUp, action, true); } }
private void BuildHierarchy(DevicesModel model, DevicesModel sortedModel, string parentId, int level) { foreach (var device in model.DeviceList.Where(d => d.ParentID == parentId)) { device.Level = level; if (string.IsNullOrEmpty(device.Description)) { device.Description = device.ID; } if (String.IsNullOrEmpty(device.Class)) { device.Class = "Unknown"; } sortedModel.DeviceList.Add(device); var children = Model.DeviceList.Where(d => d.ParentID == device.ID); if (children.Count() > 0) { device.HasChildren = true; BuildHierarchy(Model, sortedModel, device.ID, level + 1); } } // for each device }
private bool AddOrEditEntityObject(bool add = false) { if (add) { model = new DevicesModel(); model.idNaprava = 0; model.idStranka = clientID; model.tsIDOsebe = PrincipalHelper.GetUserPrincipal().ID; model.ts = DateTime.Now; } else if (model == null && !add) { model = GetClientDataProviderInstance().GetDeviceFromClientModelSession(deviceID, clientID); } model.Koda = txtKoda.Text; model.Naziv = txtNaziv.Text; model.Opis = ASPxMemoOpis.Text; DevicesModel newModel = CheckModelValidation(GetDatabaseConnectionInstance().SaveDeviceChanges(model)); if (newModel != null)//If new record is added we need to refresh aspxgridview. We add new record to session model. { if (add) { return(GetClientDataProviderInstance().AddDeviceToClientModelSession(newModel)); } else { return(GetClientDataProviderInstance().UpdateDeviceToClientModelSession(newModel)); } } else { return(false); } }
private DevicesView CreateDevicesView() { IDevicesModel model = new DevicesModel(); IDevicesView view = new DevicesView(); IDevicesPresenter presenter = SimpleResolver.Instance.Get<IDevicesPresenter>( new object[] { model, view } ); view.ShowView(); return view as DevicesView; }
public void Action(DevicesModel model) { _comPortSender.Action(model); }
public AppViewModel() { // Create LoginInfoModel LoginInfoModel = new LoginInfoModel { ButtonLoginOrLogoutCommand = new RelayCommand <object>(new Action <object>(LoginOrLogoutCommand), new Predicate <object>(LoginOrLogoutCommandCanExecute)) }; // Create ConversationModel ConversationModel = new ConversationModel { ButtonRejectCommand = new RelayCommand <object>(new Action <object>(RejectCommand), new Predicate <object>(RejectCommandCanExecute)), ButtonHangUpCommand = new RelayCommand <object>(new Action <object>(HangUpCommand), new Predicate <object>(HangUpCommandCanExecute)), ButtonAnswerCommand = new RelayCommand <object>(new Action <object>(AnswerCommand), new Predicate <object>(AnswerCommandCanExecute)), ButtonCallCommand = new RelayCommand <object>(new Action <object>(CallCommand), new Predicate <object>(CallCommandCanExecute)), ButtonSelectDevicesCommand = new RelayCommand <object>(new Action <object>(SelectDevicesCommand), new Predicate <object>(SelectDevicesCommandCanExecute)), ButtonMuteUnmuteAudioCommand = new RelayCommand <object>(new Action <object>(MuteUnmuteAudioCommand), new Predicate <object>(MuteUnmuteAudioCommandCanExecute)), ButtonMuteUnmuteVideoCommand = new RelayCommand <object>(new Action <object>(MuteUnmuteVideoCommand), new Predicate <object>(MuteUnmuteVideoCommandCanExecute)), ButtonMuteUnmuteSharingCommand = new RelayCommand <object>(new Action <object>(MuteUnmuteSharingCommand), new Predicate <object>(MuteUnmuteSharingCommandCanExecute)), ButtonAddAudioCommand = new RelayCommand <object>(new Action <object>(AddAudioCommand), new Predicate <object>(AddAudioCommandCanExecute)), ButtonAddRemoveVideoCommand = new RelayCommand <object>(new Action <object>(AddRemoveVideoCommand), new Predicate <object>(AddRemoveVideoCommandCanExecute)), ButtonAddRemoveSharingCommand = new RelayCommand <object>(new Action <object>(AddRemoveSharingCommand), new Predicate <object>(AddRemoveSharingCommandCanExecute)), }; // Create LayoutModel LayoutModel = new LayoutModel(); LayoutModel.LocalVideo.ButtonSetCommand = new RelayCommand <object>(new Action <object>(SetLocalVideoCommand)); LayoutModel.LocalVideo.ButtonPictureInPictureSwitchCommand = new RelayCommand <object>(new Action <object>(SwitchPictureInPictureModeOnLocalVideoCommand)); LayoutModel.RemoteVideo.ButtonSetCommand = new RelayCommand <object>(new Action <object>(SetRemoteVideoCommand)); LayoutModel.RemoteVideo.ButtonPictureInPictureSwitchCommand = new RelayCommand <object>(new Action <object>(SwitchPictureInPictureModeOnRemoteVideoCommand)); LayoutModel.Sharing.ButtonSetCommand = new RelayCommand <object>(new Action <object>(SetSharingCommand)); LayoutModel.Sharing.ButtonPictureInPictureSwitchCommand = new RelayCommand <object>(new Action <object>(SwitchPictureInPictureModeOnSharingCommand)); LayoutModel.PropertyChanged += LayoutModel_PropertyChanged; // Create DevicesModel DevicesModel = new DevicesModel(); // Create UsersModel UsersModel = new UsersModel(); // Create LanguagesModel LanguagesModel = new LanguagesModel() { ButtonSetCommand = new RelayCommand <object>(new Action <object>(SetLanguageCommand)) }; // Get Rainbow Languages service rbLanguages = Rainbow.Common.Languages.Instance; SetLanguagesList(rbLanguages.GetLanguagesIdList()); // Create ConstraintModel ConstraintModel = new ConstraintModel() { MaxFrameRateValue = "10", WidthValue = "640", HeightValue = "480", VideoConstraint = true, ButtonSetConstraintCommand = new RelayCommand <object>(new Action <object>(SetConstraintCommand), new Predicate <object>(SetConstraintCommandCanExecute)) }; }
public void Add(DevicesModel devices) { context.Devices.Add(devices); }