public Veeam GetLicensingInformation(PerformContext performContext)
        {
            Veeam veeam = new Veeam();

            try
            {
                veeam.LicenseType = VeeamLicense.TypeEx;
            }
            catch (Exception ex)
            {
                Logger.Error(performContext, "There was an error while getting the license information from the registry. We'll therefore assume its an evaluation license.");
                Logger.Debug(performContext, ex.Message, ex);

                veeam.LicenseType = LicenseTypeEx.Evaluation;
            }

            veeam.ProgramVersion = GetVersion();

            Version programVersion = Version.Parse(veeam.ProgramVersion);

            var(vsphere, hyperv) = GetVirtualMachineCount(performContext, programVersion, veeam.LicenseType);
            veeam.vSphere        = vsphere;
            veeam.HyperV         = hyperv;

            veeam.ClientVersion  = SettingManagerHelper.ClientVersion;
            veeam.Edition        = VeeamLicense.Edition;
            veeam.ExpirationDate = VeeamLicense.ExpirationDate;
            veeam.Hostname       = Environment.MachineName;
            veeam.Id             = _authService.GetDevice();
            veeam.SupportId      = VeeamLicense.SupportId;
            veeam.TenantId       = Convert.ToInt32(_authService.GetAccount());

            return(veeam);
        }
Beispiel #2
0
        private void ContextSendingRequest2(object sender, SendingRequest2EventArgs e)
        {
            e.RequestMessage.SetHeader("Authorization", $"Bearer {_authService.Token.access_token}");
            e.RequestMessage.SetHeader("Account", $"{_authService.GetAccount()}");

            if (e.RequestMessage is HttpWebRequestMessage message)
            {
                Logger.Debug($"Sending request: {message.Method} {message.Url}");
                Logger.Debug($"Sending request: {JsonConvert.SerializeObject(message, Formatting.Indented)}");
            }
            else
            {
                Logger.Debug($"Sending request: {e.RequestMessage.Method} {e.RequestMessage.Url}");
                Logger.Debug($"Sending request: {JsonConvert.SerializeObject(e.RequestMessage, Formatting.Indented)}");
            }
        }
        public MainWindowViewModel()
        {
            // resolve dependencies
            _settingManager = IocManager.Instance.Resolve <ISettingManager>();
            _authService    = IocManager.Instance.Resolve <IPortalAuthenticationService>();

            try
            {
                _serviceController = new ServiceController("LicenseMonitoringSystem");
                if (_serviceController == null)
                {
                    ServiceInstalled = false;
                    ServiceStatus    = "Program not installed.";
                }
                else
                {
                    ServiceInstalled = true;
                    ServiceStatus    = _serviceController.Status.ToString();
                }
            }
            catch (Exception ex)
            {
                ServiceInstalled = false;
                ServiceStatus    = ex.Message;
            }

            // set initial values
            AccountId = _authService.GetAccount();
            DeviceId  = _authService.GetDevice();

            // listen for changes
            this.Changed(p => p.AccountId)
            .Throttle(TimeSpan.FromMilliseconds(500))
            .ObserveOnDispatcher()
            .Subscribe(accountId =>
            {
                IsBusy = true;

                if (_canChangeAccountId)
                {
                    var prev = _authService.GetAccount();
                    if (prev != AccountId)
                    {
                        PendingChanges = true;
                    }
                }

                Debug.WriteLine($"Account ID: {accountId}");
                _settingManager.ChangeSettingForApplication(AppSettingNames.AutotaskAccountId, accountId.ToString());

                IsBusy = false;
                _canChangeAccountId = true;
            })
            .DisposeWith(_disposable);

            this.Changed(p => p.DeviceId)
            .Throttle(TimeSpan.FromMilliseconds(500))
            .ObserveOnDispatcher()
            .Subscribe(deviceId =>
            {
                IsBusy = true;
                if (_canChangeDeviceId)
                {
                    var prev = _authService.GetDevice();
                    if (prev != DeviceId)
                    {
                        PendingChanges = true;
                    }
                }

                Debug.WriteLine($"Device ID: {deviceId}");
                _settingManager.ChangeSettingForApplication(AppSettingNames.CentrastageDeviceId, deviceId.ToString());

                IsBusy             = false;
                _canChangeDeviceId = true;
            })
            .DisposeWith(_disposable);

            PendingChanges = false;
        }