public void ThenRecordsShouldBeInsertedInAvengerSMoviebaseFor(int Id, string movieName, string yearOfRelease) { var dtMovieRecords = (DataTable)DBHelpers.ShowDataInGridView(dBQueries.GetMovieRecords, dBQueries.DbConnectionStringAvengers); int characterId = (int)dtMovieRecords.Rows[0]["Id"]; string characterMovieName = dtMovieRecords.Rows[0]["Movie_Name"].ToString(); DateTime characterYearOfRelease = (DateTime)dtMovieRecords.Rows[0]["Year_Of_Release"]; AssertHelpers.AssertEquals(characterId.ToString(), Id.ToString()); AssertHelpers.AssertEquals(characterMovieName, movieName); AssertHelpers.AssertEquals(characterYearOfRelease.Year.ToString(), yearOfRelease); }
public void InseriSubProjetoDB(int childId, int parentId, string inheritParent) { string query = File.ReadAllText(GeneralHelpers.ReturnProjectPath() + "Queries/Projects/inseriSubProjeto.sql", Encoding.UTF8); query = query.Replace("$childId", childId.ToString()) .Replace("$parentId", parentId.ToString()) .Replace("$inheritParent", inheritParent); ExtentReportHelpers.AddTestInfo(2, "PARAMETERS: ID do projeto pai = " + parentId + " ID do projeto filho = " + childId); DBHelpers.ExecuteQuery(query); }
public static void InsertNewProject(int idProjeto, string nomeProjeto) { string idProjetoString = idProjeto.ToString(); string query = File.ReadAllText(GeneralHelpers.ReturnProjectPath() + "Queries/InsertNewProject.sql", Encoding.UTF8); query = query.Replace("$idProjeto", idProjetoString); query = query.Replace("$projectName", nomeProjeto); query = query.Replace("$projectDescription", nomeProjeto + " description"); DBHelpers.ExecuteQuery(query); ExtentReportHelpers.AddTestInfo(2, "PARAMETERS: Executa query - " + query); }
//验证该省名称是否存在该市 public int GetCount(string Name, int provinceId) { string sql = "select count(*) from City where Name=@name and provinceId=@provinceId "; SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar, 200), new SqlParameter("@provinceId", SqlDbType.Int, 4) }; parameters[0].Value = Name; parameters[1].Value = provinceId; return(DBHelpers.GetScalar(sql, parameters)); }
/// <summary> /// 删除一条数据 /// </summary> public int Delete(int MailId) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from SendMail "); strSql.Append(" where MailId=@MailId "); SqlParameter[] parameters = { new SqlParameter("@MailId", SqlDbType.Int, 4) }; parameters[0].Value = MailId; return(DBHelpers.ExecuteCommand(strSql.ToString(), parameters)); }
/// <summary> /// 删除一条数据 /// </summary> public int Delete(int typeID) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from MailType "); strSql.Append(" where typeID=@typeID "); SqlParameter[] parameters = { new SqlParameter("@typeID", SqlDbType.Int, 4) }; parameters[0].Value = typeID; return(DBHelpers.ExecuteCommand(strSql.ToString(), parameters)); }
private DataTable getMyTanks(string playerDBFile) { using (IDBHelpers db = new DBHelpers(playerDBFile, false)) { string sql = @"SELECT DISTINCT cmCountryID, cmTankID FROM File_TankDetails ORDER BY cmCountryID"; DataSet ds = new DataSet(); using (DataTable dt = db.GetDataTable(sql)) { dt.TableName = "myTanks"; ds.Tables.Add(dt); return(dt); } } }
//审核职位 public int Update(Tz888.Model.Mail.Position model) { Tz888.Model.Mail.Position models = GetModelByName(model.Name); if (models != null) { if (models.Id != model.Id) { return(0); } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update Position set "); strSql.Append("Name=@Name,Audit=@Audit"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 300), new SqlParameter("@Audit", SqlDbType.Int, 4) }; parameters[0].Value = model.Id; parameters[1].Value = model.Name; parameters[2].Value = model.Audit; return(DBHelpers.ExecuteSql(strSql.ToString(), parameters)); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update Position set "); strSql.Append("Name=@Name,Audit=@Audit"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 300), new SqlParameter("@Audit", SqlDbType.Int, 4) }; parameters[0].Value = model.Id; parameters[1].Value = model.Name; parameters[2].Value = model.Audit; return(DBHelpers.ExecuteSql(strSql.ToString(), parameters)); } }
public string GetSession() { string key = String.Empty; using (DBHelpers newSession = new DBHelpers(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + _playerName, "LastBattle", "WOTSStore.db"))) { key = newSession.ExecuteScalar("select rsKey from RecentBattles_Session where datetime(rsUEDateTo,'unixepoch', 'localtime') >= datetime('now', 'localtime')"); if (string.IsNullOrEmpty(key)) { return(NewSession()); } else { return(key); } } }
public ActionResult DeleteConfirmed(int id) { var order = db.Orders.Find(id); db.Orders.Remove(order); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); return(View(order)); }
/// <summary> /// 取网上展厅数据 /// </summary> /// <param name="tblName"></param> /// <param name="strGetFields"></param> /// <param name="fldName"></param> /// <param name="PageSize"></param> /// <param name="PageIndex"></param> /// <param name="doCount"></param> /// <param name="OrderType"></param> /// <param name="strWhere"></param> /// <returns></returns> public DataTable GetWebSiteList(string tblName, string strGetFields, string fldName, int PageSize, int PageIndex, int doCount, int OrderType, string strWhere) { DataSet ds = null; SqlParameter[] Parameters = new SqlParameter[] { new SqlParameter("@tblName", SqlDbType.VarChar, 255), new SqlParameter("@strGetFields", SqlDbType.VarChar, 1000), new SqlParameter("@fldName", SqlDbType.VarChar, 255), new SqlParameter("@PageSize", SqlDbType.Int, 4), new SqlParameter("@PageIndex", SqlDbType.Int, 4), new SqlParameter("@doCount", SqlDbType.Bit), new SqlParameter("@OrderType", SqlDbType.Bit), new SqlParameter("@strWhere", SqlDbType.VarChar, 1500) }; string[] name = tblName.Split(','); string namess = name[0]; Parameters[0].Value = namess; Parameters[1].Value = strGetFields; Parameters[2].Value = fldName; Parameters[3].Value = PageSize; Parameters[4].Value = PageIndex; Parameters[5].Value = doCount; Parameters[6].Value = OrderType; Parameters[7].Value = strWhere; if (name.Length == 2) { ds = DBHelper.GetWebSiteList("Sp_Conn_Sort", Parameters, "ds"); } else if (name.Length == 3) { ds = DBHelpers.GetWebSiteList("Sp_Conn_Sort", Parameters, "ds"); } else { ds = DbHelperSQL.GetWebSiteList("Sp_Conn_Sort", Parameters, "ds"); } if (ds != null && ds.Tables.Count != 0) { return(ds.Tables[0]); } return(null); }
/// <summary> /// 得到一个对象实体 /// </summary> public Tz888.Model.Mail.SendMail GetModel(int MailId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 MailId,LoginName,EMtitle,SendContext,SendCount,SendNumber,SendTime from SendMail "); strSql.Append(" where MailId=@MailId "); SqlParameter[] parameters = { new SqlParameter("@MailId", SqlDbType.Int, 4) }; parameters[0].Value = MailId; Tz888.Model.Mail.SendMail model = new Tz888.Model.Mail.SendMail(); DataSet ds = DBHelpers.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["MailId"].ToString() != "") { model.MailId = int.Parse(ds.Tables[0].Rows[0]["MailId"].ToString()); } model.LoginName = ds.Tables[0].Rows[0]["LoginName"].ToString(); model.EMtitle = ds.Tables[0].Rows[0]["EMtitle"].ToString(); model.SendContext = ds.Tables[0].Rows[0]["SendContext"].ToString(); if (ds.Tables[0].Rows[0]["SendCount"].ToString() != "") { model.SendCount = int.Parse(ds.Tables[0].Rows[0]["SendCount"].ToString()); } if (ds.Tables[0].Rows[0]["SendNumber"].ToString() != "") { model.SendNumber = int.Parse(ds.Tables[0].Rows[0]["SendNumber"].ToString()); } if (ds.Tables[0].Rows[0]["SendTime"].ToString() != "") { model.SendTime = ds.Tables[0].Rows[0]["SendTime"].ToString(); } return(model); } else { return(null); } }
public bool IsEmptySession(string sessionID) { string sql = String.Format(@"select count(rbID) from RecentBattles where rbSessionID = '{0}'", sessionID); int value = 0; using (DBHelpers db = new DBHelpers(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + _playerName, "LastBattle", "WOTSStore.db"))) { value = int.Parse(db.ExecuteScalar(sql)); } if (value > 0) { return(false); } else { return(true); } }
public MemoryTables(string dbPath) { _dbPath = dbPath; using (IDBHelpers db = new DBHelpers(dbPath, true)) { DataTable dt = db.GetDataTable("select * from Files where 0 = 1"); dt.TableName = "Files"; ds.Tables.Add(dt); dt = db.GetDataTable("select * from File_Achievements where 0 = 1"); dt.TableName = "File_Achievements"; ds.Tables.Add(dt); dt = db.GetDataTable("select * from File_Battles where 0 = 1"); dt.TableName = "File_Battles"; ds.Tables.Add(dt); dt = db.GetDataTable("select * from File_Clan where 0 = 1"); dt.TableName = "File_Clan"; ds.Tables.Add(dt); dt = db.GetDataTable("select * from File_Historical where 0 = 1"); dt.TableName = "File_Historical"; ds.Tables.Add(dt); dt = db.GetDataTable("select * from File_Company where 0 = 1"); dt.TableName = "File_Company"; ds.Tables.Add(dt); dt = db.GetDataTable("select * from File_FragList where 0 = 1"); dt.TableName = "File_FragList"; ds.Tables.Add(dt); dt = db.GetDataTable("select * from File_TankDetails where 0 = 1"); dt.TableName = "File_TankDetails"; ds.Tables.Add(dt); dt = db.GetDataTable("select * from File_Total where 0 = 1"); dt.TableName = "File_Total"; ds.Tables.Add(dt); } }
public ActionResult Create(PurchaseStatus purchaseStatus) { if (ModelState.IsValid) { db.PurchaseStatus. Add(purchaseStatus); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } return(View(purchaseStatus)); }
public static IEnumerable __ExemploRetornaClientesEConveniosDB(string codigoConvenio) { string query = File.ReadAllText(GeneralHelpers.ReturnProjectPath() + "Queries/__ExemploSelect.sql", Encoding.UTF8); query = query.Replace("$codigoConvenio", codigoConvenio); var teste = new List <string>(); teste = DBHelpers.RetornaDadosQuery(query); for (int i = 0; i < teste.Count; i++) { ArrayList result = new ArrayList(); result.Add(teste[i]); result.Add(teste[i + 1]); i++; yield return(result); } }
public ActionResult Edit(Tax tax) { if (ModelState.IsValid) { db.Entry(tax).State = EntityState.Modified; var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } return(View(tax)); }
/// <summary> /// 统计记录条数 /// </summary> /// <param name="tblName">数据表或视图名</param> /// <param name="fldName">索引列名</param> /// <param name="strWhere">统计条件</param> /// <returns>统计记录条数</returns> public int GetCount(string tblName, string fldName, string strWhere) { SqlParameter[] Parameters = new SqlParameter[] { new SqlParameter("@tblName", SqlDbType.VarChar, 255), new SqlParameter("@strGetFields", SqlDbType.VarChar, 1000), new SqlParameter("@fldName", SqlDbType.VarChar, 255), new SqlParameter("@PageSize", SqlDbType.Int, 4), new SqlParameter("@PageIndex", SqlDbType.Int, 4), new SqlParameter("@doCount", SqlDbType.Bit), new SqlParameter("@OrderType", SqlDbType.Bit), new SqlParameter("@strWhere", SqlDbType.VarChar, 1500) }; string[] name = tblName.Split(','); string namess = name[0]; Parameters[0].Value = namess; Parameters[1].Value = fldName; Parameters[2].Value = fldName; Parameters[3].Value = 1; Parameters[4].Value = 1; Parameters[5].Value = 1; Parameters[6].Value = 0; Parameters[7].Value = strWhere; DataSet ds = null; if (name.Length == 2) { ds = DBHelper.RunProcedure("Sp_Conn_Sort", Parameters, "ds"); } else if (name.Length == 3) { ds = DBHelpers.RunProcedure("Sp_Conn_Sort", Parameters, "ds"); } else { ds = DbHelperSQL.RunProcedure("Sp_Conn_Sort", Parameters, "ds"); } return(Convert.ToInt32(ds.Tables[0].Rows[0][0])); }
/// <summary> /// 得到一个对象实体集合 /// </summary> public List <Tz888.Model.Mail.Province> GetModelList() { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,Name from Province "); List <Tz888.Model.Mail.Province> list = new List <Tz888.Model.Mail.Province>(); DataSet ds = DBHelpers.Query(strSql.ToString()); foreach (DataRow row in ds.Tables[0].Rows) { Tz888.Model.Mail.Province model = new Tz888.Model.Mail.Province(); if (row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } model.Name = row["Name"].ToString(); list.Add(model); } return(list); }
/// <summary> /// 增加组 /// </summary> public int Add(Tz888.Model.Mail.Mialgroup model) { int count = GetCount(model.groupname.Trim()); if (count > 0) { return(0); } else { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Mialgroup("); strSql.Append("groupname,groupremark,audit)"); strSql.Append(" values ("); strSql.Append("@groupname,@groupremark,@audit)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@groupname", SqlDbType.VarChar, 100), new SqlParameter("@groupremark", SqlDbType.VarChar, 200), new SqlParameter("@audit", SqlDbType.Int, 4) }; parameters[0].Value = model.groupname; parameters[1].Value = model.groupremark; parameters[2].Value = model.Audit; object obj = DBHelpers.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } } }
/// <summary> /// 得到一个对象实体 /// </summary> public Tz888.Model.Mail.MailLog GetModel(int EID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 EID,MailId,MUserName,edate from MailLog "); strSql.Append(" where EID=@EID "); SqlParameter[] parameters = { new SqlParameter("@EID", SqlDbType.Int, 4) }; parameters[0].Value = EID; Tz888.Model.Mail.MailLog model = new Tz888.Model.Mail.MailLog(); DataSet ds = DBHelpers.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["EID"].ToString() != "") { model.EID = int.Parse(ds.Tables[0].Rows[0]["EID"].ToString()); } if (ds.Tables[0].Rows[0]["MailId"].ToString() != "") { model.MailId = int.Parse(ds.Tables[0].Rows[0]["MailId"].ToString()); } model.MUserName = ds.Tables[0].Rows[0]["MUserName"].ToString(); if (ds.Tables[0].Rows[0]["edate"].ToString() != "") { model.edate = ds.Tables[0].Rows[0]["edate"].ToString(); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tz888.Model.Mail.Position model) { int count = GetCount(model.Name); if (count == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Position("); strSql.Append("Name,Audit)"); strSql.Append(" values ("); strSql.Append("@Name,@Audit)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar, 300), new SqlParameter("@Audit", SqlDbType.Int, 4) }; parameters[0].Value = model.Name; parameters[1].Value = model.Audit; object obj = DBHelpers.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } } else { return(0); } }
/// <summary> /// 绑定成dropdownlist的时候用 /// </summary> public List <Tz888.Model.Mail.Industry> GetModelList() { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,Name,IsShow from Industry where IsShow=1"); List <Tz888.Model.Mail.Industry> list = new List <Tz888.Model.Mail.Industry>(); DataSet ds = DBHelpers.Query(strSql.ToString()); foreach (DataRow row in ds.Tables[0].Rows) { Tz888.Model.Mail.Industry model = new Tz888.Model.Mail.Industry(); if (row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } model.Name = row["Name"].ToString(); if (row["IsShow"].ToString() != "") { model.IsShow = int.Parse(row["IsShow"].ToString()); } list.Add(model); } return(list); }
/// <summary> /// 增加类型 /// </summary> public int Add(Tz888.Model.Mail.MailType model) { Tz888.Model.Mail.MailType models = GetModelByTypeName(model.TypeName); if (models == null) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into MailType("); strSql.Append("TypeName,TypeRemark,audit)"); strSql.Append(" values ("); strSql.Append("@TypeName,@TypeRemark,@audit)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@TypeName", SqlDbType.NVarChar, 200), new SqlParameter("@TypeRemark", SqlDbType.NVarChar, 200), new SqlParameter("@audit", SqlDbType.Int, 4) }; parameters[0].Value = model.TypeName; parameters[1].Value = model.TypeRemark; parameters[2].Value = model.Audit; object obj = DBHelpers.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } } else { return(0); } }
public string NewSession() { string iGuid = Guid.NewGuid().ToString(); Dictionary <string, string> tempDataStore = new Dictionary <string, string>(); using (DBHelpers newSession = new DBHelpers(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + _playerName, "LastBattle", "WOTSStore.db"))) { string key = newSession.ExecuteScalar("select rsKey from RecentBattles_Session where datetime(rsUEDateTo, 'unixepoch', 'localtime') >= datetime('now', 'localtime')"); string sql; if (!string.IsNullOrEmpty(key)) { if (!IsEmptySession(key)) { sql = "update RecentBattles_Session set rsDateTo = '" + WOTHelper.CurrentDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "', rsUEDateTo = strftime('%s','now') where rsKey = '" + key + "'"; newSession.ExecuteNonQuery(sql); //Thread.Sleep(1000); sql = "insert into RecentBattles_Session (rsKey, rsDateFrom, rsDateTo, rsUEDateFrom, rsUEDateTo) values ('" + iGuid + "', '" + WOTHelper.CurrentDateTime.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss") + "', '" + new DateTime(2037, 1, 1, 0, 0, 0, 0).ToString("yyyy-MM-dd HH:mm:ss") + "', strftime('%s','now'), 2114373600)"; newSession.ExecuteNonQuery(sql); return(iGuid); } else { sql = "update RecentBattles_Session set rsDateFrom = '" + WOTHelper.CurrentDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "', rsUEDateFrom = strftime('%s','now') where rsKey = '" + key + "'"; newSession.ExecuteNonQuery(sql); return(key); } } else { sql = "insert into RecentBattles_Session (rsKey, rsDateFrom, rsDateTo, rsUEDateFrom, rsUEDateTo) values ('" + iGuid + "', '" + WOTHelper.CurrentDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + new DateTime(2037, 1, 1, 0, 0, 0, 0).ToString("yyyy-MM-dd HH:mm:ss") + "', strftime('%s','now'), 2114373600)"; newSession.ExecuteNonQuery(sql); return(iGuid); } } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tz888.Model.Mail.SendMail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SendMail("); strSql.Append("LoginName,EMtitle,SendContext,SendCount,SendNumber,SendTime)"); strSql.Append(" values ("); strSql.Append("@LoginName,@EMtitle,@SendContext,@SendCount,@SendNumber,@SendTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@LoginName", SqlDbType.NVarChar, 200), new SqlParameter("@EMtitle", SqlDbType.NVarChar, 3000), new SqlParameter("@SendContext", SqlDbType.Text), new SqlParameter("@SendCount", SqlDbType.Int, 4), new SqlParameter("@SendNumber", SqlDbType.Int, 4), new SqlParameter("@SendTime", SqlDbType.DateTime) }; parameters[0].Value = model.LoginName; parameters[1].Value = model.EMtitle; parameters[2].Value = model.SendContext; parameters[3].Value = model.SendCount; parameters[4].Value = model.SendNumber; parameters[5].Value = model.SendTime; object obj = DBHelpers.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
// UpdateCashStream public int UpadateCashStream() { using (OracleConnection conn = DBHelpers.GetConnection()) { using (OracleTransaction trn = conn.BeginTransaction()) { try { // Get balance string selectSql = @"SELECT * FROM CASHSTREAM WHERE USERNAME=:name ORDER BY CREATETIME DESC"; var resultModel = conn.Query <CashStreamModel>(selectSql, new { name = "Henry" }).FirstOrDefault(); var selectedBalance = resultModel.BALANCE; resultModel.BALANCE = resultModel.BALANCE + 50; resultModel.CREATETIME = DateTime.Now; resultModel.SERVER = "ServerB"; // Add balance and save into server string strSql = @"UPDATE CASHSTREAM SET BALANCE=:BALANCE, SERVER=:SERVER, CREATETIME=:CREATETIME WHERE ID=:ID AND BALANCE=" + selectedBalance; var col = conn.Execute(strSql, resultModel); Thread.Sleep(3000); trn.Commit(); return(col); } catch (Exception ex) { Console.WriteLine(ex.Message); return(0); } } } }
public static Tuple <DateTime?, DateTime?, int?> GetSessionDates(string playerName) { using (DBHelpers newSession = new DBHelpers(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + playerName, "LastBattle", "WOTSStore.db"))) { string sql; if (UserSettings.ViewSessionID == null) { sql = String.Format("select rsID, rsKey, datetime(rsUEDateFrom, 'unixepoch', 'localtime') as rsDateFrom, datetime(rsUEDateTo, 'unixepoch', 'localtime') as rsDateTo from RecentBattles_Session where datetime(rsUEDateTo, 'unixepoch', 'localtime') >= datetime({0}, 'unixepoch', 'localtime')", WOTHelper.ConvertToUnixTimestamp(WOTHelper.CurrentDateTime)); } else { sql = String.Format("select rsID, rsKey, datetime(rsUEDateFrom, 'unixepoch', 'localtime') as rsDateFrom, datetime(rsUEDateTo, 'unixepoch', 'localtime') as rsDateTo from RecentBattles_Session where rsKey = '{0}'", UserSettings.ViewSessionID); } DataTable dt = newSession.GetDataTable(sql); if (dt.Rows.Count > 0) { return(new Tuple <DateTime?, DateTime?, int?>(Convert.ToDateTime(dt.Rows[0]["rsDateFrom"]), Convert.ToDateTime(dt.Rows[0]["rsDateTo"]), Convert.ToInt16(dt.Rows[0]["rsID"]))); } else { return(new Tuple <DateTime?, DateTime?, int?>(null, null, null)); } } }
public static void DoData(string playerFolder, string dbPath, UpdateGUIProgressBar statusBar) { using (IDBHelpers db = new DBHelpers(dbPath, true)) { db.BeginTransaction(); db.ClearTable("Files"); db.ClearTable("File_Achievements"); db.ClearTable("File_Battles"); db.ClearTable("File_Clan"); db.ClearTable("File_Company"); db.ClearTable("File_FragList"); db.ClearTable("File_Total"); string[] dir = Directory.GetFiles(playerFolder, "*.txt"); int fileCount = 0; statusBar(new Tuple <int, int>(fileCount, dir.Length - 1), 2); foreach (var historyFile in dir) { statusBar(new Tuple <int, int>(fileCount, dir.Length - 1), 2); fileCount++; try { string file = File.ReadAllText(historyFile); var file_Serializer = new JavaScriptSerializer(); file_Serializer.RegisterConverters(new[] { new DynamicJsonConverter() }); dynamic dyn_fileObject = file_Serializer.Deserialize(file, typeof(object)); //Create File table data. Dictionary <string, string> data = new Dictionary <string, string>(); SafeObjectHandler(data, "fiDate", GetSafeValue(dyn_fileObject.date)); SafeObjectHandler(data, "fiParser", GetSafeValue(dyn_fileObject.parser)); SafeObjectHandler(data, "fiTankCount", GetSafeValue(dyn_fileObject.tankcount)); SafeObjectHandler(data, "fiParserVersion", GetSafeValue(dyn_fileObject.parserversion)); FileInfo fi = new FileInfo(historyFile); SafeObjectHandler(data, "fiID", fi.Name.Replace(".txt", "")); db.Insert("Files", data); data.Clear(); string fileID = fi.Name.Replace(".txt", ""); foreach (var tank in dyn_fileObject.tanks) { SafeObjectHandler(data, "cmFileID", fileID); SafeObjectHandler(data, "cmUpdated", GetSafeValue(tank.updated)); SafeObjectHandler(data, "cmCountryID", GetSafeValue(tank.countryid)); SafeObjectHandler(data, "cmTankID", GetSafeValue(tank.tankid)); SafeObjectHandler(data, "cmBaseVersion", GetSafeValue(tank.basedonversion)); SafeObjectHandler(data, "cmLastBattleTime", GetSafeValue(tank.tankdata.lastBattleTime)); db.Insert("File_TankDetails", data); data.Clear(); string tankID = String.Empty; try { tankID = db.ExecuteScalar("select cmID from File_TankDetails where cmFileID = " + fileID + " and cmTankID = " + GetSafeValue(tank.tankid) + " and cmCountryID = " + GetSafeValue(tank.countryid)); } catch { } if (ObjectExists(tank.clan)) { if (tank.clan.GetType() != typeof(ArrayList)) { SafeObjectHandler(data, "clParentID", tankID); SafeObjectHandler(data, "clBattlesCount", GetSafeValue(tank.clan.battlesCount)); SafeObjectHandler(data, "clCapturePoints", GetSafeValue(tank.clan.capturePoints)); SafeObjectHandler(data, "clDamageDealt", GetSafeValue(tank.clan.damageDealt)); SafeObjectHandler(data, "clDamageReceived", GetSafeValue(tank.clan.damageReceived)); SafeObjectHandler(data, "clDefencePoints", GetSafeValue(tank.clan.droppedCapturePoints)); SafeObjectHandler(data, "clFrags", GetSafeValue(tank.clan.frags)); SafeObjectHandler(data, "clHits", GetSafeValue(tank.clan.hits)); SafeObjectHandler(data, "clLosses", GetSafeValue(tank.clan.losses)); SafeObjectHandler(data, "clShots", GetSafeValue(tank.clan.shots)); SafeObjectHandler(data, "clSpotted", GetSafeValue(tank.clan.spotted)); SafeObjectHandler(data, "clSurvivedBattles", GetSafeValue(tank.clan.survivedBattles)); SafeObjectHandler(data, "clWins", GetSafeValue(tank.clan.wins)); SafeObjectHandler(data, "clXP", GetSafeValue(tank.clan.xp)); db.Insert("File_Clan", data); data.Clear(); } else { foreach (var clan in tank.clan) { SafeObjectHandler(data, "clParentID", tankID); SafeObjectHandler(data, "clBattlesCount", GetSafeValue(clan.battlesCount)); SafeObjectHandler(data, "clCapturePoints", GetSafeValue(clan.capturePoints)); SafeObjectHandler(data, "clDamageDealt", GetSafeValue(clan.damageDealt)); SafeObjectHandler(data, "clDamageReceived", GetSafeValue(clan.damageReceived)); SafeObjectHandler(data, "clDefencePoints", GetSafeValue(clan.droppedCapturePoints)); SafeObjectHandler(data, "clFrags", GetSafeValue(clan.frags)); SafeObjectHandler(data, "clHits", GetSafeValue(clan.hits)); SafeObjectHandler(data, "clLosses", GetSafeValue(clan.losses)); SafeObjectHandler(data, "clShots", GetSafeValue(clan.shots)); SafeObjectHandler(data, "clSpotted", GetSafeValue(clan.spotted)); SafeObjectHandler(data, "clSurvivedBattles", GetSafeValue(clan.survivedBattles)); SafeObjectHandler(data, "clWins", GetSafeValue(clan.wins)); SafeObjectHandler(data, "clXP", GetSafeValue(clan.xp)); db.Insert("File_Clan", data); data.Clear(); } } } if (ObjectExists(tank.company)) { if (tank.company.GetType() != typeof(ArrayList)) { SafeObjectHandler(data, "clParentID", tankID); SafeObjectHandler(data, "fcBattlesCount", GetSafeValue(tank.company.battlesCount)); SafeObjectHandler(data, "fcCapturePoints", GetSafeValue(tank.company.capturePoints)); SafeObjectHandler(data, "fcDamageDealt", GetSafeValue(tank.company.damageDealt)); SafeObjectHandler(data, "fcDamageReceived", GetSafeValue(tank.company.damageReceived)); SafeObjectHandler(data, "fcDefencePoints", GetSafeValue(tank.company.droppedCapturePoints)); SafeObjectHandler(data, "fcFrags", GetSafeValue(tank.company.frags)); SafeObjectHandler(data, "fcHits", GetSafeValue(tank.company.losses)); SafeObjectHandler(data, "fcShots", GetSafeValue(tank.company.shots)); SafeObjectHandler(data, "fcSpotted", GetSafeValue(tank.company.spotted)); SafeObjectHandler(data, "fcSurvivedBattles", GetSafeValue(tank.company.survivedBattles)); SafeObjectHandler(data, "fcWins", GetSafeValue(tank.company.wins)); SafeObjectHandler(data, "fcXP", GetSafeValue(tank.company.xp)); db.Insert("File_Company", data); data.Clear(); } else { foreach (var clan in tank.company) { SafeObjectHandler(data, "fcParentID", tankID); SafeObjectHandler(data, "fcBattlesCount", GetSafeValue(clan.battlesCount)); SafeObjectHandler(data, "fcCapturePoints", GetSafeValue(clan.capturePoints)); SafeObjectHandler(data, "fcDamageDealt", GetSafeValue(clan.damageDealt)); SafeObjectHandler(data, "fcDamageReceived", GetSafeValue(clan.damageReceived)); SafeObjectHandler(data, "fcDefencePoints", GetSafeValue(clan.droppedCapturePoints)); SafeObjectHandler(data, "fcFrags", GetSafeValue(clan.frags)); SafeObjectHandler(data, "fcHits", GetSafeValue(clan.hits)); SafeObjectHandler(data, "fcLosses", GetSafeValue(clan.losses)); SafeObjectHandler(data, "fcShots", GetSafeValue(clan.shots)); SafeObjectHandler(data, "fcSpotted", GetSafeValue(clan.spotted)); SafeObjectHandler(data, "fcSurvivedBattles", GetSafeValue(clan.survivedBattles)); SafeObjectHandler(data, "fcWins", GetSafeValue(clan.wins)); SafeObjectHandler(data, "fcXP", GetSafeValue(clan.xp)); db.Insert("File_Company", data); data.Clear(); } } } string insert = "Insert into File_FragList (fgParentID, fgCountryID, fgTankID, fgValue)"; List <string> values = new List <string>(); foreach (var kills in tank.kills) { values.Add(String.Format("Select '{0}', '{1}', '{2}', '{3}'", tankID, GetSafeValue(kills[0]), GetSafeValue(kills[1]), GetSafeValue(kills[2]))); } if (values.Count > 0) { if (values.Count >= 400) { foreach (var item in values) { db.ExecuteNonQuery(insert + " " + item); } } else { db.ExecuteNonQuery(insert + string.Join(" union all ", values)); } } values.Clear(); SafeObjectHandler(data, "foParentID", tankID); SafeObjectHandler(data, "foTreesCut", GetSafeValue(tank.tankdata.treesCut)); SafeObjectHandler(data, "foBattleLifeTime", GetSafeValue(tank.tankdata.battleLifeTime)); SafeObjectHandler(data, "foLastBattleTime", GetSafeValue(tank.tankdata.lastBattleTime)); db.Insert("File_Total", data); data.Clear(); SafeObjectHandler(data, "bpParentID", tankID); SafeObjectHandler(data, "bpBattleCount", GetSafeValue(tank.tankdata.battlesCount)); SafeObjectHandler(data, "bpCapturePoints", GetSafeValue(tank.tankdata.capturePoints)); SafeObjectHandler(data, "bpDamageDealt", GetSafeValue(tank.tankdata.damageDealt)); SafeObjectHandler(data, "bpDamageReceived", GetSafeValue(tank.tankdata.damageReceived)); SafeObjectHandler(data, "bpDefencePoints", GetSafeValue(tank.tankdata.droppedCapturePoints)); SafeObjectHandler(data, "bpFrags", GetSafeValue(tank.tankdata.frags)); SafeObjectHandler(data, "bpFrags8P", GetSafeValue(tank.tankdata.frags8p)); SafeObjectHandler(data, "bpHits", GetSafeValue(tank.tankdata.hits)); SafeObjectHandler(data, "bpLosses", GetSafeValue(tank.tankdata.losses)); SafeObjectHandler(data, "bpMaxFrags", GetSafeValue(tank.tankdata.maxFrags)); SafeObjectHandler(data, "bpMaxXP", GetSafeValue(tank.tankdata.maxXP)); SafeObjectHandler(data, "bpShots", GetSafeValue(tank.tankdata.shots)); SafeObjectHandler(data, "bpSpotted", GetSafeValue(tank.tankdata.spotted)); SafeObjectHandler(data, "bpSurvivedBattles", GetSafeValue(tank.tankdata.survivedBattles)); SafeObjectHandler(data, "bpWinAndSurvive", GetSafeValue(tank.tankdata.winAndSurvived)); SafeObjectHandler(data, "bpWins", GetSafeValue(tank.tankdata.wins)); SafeObjectHandler(data, "bpXP", GetSafeValue(tank.tankdata.xp)); db.Insert("File_Battles", data); data.Clear(); SafeObjectHandler(data, "faParentID", tankID); SafeObjectHandler(data, "faDieHardSeries", GetSafeValue(tank.series.diehardSeries)); SafeObjectHandler(data, "faInvincibleSeries", GetSafeValue(tank.series.invincibleSeries)); SafeObjectHandler(data, "faKillingSeries", GetSafeValue(tank.series.killingSeries)); SafeObjectHandler(data, "faMaxDieHardSeries", GetSafeValue(tank.series.maxDiehardSeries)); SafeObjectHandler(data, "faMaxInvincibleSeries", GetSafeValue(tank.series.maxInvincibleSeries)); SafeObjectHandler(data, "faMaxKillingSeries", GetSafeValue(tank.series.maxKillingSeries)); SafeObjectHandler(data, "faMaxPiercingSeries", GetSafeValue(tank.series.maxPiercingSeries)); SafeObjectHandler(data, "faMaxSniperSeries", GetSafeValue(tank.series.maxSniperSeries)); SafeObjectHandler(data, "faPiercingSeries", GetSafeValue(tank.series.piercingSeries)); SafeObjectHandler(data, "faSniperSeries", GetSafeValue(tank.series.sniperSeries)); SafeObjectHandler(data, "faMedalAbrams", GetSafeValue(tank.major.Abrams)); SafeObjectHandler(data, "faMedalCarius", GetSafeValue(tank.major.Carius)); SafeObjectHandler(data, "faMedalEkins", GetSafeValue(tank.major.Ekins)); SafeObjectHandler(data, "faMedalKay", GetSafeValue(tank.major.Kay)); SafeObjectHandler(data, "faMedalKnispel", GetSafeValue(tank.major.Knispel)); SafeObjectHandler(data, "faMedalLavrinenko", GetSafeValue(tank.major.Lavrinenko)); SafeObjectHandler(data, "faMedalLeClerc", GetSafeValue(tank.major.LeClerc)); SafeObjectHandler(data, "faMedalPoppel", GetSafeValue(tank.major.Poppel)); SafeObjectHandler(data, "faFragsBeast", GetSafeValue(tank.tankdata.fragsBeast)); SafeObjectHandler(data, "faBattleHeroes", GetSafeValue(tank.battle.battleHeroes)); SafeObjectHandler(data, "faDefender", GetSafeValue(tank.battle.defender)); SafeObjectHandler(data, "faEveilEye", GetSafeValue(tank.battle.evileye)); SafeObjectHandler(data, "faFragsSinai", GetSafeValue(tank.battle.fragsSinai)); SafeObjectHandler(data, "faInvader", GetSafeValue(tank.battle.invader)); SafeObjectHandler(data, "faScout", GetSafeValue(tank.battle.scout)); SafeObjectHandler(data, "faSniper", GetSafeValue(tank.battle.sniper)); SafeObjectHandler(data, "faSteelwall", GetSafeValue(tank.battle.steelwall)); SafeObjectHandler(data, "faSupporter", GetSafeValue(tank.battle.supporter)); SafeObjectHandler(data, "faWarrior", GetSafeValue(tank.battle.warrior)); SafeObjectHandler(data, "faMedalBillotte", GetSafeValue(tank.epic.Billotte)); SafeObjectHandler(data, "faMedalBurda", GetSafeValue(tank.epic.Burda)); SafeObjectHandler(data, "faMedalDeLanglade", GetSafeValue(tank.epic.DeLaglanda)); //SafeObjectHandler(data, "faWarrior", tank.epic.Erohin); SafeObjectHandler(data, "faMedalFadin", GetSafeValue(tank.epic.Fadin)); SafeObjectHandler(data, "faMedalHalonen", GetSafeValue(tank.epic.Halonen)); SafeObjectHandler(data, "faHeroesOfRasseney", GetSafeValue(tank.epic.HeroesOfRassenai)); //SafeObjectHandler(data, "faWarrior", tank.epic.Horoshilov); SafeObjectHandler(data, "faMedalKolobanov", GetSafeValue(tank.epic.Kolobanov)); //SafeObjectHandler(data, "faWarrior", tank.epic.Lister); SafeObjectHandler(data, "faMedalOrlik", GetSafeValue(tank.epic.Orlik)); SafeObjectHandler(data, "faMedalOskin", GetSafeValue(tank.epic.Oskin)); SafeObjectHandler(data, "faMedalTamadaYoshio", GetSafeValue(tank.epic.TamadaYoshio)); SafeObjectHandler(data, "faMedalWittmann", GetSafeValue(tank.epic.Wittmann)); SafeObjectHandler(data, "faArmorPiercer", GetSafeValue(tank.special.armorPiercer)); SafeObjectHandler(data, "faBeastHunter", GetSafeValue(tank.special.beasthunter)); SafeObjectHandler(data, "faDieHard", GetSafeValue(tank.special.diehard)); SafeObjectHandler(data, "faHandOfDeath", GetSafeValue(tank.special.handOfDeath)); SafeObjectHandler(data, "faInvincible", GetSafeValue(tank.special.invincible)); SafeObjectHandler(data, "faKamikaze", GetSafeValue(tank.special.kamikaze)); SafeObjectHandler(data, "faLumberJack", GetSafeValue(tank.special.lumberjack)); SafeObjectHandler(data, "faMarkOfMastery", GetSafeValue(tank.special.markOfMastery)); SafeObjectHandler(data, "faMousebane", GetSafeValue(tank.special.mousebane)); SafeObjectHandler(data, "faRaider", GetSafeValue(tank.special.raider)); SafeObjectHandler(data, "faTitleSniper", GetSafeValue(tank.special.sniper)); SafeObjectHandler(data, "faTankExpertStrg", GetSafeValue(tank.special.tankExpert)); db.Insert("File_Achievements", data); data.Clear(); } } catch (Exception) { throw; } } db.ExecuteNonQuery("delete from File_Battles where bpwins > bpBattleCount"); db.EndTransaction(); } }
public static string RetornaIdIssue() { string query = SelectsQueries.RetornaIdIssue; return(DBHelpers.RetornaDadosQuery(query)[0]); }
public static void ShrinkDB(string fileName) { using (IDBHelpers dbHelpers = new DBHelpers(fileName)) { dbHelpers.ExecuteNonQuery("vacuum 'WOTSTORE'"); } }
public static void DoData(string playerFolder, string dbPath, UpdateGUIProgressBar statusBar) { using (IDBHelpers db = new DBHelpers(dbPath, true)) { db.BeginTransaction(); db.ClearTable("Files"); db.ClearTable("File_Achievements"); db.ClearTable("File_Battles"); db.ClearTable("File_Clan"); db.ClearTable("File_Company"); db.ClearTable("File_FragList"); db.ClearTable("File_Total"); string[] dir = Directory.GetFiles(playerFolder, "*.txt"); int fileCount = 0; statusBar(new Tuple<int, int>(fileCount, dir.Length-1), 2); foreach (var historyFile in dir) { statusBar(new Tuple<int, int>(fileCount, dir.Length-1), 2); fileCount++; try { string file = File.ReadAllText(historyFile); var file_Serializer = new JavaScriptSerializer(); file_Serializer.RegisterConverters(new[] { new DynamicJsonConverter() }); dynamic dyn_fileObject = file_Serializer.Deserialize(file, typeof(object)); //Create File table data. Dictionary<string, string> data = new Dictionary<string, string>(); SafeObjectHandler(data, "fiDate", GetSafeValue(dyn_fileObject.date)); SafeObjectHandler(data, "fiParser", GetSafeValue(dyn_fileObject.parser)); SafeObjectHandler(data, "fiTankCount", GetSafeValue(dyn_fileObject.tankcount)); SafeObjectHandler(data, "fiParserVersion", GetSafeValue(dyn_fileObject.parserversion)); FileInfo fi = new FileInfo(historyFile); SafeObjectHandler(data, "fiID", fi.Name.Replace(".txt", "")); db.Insert("Files", data); data.Clear(); string fileID = fi.Name.Replace(".txt", ""); foreach (var tank in dyn_fileObject.tanks) { SafeObjectHandler(data, "cmFileID", fileID); SafeObjectHandler(data, "cmUpdated", GetSafeValue(tank.updated)); SafeObjectHandler(data, "cmCountryID", GetSafeValue(tank.countryid)); SafeObjectHandler(data, "cmTankID", GetSafeValue(tank.tankid)); SafeObjectHandler(data, "cmBaseVersion", GetSafeValue(tank.basedonversion)); SafeObjectHandler(data, "cmLastBattleTime", GetSafeValue(tank.tankdata.lastBattleTime)); db.Insert("File_TankDetails", data); data.Clear(); string tankID = String.Empty; try { tankID = db.ExecuteScalar("select cmID from File_TankDetails where cmFileID = " + fileID + " and cmTankID = " + GetSafeValue(tank.tankid) + " and cmCountryID = " + GetSafeValue(tank.countryid)); } catch { } if (ObjectExists(tank.clan)) { if (tank.clan.GetType() != typeof(ArrayList)) { SafeObjectHandler(data, "clParentID", tankID); SafeObjectHandler(data, "clBattlesCount", GetSafeValue(tank.clan.battlesCount)); SafeObjectHandler(data, "clCapturePoints", GetSafeValue(tank.clan.capturePoints)); SafeObjectHandler(data, "clDamageDealt", GetSafeValue(tank.clan.damageDealt)); SafeObjectHandler(data, "clDamageReceived", GetSafeValue(tank.clan.damageReceived)); SafeObjectHandler(data, "clDefencePoints", GetSafeValue(tank.clan.droppedCapturePoints)); SafeObjectHandler(data, "clFrags", GetSafeValue(tank.clan.frags)); SafeObjectHandler(data, "clHits", GetSafeValue(tank.clan.hits)); SafeObjectHandler(data, "clLosses", GetSafeValue(tank.clan.losses)); SafeObjectHandler(data, "clShots", GetSafeValue(tank.clan.shots)); SafeObjectHandler(data, "clSpotted", GetSafeValue(tank.clan.spotted)); SafeObjectHandler(data, "clSurvivedBattles", GetSafeValue(tank.clan.survivedBattles)); SafeObjectHandler(data, "clWins", GetSafeValue(tank.clan.wins)); SafeObjectHandler(data, "clXP", GetSafeValue(tank.clan.xp)); db.Insert("File_Clan", data); data.Clear(); } else { foreach (var clan in tank.clan) { SafeObjectHandler(data, "clParentID", tankID); SafeObjectHandler(data, "clBattlesCount", GetSafeValue(clan.battlesCount)); SafeObjectHandler(data, "clCapturePoints", GetSafeValue(clan.capturePoints)); SafeObjectHandler(data, "clDamageDealt", GetSafeValue(clan.damageDealt)); SafeObjectHandler(data, "clDamageReceived", GetSafeValue(clan.damageReceived)); SafeObjectHandler(data, "clDefencePoints", GetSafeValue(clan.droppedCapturePoints)); SafeObjectHandler(data, "clFrags", GetSafeValue(clan.frags)); SafeObjectHandler(data, "clHits", GetSafeValue(clan.hits)); SafeObjectHandler(data, "clLosses", GetSafeValue(clan.losses)); SafeObjectHandler(data, "clShots", GetSafeValue(clan.shots)); SafeObjectHandler(data, "clSpotted", GetSafeValue(clan.spotted)); SafeObjectHandler(data, "clSurvivedBattles", GetSafeValue(clan.survivedBattles)); SafeObjectHandler(data, "clWins", GetSafeValue(clan.wins)); SafeObjectHandler(data, "clXP", GetSafeValue(clan.xp)); db.Insert("File_Clan", data); data.Clear(); } } } if (ObjectExists(tank.company)) { if (tank.company.GetType() != typeof(ArrayList)) { SafeObjectHandler(data, "clParentID", tankID); SafeObjectHandler(data, "fcBattlesCount", GetSafeValue(tank.company.battlesCount)); SafeObjectHandler(data, "fcCapturePoints", GetSafeValue(tank.company.capturePoints)); SafeObjectHandler(data, "fcDamageDealt", GetSafeValue(tank.company.damageDealt)); SafeObjectHandler(data, "fcDamageReceived", GetSafeValue(tank.company.damageReceived)); SafeObjectHandler(data, "fcDefencePoints", GetSafeValue(tank.company.droppedCapturePoints)); SafeObjectHandler(data, "fcFrags", GetSafeValue(tank.company.frags)); SafeObjectHandler(data, "fcHits", GetSafeValue(tank.company.losses)); SafeObjectHandler(data, "fcShots", GetSafeValue(tank.company.shots)); SafeObjectHandler(data, "fcSpotted", GetSafeValue(tank.company.spotted)); SafeObjectHandler(data, "fcSurvivedBattles", GetSafeValue(tank.company.survivedBattles)); SafeObjectHandler(data, "fcWins", GetSafeValue(tank.company.wins)); SafeObjectHandler(data, "fcXP", GetSafeValue(tank.company.xp)); db.Insert("File_Company", data); data.Clear(); } else { foreach (var clan in tank.company) { SafeObjectHandler(data, "fcParentID", tankID); SafeObjectHandler(data, "fcBattlesCount", GetSafeValue(clan.battlesCount)); SafeObjectHandler(data, "fcCapturePoints", GetSafeValue(clan.capturePoints)); SafeObjectHandler(data, "fcDamageDealt", GetSafeValue(clan.damageDealt)); SafeObjectHandler(data, "fcDamageReceived", GetSafeValue(clan.damageReceived)); SafeObjectHandler(data, "fcDefencePoints", GetSafeValue(clan.droppedCapturePoints)); SafeObjectHandler(data, "fcFrags", GetSafeValue(clan.frags)); SafeObjectHandler(data, "fcHits", GetSafeValue(clan.hits)); SafeObjectHandler(data, "fcLosses", GetSafeValue(clan.losses)); SafeObjectHandler(data, "fcShots", GetSafeValue(clan.shots)); SafeObjectHandler(data, "fcSpotted", GetSafeValue(clan.spotted)); SafeObjectHandler(data, "fcSurvivedBattles", GetSafeValue(clan.survivedBattles)); SafeObjectHandler(data, "fcWins", GetSafeValue(clan.wins)); SafeObjectHandler(data, "fcXP", GetSafeValue(clan.xp)); db.Insert("File_Company", data); data.Clear(); } } } string insert = "Insert into File_FragList (fgParentID, fgCountryID, fgTankID, fgValue)"; List<string> values = new List<string>(); foreach (var kills in tank.kills) { values.Add(String.Format("Select '{0}', '{1}', '{2}', '{3}'", tankID, GetSafeValue(kills[0]), GetSafeValue(kills[1]), GetSafeValue(kills[2])) ); } if (values.Count > 0) { if (values.Count >= 400) { foreach (var item in values) { db.ExecuteNonQuery(insert + " " + item); } } else { db.ExecuteNonQuery(insert + string.Join(" union all ", values)); } } values.Clear(); SafeObjectHandler(data, "foParentID", tankID); SafeObjectHandler(data, "foTreesCut", GetSafeValue(tank.tankdata.treesCut)); SafeObjectHandler(data, "foBattleLifeTime", GetSafeValue(tank.tankdata.battleLifeTime)); SafeObjectHandler(data, "foLastBattleTime", GetSafeValue(tank.tankdata.lastBattleTime)); db.Insert("File_Total", data); data.Clear(); SafeObjectHandler(data, "bpParentID", tankID); SafeObjectHandler(data, "bpBattleCount", GetSafeValue(tank.tankdata.battlesCount)); SafeObjectHandler(data, "bpCapturePoints", GetSafeValue(tank.tankdata.capturePoints)); SafeObjectHandler(data, "bpDamageDealt", GetSafeValue(tank.tankdata.damageDealt)); SafeObjectHandler(data, "bpDamageReceived", GetSafeValue(tank.tankdata.damageReceived)); SafeObjectHandler(data, "bpDefencePoints", GetSafeValue(tank.tankdata.droppedCapturePoints)); SafeObjectHandler(data, "bpFrags", GetSafeValue(tank.tankdata.frags)); SafeObjectHandler(data, "bpFrags8P", GetSafeValue(tank.tankdata.frags8p)); SafeObjectHandler(data, "bpHits", GetSafeValue(tank.tankdata.hits)); SafeObjectHandler(data, "bpLosses", GetSafeValue(tank.tankdata.losses)); SafeObjectHandler(data, "bpMaxFrags", GetSafeValue(tank.tankdata.maxFrags)); SafeObjectHandler(data, "bpMaxXP", GetSafeValue(tank.tankdata.maxXP)); SafeObjectHandler(data, "bpShots", GetSafeValue(tank.tankdata.shots)); SafeObjectHandler(data, "bpSpotted", GetSafeValue(tank.tankdata.spotted)); SafeObjectHandler(data, "bpSurvivedBattles", GetSafeValue(tank.tankdata.survivedBattles)); SafeObjectHandler(data, "bpWinAndSurvive", GetSafeValue(tank.tankdata.winAndSurvived)); SafeObjectHandler(data, "bpWins", GetSafeValue(tank.tankdata.wins)); SafeObjectHandler(data, "bpXP", GetSafeValue(tank.tankdata.xp)); db.Insert("File_Battles", data); data.Clear(); SafeObjectHandler(data, "faParentID", tankID); SafeObjectHandler(data, "faDieHardSeries", GetSafeValue(tank.series.diehardSeries)); SafeObjectHandler(data, "faInvincibleSeries", GetSafeValue(tank.series.invincibleSeries)); SafeObjectHandler(data, "faKillingSeries", GetSafeValue(tank.series.killingSeries)); SafeObjectHandler(data, "faMaxDieHardSeries", GetSafeValue(tank.series.maxDiehardSeries)); SafeObjectHandler(data, "faMaxInvincibleSeries", GetSafeValue(tank.series.maxInvincibleSeries)); SafeObjectHandler(data, "faMaxKillingSeries", GetSafeValue(tank.series.maxKillingSeries)); SafeObjectHandler(data, "faMaxPiercingSeries", GetSafeValue(tank.series.maxPiercingSeries)); SafeObjectHandler(data, "faMaxSniperSeries", GetSafeValue(tank.series.maxSniperSeries)); SafeObjectHandler(data, "faPiercingSeries", GetSafeValue(tank.series.piercingSeries)); SafeObjectHandler(data, "faSniperSeries", GetSafeValue(tank.series.sniperSeries)); SafeObjectHandler(data, "faMedalAbrams", GetSafeValue(tank.major.Abrams)); SafeObjectHandler(data, "faMedalCarius", GetSafeValue(tank.major.Carius)); SafeObjectHandler(data, "faMedalEkins", GetSafeValue(tank.major.Ekins)); SafeObjectHandler(data, "faMedalKay", GetSafeValue(tank.major.Kay)); SafeObjectHandler(data, "faMedalKnispel", GetSafeValue(tank.major.Knispel)); SafeObjectHandler(data, "faMedalLavrinenko", GetSafeValue(tank.major.Lavrinenko)); SafeObjectHandler(data, "faMedalLeClerc", GetSafeValue(tank.major.LeClerc)); SafeObjectHandler(data, "faMedalPoppel", GetSafeValue(tank.major.Poppel)); SafeObjectHandler(data, "faFragsBeast", GetSafeValue(tank.tankdata.fragsBeast)); SafeObjectHandler(data, "faBattleHeroes", GetSafeValue(tank.battle.battleHeroes)); SafeObjectHandler(data, "faDefender", GetSafeValue(tank.battle.defender)); SafeObjectHandler(data, "faEveilEye", GetSafeValue(tank.battle.evileye)); SafeObjectHandler(data, "faFragsSinai", GetSafeValue(tank.battle.fragsSinai)); SafeObjectHandler(data, "faInvader", GetSafeValue(tank.battle.invader)); SafeObjectHandler(data, "faScout", GetSafeValue(tank.battle.scout)); SafeObjectHandler(data, "faSniper", GetSafeValue(tank.battle.sniper)); SafeObjectHandler(data, "faSteelwall", GetSafeValue(tank.battle.steelwall)); SafeObjectHandler(data, "faSupporter", GetSafeValue(tank.battle.supporter)); SafeObjectHandler(data, "faWarrior", GetSafeValue(tank.battle.warrior)); SafeObjectHandler(data, "faMedalBillotte", GetSafeValue(tank.epic.Billotte)); SafeObjectHandler(data, "faMedalBurda", GetSafeValue(tank.epic.Burda)); SafeObjectHandler(data, "faMedalDeLanglade", GetSafeValue(tank.epic.DeLaglanda)); //SafeObjectHandler(data, "faWarrior", tank.epic.Erohin); SafeObjectHandler(data, "faMedalFadin", GetSafeValue(tank.epic.Fadin)); SafeObjectHandler(data, "faMedalHalonen", GetSafeValue(tank.epic.Halonen)); SafeObjectHandler(data, "faHeroesOfRasseney", GetSafeValue(tank.epic.HeroesOfRassenai)); //SafeObjectHandler(data, "faWarrior", tank.epic.Horoshilov); SafeObjectHandler(data, "faMedalKolobanov", GetSafeValue(tank.epic.Kolobanov)); //SafeObjectHandler(data, "faWarrior", tank.epic.Lister); SafeObjectHandler(data, "faMedalOrlik", GetSafeValue(tank.epic.Orlik)); SafeObjectHandler(data, "faMedalOskin", GetSafeValue(tank.epic.Oskin)); SafeObjectHandler(data, "faMedalTamadaYoshio", GetSafeValue(tank.epic.TamadaYoshio)); SafeObjectHandler(data, "faMedalWittmann", GetSafeValue(tank.epic.Wittmann)); SafeObjectHandler(data, "faArmorPiercer", GetSafeValue(tank.special.armorPiercer)); SafeObjectHandler(data, "faBeastHunter", GetSafeValue(tank.special.beasthunter)); SafeObjectHandler(data, "faDieHard", GetSafeValue(tank.special.diehard)); SafeObjectHandler(data, "faHandOfDeath", GetSafeValue(tank.special.handOfDeath)); SafeObjectHandler(data, "faInvincible", GetSafeValue(tank.special.invincible)); SafeObjectHandler(data, "faKamikaze", GetSafeValue(tank.special.kamikaze)); SafeObjectHandler(data, "faLumberJack", GetSafeValue(tank.special.lumberjack)); SafeObjectHandler(data, "faMarkOfMastery", GetSafeValue(tank.special.markOfMastery)); SafeObjectHandler(data, "faMousebane", GetSafeValue(tank.special.mousebane)); SafeObjectHandler(data, "faRaider", GetSafeValue(tank.special.raider)); SafeObjectHandler(data, "faTitleSniper", GetSafeValue(tank.special.sniper)); SafeObjectHandler(data, "faTankExpertStrg", GetSafeValue(tank.special.tankExpert)); db.Insert("File_Achievements", data); data.Clear(); } } catch (Exception) { throw; } } db.ExecuteNonQuery("delete from File_Battles where bpwins > bpBattleCount"); db.EndTransaction(); } }
public static void UpdateLegacyData(string fileName, Dictionary<string, Tuple<int, int, string>> tanks) { using (IDBHelpers db = new DBHelpers(fileName, true)) { db.BeginTransaction(); string sql = "select cmCountryID || '_' || cmTankID TankKey, cmCountryID, cmTankID from File_TankDetails where cmTier is null group by cmCountryID, cmTankID"; using (DataTable dt = db.GetDataTable(sql)) { if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { Tuple<int, int, string> tankDef; if (tanks.TryGetValue(row["TankKey"].ToString(), out tankDef)) { string updateSQL = String.Format("Update File_TankDetails set cmType = '{0}', cmTier = '{1}', cmTankTitle = '{2}' where cmCountryID = '{3}' and cmTankID = '{4}' and cmTier is null", tankDef.Item1, tankDef.Item2, tankDef.Item3, row["cmCountryID"], row["cmTankID"]); try { db.ExecuteNonQuery(updateSQL); } catch {/*very bad practice. never swallow errors*/ } } } } } db.EndTransaction(); } }
public static void CorrectBrokenData(string fileName) { using (IDBHelpers db = new DBHelpers(fileName)) { db.ExecuteNonQuery(@"update RecentBattles_Session set rsUEDateTo = rsUEDateFrom + 1 where rsUEDateTo = 2114373600 and rsID <> (select max(rsID) from RecentBattles_Session where rsUEDateTo = 2114373600)"); db.ExecuteNonQuery(@"delete from RecentBattles where cast(rbDamageReceived as int) < 0"); db.ExecuteNonQuery(@"delete from File_Battles where ifnull(cast(bpMaxFrags as int),0) > 15"); db.ExecuteNonQuery(@"delete from RecentBattles where cast(rbXPReceived as int) / 100 > 10000 and cast(rbBattleTime as real) <= 1384113533"); db.ExecuteNonQuery(@"delete from RecentBattles where rbBattleTime = 0"); db.ExecuteNonQuery(@"delete from RecentBattles where rbID in ( select y.rbID from RecentBattles y inner join ( select rbBattleTime, max(rbID) id from RecentBattles b2 group by rbBattleTime) x on y.rbBattleTime = x.rbBattleTime where y.rbID <> x.id)"); } }
public static void AlterDB(string fileName) { using (IDBHelpers dbHelpers = new DBHelpers(fileName)) { Console.WriteLine("Creating Tables..."); CreateTables(dbHelpers); Console.WriteLine("Altering DB..."); using (DataTable dt = dbHelpers.GetDataTable("pragma table_info(File_Battles)")) { CheckAndCreateColumn("File_Battles", "bpMileage", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingEff", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingEffWeight", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingBR", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingBRWeight", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingWN7", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingWN7Weight", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingWN8", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingWN8Weight", "INTEGER null", dbHelpers, dt); CheckAndCreateColumn("File_Battles", "bpRatingVersion", "INTEGER default (0) null", dbHelpers, dt); //CheckAndCreateColumn("File_Battles", "bpRatingExpDamage", "real default (0) null", dbHelpers, dt); //CheckAndCreateColumn("File_Battles", "bpRatingExpFrag", "real default (0) null", dbHelpers, dt); //CheckAndCreateColumn("File_Battles", "bpRatingExpSpot", "real default (0) null", dbHelpers, dt); //CheckAndCreateColumn("File_Battles", "bpRatingExpDef", "real default (0) null", dbHelpers, dt); //CheckAndCreateColumn("File_Battles", "bpRatingExpWin", "real default (0) null", dbHelpers, dt); } using (DataTable dt = dbHelpers.GetDataTable("pragma table_info(RecentBattles)")) { CheckAndCreateColumn("RecentBattles", "rbMileage", "real default(0)", dbHelpers, dt); CheckAndCreateColumn("RecentBattles", "rbRatingEff", "real default(0)", dbHelpers, dt); CheckAndCreateColumn("RecentBattles", "rbRatingBR", "real default(0)", dbHelpers, dt); CheckAndCreateColumn("RecentBattles", "rbRatingWN7", "real default(0)", dbHelpers, dt); CheckAndCreateColumn("RecentBattles", "rbRatingWN8", "real default(0)", dbHelpers, dt); CheckAndCreateColumn("RecentBattles", "rbDamageAssistedRadio", "real default(0)", dbHelpers, dt); CheckAndCreateColumn("RecentBattles", "rbDamageAssistedTracks", "real default(0)", dbHelpers, dt); CheckAndCreateColumn("RecentBattles", "rbGlobalAvgDefPoints", "REAL default (0) NULL", dbHelpers, dt); CheckAndCreateColumn("RecentBattles", "rbBattleMode", "INTEGER default (15) NULL", dbHelpers, dt); } using (DataTable dt = dbHelpers.GetDataTable("pragma table_info(RecentBattles_Session)")) { var fieldCheck = (from x in dt.AsEnumerable() where x.Field<string>("name") == "rsUEDateFrom" select x).DefaultIfEmpty(null).FirstOrDefault(); if (fieldCheck == null) { string sql = "Alter table RecentBattles_Session Add rsUEDateFrom real NULL"; dbHelpers.ExecuteNonQuery(sql); sql = "Alter table RecentBattles_Session Add rsUEDateTo real NULL"; dbHelpers.ExecuteNonQuery(sql); sql = @"UPDATE RecentBattles_Session SET rsUEDateFrom = (SELECT ifnull(min(RecentBattles.rbBattleTime), datetime('now', 'unixepoch')) FROM RecentBattles WHERE RecentBattles.rbSessionID = RecentBattles_Session.rsKey ) , rsUEDateTo = (SELECT ifnull(Max(RecentBattles.rbBattleTime), datetime('now', 'unixepoch')) FROM RecentBattles WHERE RecentBattles.rbSessionID = RecentBattles_Session.rsKey ) WHERE EXISTS ( SELECT * FROM RecentBattles WHERE RecentBattles.rbSessionID = RecentBattles_Session.rsKey )"; dbHelpers.ExecuteNonQuery(sql); sql = @"UPDATE RecentBattles_Session SET rsUEDateFrom = strftime('%s', '2000-01-01 00:00:00') , rsUEDateTo = strftime( '%s', '2000-01-01 00:00:01') WHERE rsUEDateFrom is null"; dbHelpers.ExecuteNonQuery(sql); dbHelpers.ExecuteNonQuery(sql); sql = @"update RecentBattles_Session set rsUEDateTo = strftime('%s', '2037-01-01 00:00:00') where rsID = (select max(rsID) from RecentBattles_Session)"; dbHelpers.ExecuteNonQuery(sql); } } Console.WriteLine("Altering DB done"); } }
private void RecentBattlesNavigations(bool value) { if (value != false) { using (DBHelpers helper = new DBHelpers(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + _currentPlayer, "LastBattle", "WOTSStore.db"))) { using (DataTable minMax = helper.GetDataTable(@"select min(rsID) minID, max(rsID) maxID from Recentbattles_Session")) { if (minMax.Rows.Count > 0) { barButRBMoveFirst.Enabled = (Convert.ToInt32((minMax.Rows[0]["minID"] == DBNull.Value) ? 0 : minMax.Rows[0]["minID"]) == Convert.ToInt32(barButRBMoveTo.EditValue ?? 0) ? false : value); barButRBMovePrevious.Enabled = (Convert.ToInt32(minMax.Rows[0]["minID"] == DBNull.Value ? 0 : minMax.Rows[0]["minID"]) == Convert.ToInt32(barButRBMoveTo.EditValue ?? 0) ? false : value); ; barButRBMoveTo.Enabled = value; barButRBMoveNext.Enabled = (Convert.ToInt32(minMax.Rows[0]["maxID"] == DBNull.Value ? 0 : minMax.Rows[0]["maxID"]) == Convert.ToInt32(barButRBMoveTo.EditValue ?? 0) ? false : value); ; barButRBMoveLast.Enabled = (Convert.ToInt32(minMax.Rows[0]["maxID"] == DBNull.Value ? 0 : minMax.Rows[0]["maxID"]) == Convert.ToInt32(barButRBMoveTo.EditValue ?? 0) ? false : value); ; } else { barButRBMoveFirst.Enabled = false; barButRBMovePrevious.Enabled = false; barButRBMoveTo.Enabled = false; barButRBMoveNext.Enabled = false; barButRBMoveLast.Enabled = false; } } } } else { barButRBMoveFirst.Enabled = false; barButRBMovePrevious.Enabled = false; barButRBMoveTo.Enabled = false; barButRBMoveNext.Enabled = false; barButRBMoveLast.Enabled = false; } }
private void RecentBattlesNavigate(string where) { using (DBHelpers helper = new DBHelpers(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + _currentPlayer, "LastBattle", "WOTSStore.db"))) { using (DataTable dt = helper.GetDataTable("select rsID, rsKey from Recentbattles_Session where " + where)) { if (dt.Rows.Count > 0) { barButRBMoveTo.EditValue = dt.Rows[0]["rsID"]; barButRBMoveTo.Tag = dt.Rows[0]["rsKey"]; UserSettings.ViewSessionID = dt.Rows[0]["rsKey"].ToString(); } else { using (DataTable dtFallback = helper.GetDataTable("select rsID, rsKey from Recentbattles_Session where rsID = (select max(rsID) from Recentbattles_Session where rsID < 99999999)")) { if (dtFallback.Rows.Count > 0) { barButRBMoveTo.BeginUpdate(); barButRBMoveTo.EditValue = dtFallback.Rows[0]["rsID"]; barButRBMoveTo.Tag = dtFallback.Rows[0]["rsKey"]; barButRBMoveTo.EndUpdate(); UserSettings.ViewSessionID = dtFallback.Rows[0]["rsKey"].ToString(); } } } } RecentBattlesNavigations(true); //lb.Save(); WriteHTMLDocument("LastPlayedTanks", _currentPlayer, null, null); } }
public static void Create(string fileName) { using (IDBHelpers dbHelpers = new DBHelpers(fileName)) { dbHelpers.CreateDatabase(fileName); CreateTables(dbHelpers); } }
//验证省名称是否存在 public int GetCount(string Name) { string sql = "select count(*) from Industry where Name=@name "; return(DBHelpers.GetScalar(sql, new SqlParameter("@name", Name))); }
public void Fill(dynamic file, int fileName) { if (file == null) { WOTHelper.AddToLog("File cannot be read: " + fileName); return; } using (DataTable tabFile = ds.Tables["Files"]) { DataRow row = tabFile.NewRow(); row["fiID"] = fileName; row["fiResult"] = GetSafeValue(file.header.result); row["fiUserName"] = GetSafeValue(file.header.username); row["fiTankCount"] = GetSafeValue(file.header.tankcount); row["fiParser"] = GetSafeValue(file.header.parser); row["fiServer"] = GetSafeValue(file.header.server); row["fiMessage"] = GetSafeValue(file.header.message); row["fiDate"] = GetSafeValue(file.header.date); row["fiParserVersion"] = GetSafeValue(file.header.parserversion); tabFile.Rows.Add(row); } int tempTankID = 0; using (IDBHelpers db = new DBHelpers(_dbPath, false)) { string id = db.ExecuteScalar("select max(cmID) + 1 nextID from File_TankDetails"); if (!string.IsNullOrEmpty(id)) tempTankID = int.Parse(id); else tempTankID = 1; } foreach (var item in file.tanks) { foreach (var i in item) { if (ObjectExists(i, "common")) { using (DataTable tab = ds.Tables["File_TankDetails"]) { DataRow dr = tab.NewRow(); dr["cmID"] = tempTankID; dr["cmFileID"] = fileName; dr["cmCreationTimeR"] = i.common.creationTimeR; dr["cmFrags"] = i.common.frags; dr["cmTankTitle"] = i.common.tanktitle; dr["cmPremium"] = i.common.premium; dr["cmUpdated"] = i.common.updated; dr["cmTier"] = i.common.tier; dr["cmUpdatedR"] = i.common.updatedR; dr["cmLastBattleTime"] = i.common.lastBattleTime; dr["cmFragsCompare"] = i.common.frags_compare; dr["cmLastBattleTimeR"] = i.common.lastBattleTimeR; dr["cmBaseVersion"] = i.common.basedonversion; dr["cmCreationTime"] = i.common.creationTime; dr["cmCompactDescription"] = i.common.compactDescr; dr["cmCountryID"] = i.common.countryid; dr["cmTankID"] = i.common.tankid; dr["cmType"] = i.common.type; tab.Rows.Add(dr); } } if (ObjectExists(i, "clan")) { using (DataTable tab = ds.Tables["File_Clan"]) { DataRow dr = tab.NewRow(); dr["clParentID"] = tempTankID; dr["clBattlesCount"] = i.clan.battlesCount; dr["clDefencePoints"] = i.clan.droppedCapturePoints; dr["clFrags"] = i.clan.frags; dr["clSpotted"] = i.clan.spotted; dr["clDamageDealt"] = i.clan.damageDealt; dr["clShots"] = i.clan.shots; dr["clWins"] = i.clan.wins; dr["clDamageReceived"] = i.clan.damageReceived; dr["clLosses"] = i.clan.losses; dr["clXP"] = i.clan.xp; dr["clSurvivedBattles"] = i.clan.survivedBattles; dr["clHits"] = i.clan.hits; dr["clCapturePoints"] = i.clan.capturePoints; tab.Rows.Add(dr); } } if (ObjectExists(i, "company")) { using (DataTable tab = ds.Tables["File_Company"]) { DataRow dr = tab.NewRow(); dr["fcParentID"] = tempTankID; dr["fcBattlesCount"] = GetSafeValue(i.company.battlesCount); dr["fcDefencePoints"] = GetSafeValue(i.company.droppedCapturePoints); dr["fcFrags"] = GetSafeValue(i.company.frags); dr["fcSpotted"] = GetSafeValue(i.company.spotted); dr["fcDamageDealt"] = GetSafeValue(i.company.damageDealt); dr["fcShots"] = GetSafeValue(i.company.shots); dr["fcWins"] = GetSafeValue(i.company.wins); dr["fcDamageReceived"] = GetSafeValue(i.company.damageReceived); dr["fcLosses"] = GetSafeValue(i.company.losses); dr["fcXP"] = GetSafeValue(i.company.xp); dr["fcSurvivedBattles"] = GetSafeValue(i.company.survivedBattles); dr["fcHits"] = GetSafeValue(i.company.hits); dr["fcCapturePoints"] = GetSafeValue(i.company.capturePoints); tab.Rows.Add(dr); } } using (DataTable tab = ds.Tables["File_Achievements"]) { DataRow dr = tab.NewRow(); dr["faParentID"] = tempTankID; dr["faAlaric"] = GetSafeValue(GetSafeValue(i.special.alaric)); dr["faArmorPiercer"] = GetSafeValue(i.special.armorPiercer); dr["faBattleHeroes"] = GetSafeValue(i.battle.battleHeroes); dr["faBeastHunter"] = GetSafeValue(i.special.beasthunter); dr["faBombardier"] = GetSafeValue(i.special.bombardier); dr["faDefender"] = GetSafeValue(i.battle.defender); dr["faDieHard"] = GetSafeValue(i.special.diehard); dr["faDieHardSeries"] = GetSafeValue(i.series.diehardSeries); dr["faEveilEye"] = GetSafeValue(i.battle.evileye); dr["faFragsBeast"] = GetSafeValue(i.tankdata.fragsBeast); dr["faFragsPatton"] = GetSafeValue(i.special.fragsPatton); dr["faFragsSinai"] = GetSafeValue(i.battle.fragsSinai); dr["faHandOfDeath"] = GetSafeValue(i.special.handOfDeath); dr["faHeroesOfRasseney"] = GetSafeValue(i.special.heroesOfRassenay); dr["faHuntsman"] = GetSafeValue(i.special.huntsman); dr["faInvader"] = GetSafeValue(i.battle.invader); dr["faInvincible"] = GetSafeValue(i.special.invincible); dr["faInvincibleSeries"] = GetSafeValue(i.series.invincibleSeries); dr["faIronman"] = GetSafeValue(i.special.ironMan); dr["faKamikaze"] = GetSafeValue(i.special.kamikaze); dr["faKillingSeries"] = GetSafeValue(i.series.killingSeries); dr["faLuckyDevil"] = GetSafeValue(i.special.luckyDevil); dr["faLumberJack"] = GetSafeValue(i.special.lumberjack); dr["faMarkOfMastery"] = GetSafeValue(i.special.markOfMastery); dr["faMaxDieHardSeries"] = GetSafeValue(i.series.maxDiehardSeries); dr["faMaxInvincibleSeries"] = GetSafeValue(i.series.maxInvincibleSeries); dr["faMaxKillingSeries"] = GetSafeValue(i.series.maxKillingSeries); dr["faMaxPiercingSeries"] = GetSafeValue(i.series.maxPiercingSeries); dr["faMaxSniperSeries"] = GetSafeValue(i.series.maxSniperSeries); dr["faMedalAbrams"] = GetSafeValue(i.major.medalAbrams); dr["faMedalBillotte"] = GetSafeValue(i.epic.medalBillotte); dr["faMedalBrothersInArms"] = GetSafeValue(i.epic.medalBrothersInArms); dr["faMedalBrunoPietro"] = GetSafeValue(i.epic.medalBrunoPietro); dr["faMedalBurda"] = GetSafeValue(i.epic.medalBurda); dr["faMedalCarius"] = GetSafeValue(i.major.medalCarius); dr["faMedalCrucialContribution"] = GetSafeValue(i.epic.medalCrucialContribution); dr["faMedalDeLanglade"] = GetSafeValue(i.epic.medalDeLanglade); dr["faMedalDumitru"] = GetSafeValue(i.epic.medalDumitru); dr["faMedalEkins"] = GetSafeValue(i.major.medalEkins); dr["faMedalFadin"] = GetSafeValue(i.epic.medalFadin); dr["faMedalHalonen"] = GetSafeValue(i.epic.medalHalonen); dr["faMedalKay"] = GetSafeValue(i.major.medalKay); dr["faMedalKnispel"] = GetSafeValue(i.major.medalKnispel); dr["faMedalKolobanov"] = GetSafeValue(i.epic.medalKolobanov); dr["faMedalLafayettePool"] = GetSafeValue(i.epic.medalLafayettePool); dr["faMedalLavrinenko"] = GetSafeValue(i.major.medalLavrinenko); dr["faMedalLeClerc"] = GetSafeValue(i.major.medalLeClerc); dr["faMedalLehvaslaiho"] = GetSafeValue(i.epic.medalLehvaslaiho); dr["faMedalNikolas"] = GetSafeValue(i.epic.medalNikolas); dr["faMedalOrlik"] = GetSafeValue(i.epic.medalOrlik); dr["faMedalOskin"] = GetSafeValue(i.epic.medalOskin); dr["faMedalPascucci"] = GetSafeValue(i.epic.medalPascucci); dr["faMedalPoppel"] = GetSafeValue(i.major.medalPoppel); dr["faMedalRadleyWalters"] = GetSafeValue(i.epic.medalRadleyWalters); dr["faMedalTamadaYoshio"] = GetSafeValue(i.epic.medalTamadaYoshio); dr["faMedalTarczay"] = GetSafeValue(i.epic.medalTarczay); dr["faMedalWittmann"] = GetSafeValue(i.epic.medalWittmann); dr["faMousebane"] = GetSafeValue(i.special.mousebane); dr["faPattonValley"] = GetSafeValue(i.special.pattonValley); dr["faPiercingSeries"] = GetSafeValue(i.series.piercingSeries); dr["faRaider"] = GetSafeValue(i.special.raider); dr["faScout"] = GetSafeValue(i.battle.scout); dr["faSinai"] = GetSafeValue(i.special.sinai); dr["faSniper"] = GetSafeValue(i.battle.sniper); dr["faSniperSeries"] = GetSafeValue(i.series.sniperSeries); dr["faSteelwall"] = GetSafeValue(i.battle.steelwall); dr["faSturdy"] = GetSafeValue(i.special.sturdy); dr["faSupporter"] = GetSafeValue(i.battle.supporter); dr["faTankExpertStrg"] = GetSafeValue(i.special.tankExpertStrg); dr["faTitleSniper"] = GetSafeValue(i.special.titleSniper); dr["faWarrior"] = GetSafeValue(i.battle.warrior); tab.Rows.Add(dr); } if (ObjectExists(i, "tankdata")) { using (DataTable tab = ds.Tables["File_Battles"]) { DataRow dr = tab.NewRow(); dr["bpParentID"] = tempTankID; dr["bpBattleCount"] = GetSafeValue(i.tankdata.battlesCount); dr["bpFrags8P"] = GetSafeValue(i.tankdata.frags8p); dr["bpDefencePoints"] = GetSafeValue(i.tankdata.droppedCapturePoints); dr["bpFrags"] = GetSafeValue(i.tankdata.frags); dr["bpWinAndSurvive"] = GetSafeValue(i.tankdata.winAndSurvived); dr["bpSpotted"] = GetSafeValue(i.tankdata.spotted); dr["bpDamageDealt"] = GetSafeValue(i.tankdata.damageDealt); dr["bpXPBefore8_8"] = 0; dr["bpShots"] = GetSafeValue(i.tankdata.shots); dr["bpBattlesBefore8_8"] = 0; dr["bpWins"] = GetSafeValue(i.tankdata.wins); dr["bpDamageReceived"] = GetSafeValue(i.tankdata.damageReceived); dr["bpLosses"] = GetSafeValue(i.tankdata.losses); dr["bpXP"] = GetSafeValue(i.tankdata.xp); dr["bpSurvivedBattles"] = GetSafeValue(i.tankdata.survivedBattles); dr["bpHits"] = GetSafeValue(i.tankdata.hits); dr["bpCapturePoints"] = GetSafeValue(i.tankdata.capturePoints); dr["bpDamageAssistedTracks"] = 0; dr["bpHEHitsReceived"] = 0; dr["bpPierced"] = 0; dr["bpShotsReceived"] = 0; dr["bpNoDamageShotsReceived"] = 0; dr["bpOriginalXP"] = 0; dr["bpHEHits"] = 0; dr["bpMaxXP"] = GetSafeValue(i.tankdata.maxXP); dr["bpMaxFrags"] = GetSafeValue(i.tankdata.maxFrags); dr["bpMaxDamage"] = 0; dr["bpMileage"] = 0; dr["bpBattleMode"] = 15; RatingStructure ratingStruct = new RatingStructure(); ratingStruct.WN8ExpectedTankList = WN8ExpectedTankList; ratingStruct.countryID = GetSafeValue(i.common.countryid); ratingStruct.tankID = GetSafeValue(i.common.tankid); ratingStruct.tier = GetSafeValue(i.common.tier); ratingStruct.globalTier = ratingStruct.tier; ratingStruct.singleTank = true; ratingStruct.battlesCount = GetSafeValue(i.tankdata.battlesCount); ratingStruct.battlesCount8_8 = 0; ratingStruct.capturePoints = GetSafeValue(i.tankdata.capturePoints); ratingStruct.defencePoints = GetSafeValue(i.tankdata.droppedCapturePoints); ratingStruct.damageAssistedRadio = 0; ratingStruct.damageAssistedTracks = 0; ratingStruct.damageDealt = GetSafeValue(i.tankdata.damageDealt); ratingStruct.frags = GetSafeValue(i.tankdata.frags); ratingStruct.spotted = GetSafeValue(i.tankdata.spotted); ratingStruct.wins = GetSafeValue(i.tankdata.wins); //ratingStruct.globalWinRate = (GetSafeValue(i.tankdata.wins) / GetSafeValue(i.tankdata.battlesCount)) * 100; //WOTStatistics.Core.Ratings.printRatingStruct(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage Eff = Ratings.GetRatingEff(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage BR = Ratings.GetRatingBR(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage WN7 = Ratings.GetRatingWN7(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage WN8 = Ratings.GetRatingWN8(ratingStruct); dr["bpRatingEff"] = Eff.Value; dr["bpRatingEffWeight"] = Eff.Weight; dr["bpRatingBR"] = BR.Value; dr["bpRatingBRWeight"] = BR.Weight; dr["bpRatingWN7"] = WN7.Value; dr["bpRatingWN7Weight"] = WN7.Weight; dr["bpRatingWN8"] = WN8.Value; dr["bpRatingWN8Weight"] = WN8.Weight; dr["bpRatingVersion"] = WOTStatistics.Core.UserSettings.RatingVersion; tab.Rows.Add(dr); } } using (DataTable tab = ds.Tables["File_Total"]) { DataRow dr = tab.NewRow(); dr["foParentID"] = tempTankID; dr["foCreationTime"] = i.common.creationTime; dr["foMileage"] = Convert.ToInt32(i.common.mileage); dr["foTreesCut"] = i.tankdata.treesCut; dr["foLastBattleTime"] = i.tankdata.lastBattleTime; dr["foBattleLifeTime"] = i.tankdata.battleLifeTime; tab.Rows.Add(dr); } if (ObjectExists(i, "kills")) { foreach (var k in i.kills) { using (DataTable tab = ds.Tables["File_FragList"]) { DataRow dr = tab.NewRow(); dr["fgParentID"] = tempTankID; dr["fgCountryID"] = k[0]; dr["fgTankID"] = k[1]; dr["fgValue"] = k[2]; dr["fgTankDescription"] = k[3]; tab.Rows.Add(dr); } } } } tempTankID++; } foreach (var item in file.tanks_v2) { foreach (var i in item) { if (ObjectExists(i, "common")) { using (DataTable tab = ds.Tables["File_TankDetails"]) { DataRow dr = tab.NewRow(); dr["cmID"] = tempTankID; dr["cmFileID"] = fileName; if (ObjectExists(i, "common")) { dr["cmCreationTimeR"] = i.common.creationTimeR; dr["cmFrags"] = i.common.frags; dr["cmTankTitle"] = i.common.tanktitle; dr["cmPremium"] = i.common.premium; dr["cmUpdated"] = i.common.updated; dr["cmTier"] = i.common.tier; dr["cmUpdatedR"] = i.common.updatedR; dr["cmLastBattleTime"] = i.common.lastBattleTime; dr["cmFragsCompare"] = i.common.frags_compare; dr["cmLastBattleTimeR"] = i.common.lastBattleTimeR; dr["cmBaseVersion"] = i.common.basedonversion; dr["cmCreationTime"] = i.common.creationTime; dr["cmCompactDescription"] = i.common.compactDescr; dr["cmCountryID"] = i.common.countryid; dr["cmTankID"] = i.common.tankid; dr["cmType"] = i.common.type; dr["cmHasClan"] = i.common.has_clan; dr["cmHas7x7"] = i.common.has_7x7; dr["cmHas15x15"] = i.common.has_15x15; dr["cmHasCompany"] = i.common.has_company; } tab.Rows.Add(dr); } } if (ObjectExists(i, "historical")) { using (DataTable tab = ds.Tables["File_Historical"]) { DataRow dr = tab.NewRow(); dr["hsParentID"] = tempTankID; dr["hsBattlesCount"] = i.historical.battlesCount; dr["hsDefencePoints"] = i.historical.droppedCapturePoints; dr["hsFrags"] = i.historical.frags; dr["hsSpotted"] = i.historical.spotted; dr["hsDamageDealt"] = i.historical.damageDealt; dr["hsShots"] = i.historical.shots; dr["hsWins"] = i.historical.wins; dr["hsDamageReceived"] = i.historical.damageReceived; dr["hsLosses"] = i.historical.losses; dr["hsXP"] = i.historical.xp; dr["hsSurvivedBattles"] = i.historical.survivedBattles; dr["hsHits"] = i.historical.hits; dr["hsCapturePoints"] = i.historical.capturePoints; tab.Rows.Add(dr); } } if (ObjectExists(i, "clan")) { using (DataTable tab = ds.Tables["File_Clan"]) { DataRow dr = tab.NewRow(); dr["clParentID"] = tempTankID; dr["clBattlesCount"] = i.clan.battlesCount; dr["clDefencePoints"] = i.clan.droppedCapturePoints; dr["clFrags"] = i.clan.frags; dr["clSpotted"] = i.clan.spotted; dr["clDamageDealt"] = i.clan.damageDealt; dr["clXPBefore8_9"] = i.clan.xpBefore8_9; dr["clShots"] = i.clan.shots; dr["clBattlesCountBefore8_9"] = i.clan.battlesCountBefore8_9; dr["clWins"] = i.clan.wins; dr["clDamageReceived"] = i.clan.damageReceived; dr["clLosses"] = i.clan.losses; dr["clXP"] = i.clan.xp; dr["clSurvivedBattles"] = i.clan.survivedBattles; dr["clHits"] = i.clan.hits; dr["clCapturePoints"] = i.clan.capturePoints; tab.Rows.Add(dr); } } if (ObjectExists(i, "company")) { using (DataTable tab = ds.Tables["File_Company"]) { DataRow dr = tab.NewRow(); dr["fcParentID"] = tempTankID; dr["fcBattlesCount"] = GetSafeValue(i.company.battlesCount); dr["fcDefencePoints"] = GetSafeValue(i.company.droppedCapturePoints); dr["fcFrags"] = GetSafeValue(i.company.frags); dr["fcSpotted"] = GetSafeValue(i.company.spotted); dr["fcDamageDealt"] = GetSafeValue(i.company.damageDealt); dr["fcXPBefore8_9"] = GetSafeValue(i.company.xpBefore8_9); dr["fcShots"] = GetSafeValue(i.company.shots); dr["fcBattlesCountBefore8_9"] = GetSafeValue(i.company.battlesCountBefore8_9); dr["fcWins"] = GetSafeValue(i.company.wins); dr["fcDamageReceived"] = GetSafeValue(i.company.damageReceived); dr["fcLosses"] = GetSafeValue(i.company.losses); dr["fcXP"] = GetSafeValue(i.company.xp); dr["fcSurvivedBattles"] = GetSafeValue(i.company.survivedBattles); dr["fcHits"] = GetSafeValue(i.company.hits); dr["fcCapturePoints"] = GetSafeValue(i.company.capturePoints); tab.Rows.Add(dr); } } if (ObjectExists(i, "achievements")) { using (DataTable tab = ds.Tables["File_Achievements"]) { DataRow dr = tab.NewRow(); dr["faParentID"] = tempTankID; dr["faAlaric"] = GetSafeValue(i.achievements.alaric); dr["faArmorPiercer"] = GetSafeValue(i.achievements.armorPiercer); dr["faBattleHeroes"] = GetSafeValue(i.achievements.battleHeroes); dr["faBeastHunter"] = GetSafeValue(i.achievements.beasthunter); dr["faBombardier"] = GetSafeValue(i.achievements.bombardier); dr["faDefender"] = GetSafeValue(i.achievements.defender); dr["faDieHard"] = GetSafeValue(i.achievements.diehard); dr["faDieHardSeries"] = GetSafeValue(i.achievements.diehardSeries); dr["faEveilEye"] = GetSafeValue(i.achievements.evileye); dr["faFragsBeast"] = GetSafeValue(i.achievements.fragsBeast); dr["faFragsPatton"] = GetSafeValue(i.achievements.fragsPatton); dr["faFragsSinai"] = GetSafeValue(i.achievements.fragsSinai); dr["faHandOfDeath"] = GetSafeValue(i.achievements.handOfDeath); dr["faHeroesOfRasseney"] = GetSafeValue(i.achievements.heroesOfRassenay); dr["faHuntsman"] = GetSafeValue(i.achievements.huntsman); dr["faInvader"] = GetSafeValue(i.achievements.invader); dr["faInvincible"] = GetSafeValue(i.achievements.invincible); dr["faInvincibleSeries"] = GetSafeValue(i.achievements.invincibleSeries); dr["faIronman"] = GetSafeValue(i.achievements.ironMan); dr["faKamikaze"] = GetSafeValue(i.achievements.kamikaze); dr["faKillingSeries"] = GetSafeValue(i.achievements.killingSeries); dr["faLuckyDevil"] = GetSafeValue(i.achievements.luckyDevil); dr["faLumberJack"] = GetSafeValue(i.achievements.lumberjack); dr["faMarkOfMastery"] = GetSafeValue(i.achievements.markOfMastery); dr["faMaxDieHardSeries"] = GetSafeValue(i.achievements.maxDiehardSeries); dr["faMaxInvincibleSeries"] = GetSafeValue(i.achievements.maxInvincibleSeries); dr["faMaxKillingSeries"] = GetSafeValue(i.achievements.maxKillingSeries); dr["faMaxPiercingSeries"] = GetSafeValue(i.achievements.maxPiercingSeries); dr["faMaxSniperSeries"] = GetSafeValue(i.achievements.maxSniperSeries); dr["faMedalAbrams"] = GetSafeValue(i.achievements.medalAbrams); dr["faMedalBillotte"] = GetSafeValue(i.achievements.medalBillotte); dr["faMedalBrothersInArms"] = GetSafeValue(i.achievements.medalBrothersInArms); dr["faMedalBrunoPietro"] = GetSafeValue(i.achievements.medalBrunoPietro); dr["faMedalBurda"] = GetSafeValue(i.achievements.medalBurda); dr["faMedalCarius"] = GetSafeValue(i.achievements.medalCarius); dr["faMedalCrucialContribution"] = GetSafeValue(i.achievements.medalCrucialContribution); dr["faMedalDeLanglade"] = GetSafeValue(i.achievements.medalDeLanglade); dr["faMedalDumitru"] = GetSafeValue(i.achievements.medalDumitru); dr["faMedalEkins"] = GetSafeValue(i.achievements.medalEkins); dr["faMedalFadin"] = GetSafeValue(i.achievements.medalFadin); dr["faMedalHalonen"] = GetSafeValue(i.achievements.medalHalonen); dr["faMedalKay"] = GetSafeValue(i.achievements.medalKay); dr["faMedalKnispel"] = GetSafeValue(i.achievements.medalKnispel); dr["faMedalKolobanov"] = GetSafeValue(i.achievements.medalKolobanov); dr["faMedalLafayettePool"] = GetSafeValue(i.achievements.medalLafayettePool); dr["faMedalLavrinenko"] = GetSafeValue(i.achievements.medalLavrinenko); dr["faMedalLeClerc"] = GetSafeValue(i.achievements.medalLeClerc); dr["faMedalLehvaslaiho"] = GetSafeValue(i.achievements.medalLehvaslaiho); dr["faMedalNikolas"] = GetSafeValue(i.achievements.medalNikolas); dr["faMedalOrlik"] = GetSafeValue(i.achievements.medalOrlik); dr["faMedalOskin"] = GetSafeValue(i.achievements.medalOskin); dr["faMedalPascucci"] = GetSafeValue(i.achievements.medalPascucci); dr["faMedalPoppel"] = GetSafeValue(i.achievements.medalPoppel); dr["faMedalRadleyWalters"] = GetSafeValue(i.achievements.medalRadleyWalters); dr["faMedalTamadaYoshio"] = GetSafeValue(i.achievements.medalTamadaYoshio); dr["faMedalTarczay"] = GetSafeValue(i.achievements.medalTarczay); dr["faMedalWittmann"] = GetSafeValue(i.achievements.medalWittmann); dr["faMousebane"] = GetSafeValue(i.achievements.mousebane); dr["faPattonValley"] = GetSafeValue(i.achievements.pattonValley); dr["faPiercingSeries"] = GetSafeValue(i.achievements.piercingSeries); dr["faRaider"] = GetSafeValue(i.achievements.raider); dr["faScout"] = GetSafeValue(i.achievements.scout); dr["faSinai"] = GetSafeValue(i.achievements.sinai); dr["faSniper"] = GetSafeValue(i.achievements.sniper); dr["faSniperSeries"] = GetSafeValue(i.achievements.sniperSeries); dr["faSteelwall"] = GetSafeValue(i.achievements.steelwall); dr["faSturdy"] = GetSafeValue(i.achievements.sturdy); dr["faSupporter"] = GetSafeValue(i.achievements.supporter); dr["faTankExpertStrg"] = GetSafeValue(i.achievements.tankExpertStrg); dr["faTitleSniper"] = GetSafeValue(i.achievements.titleSniper); dr["faWarrior"] = GetSafeValue(i.achievements.warrior); tab.Rows.Add(dr); } } if (ObjectExists(i, "a15x15")) { using (DataTable tab = ds.Tables["File_Battles"]) { DataRow dr = tab.NewRow(); dr["bpParentID"] = tempTankID; dr["bpBattleCount"] = GetSafeValue(i.a15x15.battlesCount); dr["bpFrags8P"] = GetSafeValue(i.a15x15.frags8p); dr["bpDefencePoints"] = GetSafeValue(i.a15x15.droppedCapturePoints); dr["bpFrags"] = GetSafeValue(i.a15x15.frags); dr["bpWinAndSurvive"] = GetSafeValue(i.a15x15.winAndSurvived); dr["bpSpotted"] = GetSafeValue(i.a15x15.spotted); dr["bpDamageDealt"] = GetSafeValue(i.a15x15.damageDealt); dr["bpXPBefore8_8"] = GetSafeValue(i.a15x15.xpBefore8_8); dr["bpShots"] = GetSafeValue(i.a15x15.shots); dr["bpBattlesBefore8_8"] = GetSafeValue(i.a15x15.battlesCountBefore8_8); dr["bpWins"] = GetSafeValue(i.a15x15.wins); dr["bpDamageReceived"] = GetSafeValue(i.a15x15.damageReceived); dr["bpLosses"] = GetSafeValue(i.a15x15.losses); dr["bpXP"] = GetSafeValue(i.a15x15.xp); dr["bpSurvivedBattles"] = GetSafeValue(i.a15x15.survivedBattles); dr["bpHits"] = GetSafeValue(i.a15x15.hits); dr["bpCapturePoints"] = GetSafeValue(i.a15x15.capturePoints); if (ObjectExists(i, "a15x15_2")) { dr["bpDamageAssistedRadio"] = GetSafeValue(i.a15x15_2.damageAssistedRadio); dr["bpDamageAssistedTracks"] = GetSafeValue(i.a15x15_2.damageAssistedTrack); dr["bpHEHitsReceived"] = GetSafeValue(i.a15x15_2.heHitsReceived); dr["bpPierced"] = GetSafeValue(i.a15x15_2.pierced); dr["bpPiercedReceived"] = GetSafeValue(i.a15x15_2.piercedReceived); dr["bpShotsReceived"] = GetSafeValue(i.a15x15_2.shotsReceived); dr["bpNoDamageShotsReceived"] = GetSafeValue(i.a15x15_2.noDamageShotsReceived); dr["bpOriginalXP"] = GetSafeValue(i.a15x15_2.originalXP); dr["bpHEHits"] = GetSafeValue(i.a15x15_2.he_hits); } if (ObjectExists(i, "max15x15")) { dr["bpMaxXP"] = GetSafeValue(i.max15x15.maxXP); dr["bpMaxFrags"] = GetSafeValue(i.max15x15.maxFrags); dr["bpMaxDamage"] = GetSafeValue(i.max15x15.maxDamage); ; } dr["bpBattleMode"] = 15; RatingStructure ratingStruct = new RatingStructure(); ratingStruct.WN8ExpectedTankList = WN8ExpectedTankList; ratingStruct.countryID = GetSafeValue(i.common.countryid); ratingStruct.tankID = GetSafeValue(i.common.tankid); ratingStruct.tier = GetSafeValue(i.common.tier); ratingStruct.globalTier = ratingStruct.tier; ratingStruct.singleTank = true; ratingStruct.battlesCount = GetSafeValue(i.a15x15.battlesCount); ratingStruct.battlesCount8_8 = GetSafeValue(i.a15x15.battlesCountBefore8_8); ratingStruct.capturePoints = GetSafeValue(i.a15x15.capturePoints); ratingStruct.defencePoints = GetSafeValue(i.a15x15.droppedCapturePoints); ratingStruct.damageAssistedRadio = GetSafeValue(i.a15x15_2.damageAssistedRadio); ratingStruct.damageAssistedTracks = GetSafeValue(i.a15x15_2.damageAssistedTrack); ratingStruct.damageDealt = GetSafeValue(i.a15x15.damageDealt); ratingStruct.frags = GetSafeValue(i.a15x15.frags); ratingStruct.spotted = GetSafeValue(i.a15x15.spotted); ratingStruct.wins=GetSafeValue(i.a15x15.wins); ratingStruct.gWinRate = ratingStruct.winRate; WOTStatistics.Core.Ratings.RatingStorage Eff = Ratings.GetRatingEff(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage BR = Ratings.GetRatingBR(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage WN7 = Ratings.GetRatingWN7(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage WN8 = Ratings.GetRatingWN8(ratingStruct); dr["bpRatingEff"] = Eff.Value; dr["bpRatingEffWeight"] = Eff.Weight; dr["bpRatingBR"] = BR.Value; dr["bpRatingBRWeight"] = BR.Weight; dr["bpRatingWN7"] = WN7.Value; dr["bpRatingWN7Weight"] = WN7.Weight; dr["bpRatingWN8"] = WN8.Value; dr["bpRatingWN8Weight"] = WN8.Weight; dr["bpRatingVersion"] = WOTStatistics.Core.UserSettings.RatingVersion; //foreach (DataRow drt in dr) //{ //} //foreach (DataRow itemarr in dr.ItemArray) //{ // WOTHelper.AddToLog("IA " + itemarr["bpBattleMode"]); //} tab.Rows.Add(dr); } } if (ObjectExists(i, "a7x7")) { using (DataTable tab = ds.Tables["File_Battles"]) { DataRow dr = tab.NewRow(); dr["bpParentID"] = tempTankID; dr["bpBattleCount"] = GetSafeValue(i.a7x7.battlesCount); dr["bpFrags8P"] = GetSafeValue(i.a7x7.frags8p); dr["bpDefencePoints"] = GetSafeValue(i.a7x7.droppedCapturePoints); dr["bpFrags"] = GetSafeValue(i.a7x7.frags); dr["bpWinAndSurvive"] = GetSafeValue(i.a7x7.winAndSurvived); dr["bpSpotted"] = GetSafeValue(i.a7x7.spotted); dr["bpDamageDealt"] = GetSafeValue(i.a7x7.damageDealt); dr["bpXPBefore8_8"] = GetSafeValue(i.a7x7.xpBefore8_8); dr["bpShots"] = GetSafeValue(i.a7x7.shots); dr["bpBattlesBefore8_8"] = GetSafeValue(i.a7x7.battlesCountBefore8_8); dr["bpWins"] = GetSafeValue(i.a7x7.wins); dr["bpDamageReceived"] = GetSafeValue(i.a7x7.damageReceived); dr["bpLosses"] = GetSafeValue(i.a7x7.losses); dr["bpXP"] = GetSafeValue(i.a7x7.xp); dr["bpSurvivedBattles"] = GetSafeValue(i.a7x7.survivedBattles); dr["bpHits"] = GetSafeValue(i.a7x7.hits); dr["bpCapturePoints"] = GetSafeValue(i.a7x7.capturePoints); dr["bpDamageAssistedRadio"] = GetSafeValue(i.a7x7.damageAssistedRadio); dr["bpDamageAssistedTracks"] = GetSafeValue(i.a7x7.damageAssistedTrack); dr["bpHEHitsReceived"] = GetSafeValue(i.a7x7.heHitsReceived); dr["bpPierced"] = GetSafeValue(i.a7x7.pierced); dr["bpPiercedReceived"] = GetSafeValue(i.a7x7.piercedReceived); dr["bpShotsReceived"] = GetSafeValue(i.a7x7.shotsReceived); dr["bpNoDamageShotsReceived"] = GetSafeValue(i.a7x7.noDamageShotsReceived); dr["bpOriginalXP"] = GetSafeValue(i.a7x7.originalXP); dr["bpHEHits"] = GetSafeValue(i.a7x7.he_hits); if (ObjectExists(i, "max7x7")) { dr["bpMaxXP"] = GetSafeValue(i.max7x7.maxXP); dr["bpMaxFrags"] = GetSafeValue(i.max7x7.maxFrags); dr["bpMaxDamage"] = GetSafeValue(i.max7x7.maxDamage); } dr["bpBattleMode"] = 7; RatingStructure ratingStruct = new RatingStructure(); ratingStruct.WN8ExpectedTankList = WN8ExpectedTankList; ratingStruct.countryID = GetSafeValue(i.common.countryid); ratingStruct.tankID = GetSafeValue(i.common.tankid); ratingStruct.tier = GetSafeValue(i.common.tier); ratingStruct.globalTier = ratingStruct.tier; ratingStruct.singleTank = true; ratingStruct.battlesCount = GetSafeValue(i.a7x7.battlesCount); ratingStruct.battlesCount8_8 = 0; ratingStruct.capturePoints = GetSafeValue(i.a7x7.capturePoints); ratingStruct.defencePoints = GetSafeValue(i.a7x7.droppedCapturePoints); ratingStruct.damageAssistedRadio = GetSafeValue(i.a7x7.damageAssistedRadio); ratingStruct.damageAssistedTracks = GetSafeValue(i.a7x7.damageAssistedTrack); ratingStruct.damageDealt = GetSafeValue(i.a7x7.damageDealt); ratingStruct.frags = GetSafeValue(i.a7x7.frags); ratingStruct.spotted = GetSafeValue(i.a7x7.spotted); ratingStruct.wins = GetSafeValue(i.a7x7.wins); ratingStruct.gWinRate = ratingStruct.winRate; WOTStatistics.Core.Ratings.RatingStorage Eff = Ratings.GetRatingEff(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage BR = Ratings.GetRatingBR(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage WN7 = Ratings.GetRatingWN7(ratingStruct); WOTStatistics.Core.Ratings.RatingStorage WN8 = Ratings.GetRatingWN8(ratingStruct); dr["bpRatingEff"] = Eff.Value; dr["bpRatingEffWeight"] = Eff.Weight; dr["bpRatingBR"] = BR.Value; dr["bpRatingBRWeight"] = BR.Weight; dr["bpRatingWN7"] = WN7.Value; dr["bpRatingWN7Weight"] = WN7.Weight; dr["bpRatingWN8"] = WN8.Value; dr["bpRatingWN8Weight"] = WN8.Weight; dr["bpRatingVersion"] = WOTStatistics.Core.UserSettings.RatingVersion; tab.Rows.Add(dr); } } if (ObjectExists(i, "total")) { using (DataTable tab = ds.Tables["File_Total"]) { DataRow dr = tab.NewRow(); dr["foParentID"] = tempTankID; dr["foCreationTime"] = i.total.creationTime; dr["foMileage"] = Convert.ToInt32(i.total.mileage); dr["foTreesCut"] = i.total.treesCut; dr["foLastBattleTime"] = i.total.lastBattleTime; dr["foBattleLifeTime"] = i.total.battleLifeTime; tab.Rows.Add(dr); } } if (ObjectExists(i, "fragslist")) { foreach (var k in i.fragslist) { using (DataTable tab = ds.Tables["File_FragList"]) { DataRow dr = tab.NewRow(); dr["fgParentID"] = tempTankID; dr["fgCountryID"] = k[0]; dr["fgTankID"] = k[1]; dr["fgValue"] = k[2]; dr["fgTankDescription"] = k[3]; tab.Rows.Add(dr); } } } } tempTankID++; } }
public static void ReIndexDB(string fileName) { using (IDBHelpers dbHelpers = new DBHelpers(fileName)) { string sql = @"SELECT name FROM sqlite_master WHERE type='table' AND name='RecentBattles';"; using (DataTable tableCheck = dbHelpers.GetDataTable(sql)) { foreach (DataRow row in tableCheck.Rows) { dbHelpers.ExecuteNonQuery(String.Format("reindex '{0}'", row["name"])); } } } }