Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
4
Indexable
Never
var errorMsg = string.Empty;
var success = true;
if (expectedHeaders != null && fileHeaderRow != null)
{
    int fixedHeaderCount = 11;
    var headerColumnCount = fileHeaderRow.Length;
    var expectedHeaderCount = expectedHeaders.Length;

    for(var i = 0; i < expectedHeaderCount; i++)
    {
        if (i <= headerColumnCount)
        {
            if (expectedHeaders[i] != fileHeaderRow[i])
            {
                success = false;
                errorMsg = $"{errorMsg}Expected: {expectedHeaders[i]} , FileHeader:{(string.IsNullOrEmpty(fileHeaderRow[i])?"Empty Header": fileHeaderRow[i])}\n";
            }
        }
    }

    if (headerColumnCount > expectedHeaderCount)
    {
        for(var i= expectedHeaderCount-1; i < headerColumnCount; i++)
        {
            if (!string.IsNullOrEmpty(fileHeaderRow[i]))
            {
                success = false;
                errorMsg = $"{errorMsg}Expected: Empty Header , FileHeader:{fileHeaderRow[i]}\n";
            }
        }
    }

    return Tuple.Create(success, errorMsg);
}
Leave a Comment