コード例 #1
0
        public async Task <ResultSingle <Deployment> > CreateDeployment(Deployment deployment = null,
                                                                        bool doCache          = true, bool throwIfError = true)
        {
            Deployment theDeployment = deployment == null ? _editApp.Deployment : deployment;

            Dictionary <string, object> data = new Dictionary <string, object>();

            if (ApplyCredit != null)
            {
                data.Add("credit_id", ApplyCredit.Id.ToString());
            }

            ResultSingle <Deployment> result = await ResultSingleUI <Deployment> .WaitForObjectAsync(
                throwIfError, theDeployment, new CachedHttpRequest <Deployment, ResultSingle <Deployment> >(
                    Backend.CreateAsync), doCache, data);

            if (result.Code >= 0)
            {
                _editDeployment     = result.Data.Payload;
                _editApp.Deployment = _editDeployment;

                if (deployment != null)
                {
                    _editDeployment.CopyTo(deployment);
                    _deployments.Add(deployment);
                    OnPropertyChanged("Deployments");
                }
            }

            return(result);
        }
コード例 #2
0
 public async Task <ResultSingle <AppServiceSubscription> > RemoveSubscriptionAsync(AppServiceSubscription subscription,
                                                                                    bool doCache = false, bool throwIfError = true)
 {
     return(await ResultSingleUI <AppServiceSubscription> .WaitForObjectAsync(
                throwIfError, subscription, new CachedHttpRequest <AppServiceSubscription, ResultSingle <AppServiceSubscription> >(
                    Backend.RemoveAsync), doCache));
 }
コード例 #3
0
        public async Task <ResultSingle <AppBackup> > BackupAppAsync(AppBackup appBackup = null,
                                                                     bool doCache        = false, bool throwIfError = true)
        {
            AppBackup theBackup = appBackup == null ? _editBackup : appBackup;

            theBackup.OwnedBy = _editApp.Deployment;

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

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

                if (appBackup != null)
                {
                    _editBackup.CopyTo(appBackup);
                }

                foreach (AppBackup backup in _backups)
                {
                    if (backup.Id == _editBackup.Id)
                    {
                        _editBackup.CopyTo(backup);
                        break;
                    }
                }
            }

            return(result);
        }
コード例 #4
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;
        }
コード例 #5
0
ファイル: AppViewModel.cs プロジェクト: inkton/nester.library
        public async Task <ResultSingle <App> > QueryAppAsync(App app      = null,
                                                              bool doCache = false, bool throwIfError = true)
        {
            App theApp = app == null ? _editApp : app;

            ResultSingle <App> result = await ResultSingleUI <App> .WaitForObjectAsync(
                throwIfError, theApp, new CachedHttpRequest <App, ResultSingle <App> >(
                    Backend.QueryAsync), doCache);

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

                if (_editApp.UserId == Backend.Permit.User.Id)
                {
                    _editApp.OwnedBy = Backend.Permit.User;
                }

                if (app != null)
                {
                    _editApp.CopyTo(app);
                }
            }

            return(result);
        }
コード例 #6
0
ファイル: AppViewModel.cs プロジェクト: inkton/nester.library
        public async Task <ResultSingle <App> > CreateAppAsync(AppServiceTier tier,
                                                               App app = null, bool doCache = false, bool throwIfError = true)
        {
            App theApp = app == null ? _editApp : app;

            theApp.ServiceTierId = tier.Id;

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

            if (result.Code == 0)
            {
                EditApp          = result.Data.Payload;
                _editApp.OwnedBy = Backend.Permit.User;

                if (throwIfError && _editApp.Status != "assigned")
                {
                    string message = "Failed to initialize the app. Please contact support.";
                    //Helpers.ErrorHandler.Exception(message, string.Empty);
                    throw new Exception(message);
                }

                if (app != null)
                {
                    _editApp.CopyTo(app);
                }
            }
            return(result);
        }
コード例 #7
0
        public async Task <ResultSingle <Permission> > UpdatePermissionAsync(Contact contact = null,
                                                                             bool doCache    = false, bool throwIfError = true)
        {
            Contact    theContact     = contact == null ? _editContact : contact;
            Permission seedPermission = new Permission();

            seedPermission.OwnedBy = theContact;

            PermissionSwitch[] switches =
            {
                new PermissionSwitch(caps => caps.CanViewApp,    "view-app"),
                new PermissionSwitch(caps => caps.CanUpdateApp,  "update-app"),
                new PermissionSwitch(caps => caps.CanDeleteApp,  "delete-app"),
                new PermissionSwitch(caps => caps.CanCreateNest, "create-nest"),
                new PermissionSwitch(caps => caps.CanUpdateNest, "update-nest"),
                new PermissionSwitch(caps => caps.CanDeleteNest, "delete-nest"),
                new PermissionSwitch(caps => caps.CanViewNest,   "view-nest")
            };

            ResultSingle <Permission>   result     = new ResultSingle <Permission>(0);
            Dictionary <string, object> permission = new Dictionary <string, object>();

            foreach (PermissionSwitch permSwitch in switches)
            {
                var capable = permSwitch.Getter(theContact.OwnerCapabilities);
                seedPermission.AppPermissionTag = permSwitch.PermissionTag;

                if (capable)
                {
                    permission["app_permission_tag"] = seedPermission.AppPermissionTag;

                    result = await ResultSingleUI <Permission> .WaitForObjectAsync(
                        false, seedPermission, new CachedHttpRequest <Permission, ResultSingle <Permission> >(
                            Backend.CreateAsync), doCache, permission);

                    if (result.Code != ServerStatus.NEST_RESULT_SUCCESS &&
                        result.Code != ServerStatus.NEST_RESULT_ERROR_PERM_FOUND)
                    {
                        break;
                    }

                    permission.Remove("app_permission_tag");
                }
                else
                {
                    result = await ResultSingleUI <Permission> .WaitForObjectAsync(
                        false, seedPermission, new CachedHttpRequest <Permission, ResultSingle <Permission> >(
                            Backend.RemoveAsync), doCache);

                    if (result.Code != ServerStatus.NEST_RESULT_SUCCESS &&
                        result.Code != ServerStatus.NEST_RESULT_ERROR_PERM_NFOUND)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
コード例 #8
0
        public async Task <ResultSingle <Contact> > ReinviteContactAsync(Contact contact = null,
                                                                         bool doCache    = false, bool throwIfError = true)
        {
            Contact theContact = contact == null ? _editContact : contact;

            return(await ResultSingleUI <Contact> .WaitForObjectAsync(
                       throwIfError, theContact, new CachedHttpRequest <Contact, ResultSingle <Contact> >(
                           Backend.UpdateAsync), doCache));
        }
コード例 #9
0
        public async Task <ResultSingle <Share> > DeleteShareAsync(
            bool doCache = true, bool throwIfError = true)
        {
            ResultSingle <Share> result = await ResultSingleUI <Share> .WaitForObjectAsync(
                throwIfError, _selectedShare, new CachedHttpRequest <Share, ResultSingle <Share> >(
                    Backend.RemoveAsync), doCache);

            return(result);
        }
コード例 #10
0
        public async Task <ResultSingle <AppBackup> > RestoreAppAsync(AppBackup appBackup,
                                                                      bool doCache = false, bool throwIfError = true)
        {
            AppBackup theBackup = appBackup == null ? _editBackup : appBackup;

            theBackup.OwnedBy = _editApp.Deployment;

            return(await ResultSingleUI <AppBackup> .WaitForObjectAsync(
                       throwIfError, appBackup, new CachedHttpRequest <AppBackup, ResultSingle <AppBackup> >(
                           Backend.UpdateAsync), doCache));
        }
コード例 #11
0
        public async Task <ResultSingle <UserT> > DeleteUserAsync(UserT user   = null,
                                                                  bool doCache = false, bool throwIfError = true, Dictionary <string, object> data = null)
        {
            UserT theUser = user == null ? Backend.Permit.User : user;

            ResultSingle <UserT> result = await ResultSingleUI <UserT> .WaitForObjectAsync(
                throwIfError, theUser, new CachedHttpRequest <UserT, ResultSingle <UserT> >(
                    Backend.RemoveAsync), doCache);

            return(result);
        }
コード例 #12
0
        public async Task <ResultSingle <Trader> > QueryUserAsync(string email, bool throwIfError = true)
        {
            Trader seed = new Trader();

            seed.Email = email;

            ResultSingle <Trader> result = await ResultSingleUI <Trader> .WaitForObjectAsync(
                throwIfError, seed, new CachedHttpRequest <Trader, ResultSingle <Trader> >(
                    Backend.QueryAsync), false);

            return(result);
        }
コード例 #13
0
        public async Task <ResultSingle <AppServiceSubscription> > CreateSubscription(AppServiceTier tier,
                                                                                      bool doCache = true, bool throwIfError = true)
        {
            AppServiceSubscription subscription = new AppServiceSubscription();

            subscription.OwnedBy          = _editApp;
            subscription.ServiceTier      = tier;
            subscription.AppServiceTierId = tier.Id;

            return(await ResultSingleUI <AppServiceSubscription> .WaitForObjectAsync(
                       throwIfError, subscription, new CachedHttpRequest <AppServiceSubscription, ResultSingle <AppServiceSubscription> >(
                           Backend.CreateAsync), doCache));
        }
コード例 #14
0
        public async Task <ResultSingle <Devkit> > QueryDevkitAsync(Devkit devkit,
                                                                    bool doCache = false, bool throwIfError = true)
        {
            ResultSingle <Devkit> result = await ResultSingleUI <Devkit> .WaitForObjectAsync(
                throwIfError, devkit, new CachedHttpRequest <Devkit, ResultSingle <Devkit> >(
                    Backend.QueryAsync), doCache);

            if (result.Code >= 0)
            {
                result.Data.Payload.CopyTo(devkit);
            }

            return(result);
        }
コード例 #15
0
        public async Task <ResultSingle <Share> > UpdateShareAsync(
            bool doCache = true, bool throwIfError = true)
        {
            ResultSingle <Share> result = await ResultSingleUI <Share> .WaitForObjectAsync(
                throwIfError, _selectedShare, new CachedHttpRequest <Share, ResultSingle <Share> >(
                    Backend.UpdateAsync), doCache);

            if (result.Code >= 0)
            {
                result.Data.Payload.CopyTo(SelectedShare);
            }

            return(result);
        }
コード例 #16
0
        public async Task <ResultSingle <Share> > QueryShareAsync(
            bool doCache = true, bool throwIfError = true)
        {
            SelectedShare.OwnedBy = _selectedIndustry;

            ResultSingle <Share> result = await ResultSingleUI <Share> .WaitForObjectAsync(
                throwIfError, SelectedShare, new CachedHttpRequest <Share, ResultSingle <Share> >(
                    Backend.QueryAsync), doCache);

            if (result.Code >= 0)
            {
                result.Data.Payload.CopyTo(SelectedShare);
            }

            return(result);
        }
コード例 #17
0
        public async Task <ResultSingle <AppServiceTier> > UpdateAppUpgradeServiceTierAsync(
            AppService service = null, AppServiceTier teir = null, Deployment deployment = null,
            bool doCache       = true, bool throwIfError   = true)
        {
            AppService     theService    = service == null ? AppService : service;
            Deployment     theDeployment = deployment == null ? _editApp.Deployment : deployment;
            AppServiceTier theTier       = teir == null ? _upgradeAppServiceTier : teir;

            theService.OwnedBy = theDeployment;

            _upgradeAppServiceTier.OwnedBy = theService;

            return(await ResultSingleUI <AppServiceTier> .WaitForObjectAsync(
                       throwIfError, theTier, new CachedHttpRequest <AppServiceTier, ResultSingle <AppServiceTier> >(
                           Backend.UpdateAsync), doCache));
        }
コード例 #18
0
        public async Task <ResultSingle <Credit> > QueryCreditAsync(Credit credit = null,
                                                                    bool dCache   = false, bool throwIfError = true)
        {
            Credit theCredit = credit == null ? EditCredit : credit;

            ResultSingle <Credit> result = await ResultSingleUI <Credit> .WaitForObjectAsync(
                throwIfError, theCredit, new CachedHttpRequest <Credit, ResultSingle <Credit> >(
                    Backend.QueryAsync), dCache, null, null);

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

            return(result);
        }
コード例 #19
0
        public async Task <ResultSingle <PaymentMethod> > CreatePaymentMethodAsync(
            bool doCache = false, bool throwIfError = true)
        {
            EditPaymentMethod.OwnedBy = Backend.Permit.User;

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

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

            return(result);
        }
コード例 #20
0
ファイル: AppViewModel.cs プロジェクト: inkton/nester.library
        public async Task <ResultSingle <App> > UpdateAppAsync(App app      = null,
                                                               bool doCache = false, bool throwIfError = true)
        {
            App theApp = app == null ? _editApp : app;

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

            if (result.Code == 0)
            {
                EditApp = result.Data.Payload;
            }

            return(result);
        }
コード例 #21
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;
        }
コード例 #22
0
        public async Task <ResultSingle <Inkton.Nest.Model.Nest> > UpdateNestAsync(Inkton.Nest.Model.Nest nest = null,
                                                                                   bool doCache = false, bool throwIfError = true)
        {
            Inkton.Nest.Model.Nest theNest = nest == null ? _editNest : nest;

            ResultSingle <Inkton.Nest.Model.Nest> result = await ResultSingleUI <Inkton.Nest.Model.Nest> .WaitForObjectAsync(
                throwIfError, theNest, new CachedHttpRequest <Inkton.Nest.Model.Nest, ResultSingle <Inkton.Nest.Model.Nest> >(
                    Backend.UpdateAsync), doCache);

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

            return(result);
        }
コード例 #23
0
        public async Task <ResultSingle <Collaboration> > QueryContactCollaborateAccountAsync(Collaboration collaboration = null,
                                                                                              bool doCache = false, bool throwIfError = true)
        {
            Collaboration theCollaboration = collaboration == null ? _collaboration : collaboration;

            theCollaboration.AccountId = "0";

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

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

            return(result);
        }
コード例 #24
0
        public async Task <ResultSingle <Contact> > RemoveContactAsync(Contact contact = null,
                                                                       bool doCache    = false, bool throwIfError = true)
        {
            Contact theContact = contact == null ? _editContact : contact;

            ResultSingle <Contact> result = await ResultSingleUI <Contact> .WaitForObjectAsync(
                throwIfError, theContact, new CachedHttpRequest <Contact, ResultSingle <Contact> >(
                    Backend.RemoveAsync), doCache);

            if (result.Code >= 0)
            {
                if (contact != null)
                {
                    _contacts.Remove(contact);
                    OnPropertyChanged("Contacts");
                }
            }

            return(result);
        }
コード例 #25
0
        public async Task <ResultSingle <Deployment> > RemoveDeploymentAsync(Deployment deployment = null,
                                                                             bool doCache          = false, bool throwIfError = true)
        {
            Deployment theDeployment = deployment == null ? _editApp.Deployment : deployment;

            ResultSingle <Deployment> result = await ResultSingleUI <Deployment> .WaitForObjectAsync(
                throwIfError, theDeployment, new CachedHttpRequest <Deployment, ResultSingle <Deployment> >(
                    Backend.RemoveAsync), doCache);

            if (result.Code == 0)
            {
                if (deployment == null)
                {
                    _deployments.Remove(deployment);
                    OnPropertyChanged("Deployments");
                }
            }

            return(result);
        }
コード例 #26
0
        public async Task <ResultSingle <Inkton.Nest.Model.Nest> > RemoveNestAsync(Inkton.Nest.Model.Nest nest = null,
                                                                                   bool doCache = false, bool throwIfError = true)
        {
            Inkton.Nest.Model.Nest theNest = nest == null ? _editNest : nest;

            ResultSingle <Inkton.Nest.Model.Nest> result = await ResultSingleUI <Inkton.Nest.Model.Nest> .WaitForObjectAsync(
                throwIfError, theNest, new CachedHttpRequest <Inkton.Nest.Model.Nest, ResultSingle <Inkton.Nest.Model.Nest> >(
                    Backend.RemoveAsync), doCache);

            if (result.Code >= 0)
            {
                if (nest != null)
                {
                    _nests.Remove(nest);
                    OnPropertyChanged("Nests");
                }
            }

            return(result);
        }
コード例 #27
0
        public async Task <ResultSingle <Deployment> > UpdateDeploymentAsync(string activity,
                                                                             Deployment deployment = null, bool doCache = true, bool throwIfError = true)
        {
            Deployment theDeployment = deployment == null ? _editApp.Deployment : deployment;

            Dictionary <string, object> data = new Dictionary <string, object>();

            data.Add("activity", activity);

            ResultSingle <Deployment> result = await ResultSingleUI <Deployment> .WaitForObjectAsync(
                throwIfError, theDeployment, new CachedHttpRequest <Deployment, ResultSingle <Deployment> >(
                    Backend.UpdateAsync), doCache, data);

            if (result.Code >= 0)
            {
                _editDeployment     = result.Data.Payload;
                _editApp.Deployment = _editDeployment;
            }

            return(result);
        }
コード例 #28
0
        public async Task<ResultSingle<AppDomain>> UpdateDomainAsync(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.UpdateAsync), doCache);

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

                /* updates to the domain invalidates attached
                 * certificates.
                */
                _editDomain.Certificate = null;
            }

            return result;
        }
コード例 #29
0
        public async Task<ResultSingle<AppDomain>> RemoveDomainAsync(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.RemoveAsync), doCache);

            if (result.Code >= 0)
            {
                if (domain != null)
                {
                    // any cert that belong to the domain
                    // are automatically removed in the server
                    _domains.Remove(domain);
                    OnPropertyChanged("Domains");
                }
            }

            return result;
        }
コード例 #30
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;
        }