Exemplo n.º 1
0
        public async Task <ICollection <Database.Entities.Device> > GetDevices(DeviceParams deviceParams = null)
        {
            var deviceQuery = _context.Devices
                              .Include(x => x.Component)
                              .Include(x => x.Kind)
                              .Include(x => x.Category)
                              .Include(x => x.Address)
                              .AsQueryable();

            if (deviceParams is null)
            {
                return(await deviceQuery.ToListAsync());
            }

            if (deviceParams.KindId.HasValueGreaterThan(0))
            {
                deviceQuery = deviceQuery.Where(x => x.KindId == deviceParams.KindId);
            }

            if (deviceParams.CategoryId.HasValueGreaterThan(0))
            {
                deviceQuery = deviceQuery.Where(x => x.CategoryId == deviceParams.CategoryId);
            }


            return(await deviceQuery.OrderBy(x => x.Name).ToListAsync());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetDevicesByCriteria([FromQuery] DeviceParams deviceParams)
        {
            var devicesFromRepo = await _repo.GetDevicesByCriteria(deviceParams);

            // var devicesToReturn = _mapper.Map<IEnumerable<DeviceToReturnDto>>(devicesFromRepo.Devices);

            return(Ok(devicesFromRepo));
        }
Exemplo n.º 3
0
        protected virtual void ApplyDeviceParams()
        {
            if (updating)
            {
                return;
            }

            DeviceParams deviceParams = null;

            if (device != null)
            {
                deviceParams = device.Parameters;
                device.Dispose();
            }
            else
            {
                deviceParams = new DeviceParams();
            }

            if (newDeviceType == null)
            {
                newDeviceType = GraphicsDeviceType;
            }

            switch (newDeviceType)
            {
            case DeviceType.Gdi:
                device = new GdiGraphicsDevice(graphics, GetCurrentViewport());
                break;

            case DeviceType.Direct3D:
                Type xnaDeviceType = GetXnaGraphicsDeviceType();
                if (xnaDeviceType == null)
                {
                    goto case DeviceType.Gdi;
                }
                device = (GraphicsDevice)Activator.CreateInstance(xnaDeviceType, this.Handle, GetCurrentViewport());
                break;

            default:
                device = null;
                break;
            }

            if (device != null)
            {
                deviceParams.Viewport = null;
                device.Parameters     = deviceParams;
            }

            Scene original = scene;

            RecreateScene(device, original.Camera, original.Projection);

            newDeviceType = null;

            Invalidate();
        }
Exemplo n.º 4
0
 public DevicesWithFilterForCountSpec(DeviceParams deviceParams)
     : base(x =>
            (string.IsNullOrEmpty(deviceParams.Search) || x.Name.ToLower()
             .Contains(deviceParams.Search)) &&
            (!deviceParams.CategoryId.HasValue || x.CategoryId == deviceParams.CategoryId) &&
            (!deviceParams.MakerId.HasValue || x.MakerId == deviceParams.MakerId)
            )
 {
 }
Exemplo n.º 5
0
        public async Task <string> RegisterDevice(string url)
        {
            var device = new DeviceParams
            {
                Type  = "WP",
                Token = url
            };
            var result = await GetResponseAsync <DeviceParams, GetDeviceIdResult>("Devices", device);

            return(result.Id);
        }
Exemplo n.º 6
0
        private void InitializeGameFramework()
        {
            parm = new DeviceParams();

            DeviceCaps _device_caps = AGT_GameFramework.GetDeviceCapabilities().DeviceCaps;

            parm.ClrFlags      = ClearFlags.Target | ClearFlags.ZBuffer;
            parm.ZDepth        = 1.0f;
            parm.Stencil       = 0;
            parm.TargetControl = this;

            parm.OnResize = new DeviceResizeHandler(OnResize);

            parm.PresentationParameters            = new PresentParameters();
            parm.PresentationParameters.Windowed   = true;
            parm.PresentationParameters.SwapEffect = SwapEffect.Discard;

            if (parm.PresentationParameters.Windowed)
            {
                parm.PresentationParameters.PresentationInterval   = PresentInterval.Default;
                parm.PresentationParameters.EnableAutoDepthStencil = true;
                parm.PresentationParameters.AutoDepthStencilFormat = DepthFormat.D16;
            }
            else
            {
                parm.PresentationParameters.PresentationInterval   = PresentInterval.Immediate;
                parm.PresentationParameters.EnableAutoDepthStencil = false;
                parm.PresentationParameters.BackBufferCount        = 1;
                parm.PresentationParameters.BackBufferHeight       = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Height;
                parm.PresentationParameters.BackBufferWidth        = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Width;
                parm.PresentationParameters.BackBufferFormat       = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Format;
            }

            if (_device_caps.SupportsHardwareTransformAndLight)
            {
                parm.Flags = CreateFlags.HardwareVertexProcessing;
                if (_device_caps.SupportsPureDevice)
                {
                    parm.Flags |= CreateFlags.PureDevice;
                    parm.Flags |= CreateFlags.MultiThreaded;
                }
            }
            else
            {
                parm.Flags  = CreateFlags.SoftwareVertexProcessing;
                parm.Flags |= CreateFlags.MultiThreaded;
            }

            gf = new AGT_GameFramework(parm);
        }
Exemplo n.º 7
0
        public async Task<IActionResult> GetDevices([FromQuery] DeviceParams deviceParams)
        {
            try
            {
                var devices = await _repo.GetDevices(deviceParams);

                var devicesToReturn = _mapper.Map<IEnumerable<DeviceDto>>(devices);

                return Ok(devicesToReturn);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);

                return StatusCode((int)HttpStatusCode.InternalServerError, "Error!");
            }
        }
