public async Task <CrawlResult> CrawlDimensionContentAsync(EntityFramework.Shared.Entities.Dimension dimension) { var webPath = $"{dimension.Zoom}/{dimension.X}/{dimension.Y}.json"; try { var client = _httpClientFactory.GetHttpClient(_webBaseAddress); var item = await client.GetAsync(webPath); var contentString = await item.Content.ReadAsStringAsync(); // get the actual content stream var cityRecords = JsonConvert.DeserializeObject <List <List <object> > >(contentString); foreach (var record in cityRecords) { try { var label = new EntityFramework.Shared.Entities.Label() { DimensionId = dimension.Id, RegisterDate = DateTime.Now, O = record[0].ToString(), Name = record[1].ToString(), Type = record[2].ToString(), X = Convert.ToDouble(record[3].ToString()), Y = Convert.ToDouble(record[4].ToString()), ExtraField1 = Convert.ToInt32(record[5].ToString()), ExtraField2 = Convert.ToInt32(record[6].ToString()), }; await _labelRepository.Add(label); } catch (Exception e) { _logger.LogError(e, $"Crawl Label Exception : {contentString}"); } } return(new CrawlResult() { Succeeded = true }); } catch (Exception e) { _logger.LogError(e, $"Crawl Label Exception : {_webBaseAddress}/{webPath}"); return(new CrawlResult() { Succeeded = false, Exception = e }); } }
private int CreateLabel(LabelOutputViewModel model) { var label = new Label { OrderDetailId = model.OrderDetailId, TypeId = model.Type, ItemCode = model.ItemCode, LotNumber = model.LotNumber, Description = model.Description, PoundWeight = model.PoundWeight, KilogramWeight = model.KilogramWeight, ProcessDate = model.ProcessDate.ToString("d"), SlaughterDate = model.SlaughterDate.ToString("d"), BestBeforeDate = model.BestBeforeDate, SpeciesBugPath = model.SpeciesBugPath, LogoPath = model.LogoPath, BornIn = model.BornInRegionName, RaisedIn = model.RaisedInRegionName, ProductOf = model.ProductOfRegionName, DistributedBy = model.DistributedBy, GermanDescription = model.GermanDescription, FrenchDescription = model.FrenchDescription, ItalianDescription = model.ItalianDescription, SwedishDescription = model.SwedishDescription, IsPrinted = model.IsPrinted, CreatedDate = model.WeighedDate, LabelFile = model.LabelFile, Customer = model.Customer, CustomerProductCode = model.CustomerProductCode, GradeName = model.GradeName, SerialNumber = model.SerialNumber, Organic = model.Organic, Primal = model.Primal, SubPrimal = model.SubPrimal, Trim = model.Trim, Refrigeration = model.Refrigeration, PackedFor = model.PackedFor, VarCustomerJobValue = model.VarCustomerJobValue, CustomerProductDescription = model.VarCustomerProductValue }; Logger.Debug( string.Format("OrderDetailId:{0}; PoundWeight:{1}; KiloWeight:{2}; LabelFile:{3}; LogoPath:{4}; ", label.OrderDetailId, label.PoundWeight, label.KilogramWeight, label.LabelFile, label.LogoPath)); _labelRepository.Add(label); _labelRepository.Save(); return(label.Id); }
private void CreateLabel(LabelOutputViewModel model) { var context = new OmsContext(); _labelRepository = new LabelRepository(context); var label = new Label { OrderDetailId = model.OrderDetailId, TypeId = model.Type, ItemCode = model.ItemCode, LotNumber = model.LotNumber, Description = model.Description, PoundWeight = model.PoundWeight, KilogramWeight = model.KilogramWeight, ProcessDate = model.ProcessDate.ToString("d"), SlaughterDate = model.SlaughterDate.ToString("d"), BestBeforeDate = model.BestBeforeDate, SpeciesBugPath = model.SpeciesBugPath, LogoPath = model.LogoPath, BornIn = model.BornInRegionName, RaisedIn = model.RaisedInRegionName, ProductOf = model.ProductOfRegionName, SlaughteredIn = model.SlaughteredInRegionName, DistributedBy = model.DistributedBy, GermanDescription = model.GermanDescription, FrenchDescription = model.FrenchDescription, ItalianDescription = model.ItalianDescription, SwedishDescription = model.SwedishDescription, IsPrinted = model.IsPrinted, CreatedDate = model.WeighedDate, LabelFile = model.LabelFile, Customer = model.Customer, CustomerPO = model.CustomerPO, CustomerProductCode = model.CustomerProductCode, GradeName = model.GradeName, SerialNumber = model.SerialNumber, Organic = model.Organic, Primal = model.Primal, SubPrimal = model.SubPrimal, AnimalName = model.AnimalName, Species = model.Species, Trim = model.Trim, Refrigeration = model.Refrigeration, PackedFor = model.PackedFor, JulianProductionDate = model.JulianProductionDate, VarCustomerJobValue = model.VarCustomerJobValue, CustomerProductDescription = model.VarCustomerProductValue, Gtin = model.Gtin, PricePerPound = model.PricePerPound, Price = model.Price, Printer = model.Printer, TareWeight = model.TareWeight, NutritionDescription = model.NutritionDescription, NutritionServingSize = model.NutritionServingSize, NutritionServingContainer = model.NutritionServingContainer, NutritionCalories = model.NutritionCalories, NutritionCaloriesFat = model.NutritionCaloriesFat, NutritionTotalFat = model.NutritionTotalFat, NutritionSatFat = model.NutritionSatFat, NutritionTransFat = model.NutritionTransFat, NutritionPolyFat = model.NutritionPolyFat, NutritionMonoFat = model.NutritionMonoFat, NutritionCholesterol = model.NutritionCholesterol, NutritionSodium = model.NutritionSodium, NutritionCarbs = model.NutritionCarbs, NutritionProtein = model.NutritionProtein, NutritionVitA = model.NutritionVitA, NutritionVitC = model.NutritionVitC, NutritionCalcium = model.NutritionCalcium, NutritionIron = model.NutritionIron, CustomerStateCode = model.CustomerStateCode, CustomerName = model.CustomerName, CustomerPhone = model.CustomerPhone, CustomerEmail = model.CustomerEmail, CustomerCity = model.CustomerCity, CustomerZipCode = model.CustomerZipCode, CustomerFax = model.CustomerFax, CustomerAddress2 = model.CustomerAddress2, CustomerAddress1 = model.CustomerAddress1 }; Logger.Debug(string.Format("OrderDetailId:{0}; PoundWeight:{1}; KiloWeight:{2}; LabelFile:{3}; LogoPath:{4}; ", label.OrderDetailId, label.PoundWeight, label.KilogramWeight, label.LabelFile, label.LogoPath)); _labelRepository.Add(label); _labelRepository.Save(); context.Dispose(); }
public async Task <string> Post([FromBody] Label Label) { await _LabelRepository.Add(Label); return(""); }