public static int GetDatas(string apiKey, DateTime date) { int count = 0; var durations = GetDurations(apiKey, date); var heartbeats = GetHeartbeats(apiKey, date); List <WakaTimeDatas> datas = AssembleHeartbeats(durations, heartbeats); List <WakaTimeDatas> notExistDatas = new List <WakaTimeDatas>(); if (ListTool.HasElements(datas)) { using (Muse db = new Muse()) { foreach (var data in datas) { if (!db.Any <WakaTimeDatas>(x => x.ID == data.ID, null)) { if (!notExistDatas.Any(x => x.ID == data.ID)) { notExistDatas.Add(data); } } } if (ListTool.HasElements(notExistDatas)) { count = db.Adds(notExistDatas); } } } return(count); }
private void GetFileToDatabaseEvent(DriveInfo drive, List <UsnEntry> data) { List <UsnFiles> temp = new List <UsnFiles>(); if (ListTool.HasElements(data)) { for (int i = 0; i < data.Count; i++) { temp.Add(new UsnFiles() { Name = data[i].FileName, IsFolder = data[i].IsFolder, Number = NumberStringTool.ToString(data[i].FileReferenceNumber), ParentNumber = NumberStringTool.ToString(data[i].ParentFileReferenceNumber), Drive = drive.Name, Usn = data[i].Usn, CreateTime = DateTimeConvert.DetailString(DateTime.Now) }); NewFileCount++; } } using (var db = new Muse()) { db.Adds(temp); } UISetFileCount(drive.Name, NewFileCount); }