Пример #1
0
 private void StatisticTen(string dirXun, StringBuilder outnamePrefix, string[] filesSelect, RasterStatics sta, string resl, string label = "day")
 {
     try
     {
         string flabel = string.Format("_{0}_{1}.LDF", label, resl);
         foreach (string stype in _statics)
         {
             string outname = "";
             if (_statics.Contains("MAX") || _statics.Contains("max"))
             {
                 StringBuilder outmaxname = new StringBuilder();
                 outmaxname.Append(dirXun).Append("\\Max\\").Append(outnamePrefix.ToString()).Append("_MAX").Append(flabel);
                 outname = outmaxname.ToString();
             }
             else if (_statics.Contains("MIN") || _statics.Contains("min"))
             {
                 StringBuilder outminname = new StringBuilder();
                 outminname.Append(dirXun).Append("\\Min\\").Append(outnamePrefix.ToString()).Append("_MIN").Append(flabel);
                 outname = outminname.ToString();
             }
             else if (_statics.Contains("AVG") || _statics.Contains("avg"))
             {
                 StringBuilder outAvgname = new StringBuilder();
                 outAvgname.Append(dirXun).Append("\\Avg\\").Append(outnamePrefix.ToString()).Append("_AVG").Append(flabel);
                 outname = outAvgname.ToString();
             }
             if (File.Exists(outname))
             {
                 if (_overwritefiles == false && _con.IshasRecord(_tableName, "ImageName", Path.GetFileName(outname)))
                 {
                     continue;
                 }
                 else
                 {
                     File.Delete(outname);
                 }
             }
             if (!Directory.Exists(Path.GetDirectoryName(outname)))
             {
                 Directory.CreateDirectory(Path.GetDirectoryName(outname));
             }
             if (sta.PeriodicAvgStat(filesSelect, outname))
             {
                 if (File.Exists(outname))// && !_con.IshasRecord(_tableName, "ImageName", Path.GetFileName(outname)))
                 {
                     _periodicsyn.TryCreatePeriodRecord(outname);
                 }
             }
         }
     }
     catch (Exception e)
     {
         throw e;
         //LogFactory.WriteLine(_dataOrigin, e.Message + "\n");
     }
 }
