13.2.10. Miscellaneous Operations

Engineering Knowledge Manager

Administration Guide | Chapter 13: EKM Client API | 13.2. Using the Library in Client Applications |

13.2.9. Managing Users and Groups |  | 13.3. Submitting and Monitoring Jobs
Prev |  | Next

### 13.2.10. Miscellaneous Operations

The final operations provided by the library include retrieving the server’s date and time, clearing or restoring a user’s recycle bin, and executing a script on the server. For script execution, the script provided by the application is actually sent to the server and executed there. The examples below show these operations.

Java

      String script=
          "obj = ekm.getObjectByPath(\"/Data/Shared Data\")\n" +
          "print \"Found object: \" + str(obj)\n";
      dataManager.executeScript(script);
      System.out.println(">>>>> Current server date/time is " + adminManager.getServerTime();
      ModelObject group = adminManager.createGroup("ParentGroup");
      String id = group.getID();
      adminManager.deleteMember(group.getName());
      List<String> idsToRestore = new ArrayList<String>();
      idsToRestore.add(id);
      adminManager.restoreRecycleBin(idsToRestore);
      adminManager.deleteMember(group.getName());
      adminManager.clearRecycleBin();

Python (Jython)

      script = \
          "obj = ekm.getObjectByPath(\"/Data/Shared Data\")\n" + \
          "print \”Found object: \” + str(obj)\n" dataManager.executeScript(script)
      print ">>>>> Current server date/time is " + str(adminManager.getServerTime())
      group = adminManager.createGroup("ParentGroup")
      id = group.getID()
      adminManager.deleteMember(group.getName())
      ids = [id]
      adminManager.restoreRecycleBin(ids)
      adminManager.deleteMember(group.getName())
      adminManager.clearRecycleBin()

Python (IronPython)

      script = \
          "obj = ekm.getObjectByPath('/Data/Shared Data')\n" + \
          "print 'Found object: ' + str(obj)\n"
      dataManager.ExecuteScript(script)
      print str(adminManager.GetServerTime())
      group = adminManager.CreateGroup("ParentGroup")
      ids = List[str]()
      ids.Add(group.ArchiveId)
      adminManager.DeleteMember(group.Name)
      adminManager.RestoreRecycleBin(ids)
      adminManager.DeleteMember(group.Name)
      adminManager.ClearRecycleBin()

C#

      StringBuilder script = new StringBuilder("a = 1\n");
      script.Append("print 'a = ' + str(a)\n");
      script.Append("b = 2\n");
      script.Append("print 'b = ' + str(b)\n");
      script.Append("print 'a + b = ' + str(a + b)\n");
      dataManager.ExecuteScript(script.ToString());
      Console.WriteLine(am.GetServerTime());
      ModelObject parent = adminManager.CreateGroup("ParentGroup");
      string id = parent.ArchiveId;
      adminManager.DeleteMember(parent.Name);
      List<string> idsToRestore = new List<string>();
      idsToRestore.Add(id);
      adminManager.RestoreRecycleBin(idsToRestore);
      adminManager.DeleteMember(parent.Name);
      adminManager.ClearRecycleBin();

Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates.

Prev | Up / Contents | Next

Release 18.2 - © ANSYS, Inc. All rights reserved.