c# open file dialog

Hi,

 

I am trying to open the FileOpenDlg using the following code and failing:

 

IManDMS mainDMS = new ManDMS();
IManSession sess = mainDMS.Sessions.Add("FILESITE_SERVER");
sess.Login("username", "password");
IManDatabase currentDatabase = sess.Databases.ItemByName("dbname");
int something = this.Handle.ToInt32();
IMANEXT2Lib.IManFileOpenDlg c = new IMANEXT2Lib.IManFileOpenDlg();
c.Sessions = sess;
c.Show(something);

 

This is causing the following image to be displayed (attached) with the message: 

 

"An unexpected WorkSite error occurred".

 

As I am not sure the above code is correct, would anyone care to guide me on this?

 

Many thanks.

Comments

  • Actually go this working now.

     

    The line:

     

    c.Sessions = sess;

     

    should be

     

    c.Sessions = new[] { sess };

     

    Hope this helps anyone out there.

  • I uually use LogonEx, that way you can used the cached logon details:

    public bool LoginEx()
    {
    var isOk = false;
    var iDms = new ManDMS();
    ContextItems context = new ContextItemsClass();
    LoginCmd oCmd = new LoginCmdClass();
    var servers = GetServers();
    foreach (var server in servers)
    {
    var arrServer = new string[1];
    arrServer[0] = server;
    context.Add("NRTSessions", iDms.Sessions);
    context.Add("SelectedNRTSessionNames", arrServer);
    context.Add("iManExt.SilentLogin", true);
    oCmd.Initialize(context);
    oCmd.Update();
    try
    {
    if (oCmd.Status == (int)CommandStatus.nrActiveCommand)
    oCmd.Execute();
    var bRefresh = false;
    bRefresh = (bool)context.Item("iManExt.Refresh");

    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }

    foreach (IManSession iSession in iDms.Sessions)
    {
    isOk = iSession.Connected;
    }
    }

    return isOk;
    }

    }

    public string[] GetServers()
    {

    var ret = new string[0];
    var servers = Registry.CurrentUser.OpenSubKey(
    @Software\Interwoven\WorkSite\8.0\Common\Login\RegisteredServers);
    if (servers != null)
    {
    ret = servers.GetSubKeyNames();

    }

    return ret;
    }

TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs