コード例 #1
0
        public static ReassignProgressItem StartReassign(HttpContext context, int tenantId, Guid fromUserId, Guid toUserId, Guid currentUserId)
        {
            lock (Queue.SynchRoot)
            {
                var task = GetProgressItemStatus(tenantId, fromUserId, typeof(ReassignProgressItem)) as ReassignProgressItem;

                if (task != null && task.IsCompleted)
                {
                    Queue.Remove(task);
                    task = null;
                }

                if (task == null)
                {
                    task = new ReassignProgressItem(context, tenantId, fromUserId, toUserId, currentUserId);
                    Queue.Add(task);
                }

                if (!Queue.IsStarted)
                {
                    Queue.Start(x => x.RunJob());
                }

                return(task);
            }
        }
コード例 #2
0
        public static IProgressItem Start(EntityType entityType, String CSVFileURI, String importSettingsJSON)
        {
            lock (_syncObj)
            {
                var operation = GetStatus(entityType);

                if (operation == null)
                {
                    var fromCache = ImportDataCache.Get(entityType);

                    if (fromCache != null)
                    {
                        return(fromCache);
                    }
                }


                if (operation == null)
                {
                    operation = new ImportDataOperation(entityType, CSVFileURI, importSettingsJSON);

                    _importQueue.Add(operation);
                }

                if (!_importQueue.IsStarted)
                {
                    _importQueue.Start(x => x.RunJob());
                }

                return(operation);
            }
        }
コード例 #3
0
        public static PdfProgressItem StartTask(HttpContext context, int tenantId, Guid userId, int invoiceId)
        {
            lock (Queue.SynchRoot)
            {
                var task = GetTaskStatus(tenantId, invoiceId);

                if (task != null && task.IsCompleted)
                {
                    Queue.Remove(task);
                    task = null;
                }

                if (task == null)
                {
                    task = new PdfProgressItem(context, tenantId, userId, invoiceId);
                    Queue.Add(task);
                }

                if (!Queue.IsStarted)
                {
                    Queue.Start(x => x.RunJob());
                }

                return(task);
            }
        }
コード例 #4
0
        public static IProgressItem Start(List <int> fileID, List <int> contactID, String subject, String bodyTemplate, bool storeInHistory)
        {
            lock (_syncObj)
            {
                var operation = _mailQueue.GetStatus(TenantProvider.CurrentTenantID);
                if (operation == null)
                {
                    if (fileID == null)
                    {
                        fileID = new List <int>();
                    }
                    if (contactID == null || contactID.Count == 0 ||
                        String.IsNullOrEmpty(subject) || String.IsNullOrEmpty(bodyTemplate))
                    {
                        return(null);
                    }

                    if (contactID.Count > GetQuotas())
                    {
                        contactID = contactID.Take(GetQuotas()).ToList();
                    }

                    operation = new SendBatchEmailsOperation(fileID, contactID, subject, bodyTemplate, storeInHistory);
                    _mailQueue.Add(operation);
                }

                if (!_mailQueue.IsStarted)
                {
                    _mailQueue.Start(x => x.RunJob());
                }
                return(operation);
            }
        }
コード例 #5
0
 public void StartScheduledBackup(BackupSchedule schedule)
 {
     lock (ProgressQueue.SynchRoot)
     {
         var item = ProgressQueue.GetItems().OfType <BackupProgressItem>().FirstOrDefault(t => t.TenantId == schedule.TenantId);
         if (item != null && item.IsCompleted)
         {
             ProgressQueue.Remove(item);
             item = null;
         }
         if (item == null)
         {
             item = FactoryProgressItem.CreateBackupProgressItem(schedule, false, TempFolder, Limit, CurrentRegion, ConfigPaths);
             ProgressQueue.Add(item);
         }
     }
 }
コード例 #6
0
 public BackupProgress StartRestore(StartRestoreRequest request)
 {
     lock (ProgressQueue.SynchRoot)
     {
         var item = ProgressQueue.GetItems().OfType <RestoreProgressItem>().FirstOrDefault(t => t.TenantId == request.TenantId);
         if (item != null && item.IsCompleted)
         {
             ProgressQueue.Remove(item);
             item = null;
         }
         if (item == null)
         {
             item = FactoryProgressItem.CreateRestoreProgressItem(request, TempFolder, UpgradesPath, CurrentRegion, ConfigPaths);
             ProgressQueue.Add(item);
         }
         return(ToBackupProgress(item));
     }
 }
コード例 #7
0
 private static T FindOrAddItem <T>(int tenantId, Func <T> itemFactory) where T : BackupProgressItemBase
 {
     lock (tasks.SynchRoot)
     {
         var item = FindItem <T>(tenantId);
         if (item != null && item.IsCompleted)
         {
             tasks.Remove(item);
             item = null;
         }
         if (item == null)
         {
             item = itemFactory();
             tasks.Add(item);
         }
         return(item);
     }
 }
コード例 #8
0
        public static IProgressItem Start()
        {
            lock (_syncObj)
            {
                var operation = _exportQueue.GetStatus(TenantProvider.CurrentTenantID);

                if (operation == null)
                {
                    operation = new ExportDataOperation();

                    _exportQueue.Add(operation);
                }

                if (!_exportQueue.IsStarted)
                    _exportQueue.Start(x => x.RunJob());

                return operation;
            }
        }
コード例 #9
0
        public BackupProgress StartTransfer(int tenantId, string targetRegion, bool transferMail, bool notify)
        {
            lock (ProgressQueue.SynchRoot)
            {
                var item = ProgressQueue.GetItems().OfType <TransferProgressItem>().FirstOrDefault(t => t.TenantId == tenantId);
                if (item != null && item.IsCompleted)
                {
                    ProgressQueue.Remove(item);
                    item = null;
                }

                if (item == null)
                {
                    item = FactoryProgressItem.CreateTransferProgressItem(targetRegion, transferMail, tenantId, TempFolder, Limit, notify, CurrentRegion, ConfigPaths);
                    ProgressQueue.Add(item);
                }

                return(ToBackupProgress(item));
            }
        }
コード例 #10
0
        public BackupProgress StartBackup(StartBackupRequest request)
        {
            lock (ProgressQueue.SynchRoot)
            {
                var item = ProgressQueue.GetItems().OfType <BackupProgressItem>().FirstOrDefault(t => t.TenantId == request.TenantId);
                if (item != null && item.IsCompleted)
                {
                    ProgressQueue.Remove(item);
                    item = null;
                }
                if (item == null)
                {
                    item = FactoryProgressItem.CreateBackupProgressItem(request, false, TempFolder, Limit, CurrentRegion, ConfigPaths);
                    ProgressQueue.Add(item);
                }

                var progress = ToBackupProgress(item);

                PublishProgress(progress);

                return(progress);
            }
        }