Пример #1
0
        /// <summary>
        /// Get list of Device's commands.
        /// </summary>
        /// <param name="pageNumber">Page Number.</param>
        /// <param name="pageSize">Items count per page.</param>
        /// <param name="loadParents">Enable or Disable loading the Parents objects.</param>
        /// <param name="loadChilds">Enable or Disable loading the Childs objects.</param>
        /// <param name="searchFor">Search text as per the 'Title' field.</param>
        /// <param name="locationID">Filter by Location ID. You can keep it null or empty to ignore this filter.</param>
        /// <param name="DeviceID">Filter by Device ID. You can keep it null or empty to ignore this filter.</param>
        /// <returns></returns>
        public APIDeviceCommandResponseModels.GetDeviceCommandsList GetDeviceCommandsList(string searchFor, long locationID, long DeviceID, bool loadDevice, int pageNumber, int pageSize)
        {
            APIDeviceCommandResponseModels.GetDeviceCommandsList result = new APIDeviceCommandResponseModels.GetDeviceCommandsList();

            IPagedList <DeviceCommand> cmdsPL = uow_Repositories.repoDeviceCommands.GetPagedList(searchFor, DeviceID, locationID, pageNumber, pageSize);
            List <DeviceCommand>       cmds   = cmdsPL.ToList();

            List <APIDeviceCommand> apiCmds = new List <APIDeviceCommand>();

            foreach (DeviceCommand cmd in cmds)
            {
                APIDeviceCommand apiCmd = TypesMapper.APIDeviceCommandAdapter.fromDeviceCommand(cmd, loadDevice);
                apiCmds.Add(apiCmd);
            }
            result.DeviceCommands = apiCmds;


            PagingInfoResponseModel pagingInfo = new PagingInfoResponseModel();

            pagingInfo.CurrentPage  = cmdsPL.PageNumber;
            pagingInfo.ItemsPerPage = cmdsPL.PageSize;
            pagingInfo.ItemsCount   = cmdsPL.TotalItemCount;
            pagingInfo.PagesCount   = cmdsPL.PageCount;
            result.PagingInfo       = pagingInfo;
            return(result);
        }
Пример #2
0
        public async Task <APIDeviceCommandResponseModels.GetDeviceCommandsList> GetDevicesListAsync(APIDeviceCommandRequestModels.GetDeviceCommandsList rm)
        {
            string strResult = await HttpPost("/api/DeviceCommands/GetDeviceCommandsList", JsonConvert.SerializeObject(rm));

            APIDeviceCommandResponseModels.GetDeviceCommandsList result = (APIDeviceCommandResponseModels.GetDeviceCommandsList)JsonConvert.DeserializeObject(strResult, typeof(APIDeviceCommandResponseModels.GetDeviceCommandsList));
            return(result);
        }
Пример #3
0
        private async void btnGetDeviceCommands_ClickAsync(object sender, EventArgs e)
        {
            Initialize();

            APIDeviceCommandRequestModels.GetDeviceCommandsList model = new APIDeviceCommandRequestModels.GetDeviceCommandsList();
            model.LoadDevice = true;

            model.PageNumber = 1; model.PageSize = 1; model.Token = Guid.Parse(txtToken.Text);

            APIDeviceCommandResponseModels.GetDeviceCommandsList cmds = await uow.DeviceCommandsService.GetDevicesListAsync(model);

            gv1.DataSource = cmds.DeviceCommands;
        }