Beispiel #1
0
        public async Task <int> Save(List <ProductResource> products)

        {
            int id = 0;

            try
            {
                json = JsonConvert.SerializeObject(products.ToArray(), Formatting.Indented);

                filename = Path.Combine(_hostingEnvironment.ContentRootPath, _appSettings.Value.JsonSavePath, RandomString.GenerateRandomString(10) + ".json");
                //write string to file
                System.IO.File.WriteAllText(filename, json);

                ProductPath path = new ProductPath
                {
                    JsonFilePath = filename
                };


                await _productPathRepository.AddAsync(path);

                await _unitOfWork.CompleteAsync();

                id = path.Id;
            }
            catch (Exception ex)
            {
                _logService.LogException(ex, "Save File Path");
            }



            return(id);
        }
Beispiel #2
0
 public void Add()
 {
     if (this.pathName == null || this.pathName.Trim().Equals(string.Empty) ||
         this.pathDir == null || this.pathDir.Trim().Equals(string.Empty))
     {
         this.Hint = "目录名、目录路径不能为空!";
     }
     else
     {
         ProductPath item = new ProductPath();
         item.Name = this.pathName.Trim();
         item.Path = this.pathDir.Trim();
         this.DirList.Add(item);
         config.ListProductPath = this.DirList.ToList();
         config.WriteConfigToFile();
         this.Hint     = "常用产品目录保存成功!";
         this.PathName = "";
         this.PathDir  = "";
     }
 }
Beispiel #3
0
 public void Remove(ProductPath product)
 {
     _context.ProductPaths.Remove(product);
 }
Beispiel #4
0
 public void Update(ProductPath product)
 {
     _context.ProductPaths.Update(product);
 }
Beispiel #5
0
 public async Task AddAsync(ProductPath product)
 {
     await _context.ProductPaths.AddAsync(product);
 }