public void LoginUser() { CurrentUser = OltpProxy.CurrentUser; // Try to get the user's client list AsyncOperation(delegate() { using (OltpProxy proxy = new OltpProxy()) { _accountsTable = proxy.Service.Account_Get(); _userPermissions = proxy.Service.User_GetAllPermissions(); } }, delegate(Exception ex) { PageBase.MessageBoxError("Failed to load user settings.", ex); return(false); }, delegate() { // Hide all menu items/sections that have NO PERMISSIONS at all (account = null) _mainMenu.Visibility = Visibility.Visible; _mainMenu.UpdateLayout(); _mainMenu.ApplyPermissions(null); _header.Visibility = Visibility.Visible; _currentPageViewer.Content = CurrentPage = null; _pageTitle.Content = ""; _accountsSelector.ItemsSource = _accountsTable; string selectedAccountCookie = String.Format("{0}.SelectedAccount", OltpProxy.CurrentUser.ID); string selectedAccount = App.Cookies[selectedAccountCookie]; if (selectedAccount != null) { DataRow[] rs = _accountsTable.Select("ID = " + selectedAccount); if (rs.Length > 0) { _accountsSelector.SelectedIndex = _accountsTable.Rows.IndexOf(rs[0]); } } }); }
private DataRow[] Filter(Oltp.AccountDataTable accounts) { DataRow[] rows = _copyToAccounts.Select(String.Format("ID <> {0}", Window.CurrentAccount.ID)); return(rows); }
/// <summary> /// /// </summary> void MainWindow_Loaded(object sender, RoutedEventArgs e) { Version v = ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion : Assembly.GetExecutingAssembly().GetName().Version; //Version v = Assembly.GetExecutingAssembly().GetName().Version; _version.Content = "Version " + v.ToString(); // Settings we should get from the deployment URL int accountID; string menuItemPath; string sessionID; #if DEBUG accountID = 1240244; sessionID = "4F873C89AEE75E485893C7AE16E09020"; menuItemPath = "management/trackers"; #endif // Normal producion if (ApplicationDeployment.IsNetworkDeployed) { if (ApplicationDeployment.CurrentDeployment.ActivationUri.Query == null) { HidePageContents("This page must be accessed via the Edge.BI interface."); return; } NameValueCollection urlParams = HttpUtility.ParseQueryString(ApplicationDeployment.CurrentDeployment.ActivationUri.Query); // Invalid account string accountIDParam = urlParams["account"]; if (accountIDParam == null || !Int32.TryParse(accountIDParam, out accountID)) { HidePageContents("Invalid account specified. Please select another account."); return; } // Log in from session param sessionID = urlParams["session"]; if (String.IsNullOrEmpty(sessionID)) { HidePageContents("Invalid session specified. Try logging out and logging back in."); return; } menuItemPath = urlParams["path"]; if (String.IsNullOrEmpty(menuItemPath)) { HidePageContents("Invalid menu path specified. Please select an item from the menu."); return; } } else { #if !DEBUG { HidePageContents("This page must be accessed via the Edge.BI interface."); return; } #endif } ApiMenuItem menuItem = null; // Get user settings AsyncOperation(delegate() { OltpProxy.SessionStart(sessionID); using (OltpProxy proxy = new OltpProxy()) { _accountsTable = proxy.Service.Account_Get(); _userPermissions = proxy.Service.User_GetAllPermissions(); menuItem = proxy.Service.ApiMenuItem_GetByPath(menuItemPath); } }, delegate(Exception ex) { HidePageContents(null, ex); return(false); }, delegate() { CurrentUser = OltpProxy.CurrentUser; DataRow[] rs = _accountsTable.Select("ID = " + accountID.ToString()); if (rs.Length < 1) { HidePageContents("Specified account was not found. Please select another account."); return; } _currentAccount = (Oltp.AccountRow)rs[0]; LoadPage(menuItem); }); }