Пример #1
0
        public App()
        {
            InitializeComponent();

            app = this;
            _AuthenticationService = DependencyService.Get <IAuthenticationService>();

            CloudService = new AzureCloudService();
            User         = DependencyService.Get <IDevice>().GetIdentifier();

            /* if we were targeting Windows Phone, we'd want to include the next line. */
            // if (Device.OS != TargetPlatform.WinPhone)
            TextResources.Culture = DependencyService.Get <ILocalize>().GetCurrentCultureInfo();


            // If the App.IsAuthenticated property is false, modally present the SplashPage.
            if (!_AuthenticationService.IsAuthenticated)
            {
                MainPage = new SplashPage();
            }
            else
            {
                GoToRoot();
            }
        }
Пример #2
0
        public void Test_GetSlotName_OutsideMainBranch()
        {
            const string logicalName = "something";
            const string systemName = "tsys";
            const string branch = "Release10";
            const string configuration = "TEST";

            var expected = string.Concat(systemName.ToLower().Take(DefaultNaming<AzureCloudService>.MaxSystemLength)) + "-" +
                           string.Concat(logicalName.ToLower().Take(DefaultNaming<AzureCloudService>.MaxComponentLength)) + "-" +
                           "r1" +
                           string.Concat(configuration.ToLower().Take(DefaultNaming<AzureCloudService>.MaxConfigurationLength));

            FlexDataConfiguration.RootBranch = "Main";

            var component =
                new AzureCloudService
                {
                    LogicalName = logicalName,
                    System = new DevOpsSystem { LogicalName = systemName }
                };

            var namer = new DefaultNaming<AzureCloudService>();

            var result = namer.GetSlotName(component, branch, configuration);

            Assert.AreEqual(expected, result);
        }
        public void Test_GetSlotName_TruncatesSystemName()
        {
            const string logicalName   = "something";
            const string branch        = "Main";
            const string configuration = "TEST";

            var systemName = Guid.NewGuid().ToString();

            var expected = string.Concat(systemName.ToLower().Take(DefaultNaming <AzureCloudService> .MaxSystemLength)) + "-" +
                           string.Concat(logicalName.ToLower().Take(DefaultNaming <AzureCloudService> .MaxComponentLength)) + "-" +
                           string.Concat(configuration.ToLower().Take(DefaultNaming <AzureCloudService> .MaxConfigurationLength));

            FlexDataConfiguration.RootBranch = branch;

            var component =
                new AzureCloudService
            {
                LogicalName = logicalName,
                System      = new DevOpsSystem {
                    LogicalName = systemName
                }
            };

            var namer = new DefaultNaming <AzureCloudService>();

            var result = namer.GetSlotName(component, branch, configuration);

            Assert.AreEqual(expected, result);
        }
Пример #4
0
        public static ICloudServiceProvider ConstructCloudProvider(CloudServiceProviders cloudProvider)
        {
            ICloudServiceProvider provider = null;

            switch (cloudProvider)
            {
            case CloudServiceProviders.IGS:
                provider = new IGSCloudService();
                break;

            case CloudServiceProviders.Azure:
                provider = new AzureCloudService();
                break;

            case CloudServiceProviders.AWS:
                provider = new AWSCloudService();
                break;

            case CloudServiceProviders.Google:
                provider = new GoogleCloudService();
                break;

            default:
                provider = new IGSCloudService();
                break;
            }
            return(provider);
        }
