// FrontEnd Plus GUI for JAD // DeCompiled : InfoviewChangeSettings.class import com.crystaldecisions.sdk.exception.SDKException; import com.crystaldecisions.sdk.framework.*; import com.crystaldecisions.sdk.occa.infostore.IInfoObjects; import com.crystaldecisions.sdk.occa.infostore.IInfoStore; import com.crystaldecisions.sdk.plugin.desktop.user.IUser; import java.io.*; import java.util.Properties; public class InfoviewChangeSettings { private IEnterpriseSession session; private IInfoStore infostore; private IInfoStore userInfostore; private String username; private String password; private String CMS; private String CMSPort; private String szValue; private String szSearch; private String szUser2Change; static String m_propFile = "XIr2.properties"; private String m_userFile; public InfoviewChangeSettings() { session = null; userInfostore = null; username = ""; password = ""; CMS = ""; CMSPort = ""; szValue = "1"; szSearch = ""; szUser2Change = ""; m_userFile = ""; Properties properties = new Properties(); try { properties.load(new FileInputStream(m_propFile)); username = properties.getProperty("user"); password = properties.getProperty("password"); CMS = properties.getProperty("CMSName"); CMSPort = properties.getProperty("CMSPort"); szSearch = properties.getProperty("searchString") + "="; szValue = properties.getProperty("newValue"); m_userFile = properties.getProperty("usersList"); System.out.println("user = " + username); System.out.println("password = " + password); System.out.println("CMSName = " + CMS); System.out.println("CMSPort = " + CMSPort); } catch(FileNotFoundException ex) { System.out.println(ex.getMessage()); } catch(IOException ex) { System.out.println(ex.getMessage()); } catch(Exception out) { out.getMessage(); } if(session == null) try { session = CrystalEnterprise.getSessionMgr().logon(username, password, CMS + ":" + CMSPort, "secEnterprise"); System.out.println("sessione aperta: " + session.toString()); infostore = (IInfoStore)session.getService("", "InfoStore"); userInfostore = (IInfoStore)session.getService("", "InfoStore"); try { FileInputStream fstream = new FileInputStream(m_userFile); DataInputStream in; for(in = new DataInputStream(fstream); in.available() != 0;) { szUser2Change = in.readLine(); String szXIr2Query = "SELECT SI_DESCRIPTION FROM CI_SYSTEMOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.User' And SI_Name = '" + szUser2Change + "'"; IInfoObjects sourceUser = userInfostore.query(szXIr2Query); System.out.println("query eseguita con successo per " + szUser2Change); IUser sUser = (IUser)sourceUser.get(0); String sDescription = ""; try { sDescription = sUser.getDescription(); if(sDescription.equals("")) { sDescription = szSearch + szValue; } else { String sDescFields[] = sDescription.split(";"); int bGO = 1; int i = 0; int nTrovato = 0; while(bGO == 1) { if(sDescFields[i].startsWith(szSearch)) { bGO = 0; nTrovato = 1; } else { i++; } if(i == sDescFields.length) bGO = 0; } if(nTrovato == 0) sDescription = sDescription + ";" + szSearch + szValue; } try { sUser.setDescription(sDescription); infostore.commit(sourceUser); System.out.println("modificato utente " + szUser2Change); } catch(SDKException ex) { System.out.println(ex.getMessage()); System.out.println("modifica non effettuata per utente " + szUser2Change); } } catch(Exception ex) { System.out.println(ex.getMessage()); } } in.close(); } catch(Exception e) { System.err.println("File input error"); } } catch(SDKException ex) { System.out.println(ex.getMessage()); } } public static void main(String Args[]) { InfoviewChangeSettings ivcs = new InfoviewChangeSettings(); } }