0
using Citrix.Common.Sdk;
using Citrix.XenApp.Sdk;
using Citrix.XenApp.Commands;
using Citrix.Management.Automation;

我正在尝试将客户端地址放入数组中以添加到列表中。问题是当我测试它时,ClientAddress 不断返回 null。我可以在线看到用户,并且他们的客户端地址在 App Center 中可见。使用 ServerName 返回没有问题。有人知道为什么 ClientAddress 不起作用吗?

    private List<string[]> findUser(string strUser)
    {

        List<string[]> list = new List<string[]>();

        GetXASessionByFarm sessions = new GetXASessionByFarm(true);

        foreach (XASession session in CitrixRunspaceFactory.DefaultRunspace.ExecuteCommand(sessions))
        {
            if (session.AccountName == objWINS + "\\" + strUser)
            {
                string[] result = new string[3];
                result[0] = strUser;
                result[1] = session.ServerName; //This is working, it comes back with the server name.
                result[2] = session.ClientAddress; //This isn't working, it comes back blank.
                MessageBox.Show(result[2]);
                list.Add(result);
            }

        }
        return list;
    }
4

1 回答 1

1

这个问题的答案是在声明 GetXASessionByFarm 之后添加以下行:

sessions.Full = true;

例如:

private List<string[]> findUser(string strUser)
{

    List<string[]> list = new List<string[]>();

    GetXASessionByFarm sessions = new GetXASessionByFarm(true);

    sessions.Full = true;

    foreach (XASession session in CitrixRunspaceFactory.DefaultRunspace.ExecuteCommand(sessions))
    {
        if (session.AccountName == objWINS + "\\" + strUser)
        {
            string[] result = new string[3];
            result[0] = strUser;
            result[1] = session.ServerName; //This is working, it comes back with the server name.
            result[2] = session.ClientAddress; //This isn't working, it comes back blank.
            MessageBox.Show(result[2]);
            list.Add(result);
        }

    }
    return list;
}

这样做的原因是因为默认情况下该命令不会返回全部信息。我不得不翻译这个并根据 Get-XASessions powershell 命令做一些猜测。当我自己解决问题时,这种感觉总是很好。显然,我在这个软件开发领域处于狂野西部边境的边缘。没有人这样做。

于 2015-01-23T19:19:09.110 回答