Пример #2
0
        //计算统计结果
        private void StatisticNext(int statistic, string dirNext, string outnamePrefix, string[] filenames, RasterStatics sta, string flabel)
        {
            try
            {
                StringBuilder outstaname = new StringBuilder();
                string        outname    = "";
                switch (statistic)
                {
                case 0:
                    outstaname.Append(dirNext).Append("\\").Append(outnamePrefix).Append("MAX").Append(flabel);
                    outname = outstaname.ToString();
                    break;

                case 1:
                    outstaname.Append(dirNext).Append("\\").Append(outnamePrefix).Append("MIN").Append(flabel);
                    outname = outstaname.ToString();
                    break;

                case 2:
                    outstaname.Append(dirNext).Append("\\").Append(outnamePrefix).Append("AVG").Append(flabel);
                    outname = outstaname.ToString();
                    break;
                }
                if (File.Exists(outname))
                {
                    if (_overwritefiles == false && _con.IshasRecord(_tableName, "ImageName", Path.GetFileName(outname)))
                    {
                        return;
                    }
                    else
                    {
                        File.Delete(outname);
                    }
                }
                if (!Directory.Exists(Path.GetDirectoryName(outname)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(outname));
                }
                if (sta.PeriodicAvgStat(filenames, outname))
                {
                    if (File.Exists(outname) && !_con.IshasRecord(_tableName, "ImageName", Path.GetFileName(outname)))
                    {
                        _periodicsyn.TryCreatePeriodRecord(outname);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #3
0
        //计算统计结果
        private void StatisticNext(int statistic, string dirNext, string outnamePrefix, string[] filenames, RasterStatics sta, string flabel, Action <int, string> progressCallback = null)
        {
            try
            {
                StringBuilder outstaname = new StringBuilder();
                string        outname    = "";
                switch (statistic)
                {
                case 0:
                    outstaname.Append(dirNext).Append("\\").Append(outnamePrefix).Append("MAX").Append(flabel);
                    outname = outstaname.ToString();
                    break;

                case 1:
                    outstaname.Append(dirNext).Append("\\").Append(outnamePrefix).Append("MIN").Append(flabel);
                    outname = outstaname.ToString();
                    break;

                case 2:
                    outstaname.Append(dirNext).Append("\\").Append(outnamePrefix).Append("AVG").Append(flabel);
                    outname = outstaname.ToString();
                    break;
                }
                if (progressCallback != null)
                {
                    progressCallback(-1, "\t\t\t\t输出文件:" + outname);
                }
                if (File.Exists(outname))
                {
                    if (_overwritefiles == false && _con.IshasRecord(_tableName, "ImageName", Path.GetFileName(outname)))
                    {
                        if (!File.Exists(Path.Combine(Path.GetDirectoryName(outname), Path.ChangeExtension(outname, ".overview.png"))))
                        {
                            OverViewHelper.OverView(outname, 800);
                        }
                        if (progressCallback != null)
                        {
                            progressCallback(-1, "\t\t\t文件已存在,跳过合成处理!");// + Path.GetFileName(outname));
                        }
                        return;
                    }
                    else
                    {
                        File.Delete(outname);
                        if (progressCallback != null)
                        {
                            progressCallback(-1, "\t\t\t重新合成处理开始...");//+ Path.GetFileName(outname));
                        }
                    }
                }
                string outdir = Path.GetDirectoryName(outname);
                if (!Directory.Exists(outdir))
                {
                    Directory.CreateDirectory(outdir);
                }
                if ((statistic == 0 && !sta.PeriodicMaxStat(filenames, outname, progressCallback)) || (statistic == 1 && !sta.PeriodicMinStat(filenames, outname, progressCallback)) ||
                    (statistic == 2 && !sta.PeriodicAvgStat(filenames, outname, null, progressCallback)))
                {
                    if (progressCallback != null)
                    {
                        progressCallback(-1, "\t\t\t\t合成处理失败!");//+ Path.GetFileName(outname));
                    }
                    if (File.Exists(outname))
                    {
                        File.Delete(outname);
                        if (progressCallback != null)
                        {
                            progressCallback(-1, "\t\t\t\t删除合成失败文件!");// + outname);
                        }
                    }
                    return;
                }
                if (File.Exists(outname))
                {
                    //生成快视图
                    string filename = OverViewHelper.OverView(outname, 800);
                    if (progressCallback != null && File.Exists(filename))
                    {
                        progressCallback(-1, "\t\t\t\t生成快视图成功!");// + Path.GetFileName(outname));
                    }
                    if (!_con.IshasRecord(_tableName, "ImageName", Path.GetFileName(outname)))
                    {
                        TryCreatePeriodRecord(outname, progressCallback);
                        if (progressCallback != null && File.Exists(filename))
                        {
                            progressCallback(-1, "\t\t\t\t入库成功!");// + Path.GetFileName(outname));
                        }
                    }
                    else
                    {
                        if (progressCallback != null && File.Exists(filename))
                        {
                            progressCallback(-1, "\t\t\t\t数据库记录已存在,入库跳过!");// + Path.GetFileName(outname));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (progressCallback != null)
                {
                    progressCallback(-5, "合成" + dirNext + "的产品失败!" + e.Message);
                }
                throw e;
            }
        }
Пример #4
0
 private void StatisticTen(string dirXun, StringBuilder outnamePrefix, string[] filesSelect, RasterStatics sta, string resl, string label = "day", Action <int, string> progressCallback = null)
 {
     try
     {
         string        flabel         = string.Format("_{0}_{1}.LDF", label, resl);
         int           statistic      = -1;
         StringBuilder outnamebuilder = new StringBuilder();
         string        outname        = "";
         foreach (string stype in _statics)
         {
             outnamebuilder.Clear();
             if (_statics.Contains("MAX") || _statics.Contains("max"))
             {
                 statistic = 0;
                 outnamebuilder.Append(dirXun).Append("\\Max\\").Append(outnamePrefix.ToString()).Append("_MAX").Append(flabel);
                 outname = outnamebuilder.ToString();
             }
             else if (_statics.Contains("MIN") || _statics.Contains("min"))
             {
                 statistic = 1;
                 outnamebuilder.Append(dirXun).Append("\\Min\\").Append(outnamePrefix.ToString()).Append("_MIN").Append(flabel);
                 outname = outnamebuilder.ToString();
             }
             else if (_statics.Contains("AVG") || _statics.Contains("avg"))
             {
                 statistic = 2;
                 outnamebuilder.Append(dirXun).Append("\\Avg\\").Append(outnamePrefix.ToString()).Append("_AVG").Append(flabel);
                 outname = outnamebuilder.ToString();
             }
             if (progressCallback != null)
             {
                 progressCallback(-1, "\t\t\t\t开始合成" + stype + "旬产品,输出文件:" + outname);
             }
             if (File.Exists(outname))
             {
                 if (_overwritefiles == false && _con.IshasRecord(_tableName, "ImageName", Path.GetFileName(outname)))
                 {
                     if (!File.Exists(Path.Combine(Path.GetDirectoryName(outname), Path.ChangeExtension(outname, ".overview.png"))))
                     {
                         OverViewHelper.OverView(outname, 800);
                     }
                     if (progressCallback != null)
                     {
                         progressCallback(-1, "\t\t\t\t文件已存在,跳过合成处理!");//+ Path.GetFileName(outname)
                     }
                     continue;
                 }
                 else
                 {
                     File.Delete(outname);
                     if (progressCallback != null)
                     {
                         progressCallback(-1, "\t\t\t\t重新合成处理开始..."); //+ Path.GetFileName(outname)
                     }
                 }
             }
             if (!Directory.Exists(Path.GetDirectoryName(outname)))
             {
                 Directory.CreateDirectory(Path.GetDirectoryName(outname));
             }
             if ((statistic == 0 && !sta.PeriodicMaxStat(filesSelect, outname, progressCallback)) || (statistic == 1 && !sta.PeriodicMinStat(filesSelect, outname, progressCallback)) ||
                 (statistic == 2 && !sta.PeriodicAvgStat(filesSelect, outname, null, progressCallback)))
             {
                 if (progressCallback != null)
                 {
                     progressCallback(-1, "\t\t\t\t合成处理失败!");// + Path.GetFileName(outname));
                 }
                 if (File.Exists(outname))
                 {
                     File.Delete(outname);
                     if (progressCallback != null)
                     {
                         progressCallback(-1, "\t\t\t\t删除合成失败文件!");// + Path.GetFileName(outname));
                     }
                 }
                 continue;
             }
             if (File.Exists(outname))
             {
                 //生成快视图
                 string filename = OverViewHelper.OverView(outname, 800);
                 if (progressCallback != null && File.Exists(filename))
                 {
                     progressCallback(-1, "\t\t\t\t生成快视图成功!");// 文件:+ Path.GetFileName(outname));
                 }
                 if (!_con.IshasRecord(_tableName, "ImageName", Path.GetFileName(outname)))
                 {
                     TryCreatePeriodRecord(outname, progressCallback);
                     if (progressCallback != null && File.Exists(filename))
                     {
                         progressCallback(-1, "\t\t\t\t入库成功!");//文件:+ Path.GetFileName(outname));
                     }
                 }
                 else
                 {
                     if (progressCallback != null && File.Exists(filename))
                     {
                         progressCallback(-1, "\t\t\t\t数据库记录已存在,入库跳过!");//文件:+ Path.GetFileName(outname));
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         if (progressCallback != null)
         {
             progressCallback(-5, "合成" + dirXun + "的旬产品失败!" + e.Message);
         }
         throw e;
     }
 }