コード例 #1
0
        static void Main(string[] args)
        {
            if (args.Length <= 0)
            {
                Console.WriteLine("Please enter a command as the first argument.");
                Console.WriteLine("\t1                 : Migrate social and local accounts with password");
                Console.WriteLine("\t2                 : Migrate social and local accounts with random password");
                Console.WriteLine("\t3 Email-address  : Get user by email address");
                Console.WriteLine("\t4 Display-name   : Get user by display name");
                Console.WriteLine("\t5                : User migration cleanup");
                return;
            }

            try
            {
                switch (args[0])
                {
                case "1":
                    MigrateUsersWithPasswordAsync().Wait();
                    break;

                case "2":
                    MigrateUsersWithRandomPasswordAsync().Wait();
                    break;

                case "3":
                    if (args.Length == 2)
                    {
                        B2CGraphClient b2CGraphClient = new B2CGraphClient(Program.Tenant, Program.ClientId, Program.ClientSecret);
                        string         JSON           = b2CGraphClient.SearcUserBySignInNames(args[1]).Result;

                        Console.WriteLine(JSON);
                        GraphAccounts users = GraphAccounts.Parse(JSON);
                    }
                    else
                    {
                        Console.WriteLine("Email address parameter is missing");
                    }
                    break;

                case "4":
                    if (args.Length == 2)
                    {
                        B2CGraphClient b2CGraphClient = new B2CGraphClient(Program.Tenant, Program.ClientId, Program.ClientSecret);
                        string         JSON           = b2CGraphClient.SearchUserByDisplayName(args[1]).Result;

                        Console.WriteLine(JSON);
                        GraphAccounts users = GraphAccounts.Parse(JSON);
                    }
                    else
                    {
                        Console.WriteLine("Display name parameter is missing");
                    }
                    break;

                case "5":
                    UserMigrationCleanupAsync().Wait();
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                if (ex.InnerException != null)
                {
                    Console.WriteLine(ex.InnerException.Message);
                }
                else
                {
                    Console.WriteLine(ex.Message);
                }
            }
            finally
            {
                Console.ResetColor();
            }

            Console.ReadLine();
        }