Esempio n. 1
0
        public void RunJob(DistributedTask _, CancellationToken cancellationToken)
        {
            try
            {
                CancellationToken = cancellationToken;

                CoreContext.TenantManager.SetCurrentTenant(CurrentTenant);
                Thread.CurrentPrincipal               = principal;
                Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo(culture);
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);

                FolderDao     = Global.DaoFactory.GetFolderDao();
                FileDao       = Global.DaoFactory.GetFileDao();
                TagDao        = Global.DaoFactory.GetTagDao();
                ProviderDao   = Global.DaoFactory.GetProviderDao();
                FilesSecurity = new FileSecurity(Global.DaoFactory);
                LinkDao       = Global.GetLinkDao();

                Logger = Global.Logger;

                Total = InitTotalProgressSteps();

                Do();
            }
            catch (AuthorizingException authError)
            {
                Error = FilesCommonResource.ErrorMassage_SecurityException;
                Logger.Error(Error, new SecurityException(Error, authError));
            }
            catch (AggregateException ae)
            {
                ae.Flatten().Handle(e => e is TaskCanceledException || e is OperationCanceledException);
            }
            catch (Exception error)
            {
                Error = error is TaskCanceledException || error is OperationCanceledException
                            ? FilesCommonResource.ErrorMassage_OperationCanceledException
                            : error.Message;
                Logger.Error(error, error);
            }
            finally
            {
                try
                {
                    TaskInfo.SetProperty(FINISHED, true);
                    PublishTaskInfo();

                    FolderDao.Dispose();
                    FileDao.Dispose();
                    TagDao.Dispose();
                    LinkDao.Dispose();

                    if (ProviderDao != null)
                    {
                        ProviderDao.Dispose();
                    }
                }
                catch { /* ignore */ }
            }
        }
Esempio n. 2
0
        public void RunJob()
        {
            IPrincipal oldPrincipal = null;

            try
            {
                oldPrincipal = Thread.CurrentPrincipal;
            }
            catch
            {
            }
            try
            {
                if (_principal != null)
                {
                    Thread.CurrentPrincipal = _principal;
                }
                CoreContext.TenantManager.SetCurrentTenant(CurrentTenant);
                Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo(_culture);
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(_culture);
                FolderDao     = Global.DaoFactory.GetFolderDao();
                FileDao       = Global.DaoFactory.GetFileDao();
                TagDao        = Global.DaoFactory.GetTagDao();
                Logger        = Global.Logger;
                ProviderDao   = Global.DaoFactory.GetProviderDao();
                FilesSecurity = new FileSecurity(Global.DaoFactory);

                try
                {
                    _step = InitProgressStep();
                }
                catch
                {
                }

                Do();
            }
            catch (AuthorizingException authError)
            {
                Error = FilesCommonResource.ErrorMassage_SecurityException;
                Logger.Error(Error, new SecurityException(Error.ToString(), authError));
            }
            catch (Exception error)
            {
                Error = error.Message;
                Logger.Error(error, error);
            }
            finally
            {
                IsCompleted = true;
                Percentage  = 100;
                try
                {
                    if (oldPrincipal != null)
                    {
                        Thread.CurrentPrincipal = oldPrincipal;
                    }
                    FolderDao.Dispose();
                    FileDao.Dispose();
                    TagDao.Dispose();
                    ProviderDao.Dispose();
                }
                catch
                {
                }
            }
        }
Esempio n. 3
0
        public void RunJob()
        {
            IPrincipal oldPrincipal = null;

            try
            {
                oldPrincipal = Thread.CurrentPrincipal;
            }
            catch
            {
            }
            try
            {
                if (principal != null)
                {
                    Thread.CurrentPrincipal = principal;
                }
                CoreContext.TenantManager.SetCurrentTenant(CurrentTenant);
                Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo(culture);
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
                FolderDao     = Global.DaoFactory.GetFolderDao();
                FileDao       = Global.DaoFactory.GetFileDao();
                TagDao        = Global.DaoFactory.GetTagDao();
                FilesSecurity = new FileSecurity(Global.DaoFactory);
                Store         = Global.GetStore();

                try
                {
                    step = InitProgressStep();
                }
                catch
                {
                }

                Do();
            }
            catch (AuthorizingException authError)
            {
                Error = new SecurityException(FilesCommonResource.ErrorMassage_SecurityException, authError);
            }
            catch (Exception error)
            {
                Error = error;
                LogManager.GetLogger("ASC.Files").Error(error);
            }
            finally
            {
                IsCompleted = true;
                Percentage  = 100;
                try
                {
                    if (oldPrincipal != null)
                    {
                        Thread.CurrentPrincipal = oldPrincipal;
                    }
                    FolderDao.Dispose();
                    FileDao.Dispose();
                    TagDao.Dispose();
                }
                catch
                {
                }
            }
        }