|
@@ -8,26 +8,22 @@
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
using System;
|
|
using System;
|
|
-using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
-using System.Net;
|
|
|
|
using System.Net.Cache;
|
|
using System.Net.Cache;
|
|
using System.Text;
|
|
using System.Text;
|
|
-using System.Threading.Tasks;
|
|
|
|
using System.Windows;
|
|
using System.Windows;
|
|
-using System.Windows.Controls;
|
|
|
|
using System.Windows.Media;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Media.Imaging;
|
|
using Com.FirmLib.Bll;
|
|
using Com.FirmLib.Bll;
|
|
using Com.FirmLib.Entity;
|
|
using Com.FirmLib.Entity;
|
|
using Com.FirmLib.UI.Manufacturer.Model;
|
|
using Com.FirmLib.UI.Manufacturer.Model;
|
|
using FirmHttpDao;
|
|
using FirmHttpDao;
|
|
-using FWindSoft.Data;
|
|
|
|
using FWindSoft.DataFramework;
|
|
using FWindSoft.DataFramework;
|
|
using FWindSoft.MVVM;
|
|
using FWindSoft.MVVM;
|
|
using FWindSoft.Wpf;
|
|
using FWindSoft.Wpf;
|
|
using Microsoft.Win32;
|
|
using Microsoft.Win32;
|
|
|
|
+using SAGA.DotNetUtils.Data;
|
|
|
|
|
|
namespace Com.FirmLib.UI.Manufacturer
|
|
namespace Com.FirmLib.UI.Manufacturer
|
|
{
|
|
{
|
|
@@ -38,10 +34,9 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
{
|
|
{
|
|
Init();
|
|
Init();
|
|
}
|
|
}
|
|
-
|
|
|
|
private void Init()
|
|
private void Init()
|
|
{
|
|
{
|
|
- LogoKey = new NameValueItem<string>();
|
|
|
|
|
|
+ InputFile = new InputFile<UrlFile>();
|
|
//为空可能引发遮罩异常
|
|
//为空可能引发遮罩异常
|
|
ImageBrush = new ImageBrush();
|
|
ImageBrush = new ImageBrush();
|
|
}
|
|
}
|
|
@@ -55,7 +50,6 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
ManufacturerId = para.ManufacturerId;
|
|
ManufacturerId = para.ManufacturerId;
|
|
BrandId = para.Id;
|
|
BrandId = para.Id;
|
|
BranchName = para.Name;
|
|
BranchName = para.Name;
|
|
- //TODO 图片信息处理
|
|
|
|
}
|
|
}
|
|
LoadBrandItem(ManufacturerId, BrandId);
|
|
LoadBrandItem(ManufacturerId, BrandId);
|
|
}
|
|
}
|
|
@@ -76,9 +70,9 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 图片编码
|
|
|
|
|
|
+ /// 上传文件输入
|
|
/// </summary>
|
|
/// </summary>
|
|
- public NameValueItem<string> LogoKey { get;private set; }
|
|
|
|
|
|
+ public InputFile<UrlFile> InputFile { get;private set; }
|
|
|
|
|
|
private ImageBrush m_ImageBrush;
|
|
private ImageBrush m_ImageBrush;
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -107,8 +101,6 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
/// </summary>
|
|
/// </summary>
|
|
public string BrandId { get; private set; }
|
|
public string BrandId { get; private set; }
|
|
#region 命令相关
|
|
#region 命令相关
|
|
-
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 上传图片
|
|
/// 上传图片
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -134,11 +126,10 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
}
|
|
}
|
|
BitmapSource imageSource = (BitmapSource)isConverter.ConvertFrom(bytes);
|
|
BitmapSource imageSource = (BitmapSource)isConverter.ConvertFrom(bytes);
|
|
ImageBrush = null;
|
|
ImageBrush = null;
|
|
- //ImageBrush =
|
|
|
|
- // new ImageBrush((ImageSource)isConverter.ConvertFrom(bytes));
|
|
|
|
ImageBrush = new ImageBrush(ImageUtil.GetCenterCropped(imageSource));
|
|
ImageBrush = new ImageBrush(ImageUtil.GetCenterCropped(imageSource));
|
|
- LogoKey.Value = fileName;
|
|
|
|
- LogoKey.Tag = bytes;
|
|
|
|
|
|
+ InputFile.Path = fileName;
|
|
|
|
+ InputFile.Content = bytes;
|
|
|
|
+ InputFile.AcceptContent();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -184,7 +175,6 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
[Command]
|
|
[Command]
|
|
public void AddProductCommand(object parameter)
|
|
public void AddProductCommand(object parameter)
|
|
{
|
|
{
|
|
-
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
if (!AddBrand())
|
|
if (!AddBrand())
|
|
@@ -203,8 +193,6 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
{
|
|
{
|
|
return IsValidated;
|
|
return IsValidated;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 删除命令
|
|
/// 删除命令
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -212,7 +200,6 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
[Command]
|
|
[Command]
|
|
public void DeleteCommand(object parameter)
|
|
public void DeleteCommand(object parameter)
|
|
{
|
|
{
|
|
-
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
if (!DeleteBrand())
|
|
if (!DeleteBrand())
|
|
@@ -231,7 +218,6 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
#endregion
|
|
#endregion
|
|
#region 私有方法
|
|
#region 私有方法
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -287,7 +273,6 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//管理图片信息
|
|
//管理图片信息
|
|
public void LoadBrandItem(string venderId,string brandId)
|
|
public void LoadBrandItem(string venderId,string brandId)
|
|
{
|
|
{
|
|
@@ -296,13 +281,12 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
var brandItem=BllFactory<BrandBll>.Instance.GetItem(venderId, brandId);
|
|
var brandItem=BllFactory<BrandBll>.Instance.GetItem(venderId, brandId);
|
|
if (brandItem == null)
|
|
if (brandItem == null)
|
|
return;
|
|
return;
|
|
- LogoKey.Name=brandItem.LogoKey;
|
|
|
|
- if (!string.IsNullOrEmpty(brandItem.LogoKey))
|
|
|
|
|
|
+ InputFile.Key=brandItem.LogoKey;
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(brandItem.LogoKey))
|
|
{
|
|
{
|
|
- //todo 调用接口加载图片信息
|
|
|
|
-
|
|
|
|
- string imageUrl = BllFactory<FileBll>.Instance.CreateImageUrl(BllHttpSetting.Instance.Default, brandItem.LogoKey);
|
|
|
|
-
|
|
|
|
|
|
+ var urlFile = UrlFileKeyParse.ParseKey(InputFile.Key);
|
|
|
|
+ InputFile.KeyEntity = urlFile;
|
|
|
|
+ string imageUrl = BllFactory<FileBll>.Instance.CreateImageUrl(FileUrlValidateFactory.Create(urlFile.SystemId),urlFile.Key);
|
|
BitmapSource bitmap = null;
|
|
BitmapSource bitmap = null;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -323,7 +307,6 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
bitmap = new BitmapImage(new Uri(imageUrl), new RequestCachePolicy(RequestCacheLevel.Reload));
|
|
bitmap = new BitmapImage(new Uri(imageUrl), new RequestCachePolicy(RequestCacheLevel.Reload));
|
|
}
|
|
}
|
|
ImageBrush = null;
|
|
ImageBrush = null;
|
|
- // ImageBrush = new ImageBrush(bitmap);
|
|
|
|
ImageBrush = new ImageBrush(bitmap);
|
|
ImageBrush = new ImageBrush(bitmap);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -331,27 +314,43 @@ namespace Com.FirmLib.UI.Manufacturer
|
|
|
|
|
|
public string GetLogoKey()
|
|
public string GetLogoKey()
|
|
{
|
|
{
|
|
- /*
|
|
|
|
- name 存储键值,value 存路径
|
|
|
|
- */
|
|
|
|
- var bytes = LogoKey.Tag as byte[];
|
|
|
|
- if (bytes == null)
|
|
|
|
- {
|
|
|
|
- //如果没有图片的加载路径,则返回默认的键值(空,或者修改前)
|
|
|
|
- return LogoKey.Name ?? string.Empty;
|
|
|
|
- }
|
|
|
|
- //如果存在路径信息,则需要上传图片,键值为null的话创建新的键值
|
|
|
|
- string logoKey = LogoKey.Name;
|
|
|
|
- if (string.IsNullOrEmpty(logoKey))
|
|
|
|
|
|
+ if (InputFile.UpdateStatus == 0)
|
|
{
|
|
{
|
|
- logoKey = BllFactory<FileBll>.Instance.CreateKey(ManufacturerId);
|
|
|
|
|
|
+ return InputFile.Key ?? string.Empty;
|
|
}
|
|
}
|
|
- var flag=BllFactory<FileBll>.Instance.UploadImage(BllHttpSetting.Instance.Default,logoKey, bytes);
|
|
|
|
- if (!flag)
|
|
|
|
|
|
+ string fileKey = InputFile.KeyEntity?.Key;
|
|
|
|
+ if (InputFile.Content != null)
|
|
{
|
|
{
|
|
- MessageTip.Show(this.GetWindow(), BllFactory<FileBll>.Instance.ErrorMessage ?? string.Empty);
|
|
|
|
- }
|
|
|
|
- return logoKey;
|
|
|
|
|
|
+ if (string.IsNullOrWhiteSpace(fileKey))
|
|
|
|
+ {
|
|
|
|
+ fileKey = new TimeKeyBuilder().CreateKey();
|
|
|
|
+ #region 扩展名处理
|
|
|
|
+ if (!string.IsNullOrEmpty(InputFile.Path))
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ fileKey += Path.GetExtension(InputFile.Path);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var urlFile = UrlFileKeyParse.CreateImageUrlFile(fileKey);
|
|
|
|
+ var flag = BllFactory<FileBll>.Instance.UploadImage(FileUrlValidateFactory.Create(urlFile.SystemId), urlFile.Key, InputFile.Content);
|
|
|
|
+ if (!flag)
|
|
|
|
+ {
|
|
|
|
+ MessageTip.Show(this.GetWindow(), BllFactory<FileBll>.Instance.ErrorMessage ?? string.Empty);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ InputFile.KeyEntity = urlFile;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return UrlFileKeyParse.CreatKey(InputFile.KeyEntity);
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
#endregion
|