public static long GetId(string screenName) { var incache = _userQueue .Find(u => u.ScreenName.Equals(screenName, StringComparison.CurrentCultureIgnoreCase)) .FirstOrDefault(); if (incache != null) { return(incache.Id); } while (true) { try { return(Database.UserCrud.GetId(screenName)); } catch (SQLiteException sqex) { if (sqex.ResultCode != SQLiteErrorCode.Locked) { throw; } } catch (SqliteCrudException cex) { if (cex.ErrorCode != SQLiteErrorCode.Locked) { throw; } } } }
public static async Task <IEnumerable <long> > GetRetweetedStatusIds(long originalId) { try { var rts = await DatabaseUtil.RetryIfLocked( async() => await Database.StatusCrud.GetRetweetedStatusesAsync(originalId)); return(rts.Select(r => r.Id) .Concat(_statusQueue.Find(s => s.RetweetedOriginalId == originalId) .Select(s => s.Id))); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); return(Enumerable.Empty <long>()); } }
private void SyncRepositoryToQueue() { var repository = Provider.GetService <ISourceRepository>(); var registry = Provider.GetService <IProjectModuleRegistry>(); var currentDateTime = DateTime.Now; var actualTasks = repository.ScheduleTasks().Where(task => (task.State == ScheduleTaskState.Initiated && task.DateTime <= task.DateTime.AddMilliseconds(Range)) || Math.Abs((currentDateTime - task.DateTime).TotalMilliseconds) <= Range); foreach (var task in actualTasks) { var targetTask = TaskQueue.Find(item => item.Id == task.Id); if (targetTask == null) { var moduleTask = registry.CreateModuleTask(task.Module.Code, new object[] { Provider, task.ProjectModuleId, task.Module.Project.UserId }); task.Task = moduleTask; TaskQueue.Add(task); } } }