You are viewing limited content. For full access, please sign in.

Question

Question

Client Automation Search in Cloud

asked on May 18, 2021

I've hit a bit of a conundrum. Using a script with Client Automation, I'm experiencing this behavior:

 

1. If I specify an entry ID or list of entry IDs in a Cloud system, I can generate pages on them with CAT if I set the window to be hidden in LaunchOptions

2. If the window is not hidden and it's an on prem system, it logs in no problem

3. If the window is not hidden and it's a cloud system, it opens the Client, puts in the credentials, but gets stuck at the login screen

4. If I run a search with the window hidden, I get "The remote procedure call failed. (0x800706BE)"

5. If I run a search with the window not hidden, it works fine

 

In short:

With the window hidden, I can't run a search but can generate pages on Cloud

With the window not hidden, I can run a search but only on-prem, as Cloud won't log in

 

My goal is to log into Cloud, run a search, and generate pages on the results

 

For code, you can reference this previous thread I posted

https://answers.laserfiche.com/questions/143253/LaunchSearch-CAT-Method-Results-Empty#repliestomain

The only difference is I'm using Cloud credentials instead of on-prem and toggling HiddenWindow = true on my LaunchOptions

 

Is there something I'm missing?

0 0

Answer

SELECTED ANSWER
replied on May 19, 2021 Show version history

The 11 client adds new functionality to make this possible. You need to bypass the cloud login screen by signing in with the SDK before launching the desktop client:

using Laserfiche.ClientAutomation;
using Laserfiche.RepositoryAccess;
using System;
using System.Collections.Generic;
using System.Linq;

namespace CATCloudLogin
{
    class Program
    {
        static string cloudRepository = "r-01010101.laserfiche.com";
        static string cloudCustomer = "111222333";
        static string username = "myuser";
        static string password = "mypassword";

        static void Main(string[] args)
        {
            try
            {
                Launch();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }

        static void Launch()
        {
            // Sign in to LF Cloud using the SDK
            CloudTicket cloudTicket = CloudLogin();

            // Create a session to connect to our LF Cloud repository
            Session cloudSession = Session.Create(cloudRepository, cloudTicket);

            List<int> generatePageEntryIds;

            // Find the documents to generage pages on
            using (Search search = new Search(cloudSession, "({LF:Basic~=\"SAMPLE\", option=\"LTN\"})"))
            {
                search.Run();

                SearchListingSettings searchSettings = new SearchListingSettings();
                searchSettings.AddColumn(SystemColumn.Id);

                using (SearchResultListing results = search.GetResultListing(searchSettings))
                {
                    generatePageEntryIds = results.Select(row => (int)row[SystemColumn.Id]).ToList();
                }
            }

            // Launch the desktop client with our cloud connection
            LaunchOptions launchOptions = new LaunchOptions();
            launchOptions.ServerName = cloudRepository;
            launchOptions.RepositoryName = cloudRepository;
            launchOptions.CloudCustomerId = cloudCustomer;
            launchOptions.SAML = cloudTicket.GetSamlToken(); // This tells the client to use our existing cloud connection
            launchOptions.HiddenWindow = true;

            using (ClientManager clientMgr = new ClientManager())
            {
                MainWindow mainWindow = null;
                clientMgr.LogIn(launchOptions, out mainWindow);

                GeneratePagesOptions genPagesOpt = new GeneratePagesOptions();
                genPagesOpt.ShowUI = false;

                mainWindow.GeneratePages(generatePageEntryIds, genPagesOpt);
            }
        }

        static CloudTicket CloudLogin()
        {
            CloudTicketRequestSettings ctrSettings = new CloudTicketRequestSettings();
            ctrSettings.AccountId = cloudCustomer;
            ctrSettings.UserName = username;
            ctrSettings.Password = password;
            CloudTicket cloudTicket = CloudTicket.GetTicket(ctrSettings);

            return cloudTicket;
        }
    }
}

One caveat: this won't work through Workflow, because ClientAutomation needs to be run in an interactive session.

2 0
replied on June 25, 2021

Hi Robert,

 

Thank you for your response. Apologies for taking so long to test it out, as this project was put on hold until now. I was trying to test it, but the "LaunchOptions" class does not contain properties for "CloudCustomerId" or "SAML." Is there a version 11 of the SDK that you're using that isn't on the support site?

 

Thanks

0 0
replied on June 29, 2021

Hi Robert,

 

Just following up.

 

Thanks

0 0
replied on June 29, 2021

Hi Brian, sorry for the delay. I forgot that ClientAutomation 11 is not shipped with the client. I am not sure when the 11 SDK is scheduled to be released, but you can get the dll from the Laserfiche Connector 11 install. It is installed in C:\Program Files\Laserfiche\LFConnector.

1 0
replied on June 29, 2021

Thanks Robert!

0 0
replied on June 29, 2021

I've just completed my test successfully, though I had to use version 10.2 of RepositoryAccess instead of 10.4 due to the following error:

 

Could not load type 'System.Runtime.Remoting.Messaging.CallContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

 

Thanks for all your help.

0 0
replied on September 28, 2021

Hi Robert,

Do I need to call the Close() method on mainWindow after this code? I have two different versions of this script running on the same server 1 hour apart, and I noticed that one of them kept failing every day with "Timeout waiting for client startup" and the other had that error sometimes. When I looked in Task Manager, I noticed there were several (6 or more) instances of the desktop client present. I manually terminated all of them from Task Manager, and then the next day the first script failed with the same "Timeout waiting for client startup" error and the second script an hour later completed, with a new instance of the desktop client stuck in Task Manager.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.