Exemple #1
0
        public static int CalculatePackageDiskspace(int packageId)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo);

            if (accountCheck < 0)
            {
                return(accountCheck);
            }

            // place log record
            TaskManager.StartTask("SPACE", "CALCULATE_DISKSPACE", packageId);

            try
            {
                // create thread parameters
                ThreadStartParameters prms = new ThreadStartParameters();
                prms.UserId     = SecurityContext.User.UserId;
                prms.Parameters = new object[] { packageId };

                Thread t = new Thread(new ParameterizedThreadStart(CalculatePackageDiskspaceAsync));
                t.Start(prms);
                return(0);
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
Exemple #2
0
        private static void CalculatePackageDiskspaceAsync(object objPrms)
        {
            ThreadStartParameters prms = (ThreadStartParameters)objPrms;

            // impersonate thread
            SecurityContext.SetThreadPrincipal(prms.UserId);

            int packageId = (int)prms.Parameters[0];

            try
            {
                // calculate
                CalculatePackagesDiskspaceTask calc = new CalculatePackagesDiskspaceTask();
                calc.CalculatePackage(packageId);
            }
            catch (Exception ex)
            {
                // write to audit log
                TaskManager.WriteError(ex);
            }
        }
        public static int CalculateOrganizationDiskspace(int itemId)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo);
            if (accountCheck < 0) return accountCheck;

            // place log record
            TaskManager.StartTask("EXCHANGE", "CALCULATE_DISKSPACE", itemId);

            try
            {
                // create thread parameters
                ThreadStartParameters prms = new ThreadStartParameters();
                prms.UserId = SecurityContext.User.UserId;
                prms.Parameters = new object[] { itemId };

                Thread t = new Thread(CalculateOrganizationDiskspaceAsync);
                t.Start(prms);
                return 0;

            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }