init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
60
Kreta.BusinessLogic/HelperClasses/ImportCo/BaseImportCo.cs
Normal file
60
Kreta.BusinessLogic/HelperClasses/ImportCo/BaseImportCo.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kreta.Core;
|
||||
using Kreta.Resources;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kreta.BusinessLogic.HelperClasses.ImportCo
|
||||
{
|
||||
public class BaseImportCo
|
||||
{
|
||||
[JsonIgnore]
|
||||
public int ImportMuvelet { get; set; }
|
||||
|
||||
protected static void ValidateDuplicatedRows(Dictionary<int, List<ValidationResult>> validationResultDictionary, Dictionary<int, string> lineNumberCompareHashDictionary, List<string> duplicatedRowConditonTextList)
|
||||
{
|
||||
//NOTE: Levalidáljuk a duplikált sorokat!
|
||||
// Azért van szükség Dictionary-re, mert így nagyságrendekkel gyorsabb a keresés!
|
||||
// Először csoportosítjuk a sorokat egyezőség(compareHash) szerint.
|
||||
var duplicatedRowDictionary = new Dictionary<string, List<int>>();
|
||||
foreach (KeyValuePair<int, string> item in lineNumberCompareHashDictionary)
|
||||
{
|
||||
int lineNumber = item.Key;
|
||||
string compareHash = item.Value;
|
||||
if (compareHash == Constants.General.ImportMD5InvalidInput)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (duplicatedRowDictionary.ContainsKey(compareHash))
|
||||
{
|
||||
duplicatedRowDictionary[compareHash].Add(lineNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
duplicatedRowDictionary.Add(compareHash, new List<int> { lineNumber });
|
||||
}
|
||||
}
|
||||
|
||||
//NOTE: Ha egynél több sor kerül egy elemhez, akkor kiírjuk hibának az adott sorokhoz, hogy többször szerepel.
|
||||
foreach (KeyValuePair<string, List<int>> item in duplicatedRowDictionary)
|
||||
{
|
||||
List<int> lineNumberList = item.Value;
|
||||
if (lineNumberList.Count > 1)
|
||||
{
|
||||
foreach (var lineNumber in lineNumberList)
|
||||
{
|
||||
var validationResult = new ValidationResult(string.Format(CommonResource.DuplicatedRow0, string.Join(", ", duplicatedRowConditonTextList)));
|
||||
if (validationResultDictionary.ContainsKey(lineNumber))
|
||||
{
|
||||
validationResultDictionary[lineNumber].Add(validationResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
validationResultDictionary.Add(lineNumber, new List<ValidationResult> { validationResult });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue