Пример #1
0
        private void ISCCPRawDataF2Database(string tableName, List <string> filelist, Action <string> ProBack)
        {
            ProBack("-------------------------------------------------");
            ProBack("ISCCP原始数据入库开始:");
            //ISCCP.D2.0.GLOBAL.2008.07.99.0000.GPC
            string   fullDir, fName, localfName;
            int      year, month, utcTime;
            DateTime fDateTime = DateTime.MinValue;
            string   pattern   = @".(?<year>\d{4}).(?<month>\d{2}).(?<day>\d{2}).(?<utc>\d{4})";

            foreach (string file in filelist)
            {
                fName = Path.GetFileName(file);
                ProBack("\t" + fName + "入库开始:");
                fullDir = Path.GetDirectoryName(file);
                if (Directory.Exists(new DirectoryInfo(_inputDir).Parent.FullName))
                {
                    localfName = file.Replace(new DirectoryInfo(_inputDir).Parent.FullName, "");
                }
                else
                {
                    localfName = file.Replace(_inputDir, "");
                }
                Match match = Regex.Match(fName, pattern);
                if (match.Success)
                {
                    //LogFactory.WriteLine(_log, "\t\t解析文件名时间信息成功!");
                    //ProBack("\t\t解析文件名时间信息成功!");
                    year      = int.Parse(match.Groups["year"].Value);
                    month     = int.Parse(match.Groups["month"].Value);
                    fDateTime = new DateTime(year, month, 1);
                    utcTime   = int.Parse(match.Groups["utc"].Value);
                    try
                    {
                        //if (_dbConnect.IshasRecord(tableName, "ImageName", fName) == false)
                        if (_dbConnect.IshasRecord(tableName, "ImageData", localfName) == false)
                        {
                            _dbConnect.InsertISCCP2Table(tableName, fDateTime, utcTime, fName, localfName);  //插入,insert
                            ProBack("\t\t\t文件入库成功!");
                            continue;
                        }
                        else
                        {
                            //if(_dbConnect.UpdateRawCLDParatable(tableName, fName, localfName))
                            //    ProBack("\t\t\t文件记录更新成功!");
                            //else
                            ProBack("\t\t\t文件记录已存在,跳过!");
                        }
                    }
                    catch (System.Exception ex)
                    {
                        ProBack("入库错误" + ex.Message);
                    }
                }
                else
                {
                    ProBack("\t\t解析文件名时间失败,文件入库失败!");
                }
            }
            ProBack("ISCCP原始数据入库结束!");
            ProBack("--------------------------------------------------------------------------------------");
        }