/// <summary> /// 选择文件 /// </summary> public void SelectFiles() { var openFileDialog = new OpenFileDialog { Multiselect = true }; if (!string.IsNullOrEmpty(StaticConfiguration.FileFilter)) { openFileDialog.Filter = StaticConfiguration.FileFilter; } if (openFileDialog.ShowDialog() == true) { foreach (FileInfo fileInfo in openFileDialog.Files) { var tempEntity = GetProductResourcesVM(fileInfo); if (tempEntity.ImageSize == 0) { continue; } if (_productResources == null) { _productResources = new ProductResourcesManagementVM { ResourceCollection = new ProductResourcesCollection() }; } _productResources.ResourceCollection.Add(tempEntity); } } }
private void BindPage(int sysNo) { if (sysNo > 0) { _productFacade = new ProductFacade(); _productFacade.GetProductGroup(sysNo, (o, group) => { if (group.FaultsHandle()) { return; } if (group.Result.SysNo != null) { _groupSysNo = group.Result.SysNo.Value; } }); _productFacade.GetProductInfo(sysNo, (obj, args) => { if (args.FaultsHandle()) { return; } if (args.Result == null || args.Result.ProductBasicInfo == null || args.Result.ProductCommonInfoSysNo == null || args.Result.ProductCommonInfoSysNo.Value <= 0) { Window.MessageBox.Show("获取商品资源信息失败.", MessageBoxType.Warning); return; } Panel_ProductDesc.Visibility = Visibility.Visible; var vm = args.Result.Convert <ProductInfo, ProductResourcesManagementVM>((v, t) => { t.PromotionTitle = v.PromotionTitle == null || string.IsNullOrWhiteSpace(args.Result.PromotionTitle.Content) ? args.Result.ProductName : args.Result.PromotionTitle.Content; t.ProductModel = v.ProductBasicInfo.ProductModel == null ? "" : args.Result.ProductBasicInfo.ProductModel.Content; }); vm.ProductResources = args.Result.ProductBasicInfo.ProductResources; vm.ProductCommonInfoSysNo = args.Result.ProductCommonInfoSysNo.Value; vm.CommonSKUNumber = args.Result.ProductBasicInfo.CommonSkuNumber; vm.ResourceCollection = new ProductResourcesCollection(); vm.ProductSysNo = sysNo; _productResourcesVM = vm; if (vm.ProductResources.Any()) { string websiteProductImgUrl = this.Window.Configuration.GetConfigValue(ConstValue.DomainName_ExternalSYS, ConstValue.ConfigKey_External_WebsiteProductImageUrl); string websiteProductOtherImgUrl = this.Window.Configuration.GetConfigValue(ConstValue.DomainName_ExternalSYS, ConstValue.ConfigKey_External_WebsiteProductOtherImageUrl); vm.ProductResources.ForEach(v => { v.Resource.TemporaryName = v.Resource.ResourceURL; v.ProductCommonInfoSysNo = vm.ProductCommonInfoSysNo; if (v.Resource.Type == ResourcesType.Image) { //Ocean.20130514, Move ImgUrl to ControlMenuConfiguration v.Resource.ResourceURL = websiteProductImgUrl + v.Resource.ResourceURL; } else { //Ocean.20130514, Move ImgUrl to ControlMenuConfiguration v.Resource.ResourceURL = websiteProductOtherImgUrl + v.Resource.ResourceURL; } }); SetResourcesStatus(); vm.ProductResources = vm.ProductResources.Where(p => p.Resource.Type == ResourcesType.Image).ToList(); } DataContext = vm; _productResourcesVM.IsNeedWatermark = true; StackPanelEdit.Visibility = Visibility.Visible; StackPanelAdd.Visibility = Visibility.Collapsed; }); } else { Panel_ProductDesc.Visibility = Visibility.Collapsed; var vm = new ProductResourcesManagementVM { ResourceCollection = new ProductResourcesCollection() }; _productResourcesVM = vm; DataContext = vm; StackPanelEdit.Visibility = Visibility.Collapsed; StackPanelAdd.Visibility = Visibility.Visible; _productResourcesVM.IsNeedWatermark = true; } }
public ProductResourcesManagementFacade(ProductResourcesManagementVM entity) { _productResources = entity; _restClient = new RestClient(ServiceBaseUrl); }