Пример #1
0
        public static DataAccessResponseType DeprovisionClosedAccounts()
        {
            var response = new DataAccessResponseType();

            try
            {
                // 1. Get list of AccountID's that are past their AccountEndDate and have ClosueApproved set to TRUE. These accounts are ready for deprovisioning:
                var accountsToDeprovision = Sql.Statements.SelectStatements.SelectClosedAccountsToDeprovision();
                if (accountsToDeprovision.Count > 0)
                {
                    foreach (string accountID in accountsToDeprovision)
                    {
                        // Get the Account
                        //var account = AccountManager.GetAccountByID(accountID, false);
                        var account = AccountManager.GetAccount(accountID, false, AccountManager.AccountIdentificationType.AccountID);

                        // Delete the account, associated user(s) and all data for each account ID the open up each data partition for future accounts:
                        var deprovisioningResponse = DeprovisioningManager.DeprovisionAccount(account);

                        // Log Custodian Activity
                        //PlatformLogManager.LogActivity(CategoryType.Custodian, ActivityType.Custodian_Scheduled_Task,
                        //account.AccountName + " has been deprovisioned. (" + account.AccountID + ") ",
                        //"Check deprovisioning log for details.", account.AccountID.ToString(), account.AccountName);
                    }

                    response.isSuccess      = true;
                    response.SuccessMessage = "Closed account(s) have been deprovisioned, see deprovisioning log for details.";
                }
                else
                {
                    // No accounts to deprovision...
                    response.isSuccess      = true;
                    response.SuccessMessage = "No accounts found for deprovisioning.";

                    // Log (Commented out to make custodian less noisy)
                    //PlatformLogManager.LogActivity(CustodianLogActivity.ScheduledTask, ""No accounts found for deprovisioning.");
                }
            }
            catch (Exception e)
            {
                //Log exception and email platform admins
                PlatformExceptionsHelper.LogExceptionAndAlertAdmins(
                    e,
                    "attempting to deprovision closed accounts",
                    System.Reflection.MethodBase.GetCurrentMethod()
                    );

                response.isSuccess    = false;
                response.ErrorMessage = e.Message;
            }

            return(response);
        }
Пример #2
0
        private static void DeprovisionAllAccounts()
        {
            try
            {
                var Accounts = AccountManager.GetAllAccounts(0, 0, "AccountNameKey", false);

                foreach (Account account in Accounts)
                {
                    try
                    {
                        var response = DeprovisioningManager.DeprovisionAccount(account);

                        if (response.isSuccess)
                        {
                            //Console.ForegroundColor = ConsoleColor.Green;
                            //Console.WriteLine(account.AccountName + " - has been deleted");
                            //Console.ResetColor();
                        }
                        else
                        {
                            //Console.ForegroundColor = ConsoleColor.Red;
                            //Console.WriteLine("There was an error deleting: " + account.AccountName);
                            //Console.ForegroundColor = ConsoleColor.DarkRed;
                            //Console.WriteLine(response.ErrorMessage);
                            //Console.ResetColor();
                        }
                    }
                    catch
                    {
                        //Console.ForegroundColor = ConsoleColor.Red;
                        //Console.WriteLine("There was an exception thrown while deleting: " + account.AccountName);
                        //Console.ForegroundColor = ConsoleColor.DarkRed;
                        //Console.WriteLine(e.Message);
                        //Console.ResetColor();
                    }
                }
            }
            catch
            {
            }
        }