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 void TestReadFromIInputStream() { var command = new AppInstallRequest(new AppInstallInfo() { AppxPath = "abc", PackageFamilyName = "def", Dependencies = new List <String>() { "ghi", "jkl" } }); var dataArray = command.Serialize().GetByteArrayForSerialization(); var dataSizeArray = BitConverter.GetBytes((UInt32)dataArray.Length); var stream = new InMemoryRandomAccessStream(); stream.WriteAsync(dataSizeArray.AsBuffer()).AsTask().Wait(); stream.WriteAsync(dataArray.AsBuffer()).AsTask().Wait(); var result = Blob.ReadFromIInputStreamAsync(stream.GetInputStreamAt(0)).AsTask().Result; Assert.AreEqual(result.Tag, DMMessageKind.InstallApp); var request = result.MakeIRequest() as AppInstallRequest; Assert.AreEqual(request.Tag, DMMessageKind.InstallApp); Assert.AreEqual(request.AppInstallInfo.AppxPath, "abc"); Assert.AreEqual(request.AppInstallInfo.PackageFamilyName, "def"); Assert.AreEqual(request.AppInstallInfo.Dependencies[0], "ghi"); Assert.AreEqual(request.AppInstallInfo.Dependencies[1], "jkl"); }
public Int32 Import(Int32 workspaceId, bool forceFlag, string filePath, string appName, int appArtifactID = -1) { // 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); ProcessOperationResult por; using (var client = _helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System)) { client.APIOptions.WorkspaceID = workspaceId; Console.WriteLine("Starting Import Application....."); por = client.InstallApplication(client.APIOptions, appInstallRequest); } if (por.Success) { PollForInstallSuccess(por.ProcessID); } else { throw new ApplicationInstallException($"There was an error installing the application {por.Message}"); } return(RetrieveAppID(workspaceId, appName)); }
public void TestSerializationRoundtripThroughStream() { var command = new AppInstallRequest(new AppInstallInfo() { AppxPath = "abc", PackageFamilyName = "def", Dependencies = new List <String>() { "ghi", "jkl" } }); var blob = command.Serialize(); var stream = new InMemoryRandomAccessStream(); blob.WriteToIOutputStreamAsync(stream.GetOutputStreamAt(0)).AsTask().Wait(); var blob2 = Blob.ReadFromIInputStreamAsync(stream.GetInputStreamAt(0)).AsTask().Result; Assert.AreEqual(blob2.Tag, blob.Tag); var command2 = blob2.MakeIRequest() as AppInstallRequest; Assert.IsNotNull(command2); Assert.AreEqual(command2.Tag, DMMessageKind.InstallApp); Assert.AreEqual(command2.AppInstallInfo.AppxPath, "abc"); Assert.AreEqual(command2.AppInstallInfo.PackageFamilyName, "def"); Assert.AreEqual(command2.AppInstallInfo.Dependencies[0], "ghi"); Assert.AreEqual(command2.AppInstallInfo.Dependencies[1], "jkl"); }
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); }
public void TestRequestSendToProxy() { var appInstallRequest = new AppInstallRequest(new AppInstallInfo() { AppxPath = "abc", PackageFamilyName = "def", Dependencies = new List <String>() { "ghi", "jkl" } }); var proxy = new ConfigurationProxyMockup(); IResponse response = proxy.SendCommandAsync(appInstallRequest).Result; Assert.AreEqual(response.Status, ResponseStatus.Success); }
/// <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 void MockupProxyInstallAppTest() { var twin = new TwinMockup(); var proxy = new ConfigurationProxyMockup(); var appInstallRequest = new AppInstallRequest(new AppInstallRequestData() { AppxPath = "abc", PackageFamilyName = "def", Dependencies = new List <String>() { "ghi", "jkl" } }); var response = proxy.SendCommandAsync(appInstallRequest).Result; Assert.AreEqual(response.Status, ResponseStatus.Success); Assert.AreEqual(response.Tag, DMMessageKind.InstallApp); }
public void TestRequestSerializeDeserialize() { var appInstallRequest = new AppInstallRequest(new AppInstallInfo() { AppxPath = "abc", PackageFamilyName = "def", Dependencies = new List <String>() { "ghi", "jkl" } }); var blob = appInstallRequest.Serialize(); var appInstallRequestRehydrated = AppInstallRequest.Deserialize(blob) as AppInstallRequest; Assert.AreEqual(appInstallRequestRehydrated.Tag, DMMessageKind.InstallApp); Assert.AreEqual(appInstallRequestRehydrated.AppInstallInfo.AppxPath, "abc"); Assert.AreEqual(appInstallRequestRehydrated.AppInstallInfo.PackageFamilyName, "def"); Assert.AreEqual(appInstallRequestRehydrated.AppInstallInfo.Dependencies[0], "ghi"); Assert.AreEqual(appInstallRequestRehydrated.AppInstallInfo.Dependencies[1], "jkl"); }
public void TestWriteToOutputStream() { var command = new AppInstallRequest(new AppInstallInfo() { AppxPath = "abc", PackageFamilyName = "def", Dependencies = new List <String>() { "ghi", "jkl" } }); var blob = command.Serialize(); var stream = new InMemoryRandomAccessStream(); blob.WriteToIOutputStreamAsync(stream.GetOutputStreamAt(0)).AsTask().Wait(); var reader = new DataReader(stream.GetInputStreamAt(0)); reader.LoadAsync(4).AsTask().Wait(); var bytes = new byte[4]; reader.ReadBytes(bytes); var size = BitConverter.ToUInt32(bytes, 0); // like I said, too brittle: //Assert.AreEqual(size, 44U); // this is somewhat brittle. var reader2 = new DataReader(stream.GetInputStreamAt(4)); reader2.LoadAsync(size).AsTask().Wait(); var bytes2 = new byte[size]; reader2.ReadBytes(bytes2); var blob2 = Blob.CreateFromByteArray(bytes2); Assert.AreEqual(blob.Tag, blob2.Tag); var command2 = blob2.MakeIRequest() as AppInstallRequest; Assert.AreEqual(command2.Tag, DMMessageKind.InstallApp); Assert.AreEqual(command2.AppInstallInfo.AppxPath, "abc"); Assert.AreEqual(command2.AppInstallInfo.PackageFamilyName, "def"); Assert.AreEqual(command2.AppInstallInfo.Dependencies[0], "ghi"); Assert.AreEqual(command2.AppInstallInfo.Dependencies[1], "jkl"); }
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}"); } }