-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProgram.cs
More file actions
101 lines (88 loc) · 3.7 KB
/
Program.cs
File metadata and controls
101 lines (88 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/********************************************************
* *
* Copyright (C) Microsoft. All rights reserved. *
* *
*********************************************************/
using System;
using System.Configuration;
namespace Microsoft.Partner.CSP.IntSandbox.Customer.Sample
{
class Program
{
static void Main(string[] args)
{
CmdLineArguments parsedArgs = new CmdLineArguments();
if (Parser.ParseArgumentsWithUsage(args, parsedArgs))
{
// the parser only ensures the switch names are specified correctly - still need to validate
if (parsedArgs.Validate())
{
if (parsedArgs.operation == Operation.DeleteAll && parsedArgs.confirm == false)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("\n\n\nAre you sure you wish to delete all customers?");
Console.Write("\n(Enter 'Y' to delete)?");
string confirmPrompt = Console.ReadLine();
parsedArgs.confirm = (confirmPrompt.ToLowerInvariant() == "Y".ToLowerInvariant());
if (!parsedArgs.confirm)
{
return;
}
}
}
else
{
return;
}
// This is the Microsoft ID of the reseller
// Please work with your Admin Agent to get it from https://partnercenter.microsoft.com/en-us/pc/AccountSettings/TenantProfile
string microsoftId = ConfigurationManager.AppSettings["MicrosoftId"];
// This is the default domain of the reseller
// Please work with your Admin Agent to get it from https://partnercenter.microsoft.com/en-us/pc/AccountSettings/TenantProfile
string defaultDomain = ConfigurationManager.AppSettings["DefaultDomain"];
// This is the appid that is registered for this application in Azure Active Directory (AAD)
// Please work with your Admin Agent to get it from https://partnercenter.microsoft.com/en-us/pc/ApiIntegration/Overview
string appId = ConfigurationManager.AppSettings["AppId"];
// This is the key for this application in Azure Active Directory
// This is only available at the time your admin agent has created a new app at https://partnercenter.microsoft.com/en-us/pc/ApiIntegration/Overview
// You could alternatively goto Azure Active Directory and generate a new key, and use that.
string key = ConfigurationManager.AppSettings["Key"];
// Prompts the user to edit the config parametres if its not already done.
Utilities.ValidateConfiguration(microsoftId, defaultDomain, appId, key);
try
{
switch (parsedArgs.operation)
{
case Operation.Export:
Orchestrator.ExportCustomers(parsedArgs.file, defaultDomain, appId, key, microsoftId);
break;
case Operation.Delete:
Orchestrator.DeleteCustomers(parsedArgs.file, defaultDomain, appId, key, microsoftId);
break;
case Operation.DeleteAll:
Orchestrator.DeleteAllCustomers(defaultDomain, appId, key, microsoftId);
break;
default:
break;
}
}
catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\n Make sure the app.config has all the right settings. The defaults in the app.config won't work."
+ "\n If the settings are correct, its possible you are hitting a service error. Try again."
+ "\n If the error persists, contact support");
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\n An unrecoverable error occurred:");
Console.WriteLine(ex.Message);
}
Console.ResetColor();
Console.Write("\n\n\nHit enter to exit the app...");
Console.ReadLine();
}
}
}
}