private List <ozUploadFileMed> ReadCsv(string pathIn, string filenameIn, int[] headers, ref int countInserted, ref int countIgnore, string initIn, ref string errorLines, string midIn, string folderIn, string importtype)
    {
        List <ozUploadFileMed> lstRet = new List <ozUploadFileMed>();

        try
        {
            string[] allLines = File.ReadAllLines(pathIn + filenameIn, System.Text.Encoding.UTF7);

            countIgnore   = 0;
            countInserted = 0;
            int countAll = 0;
            for (int i = 1; i < allLines.Count(); i++)
            {
                countAll++;
                if (allLines[i].Replace(";", "").Trim() == string.Empty)
                {
                    countIgnore++;
                    errorLines += "Linje " + countAll + " - fejlkode: Tom linje.<br>";
                    continue;
                }

                ozUploadFileMed fileRet = new ozUploadFileMed();
                string[]        datas   = allLines[i].Split(';');
                fileRet.minit = datas[headers[0] - 1];
                fileRet.navn  = datas[headers[1] - 1];
                fileRet.email = datas[headers[2] - 1];
                fileRet.norm  = datas[headers[3] - 1];

                fileRet.ansatdato  = datas[headers[4] - 1];
                fileRet.opsagtdato = datas[headers[5] - 1];
                fileRet.mansat     = datas[headers[6] - 1];

                fileRet.evn         = datas[headers[7] - 1];
                fileRet.costcenter  = datas[headers[8] - 1];
                fileRet.linemanager = datas[headers[9] - 1];
                fileRet.countrycode = datas[headers[10] - 1];
                fileRet.weblang     = datas[headers[11] - 1];


                //if (fileRet.jobid == string.Empty)
                //    fileRet.jobid = "0";
                //if (fileRet.medarbejderid == string.Empty)
                //    fileRet.medarbejderid = "0";
                //if (fileRet.timer == string.Empty)
                //    fileRet.timer = "0";
                //if (fileRet.tdato == string.Empty)
                //    fileRet.tdato = "01-01-2001";

                bool isLevelEnough = CheckUserLevel(folderIn, midIn);

                if (isLevelEnough)
                {
                    lstRet.Add(fileRet);
                }
                else
                {
                    if (fileRet.minit == initIn)
                    {
                        lstRet.Add(fileRet);
                    }
                    else
                    {
                        errorLines += "Linje " + countAll + " - fejlkode: Du har ikke rettigheder til at uploade timer for andre brugere end dig selv.<br>";
                        countIgnore++;
                    }
                }
            }

            countInserted = lstRet.Count;
        }
        catch (Exception ex)
        {
            throw new Exception("Der opstod en fejl i læsning af .csv filen: " + ex.Message);
        }

        return(lstRet);
    }
    private List <ozUploadFileMed> ReadXlsx2007(string pathIn, string filenameIn, string[] headers, ref int countInserted, ref int countIgnore, string initIn, ref string errorLines, string midIn, string folderIn, string importtype)
    {
        List <ozUploadFileMed> lstRet = new List <ozUploadFileMed>();

        try
        {
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + pathIn + filenameIn + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\";");
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);
            DataTable        dt = new DataTable();
            da.Fill(dt);

            countIgnore   = 0;
            countInserted = 0;
            int countAll = 0;
            foreach (DataRow row in dt.Rows)
            {
                countAll++;

                ozUploadFileMed fileRet = new ozUploadFileMed();
                fileRet.medarbejderid = row[headers[0]].ToString().Trim();
                fileRet.jobid         = row[headers[1]].ToString().Trim();
                fileRet.jobnavn       = row[headers[2]].ToString().Trim();
                fileRet.tdato         = row[headers[3]].ToString().Trim();
                fileRet.aktnavn       = row[headers[4]].ToString().Trim();
                fileRet.timerkom      = row[headers[5]].ToString().Trim();

                if (fileRet.medarbejderid == string.Empty && fileRet.jobid == string.Empty && fileRet.timer == string.Empty && fileRet.tdato == string.Empty && fileRet.aktnavn == string.Empty && fileRet.timerkom == string.Empty)
                {
                    countIgnore++;
                    errorLines += "Linje " + countAll + " - fejlkode: Tom linje.<br>";
                    continue;
                }
                else if (fileRet.jobid == string.Empty)
                {
                    fileRet.jobid = "0";
                }
                else if (fileRet.jobid == string.Empty)
                {
                    fileRet.jobid = "0";
                }
                else if (fileRet.medarbejderid == string.Empty)
                {
                    fileRet.medarbejderid = "0";
                }
                else if (fileRet.timer == string.Empty)
                {
                    fileRet.timer = "0";
                }
                else if (fileRet.tdato == string.Empty)
                {
                    fileRet.tdato = "01-01-2001";
                }

                bool isLevelEnough = CheckUserLevel(folderIn, midIn);

                if (isLevelEnough)
                {
                    lstRet.Add(fileRet);
                }
                else
                {
                    if (fileRet.medarbejderid == initIn)
                    {
                        lstRet.Add(fileRet);
                    }
                    else
                    {
                        errorLines += "Linje " + countAll + " - fejlkode: Du har ikke rettigheder til at uploade timer for andre brugere end dig selv.<br>";
                        countIgnore++;
                    }
                }
            }

            countInserted = lstRet.Count;


            con.Close();
        }
        catch (Exception ex)
        {
            throw new Exception("Der opstod en fejl i læsning af .xlsx filen: " + ex.Message);
        }

        return(lstRet);
    }