Beispiel #1
0
        public async Task <ActionResult <DeviceInfo> > GetDeviceInfo([FromQuery, Required] string id)
        {
            var deviceInfo = await _deviceManager.GetDevice(id).ConfigureAwait(false);

            if (deviceInfo == null)
            {
                return(NotFound());
            }

            return(deviceInfo);
        }
        public ActionResult <DeviceInfo> GetDeviceInfo([FromQuery, Required] string?id)
        {
            var deviceInfo = _deviceManager.GetDevice(id);

            if (deviceInfo == null)
            {
                return(NotFound());
            }

            return(deviceInfo);
        }
Beispiel #3
0
        async Task AddDevice(NodeDevice nodeDevice)
        {
            var nodeId = nodeDevice.Classes.FirstOrDefault().Value?.FirstOrDefault().Value?.NodeId ?? -1;

            if (nodeId <= 0)
            {
                return;
            }
            var oldNodeDevice = await NodeDatabase.Shared.GetDevice(nodeId);

            Device device = null;

            if (!string.IsNullOrWhiteSpace(oldNodeDevice?.Id))
            {
                device = await _deviceManager.GetDevice(oldNodeDevice.Id);
            }
            if (device == null)
            {
                var oldDevices = await _deviceManager.GetAllDevices();

                device = oldDevices.FirstOrDefault(x => x.Service == this.ServiceIdentifier && x.ServiceDeviceId == nodeId.ToString()) ?? new Device {
                    Service = ServiceIdentifier, Id = oldNodeDevice?.Id
                };
            }
            if (!device.Update(nodeDevice))
            {
                return;
            }
            device.Discoverable = !string.IsNullOrWhiteSpace(device.Name);
            await _deviceManager.AddDevice(device);

            nodeDevice.Id = device.Id;
            await NodeDatabase.Shared.InsertDevice(nodeDevice);
        }
Beispiel #4
0
 public override void Initialize(Context context)
 {
     this.context       = context;
     deviceManager      = context.DeviceManager;
     devices            = deviceManager.GetDevice();
     progressPanel.Left = (Width - progressPanel.Width) / 2;
     progressPanel.Top  = (Height - progressPanel.Height) / 2;
 }
Beispiel #5
0
 public override void Initialize(Context context)
 {
     this.context = context;
     deviceManager = context.DeviceManager;
     devices = deviceManager.GetDevice();
     progressPanel.Left = (Width - progressPanel.Width) / 2;
     progressPanel.Top = (Height - progressPanel.Height) / 2;
 }
Beispiel #6
0
        /// <summary>
        /// check if a file exists
        /// </summary>
        /// <param name="path">pathname to check</param>
        /// <returns>true if the file exists</returns>
        public bool FileExists(string path)
        {
            var pathInfo = MtpPath.GetPathInfo(path);

            if (!pathInfo.IsMtpPath)
            {
                return(_fileUtilities.FileExists(path));
            }

            var device = _deviceManager.GetDevice(pathInfo.DeviceName);

            if (device == null)
            {
                return(false);
            }

            return(device.GetObjectFromPath(pathInfo.RelativePathOnDevice) != null);
        }
 /// <summary>
 /// 查询设备信息
 /// </summary>
 /// <param name="where"></param>
 /// <returns></returns>
 public DataTable GetDevice(string where)
 {
     try
     {
         return(Bll.Common.ChangColName(dal.GetDevice(where)));
     }
     catch (Exception ex)
     {
         ILog.WriteErrorLog(ex);
         return(null);
     }
 }
        /// <summary>
        /// create an abstract directory object
        /// </summary>
        /// <param name="path">full path to the directory</param>
        /// <returns>an abstrcat object</returns>
        public IDirectoryInfo GetDirectoryInfo(string path)
        {
            var pathInfo = MtpPath.GetPathInfo(path);

            var device = _deviceManager.GetDevice(pathInfo.DeviceName);

            if (device == null)
            {
                throw new DirectoryNotFoundException(String.Format("Device [{0}] not found", pathInfo.DeviceName));
            }

            return(new DirectoryInfo(device, pathInfo.RelativePathOnDevice));
        }
Beispiel #9
0
    public IActionResult Edit()
    {
        var deviceId = HttpContext.Request.Query["device-id"];
        var device   = _deviceManager.GetDevice(Guid.Parse(deviceId));

        if (device == null)
        {
            throw new ArgumentException("device with the given id does not exist");
        }

        return(View(new DeviceEditViewModel(
                        device: device
                        )));
    }
        /// <summary>
        /// create an abstract file info object
        /// </summary>
        /// <param name="path">full path to the file</param>
        /// <returns>the file info</returns>
        public IFileInfo GetFileInfo(string path)
        {
            if (MtpPath.IsMtpPath(path))
            {
                var pathInfo = MtpPath.GetPathInfo(path);

                var device = _deviceManager.GetDevice(pathInfo.DeviceName);

                if (device == null)
                {
                    throw new FileNotFoundException(String.Format("Device [{0}] not found", pathInfo.DeviceName));
                }

                return(new FileInfo(device, pathInfo.RelativePathOnDevice));
            }

            return(new SystemFileInfo(new System.IO.FileInfo(path)));
        }
        /// <summary>
        /// create an abstract drive info object
        /// </summary>
        /// <param name="path">name of the drive</param>
        /// <returns>an abstrcat object</returns>
        public IDriveInfo GetDriveInfoForPath(string path)
        {
            var pathInfo = MtpPath.GetPathInfo(path);

            var device = _deviceManager.GetDevice(pathInfo.DeviceName);

            if (device == null)
            {
                throw new DriveNotFoundException(String.Format("Device [{0}] not found", pathInfo.DeviceName));
            }

            var storageObject = device.GetRootStorageObjectFromPath(pathInfo.RelativePathOnDevice);

            if (storageObject == null)
            {
                throw new DriveNotFoundException(
                          String.Format(
                              "No storage object found: Device [{0}], path [{1}]",
                              pathInfo.DeviceName,
                              pathInfo.RelativePathOnDevice));
            }

            return(new DriveInfo(device, storageObject));
        }
Beispiel #12
0
 public object Get(GetDeviceInfo request)
 {
     return(_deviceManager.GetDevice(request.Id));
 }
Beispiel #13
0
 public object Get(GetDeviceInfo request)
 {
     return(ToOptimizedResult(_deviceManager.GetDevice(request.Id)));
 }