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);
                    });
                }
            }
        }
Пример #2
0
        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
            }
        }
Пример #3
0
 public void Start()
 {
     if (!_messageQueue.IsStarted)
     {
         _messageQueue.Start(SendMessage);
     }
 }
        public void Start()
        {
            renderQueue = new WorkerQueue();
            renderQueue.Start();

            generateQueue = new WorkerQueue();
            generateQueue.Start();
        }
Пример #5
0
 public void Start()
 {
     if (!Started)
     {
         Started  = true;
         requests = new WorkerQueue <string>(4, TimeSpan.Zero, 10, true);
         requests.AddRange(urls);
         requests.Start(LoaderPortalPages);
     }
 }
Пример #6
0
        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);
                }
            }
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
        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());
                }
            }
        }
Пример #10
0
 static ImportQueue()
 {
     imports.Start(DoImport);
 }
Пример #11
0
        public static void InitRequests()
        {
            var listUrls = new List <RequestItem>
            {
                new RequestItem("~/auth.aspx"),
                new RequestItem("~/confirm.aspx"),
                new RequestItem("~/default.aspx"),
                new RequestItem("~/feed.aspx"),
                new RequestItem("~/management.aspx?type=1"),
                new RequestItem("~/management.aspx?type=2"),
                new RequestItem("~/management.aspx?type=3"),
                new RequestItem("~/management.aspx?type=4"),
                new RequestItem("~/management.aspx?type=5"),
                new RequestItem("~/management.aspx?type=6"),
                new RequestItem("~/management.aspx?type=7"),
                new RequestItem("~/management.aspx?type=10"),
                new RequestItem("~/management.aspx?type=11"),
                new RequestItem("~/management.aspx?type=15"),
                new RequestItem("~/my.aspx"),
                new RequestItem("~/preparationportal.aspx"),
                new RequestItem("~/search.aspx"),
                new RequestItem("~/servererror.aspx"),
                new RequestItem("~/startscriptsstyles.aspx"),
                new RequestItem("~/tariffs.aspx"),
                new RequestItem("~/products/files/default.aspx"),
                new RequestItem("~/products/files/doceditor.aspx"),
                new RequestItem("~/products/crm/cases.aspx"),
                new RequestItem("~/products/crm/deals.aspx"),
                new RequestItem("~/products/crm/default.aspx"),
                new RequestItem("~/products/crm/help.aspx"),
                new RequestItem("~/products/crm/invoices.aspx"),
                new RequestItem("~/products/crm/mailviewer.aspx"),
                new RequestItem("~/products/crm/sender.aspx"),
                new RequestItem("~/products/crm/settings.aspx"),
                new RequestItem("~/products/crm/tasks.aspx"),
                new RequestItem("~/products/projects/contacts.aspx"),
                new RequestItem("~/products/projects/default.aspx"),
                new RequestItem("~/products/projects/ganttchart.aspx"),
                new RequestItem("~/products/projects/GeneratedReport.aspx"),
                new RequestItem("~/products/projects/help.aspx"),
                new RequestItem("~/products/projects/import.aspx"),
                new RequestItem("~/products/projects/messages.aspx"),
                new RequestItem("~/products/projects/milestones.aspx"),
                new RequestItem("~/products/projects/projects.aspx"),
                //new RequestItem("~/products/projects/projectteam.aspx"),
                new RequestItem("~/products/projects/projecttemplates.aspx"),
                new RequestItem("~/products/projects/reports.aspx"),
                new RequestItem("~/products/projects/tasks.aspx"),
                new RequestItem("~/products/projects/timer.aspx"),
                new RequestItem("~/products/projects/timetracking.aspx"),
                new RequestItem("~/products/projects/tmdocs.aspx"),
                new RequestItem("~/products/people/default.aspx"),
                new RequestItem("~/products/people/help.aspx"),
                new RequestItem("~/products/people/profile.aspx"),
                new RequestItem("~/products/people/profileaction.aspx"),
                new RequestItem("~/addons/mail/default.aspx"),
                new RequestItem("~/products/community/default.aspx"),
                new RequestItem("~/products/community/help.aspx"),
                new RequestItem("~/products/community/modules/birthdays/default.aspx"),
                new RequestItem("~/products/community/modules/blogs/addblog.aspx"),
                new RequestItem("~/products/community/modules/blogs/default.aspx"),
                new RequestItem("~/products/community/modules/blogs/editblog.aspx"),
                new RequestItem("~/products/community/modules/blogs/viewblog.aspx"),
                new RequestItem("~/products/community/modules/bookmarking/default.aspx"),
                new RequestItem("~/products/community/modules/bookmarking/createbookmark.aspx"),
                new RequestItem("~/products/community/modules/bookmarking/bookmarkinfo.aspx"),
                new RequestItem("~/products/community/modules/bookmarking/favouritebookmarks.aspx"),
                new RequestItem("~/products/community/modules/bookmarking/userbookmarks.aspx"),
                new RequestItem("~/products/community/modules/forum/default.aspx"),
                new RequestItem("~/products/community/modules/forum/edittopic.aspx"),
                new RequestItem("~/products/community/modules/forum/managementcenter.aspx"),
                new RequestItem("~/products/community/modules/forum/newforum.aspx"),
                new RequestItem("~/products/community/modules/forum/newpost.aspx"),
                new RequestItem("~/products/community/modules/forum/posts.aspx"),
                new RequestItem("~/products/community/modules/forum/search.aspx"),
                new RequestItem("~/products/community/modules/forum/topics.aspx"),
                new RequestItem("~/products/community/modules/forum/usertopics.aspx"),
                new RequestItem("~/products/community/modules/news/default.aspx"),
                new RequestItem("~/products/community/modules/news/editnews.aspx"),
                new RequestItem("~/products/community/modules/news/editpoll.aspx"),
                new RequestItem("~/products/community/modules/news/news.aspx"),
                //new RequestItem("~/products/community/modules/wiki/default.aspx"),
                new RequestItem("~/products/community/modules/wiki/diff.aspx"),
                new RequestItem("~/products/community/modules/wiki/listcategories.aspx"),
                new RequestItem("~/products/community/modules/wiki/listfiles.aspx"),
                new RequestItem("~/products/community/modules/wiki/listpages.aspx"),
                //new RequestItem("~/products/community/modules/wiki/pagehistorylist.aspx"),
                new RequestItem("~/addons/calendar/default.aspx")
            };

            Progress = new StartupProgress {
                Total = listUrls.Count
            };
            Requests.Stop();
            Requests.Terminate();
            Requests.AddRange(listUrls);
            Requests.Start(LoaderPortalPages);
        }
Пример #12
0
 public void Start()
 {
     if (!Started)
     {
         Started = true;
         requests = new WorkerQueue<string>(4, TimeSpan.Zero, 10, true);
         requests.AddRange(urls);
         requests.Start(LoaderPortalPages);
     }
 }