Beispiel #1
0
        static void Main(string[] args)
        {
            ReadCsvFile();


            FileDataDB f = new FileDataDB();
            //   FileDataDB a = ConnectToDB(f);
            int a = 1;

            // DataFilesDB = ConfigureList(DataFiles);
            foreach (FileData fd in DataFiles)
            {
                Console.WriteLine(fd);
                f = ConfigureList(fd, a);
                ConnectToDB(f);
                DataFilesDB.Add(f);
                a++;
            }
            //  ConfigIP(DataFilesDB);
            // EnrichWithCoords(DataFilesDB);

            /*
             * foreach (FileDataDB fd in DataFilesDB)
             * {
             * FileDataDB a = ConnectToDB(fd);
             * DataFilesDB.Add(fd);
             * //  DataFilesDB.Add(a);
             * Console.WriteLine(fd);
             * }
             */
            Console.ReadLine();
        }
Beispiel #2
0
        private static FileDataDB ConfigureList(FileData fileData, int a)
        {
            //nt counter = 1;
            FileDataDB        fd          = new FileDataDB();
            List <FileDataDB> FileDatasDB = new List <FileDataDB>();
            //for (int i = 0; i < fileData.Count; i++)
            // {
            string   iString = fileData.Date;
            DateTime oDate   = Convert.ToDateTime(iString);

            fd.ID            = a;
            fd.LOCATION_NAME = fileData.LocationName;
            fd.DATE          = oDate.Date.ToString();
            fd.DAY           = Convert.ToInt32(oDate.Day);
            fd.MONTH         = Convert.ToInt32(oDate.Month);
            fd.YEAR          = Convert.ToInt32(oDate.Year);
            fd.HOUR          = Convert.ToInt32(oDate.Hour);
            fd.MINUTE        = Convert.ToInt32(oDate.Minute);
            fd.DOW           = oDate.DayOfWeek.ToString();
            fd.IP            = fileData.IP;
            fd = ConfigIP(fd);
            //     FileDatasDB.Add(fd);
            // }

            return(fd);
        }
Beispiel #3
0
        private static FileDataDB ConfigIP(FileDataDB filedata)
        {
            string ip      = filedata.IP;
            bool   IPstate = IPCheck(ip);

            if (IPstate == false)
            {
                filedata.IP = null;
            }
            return(filedata);
        }
Beispiel #4
0
 static FileDataDB ConnectToDB(FileDataDB f)
 {
     using (cmd.Connection = new SqlConnection(@"Data Source=.;Initial Catalog=TA9DB;Integrated Security=True"))
     {
         cmd.Connection.Open();
         cmd.CommandType = System.Data.CommandType.Text;
         cmd.CommandText = $"INSERT INTO DataFiles " + $" (ID,LOCATION_NAME,LONGITUDE,LATITUDE,DATE,DAY,MONTH,YEAR,HOUR,MINUTE,DOW,IP) " + $"Values ('{f.ID}','{f.LOCATION_NAME}','{f.LONGITUDE}','{f.LATITUDE}','{f.DATE}','{f.DAY}','{f.MONTH}','{f.YEAR}','{f.HOUR}','{f.MINUTE}','{f.DOW}','{f.IP}' )";
         cmd.ExecuteNonQuery();
         Console.WriteLine(f);
         return(f);
     }
 }