Prune Explorer Folder callout method template
[IDOMethod] public int method_name( string userName, string originalExplorerXML, ref string prunedExplorerXML ) { int result = (int)StdMethodResult.Success; LoadExplorerResponseData expRespData = null; if ( string.IsNullOrEmpty( userName ) ) prunedExplorerXML = originalExplorerXML; else { expRespData = LoadExplorerResponseData.FromXml( originalExplorerXML ); // Begin user implementation // End user implementation prunedExplorerXML = expRespData.ToXml(); } return result; }
// Begin user implementation ListString executableForms = new ListString(); using ( AppDB db = IDORuntime.Context.CreateAppDB() ) { try { // Get list of form names (ObjectName1) and associated executable flag // for each using ( SqlCommand cmd = db.Connection.CreateCommand() ) { cmd.CommandType = CommandType.Text; cmd.CommandText = "select ObjectName1, " + "CASE WHEN SUM(ISNULL(aau.ExecutePrivilege, 0)) >= 1 THEN 1 ELSE 0 END " + "FROM AccountAuthorizations aau " + "INNER JOIN UserNames una ON una.Username = N'" + userName + "' " + "WHERE aau.ObjectType = 0 AND " + "aau.ObjectName2 = aau.ObjectName1 AND " + "aau.UserFlag = 0 AND aau.Id IN ( " + "SELECT ugm.GroupId " + "FROM UserGroupMap ugm " + "WHERE ugm.UserId = una.UserId ) " + "group by ObjectName1"; using ( IDataReader reader = db.ExecuteReader( cmd ) ) { while ( reader.Read() ) { if ( (int) reader.GetValue(1) == 1 ) { string formName = reader.GetString(0); if ( formName != string.Empty ) executableForms.Add( formName ); } } } } } catch { } } // Prune form names from node that aren't in list of executable forms var node = (FormServer.Protocol.ExplorerNodeDef) null; int idx = 0; while ( idx < expRespData.Nodes.Count ) { node = expRespData.Nodes[idx]; if ( node.ObjectType == WinStudio.Enums.ExplorerObjectType.NormalForm || node.ObjectType == WinStudio.Enums.ExplorerObjectType.QueryForm ) { if ( !executableForms.Contains( node.ObjectTextData ) ) expRespData.Nodes.RemoveAt( idx ); else idx++; } else idx++; } // End user implementation
The ido.method: AccountAuthorizations.PruneExplorerFolder is included in the core framework as a sample callout.
This method leverages the method template and sample implementation code included above. AccountAuthorizations.PruneExplorerFolder must not be used for an actual implementation as it is not designed for efficiency when running against a large repository of forms and does not include robust error handling. However, AccountAuthorizations.PruneExplorerFolder can be specified as the value for the process default as a sample test implementation.