Пример #5
0
        async Task ExecuteLoginCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;

            try
            {
                var cloudService = new AzureCloudService();
                var user         = await cloudService.LoginAsync();

                if (user != null)
                {
                    Application.Current.MainPage = new NavigationPage(new Pages.MealList());
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"[Login] Error = {ex.Message}");
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async Task LoginAsync(MobileServiceClient client)
        {
            // Check if the token is available within the key store
            var accounts = AccountStore.FindAccountsForService("tasklist");

            if (accounts != null)
            {
                foreach (var acct in accounts)
                {
                    string token;

                    if (acct.Properties.TryGetValue("token", out token))
                    {
                        if (!AzureCloudService.IsTokenExpired(token))
                        {
                            client.CurrentUser = new MobileServiceUser(acct.Username);
                            client.CurrentUser.MobileServiceAuthenticationToken = token;
                            return;
                        }
                    }
                }
            }

            // Server Flow
            await client.LoginAsync(RootView, "facebook");

            // Store the new token within the store
            var account = new Account(client.CurrentUser.UserId);

            account.Properties.Add("token", client.CurrentUser.MobileServiceAuthenticationToken);
            AccountStore.Save(account, "tasklist");
        }
Пример #7
0
 public static AzureCloudService GetCloudService()
 {
     if (CloudService == null)
     {
         CloudService = new AzureCloudService();
     }
     return(CloudService);
 }
        public static async Task Login(this AzureCloudService service, Context ctx)
        {
            var cloudService = App.GetCloudService();
            var client       = new MobileServiceClient("http://fabrikafood.azurewebsites.net");
            var user         = await client.LoginAsync(ctx, MobileServiceAuthenticationProvider.Facebook);

            cloudService.CurrentUser = user;
        }
Пример #9
0
        /// <summary>
        /// Triggers the submission of the work items.
        /// </summary>
        //public async Task SubmitWorkItems() => await SmartConnectClient.Submit(
        //    _configurationService.GetString(Config.BranchId),
        //    _configurationService.GetString(Config.UserId)
        //);

        /// <summary>
        ///     Synchronize the local device cache with the remote Azure store. This method should be invoked
        ///     before the UI updates its view state.
        /// </summary>
        /// <returns></returns>
        public async Task SyncOfflineCacheAsync()
        {
            await AzureCloudService.SyncOfflineCacheAsync().ConfigureAwait(false);

            //await SmartConnectClient.SubmitSalesOrders(
            //  _configurationService.GetString(Config.BranchId),
            //  _configurationService.GetString(Config.UserId)
            //);
        }
Пример #10
0
        public App()
        {
            InitializeComponent();

            CloudService = new AzureCloudService();
            User         = DependencyService.Get <IDevice>().GetIdentifier();

            MainPage = new NavigationPage(new MainPage());
        }
Пример #11
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            CloudService = new AzureCloudService();

            return(true);
        }
        public static async Task Login(this AzureCloudService service, string authToken)
        {
            JObject tokenObject  = CreateTokenObject(authToken);
            var     cloudService = App.GetCloudService();
            var     client       = new MobileServiceClient("http://fabrikafood.azurewebsites.net");
            var     user         = await client.LoginAsync(MobileServiceAuthenticationProvider.Facebook, tokenObject);

            cloudService.CurrentUser = user;
        }
        public App()
        {
            InitializeComponent();

            LoadDeviceId();

            // Initialize the Cloud Service
            CloudService = new AzureCloudService();

            //MainPage = new FoodForThoughtPage();
            MainPage = new NavigationPage(new Pages.EntryPage());
        }
        /// <summary>
        /// Checks for the existence of a specific Azure Reserved IP, if it doesn't exist it will create it.
        /// </summary>
        /// <param name="client">The <see cref="NetworkManagementClient"/> that is performing the operation.</param>
        /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this cloud service spec.</param>
        /// <returns>The async <see cref="Task"/> wrapper.</returns>
        public static async Task ReserveIpIfNotReservedAsync(this NetworkManagementClient client, AzureCloudService model)
        {
            Contract.Requires(client != null);
            Contract.Requires(model != null);
            Contract.Requires(model.System != null);

            var ipName = FlexDataConfiguration.GetNaming<AzureCloudService>()
                                              .GetSlotName(
                                                  model,
                                                  FlexDataConfiguration.Branch,
                                                  FlexDataConfiguration.Configuration)
                         + "-rip";

            await client.ReserveIpIfNotReservedAsync(ipName, model.System.Location.GetEnumDescription());
        }
Пример #15
0
        //private async void LoadSomeData()
        //{
        //    if (!string.IsNullOrEmpty(Settings.AccessToken) && !string.IsNullOrEmpty(Settings.UserId))
        //    {
        //        var table = await CloudService.GetTableAsync<User>();
        //        User user = await table.ReadItemAsync(Settings.UserId);
        //        Settings.Username = user.Username;
        //    }

        //}

        private void SetMainPage()
        {
            if (!string.IsNullOrEmpty(Settings.AccessToken))
            {
                if (AzureCloudService.IsTokenExpired(Settings.AccessToken))
                {
                    var vm = new EntryPageViewModel();
                    vm.LoginCommand.Execute(null);
                }
                //NavPage = new NavigationPage(new MenuPage());
                //MainPage = NavPage;
                MainPage = new MenuPage();
            }

            //else if (!string.IsNullOrEmpty(Settings.Username) && !string.IsNullOrEmpty(Settings.Password))
            //    MainPage = new NavigationPage(new LoginPage());
            else
            {
                MainPage = new EntryPage();
            }
        }
        public async Task SetCurrentBranch(string branchId)
        {
            if (branchId.Equals(GetCurrentBranch()))
            {
                return;
            }

            try
            {
                await _syncService.PullRemoteEntitiesForBranchAsync(branchId);

                await AzureCloudService.PurgeOfflineCacheAsync();

                await AzureCloudService.SyncOfflineCacheAsync();

                _configurationService.SetString(Config.BranchId, branchId);
            }
            catch (Exception ex)
            {
                _logService.WriteErrorLogEntry($"Failed to pull set current branch ({branchId}): {ex}");
                ex.Report();
            }
        }
        /// <summary>
        /// Checks for the existence of a specific Cloud Service, if it doesn't exist it will create it.
        /// </summary>
        /// <param name="client">The <see cref="ComputeManagementClient"/> that is performing the operation.</param>
        /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this cloud service spec.</param>
        /// <returns>The async <see cref="Task"/> wrapper.</returns>
        public static async Task CreateServiceIfNotExistsAsync(this ComputeManagementClient client, AzureCloudService model)
        {
            Contract.Requires(client != null);
            Contract.Requires(model != null);

            await client.CreateServiceIfNotExistsAsync(model.AzureParameters);
        }
Пример #18
0
        /// <summary>
        /// Checks for the existence of a specific Azure Reserved IP, if it doesn't exist it will create it.
        /// </summary>
        /// <param name="client">The <see cref="NetworkManagementClient"/> that is performing the operation.</param>
        /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this cloud service spec.</param>
        /// <returns>The async <see cref="Task"/> wrapper.</returns>
        public static async Task ReserveIpIfNotReservedAsync(this NetworkManagementClient client, AzureCloudService model)
        {
            Contract.Requires(client != null);
            Contract.Requires(model != null);
            Contract.Requires(model.System != null);

            var ipName = FlexDataConfiguration.GetNaming <AzureCloudService>()
                         .GetSlotName(
                model,
                FlexDataConfiguration.Branch,
                FlexDataConfiguration.Configuration)
                         + "-rip";

            await client.ReserveIpIfNotReservedAsync(ipName, model.System.Location.GetEnumDescription());
        }
Пример #19
0
        /// <summary>
        /// Checks for the existence of a specific Cloud Service, if it doesn't exist it will create it.
        /// </summary>
        /// <param name="client">The <see cref="ComputeManagementClient"/> that is performing the operation.</param>
        /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this cloud service spec.</param>
        /// <returns>The async <see cref="Task"/> wrapper.</returns>
        public static async Task CreateServiceIfNotExistsAsync(this ComputeManagementClient client, AzureCloudService model)
        {
            Contract.Requires(client != null);
            Contract.Requires(model != null);

            await client.CreateServiceIfNotExistsAsync(model.AzureParameters);
        }
Пример #20
0
 public App()
 {
     InitializeComponent();
     CloudService = new AzureCloudService();
     MainPage     = new NavigationPage(new ContactsPage());
 }