/// <summary> /// 指写入数据库记录 /// </summary> /// <param name="task"></param> /// <returns></returns> public static bool AddTask(Task task) { try { IDbConnection sysConnection = SysDbHelper.GetSysDbConnection(); DataTable tTask = AdoDbHelper.GetDataTable(sysConnection, "select * from LR_ModelTask where 1=2"); DataRow rowNewTask = tTask.NewRow(); rowNewTask["TaskID"] = task.ID; rowNewTask["TaskName"] = task.Name; rowNewTask["TaskPath"] = task.Path; rowNewTask["LibraryName"] = task.SourcePath; rowNewTask["TaskType"] = (int)task.DatasourceType; rowNewTask["SchemaID"] = task.SchemaID; rowNewTask["ExeState"] = (int)task.State; rowNewTask["Institution"] = task.Institution; rowNewTask["Person"] = task.Creator; rowNewTask["CreateTime"] = task.CreateTime; rowNewTask["Remark"] = task.Remark; rowNewTask["MapScale"] = task.MapScale; rowNewTask["TopoTolerance"] = task.TopoTolerance; rowNewTask["UseDatasource"] = task.UseSourceDirectly; rowNewTask["StandardID"] = SysDbHelper.GetStandardID(task.StandardName); rowNewTask["LibraryID"] = 0; rowNewTask["BIsTemplate"] = 0; tTask.Rows.Add(rowNewTask); return(AdoDbHelper.UpdateTable("LR_ModelTask", tTask, sysConnection)); } catch { return(false); } }
// 保存结果,主要用于CRuleDistrict,CRulePlotClass,CRuleSheet,CRuleStatAdminRegion public bool SaveResult(string strTargetFc) { try { string strSql = "delete * from LR_ResAutoStat_PlotClass where RuleInstID='" + base.m_InstanceID + "'"; Hy.Common.Utility.Data.AdoDbHelper.ExecuteSql(base.m_ResultConnection, strSql); //------------------------------------------------// // 在结果表中存储结果 // //------------------------------------------------// DataTable ipRecordset = new DataTable(); if (!AdoDbHelper.OpenTable("LR_ResAutoStat_PlotClass", ref ipRecordset, base.m_ResultConnection)) { return(false); } for (int i = 0; i < m_arrResult.Count; i++) { RuleExpression.RESULT res = m_arrResult[i]; //------设置字段数据 DataRow dr = ipRecordset.NewRow(); dr["RuleInstID"] = base.m_InstanceID; dr["目标图层"] = strTargetFc; dr["统计内容名称"] = res.IDName; dr["计算面积"] = res.dbCalArea; dr["调查面积"] = res.dbSurveyArea; string strErr = "" + Math.Abs(res.dbError / res.dbCalArea) * 100 + ""; dr["误差(百分比)"] = strErr; dr["错误消息"] = res.strErrInfo; //------添加新记录 ipRecordset.Rows.Add(dr); //更新记录 ipRecordset.AcceptChanges(); } AdoDbHelper.UpdateTable("LR_ResAutoStat_PlotClass", ipRecordset, base.m_ResultConnection); //关闭记录集 ipRecordset.Dispose(); } catch (Exception ex) { //Hy.Check.Rule.Helper.LogAPI.CheckLog.AppendErrLogs(ex.ToString()); //显示错误信息 //XtraMessageBox.Show("CRulePlot::SaveResult():" + ex.Message + ""); return(false); } return(true); }