public void InstallApplication(int workspaceArtifactId, FileInfo rapFilePath) { try { using (IRSAPIClient rsapiClient = GetRsapiClient()) { rsapiClient.APIOptions.WorkspaceID = workspaceArtifactId; List <int> appsToOverride = new List <int>(); const bool forceFlag = true; AppInstallRequest appInstallRequest = new AppInstallRequest(appsToOverride, forceFlag) { FullFilePath = rapFilePath.FullName }; appsToOverride.Add(1043043); //todo: testing try { rsapiClient.InstallApplication(rsapiClient.APIOptions, appInstallRequest); } catch (Exception ex) { throw new Exception($"{Constants.ErrorMessages.InstallApplicationError}. InstallApplication.", ex); } } } catch (Exception ex) { throw new Exception(Constants.ErrorMessages.InstallApplicationError, ex); } }
public static Int32 ImportApplication(IRSAPIClient client, Int32 workspaceId, bool forceFlag, string filePath, string applicationName, int appArtifactID = -1) { Console.WriteLine("Starting Import Application....."); int artifactID = 0; client.APIOptions.WorkspaceID = workspaceId; //set the target workspace of application to be imported. // Create an application install request. // This list contains the ArtifactID for each Relativity Application that you want to install. List <int> appsToOverride = new List <int>(); // Set the forceFlag to true. The forceFlag unlocks any applications in the workspace // that conflict with the application that you are loading. The applications must be unlocked // for the install operation to succeed. AppInstallRequest appInstallRequest = new AppInstallRequest(); appInstallRequest.FullFilePath = filePath; appInstallRequest.ForceFlag = forceFlag; appInstallRequest.AppsToOverride.Add(appArtifactID); try { ProcessOperationResult por = null; por = client.InstallApplication(client.APIOptions, appInstallRequest); if (por.Success) { while (client.GetProcessState(client.APIOptions, por.ProcessID).State == ProcessStateValue.Running) { Thread.Sleep(10); } client.GetProcessState(client.APIOptions, por.ProcessID); Console.WriteLine("Import Application Application complete....."); } } catch (Exception ex) { Console.WriteLine("Failed to import Application" + ex.Message); } Console.WriteLine("Querying for Application artifact id...."); kCura.Relativity.Client.DTOs.Query <kCura.Relativity.Client.DTOs.RelativityApplication> query = new kCura.Relativity.Client.DTOs.Query <kCura.Relativity.Client.DTOs.RelativityApplication>(); query.Fields.Add(new FieldValue(RelativityApplicationFieldNames.Name)); query.Condition = new kCura.Relativity.Client.TextCondition(RelativityApplicationFieldNames.Name, kCura.Relativity.Client.TextConditionEnum.EqualTo, applicationName); kCura.Relativity.Client.DTOs.QueryResultSet <kCura.Relativity.Client.DTOs.RelativityApplication> queryResultSet = client.Repositories.RelativityApplication.Query(query); if (queryResultSet != null) { artifactID = queryResultSet.Results.FirstOrDefault().Artifact.ArtifactID; Console.WriteLine("Application artifactid is " + artifactID); } Console.WriteLine("Exiting Import Application method....."); return(artifactID); }
/// <summary> /// Creates a testing workspace and installs the DynamicAPI application /// </summary> private void SetupWorkspaceAndRapFile() { using (IRSAPIClient rsapiClient = GetServiceFactory().CreateProxy <IRSAPIClient>()) { try { Console.WriteLine("Starting Import Application....."); rsapiClient.APIOptions.WorkspaceID = _dynamicApiWorkspaceId; AppInstallRequest appInstallRequest = new AppInstallRequest(); int appArtifactID = -1; appInstallRequest.FullFilePath = _dapiRapFullFilePath; appInstallRequest.ForceFlag = true; appInstallRequest.AppsToOverride.Add(appArtifactID); ProcessOperationResult por = rsapiClient.InstallApplication(rsapiClient.APIOptions, appInstallRequest); if (por.Success) { ProcessInformation state; do { Thread.Sleep(10); state = rsapiClient.GetProcessState(rsapiClient.APIOptions, por.ProcessID); } while (state.State == ProcessStateValue.Running); if (state.State == ProcessStateValue.CompletedWithError) { throw new Exception(state.Message ?? state.Status ?? "The install completed an unknown error"); } else if (state.State == ProcessStateValue.HandledException || state.State == ProcessStateValue.UnhandledException) { throw new Exception(state.Message ?? state.Status ?? "The install failed with a unknown error"); } } else { throw new Exception($"There was an error installing the application {por.Message}"); } } catch (Exception ex) { throw new Exception($"{nameof(SetupWorkspaceAndRapFile)} - Could not create or find Workspace and Application: {ex.Message}"); } } }
public static void ImportApplication(IRSAPIClient client, Int32 workspaceId, bool forceFlag, string filePath, int appArtifactID = -1) { Console.WriteLine("Starting Import Application....."); client.APIOptions.WorkspaceID = workspaceId; //set the target workspace of application to be imported. // Set the forceFlag to true. The forceFlag unlocks any applications in the workspace // that conflict with the application that you are loading. The applications must be unlocked // for the install operation to succeed. var appInstallRequest = new AppInstallRequest(); appInstallRequest.FullFilePath = filePath; appInstallRequest.ForceFlag = forceFlag; appInstallRequest.AppsToOverride.Add(appArtifactID); var por = client.InstallApplication(client.APIOptions, appInstallRequest); if (por.Success) { ProcessInformation state; do { Thread.Sleep(10); state = client.GetProcessState(client.APIOptions, por.ProcessID); } while (state.State == ProcessStateValue.Running); if (state.State == ProcessStateValue.CompletedWithError) { throw new ApplicationInstallException(state.Message ?? state.Status ?? "The install completed an unknown error"); } else if (state.State == ProcessStateValue.HandledException || state.State == ProcessStateValue.UnhandledException) { throw new ApplicationInstallException(state.Message ?? state.Status ?? "The install failed with a unknown error"); } } else { throw new ApplicationInstallException($"There was an error installing the application {por.Message}"); } }