public void Clean(string sessionId, CleanArg arg = null) { _arg = arg ?? new CleanArg(); init(); try { log.LogDebug("开始进行清理任务。sessionId: " + sessionId); task = _db.Task.SingleOrDefault(x => x.Id == sessionId); _tick = TimeTic(task.CreateTime); if (task == null) { log.LogDebug("库中未找到清理任务,任务结束。sessionId: " + sessionId); return; } task.Content = (_arg.Content ?? Config.MessagePrefix) + "\r\n\r\n\r\n" + (_arg.Suffix ?? Config.MessageSuffix); CheckLogin(); if (task.Status != CleanStatus.Logined) { debug("长时间未扫码,取消本次任务"); return; } InitLoginInfo(); InitLoginUser(); SyncContact(); SyncCheck(); SendMsg(); while (!_stopSync) { } //等待最后一次同步完成 Complete(); //SyncMsg(); } catch (Exception ex) { task.Status = CleanStatus.Error; update(); log.LogError(1, ex, "清理过程中发生错误, sessionId: " + task.Id); throw; } finally { _stopSync = true; _http.Dispose(); _db.Dispose(); } }