public Entity.HardwareKitDTO GetHardwareKitDetails(Entity.SearchRequest request)
        {
            Entity.SearchResult <List <Entity.HardwareKit> > result = new Entity.SearchResult <List <Entity.HardwareKit> >();
            var hardwareKitDto = new Entity.HardwareKitDTO();

            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, request.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("guid", request.Guid, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
                    System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[KitDevice_List]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Items = DataUtils.DataReaderToList <Entity.HardwareKit>(dbDataReader, null);
                    result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
                    HardwareKitDTO hardwareKitDTO = new HardwareKitDTO();

                    if (result.Count >= 0)
                    {
                        var hardwareKit = result.Items.FirstOrDefault();
                        hardwareKitDto = (from c in result.Items
                                          group c by new
                        {
                            c.KitGuid,
                            c.KitCode,
                            c.KitType,
                        } into gcs
                                          select new HardwareKitDTO()
                        {
                            Guid = hardwareKit.Guid,
                            CompanyGuid = hardwareKit.CompanyGuid,
                            KitTypeGuid = result.Items.Count > 0 ? result.Items[0].TemplateGuid : hardwareKit.KitTypeGuid,
                            KitCode = gcs.Key.KitCode,
                            KitDevices = gcs.Select(x => new KitDeviceDTO()
                            {
                                Name = x.Name,
                                IsProvisioned = x.IsProvisioned,
                                Note = x.Note,
                                Tag = x.TagGuid,
                                KitGuid = x.KitGuid,
                                UniqueId = x.UniqueId,
                                ParentUniqueId = x.ParentUniqueId,
                            }).ToList()
                        }).FirstOrDefault();
                    }
                }
                _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }

            return(hardwareKitDto);
        }
Beispiel #2
0
        public Entity.HardwareKitDTO Get(Guid id)
        {
            //Entity.HardwareKit result = new Entity.HardwareKit();
            //try
            //{
            //    result = _hardwareKitRepository.FindBy(kt => kt.Guid.Equals(id)).Select(p => Mapper.Configuration.Mapper.Map<Entity.HardwareKit>(p)).FirstOrDefault();
            //    if (result != null)
            //    {
            //        result.KitDevices = _kitDeviceRepository.FindBy(kt => kt.KitGuid.Equals(id)).Select(p => Mapper.Configuration.Mapper.Map<Entity.KitDevice>(p)).ToList();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            //}
            //return result;

            var hardwareKitDTO = new Entity.HardwareKitDTO();

            try
            {
                hardwareKitDTO = _hardwareKitRepository.GetHardwareKitDetails(new Entity.SearchRequest
                {
                    Guid         = id.ToString().ToUpper(),
                    Version      = component.helper.SolutionConfiguration.Version,
                    CompanyId    = component.helper.SolutionConfiguration.CompanyId.ToString().ToUpper(),
                    InvokingUser = component.helper.SolutionConfiguration.CurrentUserId,
                    PageNumber   = 1,
                    PageSize     = 10
                });
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(hardwareKitDTO);
        }