Exemplo n.º 8
0
        public Device(string DeviceName, DeviceParams Params = null)
        {
            var ParamsJson      = (Params == null) ? "{}" : JSONUtility.stringify(Params);
            var DeviceNameAscii = System.Text.ASCIIEncoding.ASCII.GetBytes(DeviceName + "\0");
            var ParamsJsonAscii = System.Text.ASCIIEncoding.ASCII.GetBytes(ParamsJson + "\0");
            var ErrorBuffer     = new byte[100];

            Instance = PopCameraDevice_CreateCameraDevice(DeviceNameAscii, ParamsJsonAscii, ErrorBuffer, ErrorBuffer.Length);
            var Error = GetString(ErrorBuffer);

            if (Instance.Value <= 0)
            {
                throw new System.Exception("Failed to create Camera device with name " + DeviceName + "; " + Error);
            }
            if (!String.IsNullOrEmpty(Error))
            {
                Debug.LogWarning("Created PopCameraDevice(" + Instance.Value + ") but error was not empty (length = " + Error.Length + ") " + Error);
            }
        }
Exemplo n.º 9
0
        public DeviceParams GetDeviceParams(int idx)
        {
            var nadp = new NativeMethods.NativeAudioDeviceParams();
            int hr   = NativeMethods.WWSASGetDeviceParams(mInstanceId, idx, ref nadp);

            if (hr < 0)
            {
                throw new IndexOutOfRangeException();
            }

            var adp = new DeviceParams();

            adp.id                       = nadp.id;
            adp.defaultDevice            = nadp.isDefaultDevice != 0;
            adp.name                     = nadp.name;
            adp.mute                     = nadp.mute != 0;
            adp.peak                     = nadp.peak;
            adp.masterVolumeLevelDecibel = nadp.masterVolumeLevel;

            return(adp);
        }
Exemplo n.º 10
0
        public async Task <ActionResult <Pagination <DeviceListToReturnDTO> > > GetDevices([FromQuery] DeviceParams deviceParams)
        {
            // record count with filters applied
            var countSpec = new DevicesWithFilterForCountSpec(deviceParams);

            var totalDevices = await _unitOfWork.Repository <Device>().CountAsync(countSpec);

            var devices = _unitOfWork.Repository <Device>()
                          .Find(new DevicesWithCategoryAndMakerAndEmployeeDevices(deviceParams))
                          .ToList();

            var data = _mapper.Map <IEnumerable <DeviceListToReturnDTO> >(devices);

            return(Ok(new Pagination <DeviceListToReturnDTO>(
                          deviceParams.Page,
                          deviceParams.RecordsPerPage,
                          totalDevices,
                          data)
                      ));
        }
Exemplo n.º 11
0
        //vraca uredjaje u zavisnosti od vrijednosti parametara
        public async Task <DeviceListDto> GetDevicesByCriteria(DeviceParams deviceParams)
        {
            var devices = _context.Devices
                          .Include(d => d.DevicePropertyValues)
                          .Include(d => d.DeviceType).ThenInclude(d => d.DeviceTypeProperty)
                          .Include(d => d.DeviceType).ThenInclude(d => d.ParentDeviceType).ThenInclude(d => d.DeviceTypeProperty)
                          .AsQueryable();

            //ako postoji Name parametar, vraca uredjaje koji sadrze zadato ime
            if (!string.IsNullOrEmpty(deviceParams.Name))
            {
                var searchName = deviceParams.Name.Trim().ToLowerInvariant();
                devices = devices.Where(d => d.Name.Contains(searchName));
            }

            //ako postoji Type parametar, vraca uredjaje odgovarajuceg tipa
            if (!string.IsNullOrEmpty(deviceParams.Type))
            {
                var searchType = deviceParams.Type.Trim().ToLowerInvariant();
                devices = devices.Where(d => d.DeviceType.Name.Contains(searchType));

                //ukoliko postoje Type i PropertyValue parametri
                //vraca uredjaje tog tipa sa odgovarajucim vrijednostima osobina
                if (!string.IsNullOrEmpty(deviceParams.PropertyValue))
                {
                    var searchPropertyValue = deviceParams.PropertyValue.Trim().ToLowerInvariant();
                    devices = devices.Where(d => d.DevicePropertyValues
                                            .Any(p => p.Value.Contains(searchPropertyValue)));
                }
            }

            //ako postoji compare operator (<,>,<=,>=) i cijena, vraca odgovarajuce uredjaje

            if (!string.IsNullOrEmpty(deviceParams.CompareOperator) && deviceParams.Price != null)
            {
                switch (deviceParams.CompareOperator)
                {
                case "<":
                    devices = devices.Where(d => d.Price < deviceParams.Price);
                    break;

                case ">":
                    devices = devices.Where(d => d.Price > deviceParams.Price);
                    break;

                case ">=":
                    devices = devices.Where(d => d.Price >= deviceParams.Price);
                    break;

                case "<=":
                    devices = devices.Where(d => d.Price <= deviceParams.Price);
                    break;

                case "=":
                    devices = devices.Where(d => d.Price == deviceParams.Price);
                    break;

                default:
                    devices = devices.OrderByDescending(d => d.Price);
                    break;
                }
            }

            //izvrsava paging na osnovu zadatih vriijednosti parametara
            var pagedDevices = await devices
                               .Skip(deviceParams.PageSize *(deviceParams.PageNumber - 1))
                               .Take(deviceParams.PageSize)
                               .ToListAsync();

            var devicesMapped = _mapper.Map <IEnumerable <DeviceToReturnDto> >(pagedDevices);

            var objectToReturn = new DeviceListDto(devicesMapped, devices.Count());

            return(objectToReturn);
        }
