SDL GroupShare 2015 seemingly not working when used from command line application

When calling the following to authenticate against a GroupShare 2015 server all is fine as long as I use it from a Windows Forms app. But it fails when used as a command-line app. It just never reaches the MessageBox line. Is there a restriction when using this from a command-line app?

 

GroupShareClient groupShareClient;

groupShareClient = await GroupShareClient.AuthenticateClient("sa", "sa", new Uri("http://server2012"), GroupShareClient.AllScopes);

MessageBox.Show("connected");

Parents Reply Children
  • Hi Ziad

    Ah, sorry I didn't notice the declaration.
    Yes, you need to declare it as a task:
    Task<GroupShareClient>

    or probably just var will work:

    var groupShareClient

    However, I'm not sure even how your code works now as AuthenticateClient returns a Task:
    github.com/.../GroupShareClient.cs

    Are you using different code?
  • Hello Jesse

    I had tried that already, i.e. the Task<GroupShareClient> and var. The declaration is then fine, but it would then fail from the line

    var actualProject = await groupShareClient.Project.Get(id);
    DateTime completedDate = Convert.ToDateTime(actualProject.CompletedAt);

    Here, I am trying to get the CompletedDate of a particular project, which cannot be done with the Studio Project API, therefore I need to use one call from the GroupShare API.

    private async Task<bool> ProjectExpired(ServerProjectInfo project)
    {
    GroupShareClient groupShareClient = await GroupShareClient.AuthenticateClient("sa", "sa",
    new Uri("http://server2012"), GroupShareClient.AllScopes);

    string id = project.ProjectId.ToString();
    var actualProject = await groupShareClient.Project.Get(id);
    DateTime completedDate = Convert.ToDateTime(actualProject.CompletedAt);

    if (completedDate.AddDays(Convert.ToInt32(settings.settingArchiveDuration)) < DateTime.Now)
    return true;
    else
    return false;
    }
  • Actually, I made some progress by changing the code:

    Task <GroupShareClient> groupShareClient = GroupShareClient.AuthenticateClient("sa", "sa",
    new Uri("http://server2012"), GroupShareClient.AllScopes);
    var actualProject = await groupShareClient.Result.Project.Get(id);
    groupShareClient.Wait();

    Now I can use the Wait method, but it did not resolve the original problem. Even the UI version is not working any longer with the above changes :-(
  • Hi Ziad

    When you call  groupShareClient.Result, that is the equivalent of calling the Wait() method so you do not need Wait.

    Also, you should not be using the "await" keyword!

    Please try it like the following (remove the last line that calls Wait):

    Task <GroupShareClient> groupShareClient = GroupShareClient.AuthenticateClient("sa", "sa",
    new Uri("http://server2012"), GroupShareClient.AllScopes);

    string id = project.ProjectId.ToString();

    var actualProject = groupShareClient.Result.Project.Get(id);

    DateTime completedDate = Convert.ToDateTime(actualProject.CompletedAt);

    emoji