|
@@ -524,7 +524,6 @@ namespace Agent.Services
|
|
if (!File.Exists(policy.Path))
|
|
if (!File.Exists(policy.Path))
|
|
{
|
|
{
|
|
log.Error($"[FILE]백업 대상이 경로에 없음 (PolicyTid={policy.Tid})");
|
|
log.Error($"[FILE]백업 대상이 경로에 없음 (PolicyTid={policy.Tid})");
|
|
-
|
|
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -532,7 +531,6 @@ namespace Agent.Services
|
|
if (null == policyDirectoryPathId)
|
|
if (null == policyDirectoryPathId)
|
|
{
|
|
{
|
|
log.Error($"[FILE]정책 디렉터리 생성 실패 (PolicyTid={policy.Tid})");
|
|
log.Error($"[FILE]정책 디렉터리 생성 실패 (PolicyTid={policy.Tid})");
|
|
-
|
|
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -545,19 +543,21 @@ namespace Agent.Services
|
|
var policyIndex = GetPolicyIndex(con, transaction, policy.Tid, policy.Path);
|
|
var policyIndex = GetPolicyIndex(con, transaction, policy.Tid, policy.Path);
|
|
if (null == policyIndex)
|
|
if (null == policyIndex)
|
|
{
|
|
{
|
|
|
|
+ transaction.Rollback();
|
|
log.Error($"[FILE]인덱스 생성 실패 (PolicyTid={policy.Tid})");
|
|
log.Error($"[FILE]인덱스 생성 실패 (PolicyTid={policy.Tid})");
|
|
-
|
|
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- if (isHashCheck && FileUploadHashChk(con, transaction, policy.Tid, policyIndex.Tid, policyIndex.Path))
|
|
|
|
|
|
+ if (isHashCheck && FileUploadHashChk(con, transaction, policy.Tid, policyIndex.Tid, policyIndex.Path, policyIndex.Name))
|
|
{
|
|
{
|
|
|
|
+ transaction.Rollback();
|
|
log.Info($"[FILE]중복 업로드 제한 (PolicyTid={policy.Tid})");
|
|
log.Info($"[FILE]중복 업로드 제한 (PolicyTid={policy.Tid})");
|
|
return 2;
|
|
return 2;
|
|
}
|
|
}
|
|
|
|
|
|
if (isLimit && FileUploadLimitChk(con, transaction, policyIndex.Path, policy.Tid, policyIndex.Tid))
|
|
if (isLimit && FileUploadLimitChk(con, transaction, policyIndex.Path, policy.Tid, policyIndex.Tid))
|
|
{
|
|
{
|
|
|
|
+ transaction.Rollback();
|
|
log.Info($"[FILE]대용량 업로드 일일 제한 (PolicyTid={policy.Tid})");
|
|
log.Info($"[FILE]대용량 업로드 일일 제한 (PolicyTid={policy.Tid})");
|
|
return 3;
|
|
return 3;
|
|
}
|
|
}
|
|
@@ -565,18 +565,19 @@ namespace Agent.Services
|
|
var policyHistoryDirectoryPathId = _fileTableService.CreateDirectory(con, transaction, policyDirectoryPathId);
|
|
var policyHistoryDirectoryPathId = _fileTableService.CreateDirectory(con, transaction, policyDirectoryPathId);
|
|
if (null == policyHistoryDirectoryPathId)
|
|
if (null == policyHistoryDirectoryPathId)
|
|
{
|
|
{
|
|
|
|
+ transaction.Rollback();
|
|
log.Error($"[FILE]정책 히스토리 디렉터리 생성 실패 (PolicyTid={policy.Tid}");
|
|
log.Error($"[FILE]정책 히스토리 디렉터리 생성 실패 (PolicyTid={policy.Tid}");
|
|
-
|
|
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
var fileStreamId = _fileTableService.UploadFile(con, transaction, policyIndex.Path, policyHistoryDirectoryPathId);
|
|
var fileStreamId = _fileTableService.UploadFile(con, transaction, policyIndex.Path, policyHistoryDirectoryPathId);
|
|
if (Guid.Empty == fileStreamId)
|
|
if (Guid.Empty == fileStreamId)
|
|
{
|
|
{
|
|
|
|
+ transaction.Rollback();
|
|
log.Error($"[FILE]백업 대상 업로드에 실패 (PolicyTid={policy.Tid})");
|
|
log.Error($"[FILE]백업 대상 업로드에 실패 (PolicyTid={policy.Tid})");
|
|
-
|
|
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+
|
|
//var info = new FileInfo(policy.Path);
|
|
//var info = new FileInfo(policy.Path);
|
|
//policy.Create_Date = info.LastWriteTime;
|
|
//policy.Create_Date = info.LastWriteTime;
|
|
|
|
|
|
@@ -594,7 +595,6 @@ namespace Agent.Services
|
|
}
|
|
}
|
|
|
|
|
|
transaction.Commit();
|
|
transaction.Commit();
|
|
-
|
|
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -707,16 +707,31 @@ namespace Agent.Services
|
|
var info = new FileInfo(file);
|
|
var info = new FileInfo(file);
|
|
|
|
|
|
policyCreate_Date = info.LastWriteTime;
|
|
policyCreate_Date = info.LastWriteTime;
|
|
- String[] strfileName = fileName.Split('_');
|
|
|
|
- if (strfileName.Length > 2)
|
|
|
|
|
|
+
|
|
|
|
+ // 데이터베이스에 넣기전 파싱하는 부분 (시험번호, 사용자) 명명규칙
|
|
|
|
+
|
|
|
|
+ string sFiletype = fileName.Substring(fileName.LastIndexOf('.') + 1);
|
|
|
|
+
|
|
|
|
+ if (sFiletype == "pdf")
|
|
{
|
|
{
|
|
- policyWork_Emp = strfileName[0].ToString();
|
|
|
|
- policyTest_No = strfileName[1].ToString();
|
|
|
|
- }else
|
|
|
|
|
|
+ String[] strfileName = fileName.Split('_');
|
|
|
|
+ if (strfileName.Length > 2)
|
|
|
|
+ {
|
|
|
|
+ policyWork_Emp = strfileName[0].ToString();
|
|
|
|
+ policyTest_No = strfileName[1].ToString();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ policyWork_Emp = null;
|
|
|
|
+ policyTest_No = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
policyWork_Emp = null;
|
|
policyWork_Emp = null;
|
|
policyTest_No = null;
|
|
policyTest_No = null;
|
|
}
|
|
}
|
|
|
|
+
|
|
//성공
|
|
//성공
|
|
int result = BackupDirectoryPolicyChild(file, directoryPath, policyTid, policyEquip_Cd, policyTest_No, policyCreate_Date, policyWork_Emp, isHashCheck, isLimit);
|
|
int result = BackupDirectoryPolicyChild(file, directoryPath, policyTid, policyEquip_Cd, policyTest_No, policyCreate_Date, policyWork_Emp, isHashCheck, isLimit);
|
|
if (0 < result)
|
|
if (0 < result)
|
|
@@ -727,10 +742,10 @@ namespace Agent.Services
|
|
_reportService.AddBackupReport(policyTid, fileName, file, true);
|
|
_reportService.AddBackupReport(policyTid, fileName, file, true);
|
|
}
|
|
}
|
|
|
|
|
|
- if (2 == result || 3 == result)
|
|
|
|
- {
|
|
|
|
- results.Duplicate++;
|
|
|
|
- }
|
|
|
|
|
|
+ //if (2 == result || 3 == result)
|
|
|
|
+ //{
|
|
|
|
+ // results.Duplicate++;
|
|
|
|
+ //}
|
|
|
|
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -738,28 +753,28 @@ namespace Agent.Services
|
|
//실패
|
|
//실패
|
|
_reportService.AddBackupReport(policyTid, fileName, file, false);
|
|
_reportService.AddBackupReport(policyTid, fileName, file, false);
|
|
|
|
|
|
- //재시도 (재시도 옵션 활성화)
|
|
|
|
- result = BackupDirectoryPolicyChild(file, directoryPath, policyTid, policyEquip_Cd, policyTest_No, policyCreate_Date, policyWork_Emp, isHashCheck, isLimit);
|
|
|
|
- if (isRetry && 0 < result)
|
|
|
|
- {
|
|
|
|
- results.Success++;
|
|
|
|
- _reportService.AddRetryReport(policyTid, fileName, file, true);
|
|
|
|
|
|
+ ////재시도 (재시도 옵션 활성화)
|
|
|
|
+ //result = BackupDirectoryPolicyChild(file, directoryPath, policyTid, policyEquip_Cd, policyTest_No, policyCreate_Date, policyWork_Emp, isHashCheck, isLimit);
|
|
|
|
+ //if (isRetry && 0 < result)
|
|
|
|
+ //{
|
|
|
|
+ // results.Success++;
|
|
|
|
+ // _reportService.AddRetryReport(policyTid, fileName, file, true);
|
|
|
|
|
|
- if (2 == result || 3 == result)
|
|
|
|
- {
|
|
|
|
- results.Duplicate++;
|
|
|
|
- }
|
|
|
|
|
|
+ // if (2 == result || 3 == result)
|
|
|
|
+ // {
|
|
|
|
+ // results.Duplicate++;
|
|
|
|
+ // }
|
|
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ // continue;
|
|
|
|
+ //}
|
|
|
|
|
|
- //재시도 실패 (재시도 옵션 활성화)
|
|
|
|
- if (isRetry)
|
|
|
|
- {
|
|
|
|
- _reportService.AddRetryReport(policyTid, fileName, file, false);
|
|
|
|
|
|
+ ////재시도 실패 (재시도 옵션 활성화)
|
|
|
|
+ //if (isRetry)
|
|
|
|
+ //{
|
|
|
|
+ // _reportService.AddRetryReport(policyTid, fileName, file, false);
|
|
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ // continue;
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
|
|
|
|
var directories = Directory.GetDirectories(srcPath).ToList();
|
|
var directories = Directory.GetDirectories(srcPath).ToList();
|
|
@@ -819,7 +834,7 @@ namespace Agent.Services
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- if (isHashCheck && FileUploadHashChk(con, transaction, policyTid, policyIndex.Tid, filePath))
|
|
|
|
|
|
+ if (isHashCheck && FileUploadHashChk(con, transaction, policyTid, policyIndex.Tid, filePath, policyIndex.Name))
|
|
{
|
|
{
|
|
transaction.Rollback();
|
|
transaction.Rollback();
|
|
log.Info($"[DIRECTORY]중복 업로드 제한 (PolicyTid={policyTid})");
|
|
log.Info($"[DIRECTORY]중복 업로드 제한 (PolicyTid={policyTid})");
|
|
@@ -1089,12 +1104,26 @@ namespace Agent.Services
|
|
var info = new FileInfo(policy.Path);
|
|
var info = new FileInfo(policy.Path);
|
|
|
|
|
|
policy.Create_Date = info.LastWriteTime;
|
|
policy.Create_Date = info.LastWriteTime;
|
|
- String[] strfileName = fileName.Split('_');
|
|
|
|
- if (strfileName.Length > 2)
|
|
|
|
|
|
+
|
|
|
|
+ // 데이터베이스에 넣기전 파싱하는 부분 (시험번호, 사용자) 명명규칙
|
|
|
|
+
|
|
|
|
+ string sFiletype = fileName.Substring(fileName.LastIndexOf('.') + 1);
|
|
|
|
+
|
|
|
|
+ if (sFiletype == "pdf")
|
|
{
|
|
{
|
|
- policy.Work_Emp = strfileName[0].ToString();
|
|
|
|
- policy.Test_No = strfileName[1].ToString();
|
|
|
|
- }else
|
|
|
|
|
|
+ String[] strfileName = fileName.Split('_');
|
|
|
|
+ if (strfileName.Length > 2)
|
|
|
|
+ {
|
|
|
|
+ policy.Work_Emp = strfileName[0].ToString();
|
|
|
|
+ policy.Test_No = strfileName[1].ToString();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ policy.Work_Emp = null;
|
|
|
|
+ policy.Test_No = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
policy.Work_Emp = null;
|
|
policy.Work_Emp = null;
|
|
policy.Test_No = null;
|
|
policy.Test_No = null;
|
|
@@ -1115,22 +1144,22 @@ namespace Agent.Services
|
|
//실패
|
|
//실패
|
|
_reportService.AddBackupReport(policy.Tid, fileName, policy.Path, false);
|
|
_reportService.AddBackupReport(policy.Tid, fileName, policy.Path, false);
|
|
|
|
|
|
- //재시도 (재시도 옵션 활성화)
|
|
|
|
- if (isRetry && 0 < AddFilePolicyHistory(policy, isHashCheck, isLimit))
|
|
|
|
- {
|
|
|
|
- successFile++;
|
|
|
|
- _reportService.AddRetryReport(policy.Tid, fileName, policy.Path, true);
|
|
|
|
|
|
+ ////재시도 (재시도 옵션 활성화)
|
|
|
|
+ //if (isRetry && 0 < AddFilePolicyHistory(policy, isHashCheck, isLimit))
|
|
|
|
+ //{
|
|
|
|
+ // successFile++;
|
|
|
|
+ // _reportService.AddRetryReport(policy.Tid, fileName, policy.Path, true);
|
|
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ // continue;
|
|
|
|
+ //}
|
|
|
|
|
|
- //재시도 실패 (재시도 옵션 활성화)
|
|
|
|
- if (isRetry)
|
|
|
|
- {
|
|
|
|
- _reportService.AddRetryReport(policy.Tid, fileName, policy.Path, false);
|
|
|
|
|
|
+ ////재시도 실패 (재시도 옵션 활성화)
|
|
|
|
+ //if (isRetry)
|
|
|
|
+ //{
|
|
|
|
+ // _reportService.AddRetryReport(policy.Tid, fileName, policy.Path, false);
|
|
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ // continue;
|
|
|
|
+ //}
|
|
}catch(Exception e)
|
|
}catch(Exception e)
|
|
{
|
|
{
|
|
log.Error($"File 백업 오류(PolicyTid={policy.Tid})" + ", " + e.Message.ToString());
|
|
log.Error($"File 백업 오류(PolicyTid={policy.Tid})" + ", " + e.Message.ToString());
|
|
@@ -1204,7 +1233,6 @@ namespace Agent.Services
|
|
//File.SetCreationTime(tmpDstPath, File.GetCreationTime(tmpDstPath));
|
|
//File.SetCreationTime(tmpDstPath, File.GetCreationTime(tmpDstPath));
|
|
if (File.Exists(indexPath))
|
|
if (File.Exists(indexPath))
|
|
{
|
|
{
|
|
-
|
|
|
|
File.Delete(indexPath);
|
|
File.Delete(indexPath);
|
|
}
|
|
}
|
|
File.Move(tmpDstPath, indexPath);
|
|
File.Move(tmpDstPath, indexPath);
|
|
@@ -1448,7 +1476,7 @@ namespace Agent.Services
|
|
/// <param name="policyIndexTid"></param>
|
|
/// <param name="policyIndexTid"></param>
|
|
/// <param name="filePath"></param>
|
|
/// <param name="filePath"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public bool FileUploadHashChk(SqlConnection con, SqlTransaction transaction, int policyTid, int policyIndexTid, string filePath)
|
|
|
|
|
|
+ public bool FileUploadHashChk(SqlConnection con, SqlTransaction transaction, int policyTid, int policyIndexTid, string filePath, string fileName)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -1456,17 +1484,21 @@ namespace Agent.Services
|
|
|
|
|
|
var sql = @"
|
|
var sql = @"
|
|
SELECT TOP 1 hash
|
|
SELECT TOP 1 hash
|
|
- FROM [di_policy_history]
|
|
|
|
|
|
+ FROM [di_policy_history] a
|
|
|
|
+ INNER JOIN di_policy_index b ON a.policy_tid = b.policy_tid
|
|
WHERE 1=1
|
|
WHERE 1=1
|
|
- AND policy_tid = @PolicyTid
|
|
|
|
- AND policy_index_tid = @PolicyIndexTid
|
|
|
|
- AND hash = @willUploadFileHash
|
|
|
|
|
|
+ --AND policy_tid = @PolicyTid
|
|
|
|
+ --AND policy_index_tid = @PolicyIndexTid
|
|
|
|
+ AND hash = @willUploadFileHash
|
|
|
|
+ AND name = @FileName
|
|
|
|
+
|
|
ORDER BY upload_date DESC
|
|
ORDER BY upload_date DESC
|
|
";
|
|
";
|
|
|
|
|
|
//var willUploadFileHash = _hashService.FileToMD5(filePath);
|
|
//var willUploadFileHash = _hashService.FileToMD5(filePath);
|
|
|
|
|
|
- return willUploadFileHash.Equals(con.Query<string>(sql, new { PolicyTid = policyTid, PolicyIndexTid = policyIndexTid, willUploadFileHash = willUploadFileHash }, transaction).SingleOrDefault());
|
|
|
|
|
|
+ return willUploadFileHash.Equals(con.Query<string>
|
|
|
|
+ (sql, new { PolicyTid = policyTid, PolicyIndexTid = policyIndexTid, willUploadFileHash = willUploadFileHash, FileName = fileName }, transaction).SingleOrDefault());
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|