/************************************************************************/ /*Add by Ron.shen 此处是为了强制下载某些资源文件,主要应用于某些需要偷偷更新用户资源的场景!-_- * /************************************************************************/ #region 强制下载需要下载的资源 private void SynchDataDownFile() { string updatetime = string.Empty; DataTable SqlTable = new DataTable(); I_Sql = SqlFactory.MakeSelect(TableType.Table_Type.DownFile); SqlTable = Db_Sql.ReSelectdtb(I_Sql.GetSqlSelect()); List <ResourceInfoModel> reslist = GetResourceInfoModel(SqlTable); List <string> downFileUpdateSql = new List <string>(); IList <DbParameter[]> parlist = new List <DbParameter[]>(); foreach (ResourceInfoModel rm in reslist) { string WebSit = WebPath + rm.FileURL; bool result = LoadSavePath(rm, WebSit); if (result) { //更新已下载 DbParameter[] sqlparList = new DbParameter[1]; //sqlparList[0] = Db_Sql.CreateDbParameter("@UpdateTime", DateTime.Now); sqlparList[0] = Db_Sql.CreateDbParameter("@ID", rm.ID); //downFileUpdateSql.Add(); //parlist.Add(sqlparList); string error = ""; int t = Db_Sql.ReExNum(I_Sql.GetSqliteUpdate(), out error, sqlparList); } } //int m = Db_Sql.ReExNum(downFileUpdateSql, parlist); }
private void NoticeData(string updatetime) { I_Sql = SqlFactory.MakeSelect(TableType.Table_Type.Notice); DataTable SqlTable = new DataTable(); DataTable SqliteTable = new DataTable(); List <int> listsql = new List <int>(); List <int> listsqlite = new List <int>(); List <int> difference = new List <int>(); List <string> SelectList = new List <string>(); SqlTable = Db_Sql.ReSelectdtb(((SqlInterface)I_Sql).GetDatafromSql(updatetime)); SqliteTable = Db_Sqlite.ReSelectdtb(I_Sql.GetSqliteSelect()); Dictionary <int, NoticeModel> sqltablelist = GetSqlcNotice(SqlTable); IList <DbParameter[]> parlist = new List <DbParameter[]>(); for (int j = 0; j < SqliteTable.Rows.Count; j++) { int id = Int32.Parse(SqliteTable.Rows[j]["ID"].ToString()); for (int i = 0; i < sqltablelist.Count; i++) { if (id == sqltablelist.Keys.ToList()[i]) { DbParameter[] DbUpdate = ExecutionSelectNotice(sqltablelist[id]); parlist.Add(DbUpdate); SelectList.Add(I_Sql.GetSqliteUpdate()); sqltablelist.Remove(id); i--; } } } foreach (int Select in sqltablelist.Keys) //根据差集进行插入操作 { DbParameter[] DbInsert = ExecutionSelectNotice(sqltablelist[Select]); parlist.Add(DbInsert); SelectList.Add(I_Sql.GetSqliteInsert()); } SqlTable = Db_Sql.ReSelectdtb(I_Sql.GetSqlSelect()); SqliteTable = Db_Sqlite.ReSelectdtb(I_Sql.GetSqliteSelect()); foreach (DataRow dr in SqlTable.Rows) { int id = Int32.Parse(dr["ID"].ToString()); listsql.Add(id); } foreach (DataRow dr in SqliteTable.Rows) { int id = Int32.Parse(dr["ID"].ToString()); listsqlite.Add(id); } difference = listsqlite.Except(listsql).ToList(); foreach (int Select in difference) { Db_Sqlite.ExSQL(((SqlInterface)I_Sql).GetSqliteDelect(Select)); //删除Service端没有的数据 } int m = Db_Sqlite.ReExNum(SelectList, parlist); WriteLog("通知表需要更新" + SelectList.Count().ToString() + "条记录" + " 实际更新" + m.ToString() + "条记录"); }
private void SynchDataService() { string updatetime = string.Empty; DataTable SqlTable = new DataTable(); DataTable SqliteTable = new DataTable(); List <string> SelectList = new List <string>(); I_Sql = SqlFactory.MakeSelect(TableType.Table_Type.Service); SqlTable = Db_Sql.ReSelectdtb(I_Sql.GetSqlSelect()); SqliteTable = Db_Sqlite.ReSelectdtb(I_Sql.GetSqliteSelect()); IList <DbParameter[]> parlist = new List <DbParameter[]>(); ServiceModel servicemodel = GetServiceModel(SqlTable); if ((SqliteTable.Rows.Count > 0) && (SqlTable.Rows.Count > 0) && SqliteTable != null && SqlTable != null) { if (DateTime.Parse(SqlTable.Rows[0]["Update_Time"].ToString()) > DateTime.Parse(SqliteTable.Rows[0]["UpdateTime"].ToString())) { if (servicemodel == null) { return; } DbParameter[] DbInsert = ExecutionSelectSet(servicemodel); parlist.Add(DbInsert); SelectList.Add(I_Sql.GetSqliteUpdate()); } } else { if (servicemodel != null) { DbParameter[] DbInsert = ExecutionSelectSet(servicemodel); parlist.Add(DbInsert); SelectList.Add(I_Sql.GetSqliteInsert()); } } int m = Db_Sqlite.ReExNum(SelectList, parlist); WriteLog("服务表需要更新" + SelectList.Count().ToString() + "条记录" + " 实际更新" + m.ToString() + "条记录"); }
private void CompanyData(string updatetime) { I_Sql = SqlFactory.MakeSelect(TableType.Table_Type.Compnay); DataTable SqlTable = new DataTable(); DataTable SqliteTable = new DataTable(); List<int> listsql = new List<int>(); List<int> listsqlite = new List<int>(); List<int> difference = new List<int>(); List<string> SelectList = new List<string>(); SqlTable = Db_Sql.ReSelectdtb(((SqlInterface)I_Sql).GetDatafromSql(updatetime)); SqliteTable = Db_Sqlite.ReSelectdtb(I_Sql.GetSqliteSelect()); Dictionary<int, CompanyModel> sqltablelist = GetSqlcCompany(SqlTable); IList<DbParameter[]> parlist = new List<DbParameter[]>(); for (int j = 0; j < SqliteTable.Rows.Count; j++) { int id = Int32.Parse(SqliteTable.Rows[j]["ID"].ToString()); for (int i = 0; i < sqltablelist.Count; i++) { if (id == sqltablelist.Keys.ToList()[i]) { DbParameter[] DbUpdate = ExecutionSelectCompany(sqltablelist[id]); parlist.Add(DbUpdate); SelectList.Add(I_Sql.GetSqliteUpdate()); sqltablelist.Remove(id); i--; } } } foreach (int Select in sqltablelist.Keys) //根据差集进行插入操作 { DbParameter[] DbInsert = ExecutionSelectCompany(sqltablelist[Select]); parlist.Add(DbInsert); SelectList.Add(I_Sql.GetSqliteInsert()); } SqlTable = Db_Sql.ReSelectdtb(I_Sql.GetSqlSelect()); SqliteTable = Db_Sqlite.ReSelectdtb(I_Sql.GetSqliteSelect()); foreach (DataRow dr in SqlTable.Rows) { int id = Int32.Parse(dr["ID"].ToString()); listsql.Add(id); } foreach (DataRow dr in SqliteTable.Rows) { int id = Int32.Parse(dr["ID"].ToString()); listsqlite.Add(id); } difference = listsqlite.Except(listsql).ToList(); foreach (int Select in difference) { Db_Sqlite.ExSQL(((SqlInterface)I_Sql).GetSqliteDelect(Select)); //删除Service端没有的数据 } int m = Db_Sqlite.ReExNum(SelectList, parlist); WriteLog("公司表需要更新" + SelectList.Count().ToString() + "条记录" + " 实际更新" + m.ToString() + "条记录"); }
private void SynchDataSeting() { string updatetime = string.Empty; DataTable SqlTable = new DataTable(); DataTable SqliteTable = new DataTable(); List<string> SelectList = new List<string>(); I_Sql = SqlFactory.MakeSelect(TableType.Table_Type.Seting); SqlTable = Db_Sql.ReSelectdtb(I_Sql.GetSqlSelect()); SqliteTable = Db_Sqlite.ReSelectdtb(I_Sql.GetSqliteSelect()); IList<DbParameter[]> parlist = new List<DbParameter[]>(); SetModel setmodel = GetSetModel(SqlTable); if ((SqliteTable.Rows.Count > 0) && (SqlTable.Rows.Count > 0) && SqliteTable != null && SqlTable != null) { if (DateTime.Parse(SqlTable.Rows[0]["UpdateTime"].ToString()) > DateTime.Parse(SqliteTable.Rows[0]["UpdateTime"].ToString())) { if (setmodel == null) return; DbParameter[] DbInsert = ExecutionSelectSet(setmodel); parlist.Add(DbInsert); SelectList.Add(I_Sql.GetSqliteUpdate()); } } else { if (setmodel != null) { DbParameter[] DbInsert = ExecutionSelectSet(setmodel); parlist.Add(DbInsert); SelectList.Add(I_Sql.GetSqliteInsert()); } } int m = Db_Sqlite.ReExNum(SelectList, parlist); WriteLog("参数配置表需要更新" + SelectList.Count().ToString() + "条记录" + " 实际更新" + m.ToString() + "条记录"); }
private void SynchDataDownFile() { string updatetime = string.Empty; DataTable SqlTable = new DataTable(); I_Sql = SqlFactory.MakeSelect(TableType.Table_Type.DownFile); SqlTable = Db_Sql.ReSelectdtb(I_Sql.GetSqlSelect()); List<ResourceInfoModel> reslist = GetResourceInfoModel(SqlTable); List<string> downFileUpdateSql = new List<string>(); IList<DbParameter[]> parlist = new List<DbParameter[]>(); foreach (ResourceInfoModel rm in reslist) { string WebSit = WebPath + rm.FileURL; bool result= LoadSavePath(rm,WebSit); if (result) { //更新已下载 DbParameter[] sqlparList = new DbParameter[1]; //sqlparList[0] = Db_Sql.CreateDbParameter("@UpdateTime", DateTime.Now); sqlparList[0] = Db_Sql.CreateDbParameter("@ID", rm.ID); //downFileUpdateSql.Add(); //parlist.Add(sqlparList); string error = ""; int t= Db_Sql.ReExNum(I_Sql.GetSqliteUpdate(), out error, sqlparList); } } //int m = Db_Sql.ReExNum(downFileUpdateSql, parlist); }