예제 #1
0
        public void UploadDir(string relativePath, string mappedPath)
        {
            if (!CanUpload())
            {
                return;
            }
            if (!Directory.Exists(mappedPath))
            {
                return;
            }

            var tenant = TenantManager.GetCurrentTenant();
            var key    = typeof(UploadOperationProgress).FullName + tenant.TenantId;
            UploadOperationProgress uploadOperation;

            lock (Locker)
            {
                uploadOperation = Queue.GetTask <UploadOperationProgress>(key);
                if (uploadOperation != null)
                {
                    return;
                }

                uploadOperation = new UploadOperationProgress(ServiceProvider, key, tenant.TenantId, relativePath, mappedPath);
                Queue.QueueTask(uploadOperation);
            }
        }
예제 #2
0
        public static async void UploadDir(string relativePath, string mappedPath)
        {
            if (!CanUpload())
            {
                return;
            }
            if (!Directory.Exists(mappedPath))
            {
                return;
            }

            var tenant = CoreContext.TenantManager.GetCurrentTenant();
            var key    = typeof(UploadOperationProgress).FullName + tenant.TenantId;
            UploadOperationProgress uploadOperation;

            lock (Locker)
            {
                uploadOperation = Cache.Get <UploadOperationProgress>(key);
                if (uploadOperation != null)
                {
                    return;
                }

                uploadOperation = new UploadOperationProgress(relativePath, mappedPath);
                Cache.Insert(key, uploadOperation, DateTime.MaxValue);
            }


            tenant.SetStatus(TenantStatus.Migrating);
            CoreContext.TenantManager.SaveTenant(tenant);

            await uploadOperation.RunJobAsync();

            tenant.SetStatus(Core.Tenants.TenantStatus.Active);
            CoreContext.TenantManager.SaveTenant(tenant);
        }