Example #1
0
        private static DateTime GetFileDateTime(string fname, string mode)
        {
            switch (mode.ToUpper())
            {
            case "MOD06":
                string dt;
                return(DataProcesser.GetOribitTime(fname, out dt));

            case "MOD03":
                string dt3;
                return(DataProcesser.GetOribitTime(fname, out dt3));

            case "AIRS":
                string outstr;
                return(AIRSDataProcesser.GetAIRSDateTimeFromStr(fname, out outstr));

            case "ISCCP":
                string isccpregex = @".(?<year>\d{4}).(?<month>\d{2}).(?<day>\d{2}).(?<utc>\d{4})";
                Match  match      = Regex.Match(fname, isccpregex);
                if (match.Success)
                {
                    int year  = int.Parse(match.Groups["year"].Value);
                    int month = int.Parse(match.Groups["month"].Value);
                    return(new DateTime(year, month, 1));
                }
                return(DateTime.MinValue);

            case "CLOUDSAT":
                string[] parts = fname.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                return(OriginData2Database.GetInfoFromCloudSATName(parts[0]));

            default:
                return(DateTime.MinValue);
            }
        }
Example #2
0
        private void AIRSRawDataF2Database(string tableName, List <string> filelist, Action <string> ProBack)
        {
            ProBack("-------------------------------------------------");
            ProBack("AIRS原始数据入库开始:");
            string   fName, localfName;
            DateTime fDateTime = DateTime.MinValue;
            string   sensor = "AIRS", dirname, dataStr;

            foreach (string file in filelist)
            {
                try
                {
                    fName = Path.GetFileName(file);
                    ProBack("\t" + fName + "入库开始:");
                    dirname = new DirectoryInfo(_inputDir).Parent.FullName;
                    if (Directory.Exists(dirname))
                    {
                        localfName = file.Replace(dirname, "");//Path.Combine(localDir, fName);
                    }
                    else
                    {
                        localfName = file.Replace(_inputDir, "");//Path.Combine(localDir, fName);
                    }
                    fDateTime = AIRSDataProcesser.GetOribitTime(file, out dataStr);
                    if (fDateTime == DateTime.MinValue)
                    {
                        ProBack("\t\t解析文件名时间信息失败,入库失败!");
                        continue;
                    }
                    //ProBack("查询记录存在否开始...");
                    //if (_dbConnect.IshasRecord(tableName, "ImageName", fName) == false)
                    if (_dbConnect.IshasRecord(tableName, "ImageData", localfName) == false)
                    {
                        //ProBack("查询完毕,开始插入新纪录...");
                        _dbConnect.InsertRawMOD06Table(tableName, fDateTime, fName, localfName, sensor);  //插入,insert
                        ProBack("\t\t\t文件入库成功!");
                    }
                    else
                    {
                        //ProBack("查询完毕,纪录已存在,开始尝试更新记录...");
                        //if (_dbConnect.UpdateRawCLDParatable(tableName, fName, localfName))
                        //    ProBack("\t\t\t文件记录更新成功!");
                        //else
                        ProBack("\t\t\t文件记录已存在,跳过!");
                    }
                }
                catch (System.Exception ex)
                {
                    ProBack("入库错误" + ex.Message);
                }
            }
            ProBack("AIRS L2数据入库结束!");
            ProBack("--------------------------------------------------------------------------------------");
        }
Example #3
0
 private void DoProcess()
 {
     try
     {
         if (_frmMode == "MOD06")
         {
             DataProcesser processer = new DataProcesser(txtDirName.Text, txtOutDir.Text, GetSelectedDatasets(), txtResl.ValueF, _envList.ToArray(), cbxOverlapPrj.Checked, cbxOverlapMosaic.Checked, cbxDirectMosaic.Checked, cbxOnlyPrj.Checked, cbxLostAdded.Checked);
             processer.IsOriginResl   = cbxOriginResl.Checked;
             processer._historyPrjDir = (cbxDirectMosaic.Checked?txtHistoryPrj.Text:null);
             if (processer.DoProcess(_state))
             {
             }
         }
         else if (_frmMode == "MYD06")
         {
             MYDDataProcesser processer = new MYDDataProcesser(txtDirName.Text, txtOutDir.Text, GetSelectedDatasets(), txtResl.ValueF, _envList.ToArray(), cbxOverlapPrj.Checked, cbxOverlapMosaic.Checked, cbxDirectMosaic.Checked, cbxOnlyPrj.Checked, cbxLostAdded.Checked);
             processer.IsOriginResl   = cbxOriginResl.Checked;
             processer._historyPrjDir = (cbxDirectMosaic.Checked ? txtHistoryPrj.Text : null);
             if (processer.DoProcess(_state))
             {
             }
         }
         else
         {
             AIRSDataProcesser processer = new AIRSDataProcesser(txtDirName.Text, txtOutDir.Text, GetSelectedDatasets(), txtResl.ValueF, _envList.ToArray(), cbxOverlapPrj.Checked, cbxOverlapMosaic.Checked, cbxDirectMosaic.Checked, cbxOnlyPrj.Checked);
             processer.IsOriginResl   = cbxOriginResl.Checked;
             processer._historyPrjDir = (cbxDirectMosaic.Checked ? txtHistoryPrj.Text : null);
             if (processer.Process(_state))
             {
             }
         }
         runTaskThread = new Thread(new ThreadStart(this.ClearRecycleFiles));
         runTaskThread.IsBackground = true;
         runTaskThread.Start();
         //_state(-1, "开始后台临时文件清理...");
     }
     catch (System.Exception ex)
     {
         LogFactory.WriteLine(_frmMode + "预处理ERROR", ex.Message);
         _state(-100, ex.Message);
         //throw ex;
     }
 }
