1、读取config.xml中的配置信息键值对
var satelliteNames = ConfigUtils.GetConfig().Satellites;//获取config.xml中名为"Satellites"中所有的值,这里config.xml中的代码为
<Satellites>
<string>GF1</string>
<string>NMC</string>
<string>AGME</string>
</Satellites>
获得的satelliteNames的类型为List<string>,内容为GF1,NMC,AGME
2、查找数据库的SQL语句
string sql = string.Format("select distinct region from xdlt_water_ecological_wetlandarea");
//这里读取xdlt_water_ecological_wetlandarea中所有的region。distinct关键字是指如果内容重复则只保留一个
3、按照条件查找数据
sql = string.Format("select * from xdlt_ocsmart_product where satellite='{0}' and sensor='{1}' and region='{2}' and period={3} and date= '{4}'", satellite, sensor ,region, period, starDate);//筛选得到一个存OCSmartProductModel类型的List
var t = Task.Run(() =>
{
var list = DbContext.Query<OCSmartProductModel>(sql);
return list;
}
);
var result = await t;//将查找结果传给result
4、加载.dat文件
mPIEService.Instance.AddRasterLayer(filepath, true);
//filepath为.dat文件的路径,true为是否加载新的.dat文件,如果界面已加载.dat文件则需改成false
5、获取右侧窗口选择的文件名
string filename = mUCWorkSpaceVM.GetInstance().SelectedFile;
6、添加新生成的文件到右侧窗口的文件列表中
mUCWorkSpaceVM.GetInstance().AddFileNode(outputPath);//outputPath为文件的路径
7、获取IRasterDataset对象
IRasterDataset _statDataset = DatasetFactory.OpenRasterDataset(_statFilePath, OpenMode.ReadOnly);//_statFilePath为文件路径名
8、新建一个窗口并将其显示在界面右侧
mParamPanel.GetInstance().SetContentCtrl(vm,false);//这里vm为已实例化的待显示的UserControl
mService.MainPanelVM.AddNewDockPanel(mParamPanel.GetInstance(), mPaneLocation.Right);//将vm显示在界面右侧
9、JSON的加载
JObject jsonObj = null;
string paramStr = JsonConvert.SerializeObject(info);//info为需要序列化的Model
var client = new RestClient();
client.EndPoint = mService.CimStaConfig.Address + @"dss/wetland/indexCalculation";
client.ContentType = "application/json";
client.Method = HttpVerb.POST;
client.PostData = "{postData: value}";
string jsonResult = client.MakeRequest("?json=" + paramStr);
jsonObj = (JObject)JsonConvert.DeserializeObject<JObject>(jsonResult);