public ResponseOutput GetProductsByBatchId(int batchId) { List <ProductDto> productDtos = new List <ProductDto>(); List <ProductInformation> products = _productService.GetProductsByBatchId(batchId); try { _logger.LogInformation("进入GetProductsByBatchId方法"); foreach (var product in products) { //过滤商品状态 //if (product.ProductStatus == ProductStatusTypeEnum.Down || product.ProductStatus == ProductStatusTypeEnum.Unknown // || product.StockType == StockStatusTypeEnum.No || product.StockType == StockStatusTypeEnum.Unknown) //{ // continue; //} //过滤库存状态 if (product.ProductStatus == ProductStatusTypeEnum.Down || product.ProductStatus == ProductStatusTypeEnum.Unknown) { continue; } //图片详情 var productDetails = _productDetailService.GetDetailsByProductId(product.Id); List <ProductDetailOutputDto> detailDtos = new List <ProductDetailOutputDto>(); if (productDetails != null) { foreach (var productDetail in productDetails) { detailDtos.Add(new ProductDetailOutputDto() { PhotoPath = productDetail.PhotoPath.Replace('\\', '/') }); } } var productDto = new ProductDto(); productDto.Id = product.Id; productDto.Code = product.ProductCode; productDto.Name = product.ProductName; if (!string.IsNullOrEmpty(product.Description)) { //修改富文本的图片为绝对路径 string processDescription = TextParse.ProcessHtmlImageUrlList(product.Description); productDto.Description = processDescription; } productDto.StockStatus = (int)product.StockType; productDto.ClassType = (int)product.Type; productDto.ProductStatus = (int)product.ProductStatus; productDto.Photos = detailDtos.Select(item => Path.Combine("http://www.bangbangfuli.cn:5001/", item.PhotoPath.Replace('\\', '/'))).ToList(); productDtos.Add(productDto); } return(new ResponseOutput(productDtos, "0", string.Empty, HttpContext.TraceIdentifier)); } catch (Exception ex) { _logger.LogError($"异常为{ex.ToString()}"); return(new ResponseOutput(null, "-1", ex.Message, HttpContext.TraceIdentifier)); } }
private void buttonBrowser_Click(object sender, EventArgs e) { try { if (openFileDialog.ShowDialog() == DialogResult.OK) { textBoxFilePath.Text = openFileDialog.FileName; TextParse textParse = new TextParse(textBoxFilePath.Text); richTextBoxView.Text = textParse.ConvertToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ResponseOutput GetProductDetailByProductId(int productId) { try { _logger.LogInformation("进入GetProductDetailByProductId方法"); ProductInformation product = _productService.GetProductById(productId); //图片详情 var productDetails = _productDetailService.GetDetailsByProductId(product.Id); List <ProductDetailOutputDto> detailDtos = new List <ProductDetailOutputDto>(); if (productDetails != null) { foreach (var productDetail in productDetails) { detailDtos.Add(new ProductDetailOutputDto() { PhotoPath = productDetail.PhotoPath.Replace('\\', '/') }); } } ProductDto dto = new ProductDto(); dto.Id = product.Id; dto.Code = product.ProductCode; dto.Name = product.ProductName; if (!string.IsNullOrEmpty(product.Description)) { //修改富文本的图片为绝对路径 string processDescription = TextParse.ProcessHtmlImageUrlList(product.Description); dto.Description = processDescription; } dto.ClassType = (int)product.Type; dto.StockStatus = (int)product.StockType; dto.ProductStatus = (int)product.ProductStatus; dto.Photos = detailDtos.Select(item => Path.Combine("http://www.bangbangfuli.cn:5001/", item.PhotoPath.Replace('\\', '/'))).ToList(); return(new ResponseOutput(dto, "0", string.Empty, HttpContext.TraceIdentifier)); } catch (Exception ex) { _logger.LogError($"异常为{ex.ToString()}"); return(new ResponseOutput(null, "-1", ex.Message, HttpContext.TraceIdentifier)); } }
internal void Import(string configContent) { var contents = TextParse.GetContent(configContent, separator); isImporting = true; try { remaining.Clear(); foreach (var c in contents) { var p = properties.FirstOrDefault(x => c.Key == x.Name); if (p == null) { if (!remaining.Keys.Contains(c.Key)) { remaining.Add(c.Key, c.Value); } continue; } try { p.SetValue(this, Convert.ChangeType(c.Value, p.PropertyType)); Debug.WriteLine("Imported {0}: {1}", p.Name, p.GetValue(this)); } catch (Exception ex) { throw new Exception(String.Format("Failed to import value ({0}). ", p.Name), ex); } } } finally { isImporting = false; RaisePropertyChanged(() => IsChanged); } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (textBoxFilePath.Text == "") { MessageBox.Show("You have to open a file firstly.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (saveFileDialog.ShowDialog() == DialogResult.OK) { try { TextParse textParse = new TextParse(textBoxFilePath.Text); textParse.ConvertToFile(saveFileDialog.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void TextParseCategoryFirstNull() { var stringFragments = TextParse.CategoryName(".unmanagedDvm.storageSubsystem.<04:21:59 PM> 11/10/2011: pipeline driver 0 started successfully."); VerifyStringFragments(stringFragments, 3); }