Ejemplo n.º 1
0
        async void  settings_Closed(object sender, object e)
        {
            bool bOK = false;

            await CheckSettingValues("DemoMode");
            await CheckSettingValues("RecordData");
           await CheckSettingValues("UnityURL");


            // Create a cancellation token from CancellationTokenSource
            cTokenSource = new CancellationTokenSource();
            var cToken = cTokenSource.Token;

            use = new UserObject();
            loginOpened = true;
            try
            {
                
                bOK = await use.Logon(cToken);
            }
            catch (OperationCanceledException)
            {
                return;
            }
            //we have a good user, update the tiles.
            if (bOK)
            {
                if (!Frame.Navigate(typeof(Hub)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            loginOpened = false;
        }
Ejemplo n.º 2
0
        //public IUserDataService _userDataService
        //{
        //    get
        //    {
        //        return Mvx.Resolve<IUserDataService>();
        //    }
        //}

        //public IUnityDataService _unityDataService
        //{
        //    get
        //    {
        //        return Mvx.Resolve<IUnityDataService>();
        //    }
        //}

        


        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        /// <remarks></remarks>
        /// <author>BD 20120801</author>
        /// <revisions></revisions>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {

            try
            {
            // create a new instance of the flyout
            settings = new SettingsFlyout();

            settings.Closed += settings_Closed;

            SettingsPane.GetForCurrentView().CommandsRequested += BlankPage_CommandsRequested;

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            Object oldURL = localSettings.Values["UnityURL"];

            if (oldURL != null)
            {
                OldURLSetting = oldURL.ToString();

            }

            Object demoMode = localSettings.Values["DemoMode"];

            if (demoMode != null)
            {
                OldDemoModeSetting = demoMode.ToString();
                objUnityData.DemoData = demoMode.ToString();

            }
            else
                demoMode = "N";

            Object RecordData = localSettings.Values["RecordData"];

            if (RecordData != null)
            {
                OldRecordDataSetting = RecordData.ToString();
                objUnityData.RecordData = RecordData.ToString();

            }
            else
                RecordData = "N";



            if (string.IsNullOrEmpty(objUnityData.UnityAppUser))
            {
                    loginOpened = true;

                    // Create a cancellation token from CancellationTokenSource
                    cTokenSource = new CancellationTokenSource();
                    var cToken = cTokenSource.Token;

                    use = new UserObject();

                    bool bOK = false;

                    try
                    {
                        bOK = await use.Logon(cToken);
                    }
                    catch (System.Threading.Tasks.TaskCanceledException )
                    {
                        return;
                        //TaskCanceledException thrown when user opens login screen, goes directly to settings. Need to suppress and log.
                    }


                    //we have a good user, update the tiles.
                    if (bOK)
                    {

                        string providerName = await use.GetUserDetails(objUnityData.UnityAppUser);

                        //Win8 session caching
                        StorageFolder temporaryFolder = ApplicationData.Current.TemporaryFolder;
                        StorageFile providerNameFile = await temporaryFolder.CreateFileAsync("ProviderName.txt", CreationCollisionOption.ReplaceExisting);
                        await FileIO.WriteTextAsync(providerNameFile, providerName);


                        var rootFrame = new Frame();
                        if (!Frame.Navigate(typeof(Hub)))
                        {
                            throw new Exception("Failed to create hub page");
                        }
                        
                        /*MVVM Framework Initialization*/
                        //Frame rootFrame = Window.Current.Content as Frame;
                        //if (rootFrame == null)
                        //    rootFrame = new Frame();
                        //var setup = new Setup(rootFrame);
                        //setup.Initialize();

                        //var start = Mvx.Resolve<IMvxAppStart>();
                        //start.Start();
                        
                    }

                    loginOpened = false;
                }
            }
            catch (Exception ex)
            {
                
                    ErrorHandler eh = new ErrorHandler(ex, "default.xaml on navigate event");
                    eh.ShowErrorDialog();
                
            }
        }