示例#1
0
        public App()
        {
            InitializeComponent();
            attachments.CollectionChanged += Attachments_CollectionChanged;

            try
            {
                var eValue = DAUtil.GetAll <OfflineItem>("OfflineItem");
                if (eValue != null && eValue.Count > 0)
                {
                    App.offlineItems = new ObservableCollection <OfflineItem>(eValue);
                }

                MessagingCenter.Subscribe <object>(this, EVENT_LAUNCH_MAIN_PAGE, SetMainPageAsRootPage);
                MessagingCenter.Subscribe <object>(this, EVENT_LAUNCH_MULTIFACTOR_PAGE, SetMultiFactorAuthenticationPage);

                if (SPUtility.IsConnected())
                {
                    MainPage = new MultiFactorLogin();
                }
                else
                {
                    var graphResponse = App.DAUtil.GetMasterInfoByName(GRAPH_AUTH_RESULT_KEY);
                    var spResponse    = App.DAUtil.GetMasterInfoByName(SHAREPOINT_AUTH_RESULT_KEY);
                    if (graphResponse == null || spResponse == null)
                    {
                        MainPage = new MultiFactorLogin();
                    }
                    else
                    {
                        OAuthHelper.GetLoggedInToken();

                        var uInfo = App.DAUtil.GetMasterInfoByName(USER_INFO_KEY);
                        if (uInfo != null)
                        {
                            var obj = JsonConvert.DeserializeObject <UserInfo>(uInfo.content, new JsonSerializerSettings {
                                DateParseHandling = DateParseHandling.None
                            });
                            if (obj != null)
                            {
                                App.CurrentUser = new User
                                {
                                    Id    = obj.UniqueId,
                                    Name  = obj.GivenName + " " + obj.FamilyName,
                                    Email = obj.DisplayableId
                                };
                            }
                        }

                        MainPage = new StartPage();
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#2
0
 public void SetMultiFactorAuthenticationPage(object sender)
 {
     MainPage = new MultiFactorLogin();
 }