Exemple #1
0
        public Entity.BaseResponse <List <Entity.BulkUploadResponse> > UploadKit(Entity.KitVerifyRequest request)
        {
            Entity.BaseResponse <List <Entity.BulkUploadResponse> > response = new Entity.BaseResponse <List <Entity.BulkUploadResponse> >();
            Entity.ActionStatus result = new Entity.ActionStatus();
            try
            {
                request.HardwareKits = request.HardwareKits.Where(t => !string.IsNullOrEmpty(t.KitCode.Trim()) && !string.IsNullOrEmpty(t.UniqueId.Trim()) && !string.IsNullOrEmpty(t.Name.Trim())).ToList();
                request.HardwareKits = request.HardwareKits.Where(t => Regex.IsMatch(t.KitCode.Trim(), SpecialCharRegex) && Regex.IsMatch(t.UniqueId.Trim(), UniqueIDSpecialCharRegex)).ToList();
                result = _service.UploadKit(request);
                if (result.Success)
                {
                    response.IsSuccess = true;
                }
                else
                {
                    response.IsSuccess = false;
                    response.Message   = result.Message;
                }

                response.Data = result.Data;
            }
            catch (Exception ex)
            {
                base.LogException(ex);
                return(new Entity.BaseResponse <List <Entity.BulkUploadResponse> >(false, ex.Message));
            }
            return(response);
        }
        public Entity.ActionStatus UploadKit(Entity.KitVerifyRequest request)
        {
            var actionStatus = new Entity.ActionStatus();

            try
            {
                var verifyResult = _hardwareKitRepository.VerifyHardwareKit(request, false);

                if (verifyResult.Success)
                {
                    actionStatus = _hardwareKitRepository.SaveHardwareKit(request, false);
                }
                else
                {
                    actionStatus.Data    = verifyResult.Data;
                    actionStatus.Success = verifyResult.Success;
                    actionStatus.Message = verifyResult.Message;
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                return(new Entity.ActionStatus
                {
                    Success = false,
                    Message = ex.Message
                });
            }
            return(actionStatus);
        }
        public Entity.BaseResponse <bool> UploadKit(Entity.KitVerifyRequest request)
        {
            Entity.BaseResponse <bool> response = new Entity.BaseResponse <bool>(true);
            Entity.ActionStatus        result   = new Entity.ActionStatus();

            try
            {
                result = _service.UploadKit(request);

                if (result.Success)
                {
                    response.IsSuccess = true;
                    response.Message   = "";
                    response.Data      = true;
                }
                else
                {
                    response.IsSuccess = false;
                    response.Message   = result.Message;
                    response.Data      = false;
                }
            }
            catch (Exception ex)
            {
                return(new Entity.BaseResponse <bool>(false, ex.Message));
            }

            return(response);
        }
        public Entity.BaseResponse <List <Entity.BulkUploadResponse> > VerifyKit(Entity.KitVerifyRequest request)
        {
            Entity.BaseResponse <List <Entity.BulkUploadResponse> > response = new Entity.BaseResponse <List <Entity.BulkUploadResponse> >(true);
            try
            {
                List <Entity.KitVerifyResponse> lstTestData = new List <Entity.KitVerifyResponse>();
                //TODO

                var result = _service.VerifyKit(request);

                if (result.Success)
                {
                    response.IsSuccess = true;
                }
                else
                {
                    response.IsSuccess = false;
                }

                response.Data = result.Data;
            }
            catch (Exception ex)
            {
                return(new Entity.BaseResponse <List <Entity.BulkUploadResponse> >(false, ex.Message));
            }
            return(response);
        }
        public Entity.ActionStatus UploadKit(Entity.KitVerifyRequest request)
        {
            var actionStatus = new Entity.ActionStatus();

            try
            {
                var verifyResult = _hardwareKitRepository.VerifyHardwareKit(request, false);

                if (verifyResult.Success)
                {
                    actionStatus = _hardwareKitRepository.SaveHardwareKit(request, false);
                }
                else
                {
                    actionStatus.Data    = verifyResult.Data;
                    actionStatus.Success = verifyResult.Success;
                    actionStatus.Message = verifyResult.Message;
                }
            }
            catch (Exception ex)
            {
                _logger.Error(Constants.ACTION_EXCEPTION, "HardwareKit.Upload " + ex);
                return(new Entity.ActionStatus
                {
                    Success = false,
                    Message = ex.Message
                });
            }
            return(actionStatus);
        }
        public Entity.ActionStatus Manage(Entity.KitVerifyRequest hardwareKit, bool isEdit = false)
        {
            Entity.ActionStatus actionStatus = new Entity.ActionStatus(true);
            try
            {
                var verifyResult = _hardwareKitRepository.VerifyHardwareKit(hardwareKit, isEdit);

                if (verifyResult.Success)
                {
                    actionStatus = _hardwareKitRepository.SaveHardwareKit(hardwareKit, isEdit);
                }
                else
                {
                    List <Entity.BulkUploadResponse> errorResult = verifyResult.Data;

                    actionStatus.Data    = errorResult;          // verifyResult.Data;
                    actionStatus.Success = verifyResult.Success;
                    actionStatus.Message = verifyResult.Message; // "H/W Kit ID / Unique ID already exists";
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                actionStatus.Success = false;
                actionStatus.Message = ex.Message;
            }
            return(actionStatus);
        }
Exemple #7
0
        public Entity.BaseResponse <List <Entity.BulkUploadResponse> > VerifyKit(Entity.KitVerifyRequest request)
        {
            Entity.BaseResponse <List <Entity.BulkUploadResponse> > response = new Entity.BaseResponse <List <Entity.BulkUploadResponse> >(true);
            try
            {
                List <Entity.KitVerifyResponse> lstTestData = new List <Entity.KitVerifyResponse>();
                //TODO

                response.IsSuccess = false;
                var result = _service.VerifyKit(request);
                if (result.Success)
                {
                    if (request.HardwareKits.Where(t => string.IsNullOrEmpty(t.KitCode.Trim()) || string.IsNullOrEmpty(t.UniqueId.Trim()) || string.IsNullOrEmpty(t.Name.Trim())).FirstOrDefault() == null)
                    {
                        if (request.HardwareKits.Where(t => Regex.IsMatch(t.KitCode.Trim(), SpecialCharRegex) && Regex.IsMatch(t.UniqueId.Trim(), UniqueIDSpecialCharRegex)).FirstOrDefault() != null)
                        {
                            response.IsSuccess = true;
                        }
                        else
                        {
                            response.IsSuccess = false;
                        }
                    }
                    else
                    {
                        response.IsSuccess = false;
                    }
                }
                else
                {
                    response.IsSuccess = false;
                    response.Message   = result.Message;
                }
                if (!response.IsSuccess)
                {
                    response.IsSuccess = false;
                    response.Message   = "KitCode or UniqueID is Invalid!";
                    var responseData = ((List <Entity.BulkUploadResponse>)result.Data);
                    responseData.Where(t => !Regex.IsMatch(t.kitCode.Trim(), SpecialCharRegex)).AsEnumerable().All(x => { x.hardwareKitError = "Invalid KitCode"; return(true); });
                    responseData.Where(t => !Regex.IsMatch(t.uniqueId.Trim(), UniqueIDSpecialCharRegex)).AsEnumerable().All(x => { x.hardwareKitError = "Invalid UniqueId"; return(true); });

                    responseData.Where(t => string.IsNullOrEmpty(t.kitCode.Trim()) && string.IsNullOrEmpty(t.hardwareKitError)).AsEnumerable().All(x => { x.hardwareKitError = "Invalid KitCode"; return(true); });
                    responseData.Where(t => string.IsNullOrEmpty(t.uniqueId.Trim()) && string.IsNullOrEmpty(t.hardwareKitError)).AsEnumerable().All(x => { x.hardwareKitError = "Invalid UniqueId"; return(true); });
                    responseData.Where(t => string.IsNullOrEmpty(t.name.Trim()) && string.IsNullOrEmpty(t.hardwareKitError)).AsEnumerable().All(x => { x.hardwareKitError = "Invalid Name"; response.Message = "KitCode or UniqueID or Name is Invalid!"; return(true); });
                    result.Data = responseData;
                }
                response.Data = result.Data;
            }
            catch (Exception ex)
            {
                base.LogException(ex);
                return(new Entity.BaseResponse <List <Entity.BulkUploadResponse> >(false, ex.Message));
            }
            return(response);
        }
        public Entity.ActionStatus Manage(Entity.KitVerifyRequest hardwareKit, bool isEdit = false)
        {
            Entity.ActionStatus actionStatus = new Entity.ActionStatus(true);
            try
            {
                //foreach (var kit in hardwareKit.HardwareKits)
                //{
                //    if (string.IsNullOrWhiteSpace(kit.Tag)) continue;
                //    var tagGuid = Guid.Parse(kit.Tag);
                //    var kitAttribute = _kitTypeAttributeRepository.FindBy(t => t.Guid.Equals(tagGuid)).FirstOrDefault();
                //    if (kitAttribute != null)
                //    {
                //        kit.Tag = kitAttribute.Tag;
                //        kit.AttributeName = kitAttribute.LocalName;
                //    }
                //}

                var verifyResult = _hardwareKitRepository.VerifyHardwareKit(hardwareKit, isEdit);

                if (verifyResult.Success)
                {
                    actionStatus = _hardwareKitRepository.SaveHardwareKit(hardwareKit, isEdit);
                }
                else
                {
                    List <Entity.BulkUploadResponse> errorResult = verifyResult.Data;
                    //if (errorResult != null)
                    //{
                    //    foreach (var error in errorResult)
                    //    {
                    //        if (string.IsNullOrWhiteSpace(error.tag)) continue;

                    //        var tag = error.tag;
                    //        var kitAttribute = _kitTypeAttributeRepository.FindBy(t => t.Tag.Equals(error.tag) && t.LocalName.Equals(error.attributename)).FirstOrDefault();
                    //        if (kitAttribute != null)
                    //        {
                    //            error.tag = kitAttribute.Guid.ToString();
                    //        }
                    //    }
                    //}

                    actionStatus.Data    = errorResult;          // verifyResult.Data;
                    actionStatus.Success = verifyResult.Success;
                    actionStatus.Message = verifyResult.Message; // "H/W Kit ID / Unique ID already exists";
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                actionStatus.Success = false;
                actionStatus.Message = ex.Message;
            }
            return(actionStatus);
        }
 public Entity.BaseResponse <List <Entity.BulkUploadResponse> > Manage([FromBody] Entity.KitVerifyRequest request, bool isEdit = false)
 {
     Entity.BaseResponse <List <Entity.BulkUploadResponse> > response = new Entity.BaseResponse <List <Entity.BulkUploadResponse> >(true);
     try
     {
         var status = _service.Manage(request, isEdit);
         response.IsSuccess = status.Success;
         response.Message   = status.Message;
         response.Data      = status.Data;
     }
     catch (Exception ex)
     {
         return(new Entity.BaseResponse <List <Entity.BulkUploadResponse> >(false, ex.Message));
     }
     return(response);
 }
        public Entity.ActionStatus VerifyKit(Entity.KitVerifyRequest request, bool isEdit = false)
        {
            var result = new Entity.ActionStatus();

            try
            {
                result = _hardwareKitRepository.VerifyHardwareKit(request, isEdit);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                return(new Entity.ActionStatus
                {
                    Success = false,
                    Message = ex.Message
                });
            }
            return(result);
        }
        public Entity.ActionStatus VerifyKit(Entity.KitVerifyRequest request, bool isEdit = false)
        {
            var result = new Entity.ActionStatus();

            try
            {
                result = _hardwareKitRepository.VerifyHardwareKit(request, isEdit);
            }
            catch (Exception ex)
            {
                _logger.Error(Constants.ACTION_EXCEPTION, "HardwareKit.Verify " + ex);
                return(new Entity.ActionStatus
                {
                    Success = false,
                    Message = ex.Message
                });
            }
            return(result);
        }
        public ActionStatus SaveHardwareKit(Entity.KitVerifyRequest requestData, bool isEdit)
        {
            var response            = new ActionStatus();
            var result              = new List <BulkUploadResponse>();
            var createdHardwareKits = new List <BulkUploadResponse>();

            try
            {
                var xmlData = string.Empty;
                using (var stringwriter = new System.IO.StringWriter())
                {
                    var serializer = new XmlSerializer(requestData.GetType());
                    serializer.Serialize(stringwriter, requestData);
                    xmlData = stringwriter.ToString();
                }



                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version); parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("data", xmlData.ToString(), DbType.Xml, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("isEdit", (isEdit == false ? 0 : 1), DbType.Boolean, ParameterDirection.Input));
                    System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[HardwareKit_AddUpdate]", CommandType.StoredProcedure, null), parameters.ToArray());
                    // result = DataUtils.DataReaderToList<Entity.BulkUploadResponse>(dbDataReader, null);


                    while (dbDataReader.Read())
                    {
                        var item = new Entity.BulkUploadResponse();
                        if (dbDataReader["kitGuid"] != null)
                        {
                            //createdHardwareKits.Add(new Guid(dbDataReader["kitGuid"].ToString().ToUpper()));
                            item.kitGuid     = new Guid(dbDataReader["kitGuid"].ToString().ToUpper());
                            item.kitTypeGuid = new Guid(dbDataReader["kitTypeGuid"].ToString().ToUpper());
                            item.kitCode     = (dbDataReader["kitCode"].ToString());

                            createdHardwareKits.Add(item);
                        }
                        else
                        {
                            response.Message = dbDataReader["fieldname"].ToString().ToUpper();
                            response.Data    = null;
                            response.Success = false;
                        }
                    }

                    if (createdHardwareKits.Count != 0 || createdHardwareKits.Count == 1)
                    {
                        //requestData.HardwareKits.FirstOrDefault(). = createdHardwareKits.FirstOrDefault();
                        response.Success = true;
                        response.Data    = createdHardwareKits;
                    }
                    else
                    {
                        response.Success = false;
                        response.Data    = createdHardwareKits;
                        response.Message = "Unable to save Hardware-Kit";
                    }
                }

                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);
        }