You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.3 KiB
58 lines
1.3 KiB
using EC.Entity.Transport;
|
|
using EC.Service.Base;
|
|
using EC.Utils;
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace EC.Service.Transport
|
|
{
|
|
public class PhotoService : MvcService<PhotoEntity>
|
|
{
|
|
public PhotoService()
|
|
{
|
|
}
|
|
|
|
#region BLL
|
|
|
|
public PhotoEntity InsertPhoto(string path, int type)
|
|
{
|
|
//保存图片信息
|
|
var entity = new PhotoEntity
|
|
{
|
|
SerialNumber = Guid.NewGuid().ToString(),
|
|
Type = type,
|
|
Path = path,
|
|
CreateTime = DateTime.Now
|
|
};
|
|
Insert(entity);
|
|
return entity;
|
|
}
|
|
|
|
#endregion BLL
|
|
|
|
#region Extend
|
|
|
|
/// <summary>
|
|
/// 获取保存路径
|
|
/// </summary>
|
|
/// <param name="license">车牌号</param>
|
|
/// <returns></returns>
|
|
public static string GetSaveImagePath(string license)
|
|
{
|
|
var now = DateTime.Now;
|
|
var workPath = EnvUtil.GetWorkDirectory();
|
|
var subPath = Path.Combine(new string[] { "cap", now.ToString("yyyy"), now.ToString("MM"), now.ToString("dd") });
|
|
//var subPath = Path.Combine("cap", now.ToString("yyyy-MM-dd"));
|
|
var fileFolder = Path.Combine(workPath, subPath);
|
|
if (!Directory.Exists(fileFolder))
|
|
{
|
|
Directory.CreateDirectory(fileFolder);
|
|
}
|
|
var fileName = $"{now:HHmmssffff}_{license}.jpg";
|
|
var path = Path.Combine(fileFolder, fileName);
|
|
return path;
|
|
}
|
|
|
|
#endregion Extend
|
|
}
|
|
}
|