Exemple #1
0
        private void CheckIfEnterpriseAdmin()
        {
            if (_auth.AuthContext.IsEnterpriseAdmin)
            {
                Enterprise = new EnterpriseData(_auth);

                _auth.PushNotifications?.RegisterCallback(EnterpriseNotificationCallback);
                Task.Run(async() =>
                {
                    try
                    {
                        await Enterprise.PopulateEnterprise();

                        await this.AppendEnterpriseCommands(this);

                        var entRq = new GetEnterpriseDataCommand
                        {
                            include = new[] { "licenses", "managed_companies" }
                        };
                        var entRs = await _auth.ExecuteAuthCommand <GetEnterpriseDataCommand, GetEnterpriseDataResponse>(entRq);

                        if (entRs.ManagedCompanies?.Count > 0)
                        {
                            _managedCompanies.AddRange(entRs.ManagedCompanies);
                            Commands.Add("mc-list",
                                         new SimpleCommand
                            {
                                Order       = 70,
                                Description = "List managed companies",
                                Action      = ListManagedCompanies,
                            });
                            Commands.Add("mc-login",
                                         new ParsableCommand <EnterpriseMcLoginOptions>
                            {
                                Order       = 71,
                                Description = "Login to managed company",
                                Action      = LoginToManagedCompany,
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e);
                    }
                });
            }
        }
Exemple #2
0
 public McEnterpriseContext(ManagedCompanyAuth auth)
 {
     if (auth.AuthContext.IsEnterpriseAdmin)
     {
         Enterprise = new EnterpriseData(auth, auth.TreeKey);
         Task.Run(async() =>
         {
             try
             {
                 await Enterprise.PopulateEnterprise();
                 await this.AppendEnterpriseCommands(this);
             }
             catch (Exception e)
             {
                 Debug.WriteLine(e);
             }
         });
     }
 }