跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

提交记录
修改Core/Librarys/SQLite/SQLiteBuilder.cs+1 −71看文件
@@ -178,11 +178,7 @@ namespace Core.Librarys.SQLite
178178
179179 }
180180
181删除: if (!isNew)
182删除: {
183删除: HandleVersion1002Migrate();
184删除: }
185删除:
181新增:
186182 // 处理表字段删除
187183 foreach (var dbModel in modelInfosDb)
188184 {
@@ -251,72 +247,6 @@ namespace Core.Librarys.SQLite
251247 }
252248
253249
254删除: /// <summary>
255删除: /// 数据迁移,1.0.0.2升级1.0.0.3时需要转移表数据
256删除: /// </summary>
257删除: private void HandleVersion1002Migrate()
258删除: {
259删除: AppState.ActionText = "导入数据中,请勿退出...";
260删除: //if (ExecuteNonQuery("select count(*) from sqlite_master where type='table' and name='AppModels'") != 0)
261删除: //{
262删除: // return;
263删除: //}
264删除: ExecuteNonQuery($"insert into AppModels(ID,Name,Description,File,TotalTime) select null,ProcessName as Name,ProcessDescription as Description,File,sum(Time) as TotalTime from DailyLogModels where 1=1 GROUP BY Name");
265删除:
266删除: using (var con = new SQLiteConnection(connstr))
267删除: {
268删除: con.Open();
269删除: using (var cmd = new SQLiteCommand(con))
270删除: {
271删除: cmd.CommandText = $"select ID,Name,Description from AppModels GROUP BY Name";
272删除:
273删除: List<string> sqlList = new List<string>();
274删除:
275删除: using (var rd = cmd.ExecuteReader())
276删除: {
277删除: while (rd.Read())
278删除: {
279删除: var ID = rd[0];
280删除: var Name = rd[1].ToString();
281删除: var Description = rd[2].ToString();
282删除: var icon = Iconer.Get(Name, Description);
283删除:
284删除: Name = SQLiteEscape(Name);
285删除:
286删除: sqlList.Add($"update DailyLogModels set AppModelID={ID} where ProcessName='{Name}'");
287删除: sqlList.Add($"update HoursLogModels set AppModelID={ID} where ProcessName='{Name}'");
288删除: sqlList.Add($"update AppModels set IconFile='{icon}' where ID={ID}");
289删除: }
290删除: }
291删除:
292删除: int take = 50;
293删除: bool isRuning = true;
294删除: int index = 0;
295删除: double count = sqlList.Count;
296删除: while (isRuning)
297删除: {
298删除: var sqlArr = sqlList.Skip(index).Take(take).ToArray();
299删除: cmd.CommandText = string.Join("; ", sqlArr);
300删除: cmd.ExecuteNonQuery();
301删除:
302删除: index += take;
303删除:
304删除: if (sqlArr.Length == 0)
305删除: {
306删除: isRuning = false;
307删除: }
308删除: double num = sqlList.Skip(index).Count();
309删除:
310删除: // 更新进度
311删除: AppState.ProcessValue = (int)((count - num) / count * 100);
312删除: Debug.WriteLine("加载:" + AppState.ProcessValue);
313删除: }
314删除: Debug.WriteLine("结束!");
315删除:
316删除: }
317删除: }
318删除:
319删除: }
320250
321251 private string SQLiteEscape(string str)
322252 {