Commit ec8e4ecf by 肖小磊

KFILE

parent 1de86716
......@@ -39,11 +39,11 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="BLToolkit.4">
<HintPath>..\..\FTM.API\packages\BLToolkit.4.dll</HintPath>
<HintPath>..\DLLS\BLToolkit.4.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ICSharpCode.SharpZipLib.dll</HintPath>
<HintPath>..\DLLS\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\FTM.API\FTM.API.Core\bin\Newtonsoft.Json.dll</HintPath>
......
......@@ -99,6 +99,7 @@ namespace FTM.API.Controllers
[Route("Task/CreateDownLoadTask"), HttpPost]
public HttpResponse<bool> CreateDownLoadTask(DownLoadTaskRequest request)
{
Logger.Write(Logger.LoggerLevel.Info, "CreateDownLoadTask come on ");
HttpResponse<bool> response = null;
//if (!ValidateRequest(request))
//{
......@@ -108,11 +109,15 @@ namespace FTM.API.Controllers
{
if (request.TaskID.HasValue && request.TaskID > 0)
{
Logger.Write(Logger.LoggerLevel.Info, "UpdateDownLoadTask");
response = TaskService.UpdateDownLoadTask(request);
}
else
{
Logger.Write(Logger.LoggerLevel.Info, "CreateDownLoadTask->TaskService is null?" + (TaskService == null));
response = TaskService.CreateDownLoadTask(request);
Logger.Write(Logger.LoggerLevel.Info, "response:" + response.ErrorMessage + response.Data);
}
UnzipFile(request);
}
......@@ -121,7 +126,10 @@ namespace FTM.API.Controllers
//TODO Logger.Write
//Logger.Write(Logger.LoggerLevel.Error, ee.ToString());
response = new HttpResponse<bool> { ErrorMessage = "system error," + ee.Message, StatusCode = StateCode.SystemError, Data = false };
Logger.Write(Logger.LoggerLevel.Info, "Exception:" + ee.ToString());
}
Logger.Write(Logger.LoggerLevel.Info, "end:");
Logger.Write(Logger.LoggerLevel.Info, "response:" + response.ErrorMessage + response.Data);
return response;
}
......@@ -301,7 +309,7 @@ namespace FTM.API.Controllers
{
if (reqeust.Type == (int)TaskType.Remforpos || reqeust.Type == (int)TaskType.NGCOD)
{
string filepath= "";
string filepath = "";
if (!string.IsNullOrEmpty(reqeust.HttpFilePath))
{
filepath = reqeust.HttpFilePath;
......
......@@ -29,6 +29,7 @@
<SccAuxPath>Svn</SccAuxPath>
<SccProvider>SubversionScc</SccProvider>
<TargetFrameworkProfile />
<Use64BitIISExpress />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -61,10 +62,10 @@
<Private>True</Private>
</Reference>
<Reference Include="BLToolkit.4">
<HintPath>..\..\FTM.API\FTM.API.Core\bin\BLToolkit.4.dll</HintPath>
<HintPath>..\DLLS\BLToolkit.4.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>D:\360安全浏览器下载\SharpZipLib\SharpZipLib\net-11\ICSharpCode.SharpZipLib.dll</HintPath>
<HintPath>..\DLLS\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
......
......@@ -31,7 +31,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\packages\ICSharpCode.SharpZipLib.dll</HintPath>
<HintPath>..\DLLS\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
......
......@@ -39,6 +39,11 @@ namespace FTM.Http.Request
public string FilePath { get; set; }
/// <summary>
/// K#图片下载路径
/// </summary>
public string KFilePath { get; set; }
/// <summary>
/// 终端列表
/// </summary>
public List<Pos> Clients { get; set; }
......
......@@ -44,6 +44,16 @@ namespace FTM.Model
public string FilePath { get; set; }
/// <summary>
/// K#下载文件地址
/// </summary>
public string KFilePath { get; set; }
/// <summary>
/// K#下载合并文件地址
/// </summary>
public string KFilePathMerge { get; set; }
/// <summary>
/// 文件 HASH值
/// </summary>
public string FileHash { get; set; }
......
......@@ -31,7 +31,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="BLToolkit.4">
<HintPath>..\packages\BLToolkit.4.dll</HintPath>
<HintPath>..\DLLS\BLToolkit.4.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......
......@@ -31,7 +31,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="BLToolkit.4">
<HintPath>..\packages\BLToolkit.4.dll</HintPath>
<HintPath>..\DLLS\BLToolkit.4.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
......
......@@ -289,8 +289,10 @@ namespace FTM.Service
public HttpResponse<bool> CreateDownLoadTask(DownLoadTaskRequest request)
{
Logger.Write(Logger.LoggerLevel.Info, "CreateDownLoadTask IN");
if (request.Type == (int)TaskType.ScreenSync)
{
Logger.Write(Logger.LoggerLevel.Info, "系统已存在键位同步任务");
return new HttpResponse<bool> { ErrorMessage = "系统已存在键位同步任务,不允许再次创建", StatusCode = StateCode.ParamError };
}
......@@ -317,13 +319,57 @@ namespace FTM.Service
DownLoadTask.HttpFileHash = request.HttpFileHash;
DownLoadTask.HttpFilePath = request.HttpFilePath;
DownLoadTask.CustomID = request.CustomID;
DownLoadTask.KFilePath = request.KFilePath;
Logger.Write(Logger.LoggerLevel.Info, request.FilePath + string.IsNullOrEmpty(request.FilePath));
if (!string.IsNullOrWhiteSpace(request.FilePath))
{
Logger.Write(Logger.LoggerLevel.Info, "NOT NULL");
long fileSize = 0;
var md5 = FileProcess(request.Type, request.FilePath, out fileSize);
DownLoadTask.FileHash = md5;
DownLoadTask.FileSize = fileSize;
//如果是SOK图片下放,则要看是否有K#文件上传,如果有,则要将K#文件与上传的文件合并
if (request.Type == (int)TaskType.SOK1Update && !string.IsNullOrWhiteSpace(request.KFilePath))
{
//1.创建合并的文件夹
string mergeDir = Guid.NewGuid().ToString();
string kfileDir = "/Uploadfiles/kfiles";
string realKfiles = HttpContext.Current.Server.MapPath(kfileDir);
string merger_dir_full = string.Format("/Uploadfiles/{0}", mergeDir);
string real_dir_full = HttpContext.Current.Server.MapPath(merger_dir_full);
Logger.Write(Logger.LoggerLevel.Info, "real_dir_full:" + real_dir_full);
if (!Directory.Exists(real_dir_full))
{
Directory.CreateDirectory(real_dir_full);
}
if (!Directory.Exists(realKfiles))
{
Directory.CreateDirectory(realKfiles);
}
//2.复制待压缩的2个文件到合并的文件夹
string sourceFilePath = HttpContext.Current.Server.MapPath("/" + request.FilePath);
string desFilePath = HttpContext.Current.Server.MapPath(string.Format("{0}/{1}", merger_dir_full, Path.GetFileName(request.FilePath)));
Logger.Write(Logger.LoggerLevel.Info, "sourceFilePath:" + sourceFilePath + ",desFilePath:" + desFilePath);
File.Copy(sourceFilePath, desFilePath, true);
string sourceKFilePath = HttpContext.Current.Server.MapPath("/" + request.KFilePath);
string desKFilePath = HttpContext.Current.Server.MapPath(string.Format("{0}/k{1}", merger_dir_full, Path.GetExtension(request.KFilePath)));
Logger.Write(Logger.LoggerLevel.Info, "sourceKFilePath:" + sourceKFilePath + ",desKFilePath:" + desKFilePath);
File.Copy(sourceKFilePath, desKFilePath, true);
//3.压缩合并的文件夹
string zipFileName = HttpContext.Current.Server.MapPath(string.Format("/Uploadfiles/kfiles/{0}.zip", mergeDir));
Logger.Write(Logger.LoggerLevel.Info, "zipFileName:" + zipFileName);
ZipClass.ZipNo(real_dir_full, zipFileName);
var md5 = FileProcess(request.Type, string.Format("Uploadfiles/kfiles/{0}.zip", mergeDir), out fileSize);
DownLoadTask.FileHash = md5;
DownLoadTask.FileSize = fileSize;
}
else
{
var md5 = FileProcess(request.Type, request.FilePath, out fileSize);
DownLoadTask.FileHash = md5;
DownLoadTask.FileSize = fileSize;
}
}
DownLoadTask.CreateUser = UserUtility.CurrentUser.UserID;
DownLoadTask.EditUser = UserUtility.CurrentUser.UserID;
......@@ -395,11 +441,11 @@ namespace FTM.Service
//TODO DBLogManager.LogEvent
//DBLogManager.LogEvent("创建任务", string.Format("任务名称:{0}", request.Name));
if (TaskRepository.CreateDownLoadTask(DownLoadTask))
{
UnzipFile(request);
return new HttpResponse<bool> { Data = true };
}
//if (TaskRepository.CreateDownLoadTask(DownLoadTask))
//{
// UnzipFile(request);
// return new HttpResponse<bool> { Data = true };
//}
}
catch (Exception ex)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment