Exemplo n.º 1
0
        private VariantConfigurationSnapshot GetDiagnosticInfoSnapshot(SettingOverrideSync.SettingOverrideDiagnosableArgument argument, out string error)
        {
            IConstraintProvider constraintProvider = MachineSettingsContext.Local;

            if (argument.HasArgument("user"))
            {
                string userId = argument.GetArgument <string>("user");
                if (!string.IsNullOrWhiteSpace(userId))
                {
                    string orgId = null;
                    if (argument.HasArgument("org"))
                    {
                        orgId = argument.GetArgument <string>("org");
                    }
                    if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled&& string.IsNullOrEmpty(orgId))
                    {
                        error = "Org is required.";
                        return(null);
                    }
                    ADUser user = null;
                    ADNotificationAdapter.TryRunADOperation(delegate()
                    {
                        user = new SettingOverrideSync.UserResolver(userId, orgId).Resolve();
                    }, 3);
                    if (user == null)
                    {
                        error = "User not found.";
                        return(null);
                    }
                    constraintProvider = user.GetContext(null);
                }
            }
            error = null;
            return(VariantConfiguration.GetSnapshot(constraintProvider, null, null));
        }
Exemplo n.º 2
0
        public XElement GetDiagnosticInfo(DiagnosableParameters parameters)
        {
            SettingOverrideSync.SettingOverrideDiagnosableArgument settingOverrideDiagnosableArgument = new SettingOverrideSync.SettingOverrideDiagnosableArgument(parameters);
            XElement xelement = new XElement(this.GetDiagnosticComponentName());

            if (settingOverrideDiagnosableArgument.HasArgument("refresh"))
            {
                this.RefreshAndWait();
            }
            if (settingOverrideDiagnosableArgument.HasArgument("errors"))
            {
                xelement.Add(this.GetErrorsDiagnosticInfo());
            }
            else if (settingOverrideDiagnosableArgument.HasArgument("overrides"))
            {
                xelement.Add(this.GetOverridesDiagnosticInfo());
            }
            else if (settingOverrideDiagnosableArgument.HasArgument("refresh"))
            {
                xelement.Add(this.GetOverridesDiagnosticInfo());
            }
            else if (settingOverrideDiagnosableArgument.HasArgument("config"))
            {
                string content = null;
                VariantConfigurationSnapshot diagnosticInfoSnapshot = this.GetDiagnosticInfoSnapshot(settingOverrideDiagnosableArgument, out content);
                if (diagnosticInfoSnapshot != null)
                {
                    xelement.Add(this.GetConstraintDiagnosticInfo(diagnosticInfoSnapshot));
                    xelement.Add(this.GetConfigurationDiagnosticInfo(diagnosticInfoSnapshot));
                }
                else
                {
                    xelement.Add(new XElement("Error", content));
                }
            }
            else
            {
                xelement.Add(new XElement("Help", "Allowed arguments: " + string.Join(", ", settingOverrideDiagnosableArgument.ArgumentSchema.Keys) + "."));
            }
            return(xelement);
        }