更新wtm
This commit is contained in:
1 parent
f119665d29
commit
3467d4aa9d
60 files changed
+1932
-397
No files matched your search
@@ -20,7 +20,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
|
||||
public override Stream GetFileData(IWtmFile file)
|
||||
{
|
||||
var rv = _wtm.DC.Set<FileAttachment>().CheckID(file.GetID()).FirstOrDefault();
|
||||
var rv = wtm.DC.Set<FileAttachment>().CheckID(file.GetID()).FirstOrDefault();
|
||||
if (rv != null)
|
||||
{
|
||||
return new MemoryStream((rv as FileAttachment).FileData);
|
||||
@@ -37,7 +37,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
file.UploadTime = DateTime.Now;
|
||||
file.SaveMode = _modeName;
|
||||
file.ExtraInfo = extra;
|
||||
file.TenantCode = _wtm.LoginUserInfo?.CurrentTenant;
|
||||
file.TenantCode = wtm.LoginUserInfo?.CurrentTenant;
|
||||
var ext = string.Empty;
|
||||
if (string.IsNullOrEmpty(fileName) == false)
|
||||
{
|
||||
@@ -50,8 +50,8 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
data.CopyTo(dataStream);
|
||||
file.FileData = dataStream.ToArray();
|
||||
}
|
||||
_wtm.DC.AddEntity(file);
|
||||
_wtm.DC.SaveChanges();
|
||||
wtm.DC.AddEntity(file);
|
||||
wtm.DC.SaveChanges();
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
{
|
||||
public abstract class WtmFileHandlerBase : IWtmFileHandler
|
||||
{
|
||||
protected WTMContext _wtm;
|
||||
public WTMContext wtm;
|
||||
public WtmFileHandlerBase(WTMContext wtm)
|
||||
{
|
||||
_wtm = wtm;
|
||||
this.wtm = wtm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
public IWtmFileHandler CreateFileHandler(string saveMode = null, IDataContext dc = null)
|
||||
{
|
||||
ConstructorInfo ci = null;
|
||||
//if(dc != null)
|
||||
//{
|
||||
// _wtm.DC = dc;
|
||||
//}
|
||||
if (dc != null)
|
||||
{
|
||||
_wtm.DC = dc;
|
||||
}
|
||||
if (string.IsNullOrEmpty(saveMode))
|
||||
{
|
||||
ci = _defaultHandler;
|
||||
@@ -154,8 +154,14 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
}).FirstOrDefault();
|
||||
if (rv != null && withData == true)
|
||||
{
|
||||
var fh = CreateFileHandler(rv.SaveMode, dc);
|
||||
rv.DataStream = fh.GetFileData(rv);
|
||||
try
|
||||
{
|
||||
var fh = CreateFileHandler(rv.SaveMode, dc);
|
||||
rv.DataStream = fh.GetFileData(rv);
|
||||
}
|
||||
catch {
|
||||
rv = null;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
|
||||
public override (string path, string handlerInfo) Upload(string fileName, long fileLength, Stream data, string group = null, string subdir = null, string extra = null)
|
||||
{
|
||||
var localSettings = _wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "local").Select(x => x.Value).FirstOrDefault();
|
||||
var localSettings = wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "local").Select(x => x.Value).FirstOrDefault();
|
||||
|
||||
var groupdir = "";
|
||||
if (string.IsNullOrEmpty(group))
|
||||
@@ -91,7 +91,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
string rv = "";
|
||||
if (path.StartsWith("."))
|
||||
{
|
||||
rv = Path.Combine(_wtm.ConfigInfo.HostRoot, path);
|
||||
rv = Path.Combine(wtm.ConfigInfo.HostRoot, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
|
||||
public override Stream GetFileData(IWtmFile file)
|
||||
{
|
||||
var ossSettings = _wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
var ossSettings = wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
FileHandlerOptions groupInfo = null;
|
||||
if (string.IsNullOrEmpty(file.HandlerInfo))
|
||||
{
|
||||
@@ -60,7 +60,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
ext = fileName.Substring(dotPos + 1);
|
||||
}
|
||||
|
||||
var ossSettings = _wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
var ossSettings = wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
FileHandlerOptions groupInfo = null;
|
||||
if (string.IsNullOrEmpty(group))
|
||||
{
|
||||
@@ -95,8 +95,15 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
}
|
||||
var fullPath = Path.Combine(pathHeader, $"{Guid.NewGuid().ToNoSplitString()}.{ext}");
|
||||
fullPath = fullPath.Replace("\\", "/");
|
||||
var imagetypes = new string[]{ "jpg","jpeg","bmp","tif","gif","png"};
|
||||
ObjectMetadata md = new ObjectMetadata();
|
||||
ext = ext.ToLower();
|
||||
if (imagetypes.Contains(ext))
|
||||
{
|
||||
md.ContentType = "image/jpg";
|
||||
}
|
||||
OssClient client = new OssClient(groupInfo.ServerUrl, groupInfo.Key, groupInfo.Secret);
|
||||
var result = client.PutObject(groupInfo.GroupLocation, fullPath, data);
|
||||
var result = client.PutObject(groupInfo.GroupLocation, fullPath, data,md);
|
||||
if (result.HttpStatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
return (fullPath, groupInfo.GroupName);
|
||||
@@ -109,7 +116,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
|
||||
public override void DeleteFile(IWtmFile file)
|
||||
{
|
||||
var ossSettings = _wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
var ossSettings = wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
FileHandlerOptions groupInfo = null;
|
||||
if (string.IsNullOrEmpty(file.HandlerInfo))
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
}
|
||||
|
||||
[ProviderAlias("WTM")]
|
||||
public class WTMLoggerProvider : ILoggerProvider
|
||||
{
|
||||
private IServiceProvider sp = null;
|
||||
|
||||
Reference in new issue
Block a user