Exemplo n.º 12
0
        public DevicesWithCategoryAndMakerAndEmployeeDevices(DeviceParams deviceParams)
            : base(x =>
                   (string.IsNullOrEmpty(deviceParams.Search) ||
                    x.Name.ToLower().Contains(deviceParams.Search) ||
                    x.ProductId.ToLower().Contains(deviceParams.Search) ||
                    x.Id.ToString().Contains(deviceParams.Search)
                   ) &&
                   (!deviceParams.CategoryId.HasValue || x.CategoryId == deviceParams.CategoryId) &&
                   (!deviceParams.MakerId.HasValue || x.MakerId == deviceParams.MakerId)
                   )
        {
            AddInclude(q => q.Include(d => d.Category));
            AddInclude(q => q.Include(d => d.Maker));
            AddInclude(q => q.Include(d => d.EmployeeDevice).ThenInclude(d => d.Employee));

            if (!string.IsNullOrEmpty(deviceParams.Sort))
            {
                switch (deviceParams.Sort)
                {
                // productId
                case "productIdAsc":
                    ApplyOrderBy(d => d.ProductId);
                    break;

                case "productIdDesc":
                    ApplyOrderByDescending(d => d.ProductId);
                    break;

                // category
                case "categoryAsc":
                    ApplyOrderBy(d => d.Category.Name);
                    break;

                case "categoryDesc":
                    ApplyOrderByDescending(d => d.Category.Name);
                    break;

                // makers
                case "makerAsc":
                    ApplyOrderBy(d => d.Maker.Name);
                    break;

                case "makerDesc":
                    ApplyOrderByDescending(d => d.Maker.Name);
                    break;

                // employees
                case "employeesAssignedAsc":
                    ApplyOrderBy(d => d.EmployeeDevice.Count);
                    break;

                case "employeesAssignedDesc":
                    ApplyOrderByDescending(d => d.EmployeeDevice.Count);
                    break;

                // purchasedDate
                case "purchasedAsc":
                    ApplyOrderBy(d => d.Purchased);
                    break;

                case "purchasedDesc":
                    ApplyOrderByDescending(d => d.Purchased);
                    break;

                // value
                case "valueAsc":
                    ApplyOrderBy(d => d.Value);
                    break;

                case "valueDesc":
                    ApplyOrderByDescending(d => d.Value);
                    break;

                // Name
                case "nameAsc":
                    ApplyOrderBy(d => d.Name);
                    break;

                case "nameDesc":
                    ApplyOrderByDescending(d => d.Name);
                    break;

                // Id (PK)
                case "idAsc":
                    ApplyOrderBy(d => d.Id);
                    break;

                case "idDesc":
                    ApplyOrderByDescending(d => d.Id);
                    break;

                default:
                    ApplyOrderByDescending(d => d.Id);
                    break;
                }
            }
            else // default sort
            {
                ApplyOrderByDescending(d => d.Id);
            }

            var skip = (deviceParams.Page - 1) * deviceParams.RecordsPerPage;

            ApplyPaging(skip, deviceParams.RecordsPerPage);
        }
        public async Task <ActionResult <IEnumerable <EmployeeForReturnDTO> > > GetEmployees([FromQuery] DeviceParams pagination)
        {
            var entityCount = await _unitOfWork.Repository <Employee>().CountAsync(d => d.Id != 0);

            await HttpContext.InsertPaginationParametersInResponse(entityCount, pagination.RecordsPerPage);

            var employees = _unitOfWork.Repository <Employee>()
                            .Find(new EmployeesSpec((pagination.Page - 1) * pagination.RecordsPerPage, pagination.RecordsPerPage))
                            .ToList();

            return(Ok(_mapper
                      .Map <IEnumerable <EmployeeForReturnDTO> >(employees)));
        }