Example #4
0
        /// <summary>
        /// 将扫描得到的原始数据文件归档
        /// </summary>
        /// <param name="files"></param>
        /// <param name="dir"></param>
        /// <param name="mode"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        private static List <string> Uniformfiles2Dir(List <string> files, string dir, string mode, Action <string> state)
        {
            List <string> filesDir = new List <string>();
            string        dstDir = "", fname, dstfname, tempf, tempdstf;
            DateTime      fdate = DateTime.MinValue;
            StringBuilder fn, dstfn, dstDirB;

            foreach (string file in files)
            {
                fname = Path.GetFileName(file);
                if (mode.ToUpper() == "AIRS")
                {
                    #region 筛选中国区的AIRS文件
                    RasterProject.PrjEnvelope       env        = AIRSDataProcesser.GetAIRSFileEnv(file);
                    GeoDo.RasterProject.PrjEnvelope dstmainPrj = GeoDo.RasterProject.PrjEnvelope.Intersect(_chinaENV, env);
                    if (dstmainPrj == null || dstmainPrj.Width <= 0 || dstmainPrj.Height <= 0)
                    {
                        if (state != null)
                        {
                            state("文件不在中国区!" + fname);
                        }
                        continue;
                    }
                    #endregion
                }
                if (state != null)
                {
                    state("开始归档" + fname + "...");
                }
                fdate   = GetFileDateTime(fname, mode);
                dstDirB = new StringBuilder(dir);
                dstDirB.Append("\\").Append(fdate.Year.ToString()).Append("\\").Append(fdate.Month.ToString());
                dstDir = dstDirB.ToString();
                if (!Directory.Exists(dstDir))
                {
                    Directory.CreateDirectory(dstDir);
                }
                dstfname = dstDirB.Append("\\").Append(fname).ToString(); //Path.Combine(dstDir, fname);
                //文件复制
                if (mode.ToUpper() != "CLOUDSAT")
                {
                    if (dstfname != file && !File.Exists(dstfname))
                    {
                        System.IO.File.Copy(file, dstfname);
                    }
                    else
                    {
                        if (state != null)
                        {
                            state("文件已存在或源数据位置与目标数据位置相同,跳过归档!");
                        }
                    }
                    if (!filesDir.Contains(dstfname))
                    {
                        filesDir.Add(dstfname);
                    }
                    if (mode == "AIRS")
                    {
                        fn       = new StringBuilder(file);
                        dstfn    = new StringBuilder(dstfname);
                        tempf    = fn.Append(".xml").ToString();
                        tempdstf = dstfn.Append(".xml").ToString();
                        if (File.Exists(tempf) && !File.Exists(tempdstf))
                        {
                            System.IO.File.Copy(tempf, tempdstf, true);
                        }
                        tempf    = fn.Append(".jpg").ToString();
                        tempdstf = dstfn.Append(".jpg").ToString();
                        if (File.Exists(tempf) && !File.Exists(tempdstf))
                        {
                            System.IO.File.Copy(tempf, tempdstf, true);
                        }
                        tempf    = fn.Append(".map.gz").ToString();
                        tempdstf = dstfn.Append(".map.gz").ToString();
                        if (File.Exists(tempf) && !File.Exists(tempdstf))
                        {
                            System.IO.File.Copy(tempf, tempdstf, true);
                        }
                        //if (File.Exists(file + ".jpg") && !File.Exists(dstfname + ".jpg"))
                        //    System.IO.File.Copy(file + ".jpg", dstfname + ".jpg", true);
                        //if (File.Exists(file + ".map.gz") && !File.Exists(dstfname + ".map.gz"))
                        //    System.IO.File.Copy(file + ".map.gz", dstfname + ".map.gz", true);
                    }
                }
                else
                {
                    UnzipCloudSATFiles(file, dstDir, state);
                    filesDir.Add(dstfname.Substring(0, dstfname.Length - 4));
                }
                if (state != null)
                {
                    state("归档完成!");
                }
            }
            if (state != null)
            {
                state(mode + "数据归档完成!");
            }
            return(filesDir);
        }