static void Main(string[] args) { using (var client = new OltpLogicClient(null)) { // To be retrieved from iFrame URL parameter. // Validation is currently disabled in MorWebOTLP database //string sessionID = null; // Logging in is required otherwise all other service operations will fail (comment out these lines to see how) //Oltp.UserDataTable user = client.Service.User_LoginBySessionID(sessionID); Console.WriteLine("Logged in as {0}", client.CurrentUser.Name); // Get all campaigns for every account Oltp.AccountDataTable accounts = client.Service.Account_Get(); foreach (Oltp.AccountRow account in accounts.Rows) { Console.WriteLine(); Console.WriteLine("Campaigns for account {0} - {1}:", account.ID, account.Name); Console.WriteLine("--------------------------------------------"); Oltp.CampaignDataTable campaigns = client.Service.Campaign_Get(account.ID, null, null, null, false); foreach (Oltp.CampaignRow campaign in campaigns.Rows) { Console.WriteLine("{0} - {1}", campaign.GK, campaign.Name); } } Console.ReadLine(); } }
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]); } } }); }
/// <summary> /// /// </summary> /// <param name="filter"></param> /// <param name="include"></param> private void GetPermissionTargets(Oltp.AccountRow account) { Oltp.AccountRow currentAccount = account == null ? this.Window.CurrentAccount : account; if (currentAccount == null) { return; } Oltp.UserGroupDataTable groupsWith = null; Oltp.UserDataTable usersWith = null; Oltp.UserGroupDataTable groupsWithout = null; Oltp.UserDataTable usersWithout = null; // Set to null if we need to retrieve it from db _copyToAccounts = Window.CurrentUser.AccountAdmin ? Window.AvailableAccounts : null; Window.AsyncOperation(delegate() { using (OltpProxy proxy = new OltpProxy()) { groupsWith = proxy.Service.UserGroup_GetGroupsWithPermissions(currentAccount.ID); usersWith = proxy.Service.User_GetUsersWithPermissions(currentAccount.ID); groupsWithout = proxy.Service.UserGroup_GetGroupsWithoutPermissions(currentAccount.ID); usersWithout = proxy.Service.User_GetUsersWithoutPermissions(currentAccount.ID); _copyToAccounts = // If not null _copyToAccounts ?? // else proxy.Service.Account_GetByPermission(this.PageData.Path); } }, delegate() { // Get an empty new list if (_items == null) { _items = new ObservableCollection <DataRow>(); } else { _items.Clear(); } // Add all items foreach (DataRow r in groupsWith.Rows) { _items.Add(r); } foreach (DataRow r in usersWith.Rows) { _items.Add(r); } _listTable.ListView.ItemsSource = _items; //-------------------------------// // Populate 'add' combo boxes if (_groupsToAdd == null) { _groupsToAdd = new ObservableCollection <object>(); } else { _groupsToAdd.Clear(); } if (_usersToAdd == null) { _usersToAdd = new ObservableCollection <object>(); } else { _usersToAdd.Clear(); } _groupsToAdd.Add("Add group"); _usersToAdd.Add("Add user"); foreach (DataRow r in groupsWithout.Rows) { _groupsToAdd.Add(r); } foreach (DataRow r in usersWithout.Rows) { _usersToAdd.Add(r); } _comboAddGroup.ItemsSource = _groupsToAdd; _comboAddUser.ItemsSource = _usersToAdd; _comboAddGroup.SelectedIndex = 0; _comboAddUser.SelectedIndex = 0; if (_copyToAccountsListBox != null) { _copyToAccountsListBox.DataContext = Filter(_copyToAccounts); } }); }
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); }); }