📄 clslinkattdatabase.cs
字号:
}
pFeatureCursor.UpdateFeature(pFeature);
pFeature = pFeatureCursor.NextFeature();
}
//pFeature = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
pFeatureCursor = null;
WndTable10.Dispose();
WndTable10 = null;
pFC = null;
//System.Runtime.InteropServices.Marshal.ReleaseComObject(pFC);
}
public void CreateDay(double height, String item, StreamWriter w)//日统计
{
String dateSql = Gettime();
String Wnd10 = "SELECT STATIONNUM," + item + " from t_wndrsc_statistic t where t.enddate ='" + dateSql + "' and t.stattype='1' and t.height='" + height + "'";
String daypath = ReadString("PATH", "Daypath", Application.StartupPath);
String directorypath = daypath + "\\" + dateSql;
if (!System.IO.Directory.Exists(directorypath))
{
System.IO.Directory.CreateDirectory(directorypath);
}
String name = "wndrsc_day_" + height.ToString() + "_" + item + "_" + dateSql + ".img";
w.WriteLine(DateTime.Now.ToString() + " 正在生成" + name+"...");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 正在生成" + name + "...");
if (System.IO.File.Exists(@directorypath + "\\" + name))
{
System.IO.File.Delete(@directorypath + "\\" + name);
}
try
{
string sendTableName = "t_wndrsc_statistic";
DataSet Wndds10 = new DataSet();
DataTable WndTable10;
Wndds10 = SelectDataBase(Wnd10, sendTableName);
WndTable10 = Wndds10.Tables[0];
String windFilePath = Application.StartupPath + "\\wind\\windEnergy.shp";
String polygonPath = Application.StartupPath + "\\wind\\sj.shp";
IFeatureClass pFC = ReadPointShp(windFilePath);
if (pFC == null) return;
IFeatureCursor pFeatureCursor1;
pFeatureCursor1 = pFC.Update(null, false);
IGeoDataset windDataset = (IGeoDataset)ReadPointShp(polygonPath);
if (item == "wpowerdensity")
{
item = "wpd";
}
int nTem1 = pFeatureCursor1.Fields.FindField(item);
//添加字段
addfield(nTem1, item, pFC, WndTable10);
//插值生成等值面
IRaster pRasterDem = IDW(pFC, item, windDataset);
w.WriteLine(DateTime.Now.ToString() + " 插值生成等值面完成");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 插值生成等值面完成");
//删除字段
IFields pFields = pFC.Fields;
int lFieldnumber = pFields.FindField(item);
IField pField1 = pFields.get_Field(lFieldnumber);
pFC.DeleteField(pField1);
//生成图片并加载栅格图层
createimg(pRasterDem, directorypath, name, windDataset);
w.WriteLine(DateTime.Now.ToString() + " 等值面图片生成");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 等值面图片生成");
//删除重复记录
Querydata("1", dateSql, height, item);
//添加记录到数据库
String addSQL = "insert into t_wndrsc_product (STATTYPE, ENDDATE, HEIGHT, ITEM, FILENAME, path, OPERATETIME) values ('1', '" + dateSql + "', '" + height + "', '" + item + "', '" + name + "', '" + directorypath + "', sysdate)";
//MessageBox.Show(addSQL);
UpdateDataBase(addSQL);
w.WriteLine(DateTime.Now.ToString() + " 操作记录添加到数据库");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 操作记录添加到数据库");
//释放内存
pRasterDem = null;
WndTable10.Dispose();
WndTable10 = null;
Wndds10.Dispose();
Wndds10 = null;
windDataset = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor1);
pFeatureCursor1 = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFC);
pFC = null;
}
catch(Exception e)
{
w.WriteLine(DateTime.Now.ToString() + e.Message);
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + e.Message);
}
}
public void CreateMonth(double height, String item, StreamWriter w)//月统计
{
String monthSql = Getmonth();
String wndMonth = "SELECT STATIONNUM," + item + " from t_wndrsc_statistic t where SUBSTR(t.enddate,0,6) ='" + monthSql + "' and t.stattype='3' and t.height='" + height + "'";
String daypath = ReadString("PATH", "Monthpath", Application.StartupPath);
String directorypath = daypath + "\\" + monthSql;
if (!System.IO.Directory.Exists(directorypath))
{
System.IO.Directory.CreateDirectory(directorypath);
}
String name = "wndrsc_month_" + height.ToString() + "_" + item + "_" + monthSql + ".img";
if (System.IO.File.Exists(@directorypath + "\\" + name))
{
System.IO.File.Delete(@directorypath + "\\" + name);
}
w.WriteLine(DateTime.Now.ToString() + " 正在生成" + name + "...");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 正在生成" + name + "...");
try
{
string sendTableName = "t_wndrsc_statistic";
DataSet Wndds10 = new DataSet();
DataTable WndTable10;
Wndds10 = SelectDataBase(wndMonth, sendTableName);
WndTable10 = Wndds10.Tables[0];
String windFilePath = Application.StartupPath + "\\wind\\windEnergy.shp";
String polygonPath = Application.StartupPath + "\\wind\\sj.shp";
IFeatureClass pFC = ReadPointShp(windFilePath);
if (pFC == null) return;
IFeatureCursor pFeatureCursor1;
pFeatureCursor1 = pFC.Update(null, false);
IGeoDataset windDataset = (IGeoDataset)ReadPointShp(polygonPath);
if (item == "wpowerdensity")
{
item = "wpd";
}
int nTem1 = pFeatureCursor1.Fields.FindField(item);
//添加字段
addfield(nTem1, item, pFC, WndTable10);
//插值生成等值面
IRaster pRasterDem = IDW(pFC, item, windDataset);
w.WriteLine(DateTime.Now.ToString() + " 插值生成等值面完成");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 插值生成等值面完成");
//删除字段
IFields pFields = pFC.Fields;
int lFieldnumber = pFields.FindField(item);
IField pField1 = pFields.get_Field(lFieldnumber);
pFC.DeleteField(pField1);
//生成图片并加载栅格图层
createimg(pRasterDem, directorypath, name, windDataset);
w.WriteLine(DateTime.Now.ToString() + " 等值面图片生成");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 等值面图片生成");
//删除重复记录
Querydata("3", monthSql, height, item);
//添加记录到数据库
String addSQL = "insert into t_wndrsc_product (STATTYPE, ENDDATE, HEIGHT, ITEM, FILENAME, path, OPERATETIME) values ('3', '" + monthSql + "', '" + height + "', '" + item + "', '" + name + "', '" + directorypath + "', sysdate)";
//MessageBox.Show(addSQL);
UpdateDataBase(addSQL);
w.WriteLine(DateTime.Now.ToString() + " 操作记录添加到数据库");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 操作记录添加到数据库");
//释放内存
pRasterDem = null;
WndTable10.Dispose();
WndTable10 = null;
Wndds10.Dispose();
Wndds10 = null;
windDataset = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor1);
pFeatureCursor1 = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFC);
pFC = null;
}
catch (Exception e)
{
w.WriteLine(DateTime.Now.ToString() + e.Message);
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + e.Message);
}
}
public void CreateYear(double height, String item, StreamWriter w)//年统计
{
String yearSql = Getyear();
String wndyear = "SELECT STATIONNUM," + item + " from t_wndrsc_statistic t where SUBSTR(t.enddate,0,4) ='" + yearSql + "' and t.stattype='3' and t.height='" + height + "'";
String daypath = ReadString("PATH", "Yearpath", Application.StartupPath);
String directorypath = daypath + "\\" + yearSql;
if (!System.IO.Directory.Exists(directorypath))
{
System.IO.Directory.CreateDirectory(directorypath);
}
String name = "wndrsc_year_" + height.ToString() + "_" + item + "_" + yearSql + ".img";
if (System.IO.File.Exists(@directorypath + "\\" + name))
{
System.IO.File.Delete(@directorypath + "\\" + name);
}
w.WriteLine(DateTime.Now.ToString() + " 正在生成" + name + "...");
w.Flush();
//Console.WriteLine(DateTime.Now.ToString() + " 正在生成" + name + "...");
try
{
string sendTableName = "t_wndrsc_statistic";
DataSet Wndds10 = new DataSet();
DataTable WndTable10;
Wndds10 = SelectDataBase(wndyear, sendTableName);
WndTable10 = Wndds10.Tables[0];
String windFilePath = Application.StartupPath + "\\wind\\windEnergy.shp";
String polygonPath = Application.StartupPath + "\\wind\\sj.shp";
IFeatureClass pFC = ReadPointShp(windFilePath);
if (pFC == null) return;
IFeatureCursor pFeatureCursor1;
pFeatureCursor1 = pFC.Update(null, false);
IGeoDataset windDataset = (IGeoDataset)ReadPointShp(polygonPath);
if (item == "wpowerdensity")
{
item = "wpd";
}
int nTem1 = pFeatureCursor1.Fields.FindField(item);
//添加字段
addfield(nTem1, item, pFC, WndTable10);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -