实习期学到的技术(一)
数据清洗
从基础数据表中整理出自己想要的数据,在进行拼接,最后存入事先创建好的表中。
具体方法(1)
定义一个抽象类的方法(基础的操作方法 提供访问)
public abstract class OperationBase
{
protected string _conntionString = ConfigurationManager.ConnectionStrings["SqlServerDBConn"].ConnectionString;
protected string _conntionStringStatistics = ConfigurationManager.ConnectionStrings["SqlServerDBConnStatistics"].ConnectionString;
public delegate void ErrorMessageDelegate(Exception ex);
public delegate void SuccessDelegate();
/// <summary>
/// 错误信息
/// </summary>
public string ErrorMessage { get; protected set; }
/// <summary>
/// 获取错误回调函数
/// </summary>
public abstract event ErrorMessageDelegate ErrorMessageCallBack;
/// <summary>
/// 获取成功回调函数
/// </summary>
public abstract event SuccessDelegate SuccessCallBack;
public abstract bool Main();
protected abstract void DataImport(params object[] data);
}
(2)调用抽象类OperationBase
public class GetRoadNetworkAnalysisOP : OperationBase
{
public override event ErrorMessageDelegate ErrorMessageCallBack;
public override event SuccessDelegate SuccessCallBack;
//程序出入口
public override bool Main()
{
// throw new NotImplementedException();
}
//数据的导入(删除原来的数据在添加新的数据)
protected override void DataImport(params object[] data)
{
// throw new NotImplementedException();
}
//自己写一个返回list<> (从基础数据中得到想要的数据)
private List<RoadNetworkAnalysisBase> RoadNetworkAnalysis_GetRoadNetworkAnalysis()
{
(定义所需要字段的标的实体)
(在定义接收数据的实体)
数据拼接(可以写sql,list<>)
返回数据
}
}
(3)
public class GetRoadNetworkAnalysis
{
public delegate List<RoadNetworkAnalysisBase> RoadNetworkAnalysisDataBind();
/// <summary>
/// 获取数据
/// </summary>
public event RoadNetworkAnalysisDataBind RoadNetworkAnalysisInfo;
public List<RoadNetworkAnalysisBase> BasislistRoadNetworkAnalysis { get; private set; }
public List<S_RoadNetworkAnalysis> ResultRoadNetworkAnalysis { get; private set; }
public List<T_Administrative> Administrative { get; private set; }
public List<T_Company> Company { get; private set; }
public GetRoadNetworkAnalysis(/*string regoinCode*/)
{
BasislistRoadNetworkAnalysis = new List<RoadNetworkAnalysisBase>();
ResultRoadNetworkAnalysis = new List<S_RoadNetworkAnalysis>();
}
/// <summary>
/// 数据清洗
/// </summary>
public void DataCleaning()
{
if (RoadNetworkAnalysisInfo == null)
{
return;
}
else
{
BasislistRoadNetworkAnalysis = RoadNetworkAnalysisInfo(/*RegoinCode*/);
GetRoadNetworkAnalysisInfo();
}
}
public List<S_RoadNetworkAnalysis> GetRoadNetworkAnalysisInfo()
{
return ResultRoadNetworkAnalysis;
}
}
--完