예제 #1
0
        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);
        }
        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;
        }
예제 #3
0
        public ManagedSupport GetManagedServer()
        {
            var device = _authService.GetDevice();

            return(_context.ManagedServers.Where(e => e.DeviceId == device).SingleOrDefault());
        }