/// <summary>更新品牌的LOGO的处理 /// </summary> /// <returns>更新品牌的LOGO的结果View</returns> public ActionResult UpdateLogo(int id) { HttpPostedFileBase file = Request.Files[0]; if (!file.ContentType.Contains("image") || file.ContentLength > 65535) { return(Content("error")); } //如果获取该ID的品牌信息失败,返回错误 BrandItem brand = BrandManager.GetBrandByID(id); if (brand == null) { return(Content("error")); } //上传的LOGO图片必须是100*50的大小 string mimetype = file.ContentType; BitmapDecoder decoder = BitmapDecoder.Create(file.InputStream, BitmapCreateOptions.None, BitmapCacheOption.Default); if (decoder.Frames[0].PixelWidth != 100 || decoder.Frames[0].PixelHeight != 50) { return(Content("error - must be 100*50 dimension")); } string logo_filename = BrandManager.GetLogoFileName(brand, mimetype); file.SaveAs(HttpContext.Server.MapPath("~/Images/logo/" + logo_filename)); BrandManager.UpdateBrandItem(null); return(Content("ok-" + logo_filename)); }
/// <summary> /// Saves and updates the brand details /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (form.ValidateData()) { if (QueryHelper.GetInteger("ItemID", 0) > 0) { var brandData = CustomTableItemProvider.GetItem <BrandItem>(QueryHelper.GetInteger("ItemID", 0)); brandData.BrandCode = ValidationHelper.GetInteger(form.GetFieldValue("BrandCode"), 0); Response.Cookies["status"].Value = QueryStringStatus.Updated; Response.Cookies["status"].HttpOnly = false; form.SaveData($"{CurrentDocument.Parent.AbsoluteURL}?status={QueryStringStatus.Updated}"); } else { var brandData = new BrandItem(); brandData.BrandCode = ValidationHelper.GetInteger(form.GetFieldValue("BrandCode"), 0); brandData.BrandName = ValidationHelper.GetString(form.GetFieldValue("BrandName"), string.Empty); brandData.BrandDescription = ValidationHelper.GetString(form.GetFieldValue("BrandDescription"), string.Empty); brandData.Status = ValidationHelper.GetBoolean(form.GetFieldValue("Status"), true); Response.Cookies["status"].Value = QueryStringStatus.Added; Response.Cookies["status"].HttpOnly = false; form.SaveData($"{CurrentDocument.Parent.AbsoluteURL}?status={QueryStringStatus.Added}"); } } else { form.ShowValidationErrorMessage = true; } }
public static BrandItem smethod_3(string string_1, string string_2) { BrandItem class2 = new BrandItem(); string address = "http://item.taobao.com/item.htm?spm=0.0.0.0.7NgNnN&id=" + string_1; WebClient client = new WebClient(); client.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"); client.Headers.Add("Referer", "http://pub.alimama.com/myunion.htm?spm=a219t.7473494.1998155389.3.5o4qvy"); client.Headers.Add("Accept-Encoding", "gzip,deflate,sdch"); client.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8"); client.Headers.Add("Cookie", string_2); string str2 = GzipUtil.zip_to_string(client.DownloadData(address), Encoding.GetEncoding("GB2312")); int index = str2.IndexOf("<ul id=\"J_AttrUL\">"); if (index != -1) { int startIndex = str2.IndexOf("品牌:", index); if (startIndex != -1) { startIndex += 3; int num4 = str2.IndexOf("<", startIndex) - startIndex; if (num4 > 0) { string str3 = smethod_4(GzipUtil.smethod_4(str2.Substring(startIndex, num4))); class2.string_0 = str3; } } int num5 = str2.IndexOf("型号:", index); if (num5 != -1) { num5 += 3; int num6 = str2.IndexOf("<", num5) - num5; if (num6 > 0) { string str4 = smethod_4(GzipUtil.smethod_4(str2.Substring(num5, num6))); class2.string_1 = str4; } } int num7 = str2.IndexOf("货号:", index); if (num7 != -1) { num7 += 3; int num8 = str2.IndexOf("<", num7) - num7; if (num8 > 0) { string str5 = smethod_4(GzipUtil.smethod_4(str2.Substring(num7, num8))); class2.string_2 = str5; } } int length = str2.IndexOf("</ul>", index) - index; if (length > 0) { string str6 = smethod_4(GzipUtil.smethod_4(str2.Substring(index, length))); str6 = str6.Substring(0, str6.LastIndexOf("</li>") + 5) + "</ul>"; class2.string_3 = str6; } } return(class2); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!this.StopProcessing) { BrandItem brandData = null; brandData = new BrandItem(); form.AlternativeFormFullName = "KDA.Brand.KDA_Brand"; form.Info = brandData; form.VisibilityFormName = "KDA.Brand.KDA_Brand"; form.SubmitButton.Visible = false; btnCancel.Text = ResHelper.GetString("Kadena.CreateBrand.Cancel"); form.ValidationErrorMessage = ResHelper.GetString("Kadena.Brands.FormError"); if (QueryHelper.GetInteger("ItemID", 0) > 0) { brandData = CustomTableItemProvider.GetItem <BrandItem>(QueryHelper.GetInteger("ItemID", 0)); form.Mode = CMS.Base.Web.UI.FormModeEnum.Update; form.Info = brandData; btnSave.Text = ResHelper.GetString("Kadena.CreateBrand.Update"); } else { form.Mode = CMS.Base.Web.UI.FormModeEnum.Insert; form.Info = brandData; btnSave.Text = ResHelper.GetString("Kadena.CreateBrand.Save"); } } }
public IActionResult Edit(BrandItem modell, IFormFile filePath) { if (ModelState.IsValid) { try { if (filePath != null) { modell.TitleImagePath = filePath.FileName; using (var stream = new FileStream(Path.Combine(_hostingEnv.WebRootPath, "img/brands/", filePath.FileName), FileMode.Create)) { filePath.CopyTo(stream); } } _dataManager.BrandItems.SaveBrandItem(modell); return(RedirectToAction(nameof(EditBrandController.Index), nameof(EditBrandController).CutController())); } catch (DbUpdateException e) { ViewBag.Except = true; return(View(modell)); } } return(View(modell)); }
public IActionResult Add() { ViewBag.Except = false; BrandItem brand = new BrandItem(); return(View(brand)); }
private void AddItem(BrandItem item) { if (SearchCriteria != null && Model != null) { SearchCriteria.SelectedBrandItems.Add(item); } }
public string kaola_vender_brand_get(string method, string time)//public List<BrandInfo> GetAllBrand(string method, string time) { StringBuilder sb = new StringBuilder(200); sb.Append("access_token" + str_access_tokenli[2]); //令牌 sb.Append("app_key" + str_app_keyli[2]); //密钥 sb.Append(str_method + method); //调用接口 sb.Append(str_timestamp + time); //时间戳 string s = string.Empty; string app_secret = app_secretli[2]; s = app_secret + sb.ToString() + app_secret; //使用MD5进行加密,再转化成大写 string sign = kaola_sign.To32Md5(s).ToUpper(); //string sign = kaola_sign.signValues(sb.ToString()); //签名 string url = kaola_sign.kaola_Invok_URL(str_access_tokenli[2], str_app_keyli[2], method, sign, time); WebRequest request = (WebRequest)HttpWebRequest.Create(url); //调用接口 WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader read = new StreamReader(stream, Encoding.UTF8); string data = read.ReadToEnd(); BrandModel bi = new BrandModel(); bi = kaola_seralia.ScriptDeserialize <BrandModel>(data); List <BrandInfo> li = new List <BrandInfo>(); BrandItem bim = new BrandItem(); bim = bi.kaola_vender_brand_get_response; li = bim.brand_list; return(data); }
private static string GetBrandCode(string brandName) { string brandCode = string.Empty; BrandItem brand = GetBrand(brandName); if (brand != null) { brandCode = brand.BrandCode.ToString(); } return(brandCode); }
private void OnCheck(RoutedEventArgs e) { CheckBox checkBox = e.OriginalSource as CheckBox; ContentPresenter presenter = checkBox?.TemplatedParent as ContentPresenter; BrandItem item = presenter?.Content as BrandItem; if (item != null) { ViewModel.OnCheck(item); } }
/// <summary>管理员请求创建新品牌的操作处理 /// </summary> /// <returns>创建新品牌的结果</returns> public ActionResult Create(BrandItem brand) { BrandManager.AddNewBrand(brand); if (brand != null) { return(Json(brand)); } else { return(Content("error")); } }
public void SaveBrandItem(BrandItem entity) { if (entity.Id == default) { context.Entry(entity).State = EntityState.Added; } else { context.Entry(entity).State = EntityState.Modified; } context.SaveChanges(); }
/// <summary> /// Add new brand info /// </summary> /// <param name="newBrand">品牌的名称</param> /// <returns>新创建的品牌信息对象</returns> public static BrandItem AddNewBrand(BrandItem newBrand) { using (SolemartDBContext context = new SolemartDBContext()) { context.BrandItems.Add(newBrand); if (context.SaveChanges() > 0) { return(newBrand); } return(null); } }
public void OnCheck(BrandItem item) { if (item.Selected) { AddItem(item); } else { DeleteItem(item); } SearchCriteria.BrandComplited(); }
private int GetBrandID(string brandName) { int brandID = default(int); if (!string.IsNullOrWhiteSpace(brandName)) { BrandItem brand = CustomTableItemProvider.GetItems <BrandItem>().WhereEquals("BrandName", brandName).FirstOrDefault(); if (brand != null) { brandID = brand.ItemID; } } return(brandID); }
public void SelectEntities() { try { if (SearchCriteria != null) { long catalogId = SelectedItem?.Id ?? -1L; Entities.Clear(); if (!SearchCriteria.EnabledAdvancedSearch) { SearchCriteria.SelectedBrandItems.Clear(); SearchCriteria.SelectedDirectoryItems.Clear(); } if (SearchCriteria.IsModified || SearchCriteria.BrandItemIdsChanged || SearchCriteria.DirectoryItemIdsChanged) { count = GetCount(); needToUpdateCount = false; oldExternalBrandItem = ExternalBrandItem; Application.Current.Dispatcher.Invoke( () => { StartRowIndex = 0; OnPropertyChanged(nameof(Count)); }); } if (StartRowIndex < Count) { GetItems(StartRowIndex, MaximumRows).ForEach(x => Entities.Add(x)); CatalogItem catalogItem = Entities.FirstOrDefault(x => x != null && x.Id == catalogId) ?? Entities.FirstOrDefault(); Application.Current.Dispatcher.Invoke( () => { OnPropertyChanged(nameof(Entities)); SelectedItem = catalogItem; SearchCriteria.SearchComplited(); }); } } } catch (Exception e) { ; //TODO Вывести Exception в стилизированное окно ошибок } }
public bool DeleteBrand(int itemID) { var flag = false; try { BrandItem objBrand = new BrandItem(); objBrand = CustomTableItemProvider.GetItems <BrandItem>().WhereEquals("ItemID", itemID); flag = objBrand.Delete(); } catch (Exception ex) { EventLogProvider.LogException("Webservice.asmx.cs", "DeleteBrand()", ex); } return(flag); }
public void SelectEntities() { if (SearchCriteria != null) { try { long brandId = SelectedItem?.Id ?? -1L; Entities.Clear(); LongHolder position = new LongHolder { Value = 0 }; List <BrandItem> loadedEntities = GetItems().Select(x => new BrandItem(x) { Position = position.Value++ }).ToList(); if (SearchCriteria != null) { loadedEntities.ForEach( x => x.Selected = SearchCriteria.SelectedBrandItems.Any(s => s.Id == x.Id && s.Selected)); SearchCriteria.BrandItems = loadedEntities; SearchCriteria.SelectedBrandItems.Clear(); Entities.Where(x => x.Selected).ToList().ForEach(x => SearchCriteria.SelectedBrandItems.Add(x)); } BrandItem brandItem = loadedEntities.FirstOrDefault(x => x != null && x.Id == brandId) ?? Entities.FirstOrDefault(); Application.Current.Dispatcher.Invoke( () => { Entities.AddRange(loadedEntities); OnPropertyChanged(nameof(Entities)); SelectedItem = brandItem; SearchCriteria.BrandComplited(); }); } catch (Exception e) { ; //throw; } } }
/// <summary>更新了品牌的LOGO图片 /// </summary> /// <param name="newBrand">要更新的品牌</param> /// <returns>是否更新成功</returns> public static bool UpdateBrandItem(BrandItem newBrand) { using (SolemartDBContext context = new SolemartDBContext()) { BrandItem oldBrand = context.BrandItems.Find(newBrand.BrandID); if (oldBrand != null) { oldBrand.ZhName = newBrand.ZhName; oldBrand.EnName = newBrand.EnName; oldBrand.BrandLogo = newBrand.BrandLogo; oldBrand.BrandUrl = newBrand.BrandUrl; oldBrand.Description = newBrand.Description; return(context.SaveChanges() > 0); } return(false); } }
public IActionResult GetBrandById(int id) { var brand = new BrandItem(); try { var url = $"{Common.Common.ApiUrl}/Brand/Brand/{id}"; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.Method = "GET"; var response = httpWebRequest.GetResponse(); { string responseData; Stream responseStream = response.GetResponseStream(); try { StreamReader streamReader = new StreamReader(responseStream); try { responseData = streamReader.ReadToEnd(); } finally { ((IDisposable)streamReader).Dispose(); } } finally { ((IDisposable)responseStream)?.Dispose(); } brand = JsonConvert.DeserializeObject <BrandItem>(responseData); } return(Json(new { response = brand, status = 1 })); } catch (Exception ex) { return(new JsonResult(new { status = -1, response = brand })); } }
public void SelectBrandPopupItems() { BrandItems.Clear(); BrandItems.Add(new BrandItem(SearchCriteria.FirstBrandItemEntity)); DataService.Select <BrandItemEntity>() .OrderBy(x => x.Name) .ToList() .ForEach(x => BrandItems.Add(new BrandItem(x))); if (SearchCriteria != null) { BrandItem selectBrandItem = BrandItems.FirstOrDefault(x => x.Id == SearchCriteria.BrandId) ?? BrandItems.FirstOrDefault(); SearchCriteria.BrandId = selectBrandItem?.Id ?? SearchCriteria.FirstBrandItemEntity.Id; SearchCriteria.BrandName = selectBrandItem?.Name ?? SearchCriteria.FirstBrandItemEntity.Name; } }
private static void SavePOS(POSDto posDto) { POSCategoryItem posCategory = GetPOSCategory(posDto.POSCategory); BrandItem brand = GetBrand(posDto.Brand); if (posCategory != null && brand != null) { POSNumberItem pos = new POSNumberItem() { BrandID = brand.BrandCode, BrandName = brand.BrandName, Year = ValidationHelper.GetInteger(posDto.Year, default(int)), POSCode = ValidationHelper.GetString(posDto.POSCode, default(string)), POSNumber = ValidationHelper.GetString(GetPOSNumber(posDto), default(string)), POSCategoryID = posCategory.ItemID, POSCategoryName = posCategory.PosCategoryName }; pos.Insert(); _currentPOSList.Add(pos); } }
private IEnumerable <BrandItem> GetItems(ItemSearch newsearch) { iDB2DataReader readerITM = null; Item item = new Item(); List <BrandItem> itemlist = new List <BrandItem>(); item.List(Request.Cookies["SecToken"]["SecurityKey"], newsearch, ref readerITM); if (readerITM != null) { while (readerITM.Read()) { var newitem = new BrandItem { ItemID = readerITM["ITMITM"].ToString(), Size = readerITM["ITMDSS"].ToString(), ItemDescEng = readerITM["ITMEED"].ToString() }; itemlist.Add(newitem); } } return(itemlist); }
private void DeleteItem(BrandItem item) { SearchCriteria?.SelectedBrandItems?.Remove(item); }
/// <summary> /// 根据brand信息,决定该brand的存储的LOGO文件名 /// </summary> /// <param name="brand"></param> /// <returns></returns> public static string GetLogoFileName(BrandItem brand, string mimetype) { string ext = mimetype.Substring(mimetype.IndexOf('/') + 1); return(string.Format("{0}.{1}", brand.EnName, ext)); }
/// <summary> /// Parse the content of the selected .csv file in the objects of the classes associated with the database /// </summary> public void ParseFile() { using (StreamReader StreamReader = new StreamReader(StrFilePath, Encoding.Default)) { string Line, BrandName = "", FamilyName = "", SubfamilyName = ""; string[] SplitedLine; bool Existence; int BrandReference = 1, FamilyReference = 1, SubfamilyReference = 1, NumberBrands, NumberFamilies, NumberSubfamilies; StreamReader.ReadLine(); // Read the first line of the file // Read all other lines in the file while ((Line = StreamReader.ReadLine()) != null) { SplitedLine = Line.Split(';'); // Item characteristic Existence = false; foreach (Brand Brand in Brands) { if (Brand.GetName() == SplitedLine[2]) { BrandReference = Brand.GetBrandReference(); BrandName = Brand.GetName(); Existence = true; break; } } // Add the brand if it does not already exist if (!Existence) { Brands.Add(new Brand(Brands.Count + 1, SplitedLine[2])); BrandReference = Brands.Count; } Existence = false; foreach (Family Family in Families) { if (Family.GetName() == SplitedLine[3]) { FamilyReference = Family.GetFamilyReference(); FamilyName = Family.GetName(); Existence = true; break; } } // Add the family if it does not already exist if (!Existence) { Families.Add(new Family(Families.Count + 1, SplitedLine[3])); FamilyReference = Families.Count; } Existence = false; foreach (Subfamily Subfamily in Subfamilies) { if (Subfamily.GetName() == SplitedLine[4]) { SubfamilyReference = Subfamily.GetSubfamilyReference(); SubfamilyName = Subfamily.GetName(); Existence = true; break; } } // Add the subfamily if it does not already exist if (!Existence) { Subfamilies.Add(new Subfamily(Subfamilies.Count + 1, FamilyReference, SplitedLine[4])); SubfamilyReference = Subfamilies.Count; } Existence = false; foreach (Item Item in Items) { // Replacing the current item characteristics with these if the item reference already exists if (Item.GetItemReference() == SplitedLine[1]) { Anomalies.Add(Item.GetItemReference()); Item.SetDescription(SplitedLine[0]); Item.SetBrandReference(BrandReference); Item.SetSubfamilyReference(SubfamilyReference); Item.SetPrice(float.Parse(SplitedLine[5])); if (BrandName != SplitedLine[2]) { NumberBrands = 0; foreach (Item BrandItem in Items) { if (BrandItem.GetBrandReference() == BrandReference) { NumberBrands++; } } if (NumberBrands == 0) { foreach (Brand Brand in Brands) { if (Brand.GetBrandReference() == BrandReference) { Brands.Remove(Brand); break; } } } } if (SubfamilyName != SplitedLine[4]) { NumberSubfamilies = 0; foreach (Item SubfamilyItem in Items) { if (SubfamilyItem.GetSubfamilyReference() == SubfamilyReference) { NumberSubfamilies++; } } if (NumberSubfamilies == 0) { foreach (Subfamily Subfamily in Subfamilies) { if (Subfamily.GetSubfamilyReference() == SubfamilyReference) { Subfamilies.Remove(Subfamily); break; } } } } if (FamilyName != SplitedLine[3]) { NumberFamilies = 0; foreach (Subfamily Subfamily in Subfamilies) { if (Subfamily.GetFamilyReference() == FamilyReference) { NumberFamilies++; } } if (NumberFamilies == 0) { foreach (Family Family in Families) { if (Family.GetFamilyReference() == FamilyReference) { Families.Remove(Family); break; } } } } Existence = true; break; } } // Adding the item if the item reference does not yet exist if (!Existence) { Items.Add(new Item(SplitedLine[1], SplitedLine[0], SubfamilyReference, BrandReference, float.Parse(SplitedLine[5]))); } } } }