using System;

public interface IImportData

{

bool ImportData();

}

public class sqlite2sqlServer : IImportData

{

public virtual bool ImportData()

{

// TODO: implement

bool isSuccessful = true;

dedestinationTableName = Destination;

using (sqliteDataReader reader = sqliteHelper.ExecuteReader(sql_sqlite))

using (System.Data.sqlClient.sqlBulkCopy bulkCopy = new System.Data.sqlClient.sqlBulkCopy(PubConstant.ConnectionString))

{

{

bulkCopy.DestinationTableName = Destination;

try

{

bulkCopy.WriteToServer(reader);

}

catch (Exception ex)

{

isSuccessful = false;

throw new Exception(ex.Message);

}

}

}

return isSuccessful;

}

public virtual bool Hook()

{

// TODO: implement

Type t = typeof(T);

T dal = (T)Assembly.GetAssembly(t).CreateInstance(t.FullName);

//XPWY.DAL.QuestionFace dal = new DAL.QuestionFace();

MethodInfo methodInfo = dal.GetType().GetMethod("GetList",new Type[]{typeof(string)});

DataSet ds = methodInfo.Invoke(dal,new String[] { " BatchID=" + this.BatchID.ToString() }) as DataSet;

//GetList(" BatchID=" + this.BatchID.ToString());

if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)

{

return true;

}

else

{

return false;

}

}

public virtual bool ImportDataFromsqliteTosqlServer()

{

// TODO: implement

if(Hook)

{

return ImportData();

}

return false;

}

public System.Int32 BatchID;

public System.String Destination;

public System.String sql_sqlite;

}

public class QuestionFace : sqlite2sqlServer

{

public QuestionFace(System.Int32 nBatchID)

{

this.BatchID = nBatchID;

this.Destination="QuetionFace";

this.sql_sqlite="select * from QuestionFace";

}

public sealed bool ImportDataFromsqliteTosqlServer()

{

// TODO: implement

return base.ImportDataFromsqliteTosqlServer();

}

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