public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } //Load 1:M relationship from DB: ProductMeta itemToDelete = await _context.ProductMeta.Include(p => p.products) .AsNoTracking().FirstOrDefaultAsync(pd => pd.Id == id); var scrapedItems = itemToDelete.products; if (itemToDelete == null) { return(NotFound()); } try { //Delete Parent obj: _context.ProductMeta.Remove(itemToDelete); //Delete Children too: _context.RemoveRange(scrapedItems); await _context.SaveChangesAsync(); _logger.LogInformation($"Obj Deleted from Database:\nID:{itemToDelete.Id}\nURL:{itemToDelete.ProductUrl}"); } catch (Exception e) { _logger.LogError(e, "Error Deleting obj"); } return(RedirectToPage("./SavedProducts")); }
private async Task <ProductMeta> GetProductMeta(ulong id) { ProductMeta productMeta = new ProductMeta() { Categories = Mapper.Map <IList <Category>, IList <WpTerms> >(await _goodsService.GetCategoriesByPostId(id)) }; return(productMeta); }
public async Task <IActionResult> Update(string id, [FromBody] ProductMeta productMeta) { var result = await _productService.Update(CurrentUser.TenantId, CurrentUser.Id, CurrentUser.FullName, CurrentUser.Avatar, id, productMeta); if (result.Code <= 0) { return(BadRequest(result)); } return(Ok(result)); }
private void btnOK_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("正在分类...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; NeuralNet ooC = new NeuralNet(cmbInRaster.Text, txtROI.Text, actFun, float.Parse(spinContribution.EditValue.ToString()), float.Parse(spinTraingRate.EditValue.ToString()), float.Parse(spinMomentum.EditValue.ToString()), float.Parse(spinCriteria.EditValue.ToString()), hiddenLyr, maxSweep, minActThres, txtOut.Text); ooC.Execute(); BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "面向对象识别", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); if (XtraMessageBox.Show("分类完成,是否加载?", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.OK) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } catch (Exception ex) { //此处调用成功并写出结果后仍会抛出异常。 Log.WriteLog(typeof(frmSegmentation), ex); if (File.Exists(txtOut.Text.TrimEnd())) { FileInfo fInfo = new FileInfo(txtOut.Text.TrimEnd()); if (fInfo.Length / (1024 * 1024) > 1) { BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "中分宽幅影像分类结果", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); if (XtraMessageBox.Show("分类完成,是否加载?", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.OK) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } } else { XtraMessageBox.Show("分类失败:\r\n" + ex.Message, "提示信息"); } } finally { frmWait.Close(); } }
private void button14_Click(object sender, EventArgs e) { if (this.listBox2.Items.Count < 1) { return; } foreach (var item in listBox2.Items) { ProductMeta meta = new ProductMeta(item.ToString(), "", txtDocRegion.Text, txtDocDesc.Text, txtDocSub.Text); meta.WriteDocMeta(); } MessageBox.Show("Finished."); }
// //执行 // private void btnRun_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("正在分类...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; //获取组合的条件运算公式,若检查失败,提示并返回 RasterMapAlgebraOp op = new RasterMapAlgebraOp(Canvas.instance.decisionTree.GetLayer(0).nodeList[0], DecisionTree.variableTable); string msg = ""; if (!op.CheckExp(Canvas.instance.decisionTree.GetLayer(0).nodeList[0], out msg)) { XtraMessageBox.Show(msg); return; } SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "保存结果文件"; dialog.Filter = "tiff(*.tif)|*.tif|All files(*.*)|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { op.Execute(dialog.FileName); } //元数据 if (_treeFile.Contains("gf4.tree")) { BLL.ProductMeta meta = new ProductMeta(dialog.FileName, "GF4", "", "长时间序列识别结果", "作物识别结果"); meta.WriteGeoMeta(); } else { BLL.ProductMeta meta = new ProductMeta(dialog.FileName, "", "", "决策树识别结果", "作物识别结果"); meta.WriteGeoMeta(); } //快视图 BLL.ProductQuickView view = new BLL.ProductQuickView(dialog.FileName); view.Create(); if (DialogResult.OK == XtraMessageBox.Show("分类完毕,是否加分类载结果?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { MAP.AddRasterFileToMap(dialog.FileName); } //this.Close(); } catch (Exception ex) { XtraMessageBox.Show("分类失败:" + ex.Message); } finally { frmWait.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("正在分类...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; MaximumLikeHood ooC = new MaximumLikeHood(cmbInRaster.Text, txtROI.Text, txtOut.Text); ooC.Execute(); BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "面向对象识别", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); if (XtraMessageBox.Show("分类完成,是否加载?", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.OK) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } catch (Exception ex) { //此处调用成功并写出结果后IDL仍会抛出异常。通过判断输出文件确定是否成功 Log.WriteLog(typeof(frmSegmentation), ex); if (File.Exists(txtOut.Text.TrimEnd())) { BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "面向对象识别", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); FileInfo fInfo = new FileInfo(txtOut.Text.TrimEnd()); if (fInfo.Length / (1024 * 1024) > 1) { if (XtraMessageBox.Show("分类完成,是否加载?", "提示信息", MessageBoxButtons.OKCancel) == DialogResult.OK) { MAP.AddRasterFileToMap(txtOut.Text.TrimEnd()); } this.Close(); } } else { XtraMessageBox.Show("分类失败:\r\n" + ex.Message, "提示信息"); } } finally { frmWait.Close(); } }
// GET: Product/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Product product = db.Products.Find(id); ProductMeta productMeta = product.ProductMetas.Where(m => m.MetaKey == "img_icon").Single(); if (product == null) { return(HttpNotFound()); } ViewBag.Icon = productMeta.MetaValue; ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", product.UserID); return(View(product)); }
private void buttonOK_Click(object sender, EventArgs e) { if (this.listBoxFile.Items.Count < 1) { return; } foreach (var item in listBoxFile.Items) { ProductMeta meta = new ProductMeta(item.ToString(), textBoxDataSource.Text, textBoxRegion.Text, txtDesc.Text, txtSubClass.Text); if (item.ToString().EndsWith(".shp")) { meta.WriteShpMeta(); } else { meta.WriteGeoMeta(); } ProductQuickView view = new ProductQuickView(item.ToString()); view.Create(); } MessageBox.Show("Finished."); }
public ActionResult Create([Bind(Include = "ProductName,ProductInfo,ProductRelease,ProductModified,ProductStatus,Price,UserID")] Product product) { ProductMeta productMeta = new ProductMeta(); var icon = Request.Form["icon"]; try { if (ModelState.IsValid) { product.ProductRelease = DateTime.Now; product.ProductModified = DateTime.Now; db.Products.Add(product); productMeta.MetaKey = "img_icon"; productMeta.MetaValue = icon; productMeta.ProductID = product.ProductID; db.SaveChanges(); product.ProductMetas.Add(productMeta); db.SaveChanges(); return(RedirectToAction("Edit", new { id = product.ProductID })); } } catch (DataException /*de*/) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } ViewBag.Icon = icon; ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", product.UserID); return(View(product)); }
public async Task <IActionResult> OnPostAsync() { //Check to see if user selected any prefilled site info: if (!String.IsNullOrEmpty(prefilledSite)) { _logger.LogInformation($"Using pre-filled info:{prefilledSite}"); var siteData = new FormattedSites(); siteData.formattedSitesDict.TryGetValue(prefilledSite, out List <string> priceNamesList); Console.WriteLine($"FOUND: {priceNamesList[0]}+ {priceNamesList[1]}"); //When using prefilled info, it's always in the same order: price, name priceId = priceNamesList[0]; productNameId = priceNamesList[1]; } var productMeta = new ProductMeta { ProductUrl = url, PriceHtmlId = priceId, NameHtmlId = productNameId, VanityName = vanityName }; try { //Save changes to database and scrape the newly added product. _context.ProductMeta.Add(productMeta); await _context.SaveChangesAsync(); scrape scraper = new scrape(_context); scraper.ScrapeSingle(productMeta.ProductUrl, productMeta.PriceHtmlId, productMeta.NameHtmlId, productMeta.Id, _context); } catch (Exception e) { _logger.LogWarning(e, "Error Saving to database:"); } return(RedirectToPage("SavedProducts")); }
private void btnOK_Click(object sender, EventArgs e) { frmWaitDialog frmWait = new frmWaitDialog("GF3分类...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; ClassificationBLL.GF3Classification gf3Class = new ClassificationBLL.GF3Classification(_GF3Polarity, _GF1, _pixelROI, _segmentROI, _class); frmWait.Caption = "参数检查..."; string msg = ""; if (!gf3Class.ChkPara(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "极化特征区域统计..."; if (!gf3Class.ZonalPolarity(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "图斑尺度分类..."; Application.DoEvents(); if (!gf3Class.SVMFeature(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "像元尺度分类..."; Application.DoEvents(); if (!gf3Class.SVMPixel(out msg)) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "计算图斑信息熵..."; Application.DoEvents(); if (!gf3Class.Entropy()) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } frmWait.Caption = "混合图斑修正..."; Application.DoEvents(); if (!gf3Class.ClassMerge()) { XtraMessageBox.Show(msg, "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } BLL.ProductMeta meta = new ProductMeta(_class, "GF3", "", "图斑像元综合分类", "作物识别结果"); meta.WriteGeoMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(_class); view.Create(); if (DialogResult.OK == XtraMessageBox.Show("分类完毕!是否加载结果?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { MapAPI.AddRasterFileToMap(_class); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } finally { frmWait.Close(); } }
protected void DbFetchProductChildren() { ProductMeta itemMeta = new ProductMeta(); SelectStatement select = new SelectStatement(itemMeta); select.Where.Add(itemMeta.FK_ProductCategoryID.ChildForeignKey[0], this.GetPrimaryKeyValue()[0]); this.ProductChildren = (EntityCollection<ProductEntity, ProductMeta>)select.Execute(); SetOldProductChildrenIDs(); }
private void btnOK_Click(object sender, EventArgs e) { string msg = string.Empty; frmWaitDialog frmWait = new frmWaitDialog("正在执行...", "提示信息"); try { frmWait.Owner = this; frmWait.TopMost = false; string fishNet = string.Empty; string firstUnit = this.cmbFirstUnit.Text; if (chkNewNet.Checked) { SampleData.firstSample = cmbFirstUnit.Text; SampleData.villageField = cmbVillage.Text; SampleData.layerField = cmbLayer.Text; SampleData.farmLand = cmbCultivation.Text; SampleData.ASCDL = cmbASCDL.Text; SampleData.targetCrop = cmbCrop.SelectedIndex; if (!SampleSelection.ChkData(out msg)) { XtraMessageBox.Show(msg); return; } //一级单元范围内创建渔网 frmWait.Caption = "创建二级抽样单元..."; fishNet = System.IO.Path.Combine(ConstDef.PATH_TEMP, DateTime.Now.ToFileTime().ToString() + ".shp"); int width = int.Parse(spinLength.EditValue.ToString()); int height = int.Parse(this.spinWidth.EditValue.ToString()); if (!EnviVars.instance.GpExecutor.CreateFishNet(firstUnit, width, height, fishNet, out msg)) { XtraMessageBox.Show(msg); return; } } else { SampleData.firstSample = cmbFirstUnit.Text; SampleData.villageField = cmbVillage.Text; SampleData.layerField = cmbLayer.Text; SampleData.farmLand = cmbCultivation.Text; SampleData.ASCDL = cmbASCDL.Text; SampleData.targetCrop = cmbCrop.SelectedIndex; if (!SampleSelection.ChkData(out msg)) { XtraMessageBox.Show(msg); return; } if (string.IsNullOrEmpty(cmbSecondUint.Text)) { XtraMessageBox.Show("二级抽样单元为空!"); return; } fishNet = cmbSecondUint.Text; } //抽选样本 frmWait.Caption = "抽选样本..."; SamplePara para = new SamplePara(); para.isNum = chkSampleNum.Checked; para.sampleNum = int.Parse(this.spinSampleNum.EditValue.ToString()); para.sampleRate = double.Parse(this.spinPercent.EditValue.ToString()) / 100; SampleSelection.Sampling(firstUnit, cmbVillage.Text, cmbLayer.Text, fishNet, cmbCultivation.Text, para, txtOut.Text); SampleFrame sampleFrame = new SampleFrame(); frmWait.Caption = "计算耕地面积..."; if (!SampleSelection.CalLandArea(txtOut.Text, SampleData.farmLand, out msg)) { XtraMessageBox.Show(msg); return; } frmWait.Caption = "计算分类面积..."; if (!sampleFrame.CalClassArea(txtOut.Text, SampleData.ASCDL, SampleData.targetCrop, out msg)) { XtraMessageBox.Show(msg); return; } BLL.ProductMeta meta = new ProductMeta(txtOut.Text.TrimEnd(), "", "", "二级样方", "抽样和面积推算结果"); meta.WriteShpMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(txtOut.Text.TrimEnd()); view.Create(); System.Windows.Forms.DialogResult dialogResult = XtraMessageBox.Show("抽样完成,是否加载结果?", "提示信息", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { MapAPI.AddShpFileToMap(txtOut.Text); this.Close(); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); Log.WriteLog(typeof(frmSymbolSelector), ex); } finally { frmWait.Close(); } }
private void siBOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cBESave.Text.Trim())) { MessageBox.Show("错误信息:\n输出结果的值:是必需的"); } else { frmWaitDialog frmWait = new frmWaitDialog("正在生成...", "提示信息"); try { DataTable ExtandTable = new DataTable(); SampleSimulation Sim = new SampleSimulation(); int sampleSum = SamplingSum - sampleNum; //第一次抽样,剩余的样本总量 int sampleExtandNum = 0; //扩充的样本量 //每次抽样得到的样本 sampleTable = SampleZones[gridView1.FocusedRowHandle]; if (string.IsNullOrEmpty(tEExtend.Text.Trim()) && string.IsNullOrEmpty(tEScale.Text.Trim())) { ExtandTable = sampleTable; } else { if (cEExtend.Checked == true) { sampleExtandNum = Convert.ToInt32(tEExtend.Text); } else { sampleExtandNum = Convert.ToInt32(sampleSum * (Convert.ToDouble(tEScale.Text) / 100)); } if (0 > sampleExtandNum || sampleExtandNum > sampleSum) { MessageBox.Show("输入的扩充样本量超出范围,请重新输入!"); return; } else if (sampleExtandNum == 0) { ExtandTable = sampleTable; } else { ExtandTable = Sim.ExtendSample(sampleSumTable, sampleTable, sampleExtandNum, cBELayer.Text, cBEBasis.Text); } } if (ExtandTable != null) { if (Sim.CreateShpFile(cBFile.Text, ExtandTable, cBESave.Text)) { BLL.ProductMeta meta = new ProductMeta(cBESave.Text.TrimEnd(), "", "", "一级样本村", "抽样和面积推算结果"); meta.WriteShpMeta(); BLL.ProductQuickView view = new BLL.ProductQuickView(cBESave.Text.TrimEnd()); view.Create(); System.Windows.Forms.DialogResult dialogResult = XtraMessageBox.Show("保存样本成功,是否加载结果?", "提示信息", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { //添加结果到主地图视图 IFeatureClass pFC = EngineAPI.OpenFeatureClass(cBESave.Text); if (pFC != null) { IFeatureLayer pFLyr = new FeatureLayerClass(); pFLyr.FeatureClass = pFC; pFLyr.Name = (pFC as IDataset).Name; MapAPI.UniqueValueRender(pFLyr, "KC"); EnviVars.instance.MapControl.AddLayer(pFLyr); } } } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Log.WriteLog(typeof(frmSampleSimulation), ex); } finally { frmWait.Close(); this.Close(); } } }