/// <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(); // Log in from cookie int? userID = GetUserIDFromCookie(); bool logout = userID == null; if (userID != null) { try { OltpProxy.SessionStart(userID.Value); } catch { logout = true; } } if (logout) { LogoutUser(); } else { LoginUser(); } }
/// <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); }); }