public static void Make(HelpCenterRequest request, Action <HelpCenterRequest, string> starter) { if (!DownloadEnabled) { return; } lock (LockObj) { if (Tasks.GetItems().Any(r => r.Url == request.Url)) { return; } Tasks.Add(request); if (!Tasks.IsStarted) { Tasks.Start(r => { var html = SendRequest(r.Url); starter(r, html); }); } } }
private static string SizePhoto(Guid userID, byte[] data, long maxFileSize, Size size, bool now) { if (data == null || data.Length <= 0) { throw new UnknownImageFormatException(); } if (maxFileSize != -1 && data.Length > maxFileSize) { throw new ImageWeightLimitException(); } var resizeTask = new ResizeWorkerItem(userID, data, maxFileSize, size, GetDataStore(), UserPhotoThumbnailSettings.LoadForUser(userID)); if (now) { //Resize synchronously ResizeImage(resizeTask); return(GetSizedPhotoAbsoluteWebPath(userID, size)); } else { if (!ResizeQueue.GetItems().Contains(resizeTask)) { //Add ResizeQueue.Add(resizeTask); if (!ResizeQueue.IsStarted) { ResizeQueue.Start(ResizeImage); } } return(GetDefaultPhotoAbsoluteWebPath(size)); //NOTE: return default photo here. Since task will update cache } }
public static int Add(string url, string token, bool processClosed, bool disableNotifications) { lock (Imports.SynchRoot) { if (Imports.GetItems().Count(x => x.Id == CoreContext.TenantManager.GetCurrentTenant().TenantId) > 0) { throw new DuplicateNameException("Import already running"); } } lock (Completed) { Completed.RemoveAll(x => x.Id == CoreContext.TenantManager.GetCurrentTenant().TenantId); } SecurityContext.DemandPermissions(ASC.Core.Users.Constants.Action_AddRemoveUser); ProjectSecurity.DemandCreateProject(); var importTask = new ImportFromBasecamp(url, token, HttpContext.Current, SecurityContext.CurrentAccount.ID, processClosed, disableNotifications, Global.EngineFactory);//NOTE: engine factory newly created!!! lock (Imports.SynchRoot) { Imports.Add(importTask); } return(importTask.Id); }
public void MarkAsNew(FileEntry fileEntry, List <Guid> userIDs = null) { if (CoreBaseSettings.Personal) { return; } if (fileEntry == null) { return; } userIDs ??= new List <Guid>(); var taskData = ServiceProvider.GetService <AsyncTaskData>(); taskData.FileEntry = (FileEntry)fileEntry.Clone(); taskData.UserIDs = userIDs; if (fileEntry.RootFolderType == FolderType.BUNCH && !userIDs.Any()) { var folderDao = DaoFactory.FolderDao; var path = folderDao.GetBunchObjectID(fileEntry.RootFolderId); var projectID = path.Split('/').Last(); if (string.IsNullOrEmpty(projectID)) { return; } var projectTeam = FileSecurity.WhoCanRead(fileEntry) .Where(x => x != AuthContext.CurrentAccount.ID).ToList(); if (!projectTeam.Any()) { return; } taskData.UserIDs = projectTeam; } lock (locker) { tasks.Add(taskData); if (!tasks.IsStarted) { tasks.Start(FileMarkerHelper.ExecMarkFileAsNew); } } }
public static int Add(string url, string userName, string password, bool processClosed, bool disableNotifications, bool importUsersAsCollaborators, IEnumerable <int> projects) { var status = GetStatus(); if (imports.GetItems().Count(x => x.Id == TenantProvider.CurrentTenantID) > 0 || (status.Started && !status.Completed)) { throw new DuplicateNameException("Import already running"); } SecurityContext.DemandPermissions(Constants.Action_AddRemoveUser); var importTask = new ImportFromBasecamp(url, userName, password, SecurityContext.CurrentAccount.ID, processClosed, disableNotifications, importUsersAsCollaborators, Global.EngineFactory, projects); imports.Add(importTask); return(importTask.Id); }
private static void ExecGenerateThumbnail(byte[] imageData, int contactID) { var resizeWorkerItem = new ResizeWorkerItem { ContactID = contactID, RequireFotoSize = new[] { _mediumSize, _smallSize }, ImageData = imageData, DataStore = Global.GetStore() }; if (!ResizeQueue.GetItems().Contains(resizeWorkerItem)) { ResizeQueue.Add(resizeWorkerItem); } if (!ResizeQueue.IsStarted) { ResizeQueue.Start(ExecResizeImage); } }
public static void MarkAsNew(FileEntry fileEntry, List <Guid> userIDs) { if (CoreContext.Configuration.Personal) { return; } if (fileEntry == null) { return; } userIDs = userIDs ?? new List <Guid>(); var taskData = new AsyncTaskData { FileEntry = (FileEntry)fileEntry.Clone(), UserIDs = userIDs }; if (fileEntry.RootFolderType == FolderType.BUNCH && !userIDs.Any()) { var projectTeam = Global.GetProjectTeam(fileEntry); if (!projectTeam.Any()) { return; } taskData.UserIDs = projectTeam.ToList(); } lock (SyncObj) { AsyncTasks.Add(taskData); if (!AsyncTasks.IsStarted) { AsyncTasks.Start(ExecMarkFileAsNew); } } }
public static void Make(HelpCenterRequest request) { if (!DownloadEnabled) { return; } lock (LockObj) { if (Tasks.GetItems().Any(r => r.Url == request.Url)) { return; } Tasks.Add(request); if (!Tasks.IsStarted) { Tasks.Start(r => r.SendRequest()); } } }
public void EnqueueRequest(ApiRequest request) { _log.DebugFormat("queue request \"{0}\"", request); _messageQueue.Add(request); }