public ActionStatus VerifyHardwareKit(KitVerifyRequest request, bool isEdit = false) { var response = new ActionStatus(true); var result = new List <BulkUploadResponse>(); try { logger.InfoLog(Constants.ACTION_ENTRY, "HardwareKitRepository.VerifyHardwareKit"); var xmlData = string.Empty; using (var stringwriter = new System.IO.StringWriter()) { var serializer = new XmlSerializer(request.GetType()); serializer.Serialize(stringwriter, request); xmlData = stringwriter.ToString(); } using (var sqlDataAccess = new SqlDataAccess(ConnectionString)) { List <System.Data.Common.DbParameter> parameters = new List <System.Data.Common.DbParameter>(); parameters.Add(sqlDataAccess.CreateParameter("data", xmlData.ToString(), DbType.Xml, ParameterDirection.Input)); parameters.Add(sqlDataAccess.CreateParameter("isEdit", (isEdit == false ? 0 : 1), DbType.Boolean, ParameterDirection.Input)); parameters.Add(sqlDataAccess.CreateParameter("invokinguser", component.helper.SolutionConfiguration.CurrentUserId, DbType.Guid, ParameterDirection.Input)); parameters.Add(sqlDataAccess.CreateParameter("version", component.helper.SolutionConfiguration.Version, DbType.String, ParameterDirection.Input)); System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[HardwareKit_Validate]", CommandType.StoredProcedure, null), parameters.ToArray()); result = DataUtils.DataReaderToList <Entity.BulkUploadResponse>(dbDataReader, null); response.Data = result; var errorResult = result.Where(x => !string.IsNullOrEmpty(x.hardwareKitError)); var isValid = errorResult.Count(); if (isValid > 0) { response.Success = false; response.Message = errorResult.FirstOrDefault().hardwareKitError; //foreach (var error in errorResult) //{ // response.Message += error.hardwareKitError + ". "; //} } else { response.Success = true; } } logger.InfoLog(Constants.ACTION_EXIT, "HardwareKitRepository.VerifyHardwareKit"); } catch (Exception ex) { response.Success = false; response.Message = ex.Message.ToString(); logger.ErrorLog(Constants.ACTION_EXCEPTION, ex); } return(response); }
public ActionStatus VerifyHardwareKit(KitVerifyRequest request, bool isEdit = false) { var response = new ActionStatus(true); var result = new List <BulkUploadResponse>(); try { _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name); var xmlData = string.Empty; using (var stringwriter = new System.IO.StringWriter()) { var serializer = new XmlSerializer(request.GetType()); serializer.Serialize(stringwriter, request); xmlData = stringwriter.ToString(); } using (var sqlDataAccess = new SqlDataAccess(ConnectionString)) { List <System.Data.Common.DbParameter> parameters = new List <System.Data.Common.DbParameter>(); parameters.Add(sqlDataAccess.CreateParameter("data", xmlData, DbType.Xml, ParameterDirection.Input)); parameters.Add(sqlDataAccess.CreateParameter("isEdit", (isEdit == false ? 0 : 1), DbType.Boolean, ParameterDirection.Input)); parameters.Add(sqlDataAccess.CreateParameter("invokinguser", component.helper.SolutionConfiguration.CurrentUserId, DbType.Guid, ParameterDirection.Input)); parameters.Add(sqlDataAccess.CreateParameter("version", component.helper.SolutionConfiguration.Version, DbType.String, ParameterDirection.Input)); System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[KitDevice_Validate]", CommandType.StoredProcedure, null), parameters.ToArray()); result = DataUtils.DataReaderToList <Entity.BulkUploadResponse>(dbDataReader, null); response.Data = result; var isValid = result.Where(x => !string.IsNullOrEmpty(x.kitError) || !string.IsNullOrEmpty(x.deviceError)).Count(); if (isValid > 0) { response.Success = false; } else { response.Success = true; } } _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name); } catch (Exception ex) { response.Success = false; response.Message = ex.Message.ToString(); _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name); } return(response); }