Exemplo n.º 1
0
        public async Task<ResultSingle<AppDomain>> CreateDomainAsync(AppDomain domain = null,
            bool doCache = false, bool throwIfError = true)
        {
            AppDomain theDomain = domain == null ? _editDomain : domain;

            ResultSingle<AppDomain> result = await ResultSingleUI<AppDomain>.WaitForObjectAsync(
                throwIfError, theDomain, new CachedHttpRequest<AppDomain, ResultSingle<AppDomain>>(
                    Backend.CreateAsync), doCache);

            if (result.Code >= 0)
            {
                _editDomain = result.Data.Payload;
                 
                // Add the default free certificate
                AppDomainCertificate cert = new AppDomainCertificate();
                cert.OwnedBy = _editDomain;
                cert.Tag = _editDomain.Tag;
                cert.Type = "free";

                await CreateDomainCertificateAsync(cert);

                if (domain != null)
                {
                    _editDomain.CopyTo(domain);
                    _domains.Add(domain);
                    OnPropertyChanged("Domains");
                }
            }

            return result;
        }
Exemplo n.º 2
0
        public async Task<ResultSingle<AppDomainCertificate>> UpdateDomainCertificateAsync(AppDomainCertificate cert = null,
            bool doCache = false, bool throwIfError = true)
        {
            AppDomainCertificate theCert = cert == null ? _editDomain.Certificate : cert;

            ResultSingle<AppDomainCertificate> result = await ResultSingleUI<AppDomainCertificate>.WaitForObjectAsync(
                throwIfError, theCert, new CachedHttpRequest<AppDomainCertificate, ResultSingle<AppDomainCertificate>>(
                    Backend.UpdateAsync), doCache);

            if (result.Code >= 0)
            {
                _editDomain.Certificate = result.Data.Payload;
            }

            return result;
        }
Exemplo n.º 3
0
        public async Task<ResultSingle<AppDomain>> QueryDomainAsync(AppDomain domain = null, 
            bool doCache = false, bool throwIfError = true)
        {
            AppDomain theDomain = domain == null ? _editDomain : domain;

            ResultSingle<AppDomain> result = await ResultSingleUI<AppDomain>.WaitForObjectAsync(
                throwIfError, theDomain, new CachedHttpRequest<AppDomain, ResultSingle<AppDomain>>(
                    Backend.QueryAsync), doCache, null, null);

            if (result.Code >= 0)
            {
                _editDomain = result.Data.Payload;

                AppDomainCertificate seedCert = new AppDomainCertificate();
                seedCert.OwnedBy = _editDomain;

                ResultMultiple<AppDomainCertificate> certResult = await ResultMultipleUI<AppDomainCertificate>.WaitForObjectsAsync(
                    true, seedCert, new CachedHttpRequest<AppDomainCertificate, ResultMultiple<AppDomainCertificate>>(
                        Backend.QueryAsyncListAsync), true);

                if (certResult.Code >= 0)
                {
                    ObservableCollection<AppDomainCertificate> list = certResult.Data.Payload;

                    if (list.Any())
                    {
                        theDomain.Certificate = list.First();
                        theDomain.Certificate.OwnedBy = theDomain;
                    }
                }

                if (domain != null)
                {
                    _editDomain.CopyTo(domain);
                }
            }

            return result;
        }
Exemplo n.º 4
0
        public async Task<ResultMultiple<AppDomain>> QueryDomainsAsync(
            bool doCache = false, bool throwIfError = true)
        {
            ResultMultiple<AppDomain> result = await ResultMultipleUI<AppDomain>.WaitForObjectsAsync(
                true, _editDomain, new CachedHttpRequest<AppDomain, ResultMultiple<AppDomain>>(
                    Backend.QueryAsyncListAsync), true);

            if (result.Code >= 0)
            {
                _domains = result.Data.Payload;

                foreach (AppDomain domain in _domains)
                {
                    domain.OwnedBy = _editApp;
                    domain.Primary = (_editApp.PrimaryDomainId == domain.Id);
                    domain.IPAddress = _editApp.IPAddress;
 
                    AppDomainCertificate seedCert = new AppDomainCertificate();
                    seedCert.OwnedBy = domain;

                    ResultMultiple<AppDomainCertificate> certResult = await ResultMultipleUI<AppDomainCertificate>.WaitForObjectsAsync(
                        true, seedCert, new CachedHttpRequest<AppDomainCertificate, ResultMultiple<AppDomainCertificate>>(
                            Backend.QueryAsyncListAsync), true);

                    if (certResult.Code >= 0)
                    {
                        ObservableCollection<AppDomainCertificate> list = certResult.Data.Payload;

                        if (list.Any())
                        {
                            domain.Certificate = list.First();
                            domain.Certificate.OwnedBy = domain;
                        }
                    }
                }
            }

            return result;
        }
        async private void OnUpdateDomainButtonClickedAsync(object sender, EventArgs e)
        {
            IsServiceActive = true;

            try
            {
                if (AppViewModel.DomainViewModel.EditDomain.Certificate != null)
                {
                    await Process(AppViewModel.DomainViewModel.EditDomain.Certificate, true,
                                  AppViewModel.DomainViewModel.RemoveDomainCertificateAsync
                                  );
                }

                string type = Type.SelectedItem as string;

                if (type != "None")
                {
                    AppDomainCertificate cert = new AppDomainCertificate();
                    cert.OwnedBy          = AppViewModel.DomainViewModel.EditDomain;
                    cert.Tag              = AppViewModel.DomainViewModel.EditDomain.Tag;
                    cert.Type             = type.ToLower();
                    cert.PrivateKey       = PrivateKey.Text;
                    cert.CertificateChain = Chain.Text;

                    await Process(cert, true,
                                  AppViewModel.DomainViewModel.CreateDomainCertificateAsync
                                  );
                }
            }
            catch (Exception ex)
            {
                await ErrorHandler.ExceptionAsync(this, ex);
            }

            IsServiceActive = false;
        }