Exemplo n.º 1
0
        public bool GetCreatedObjectsStatus()
        {
            bool state = false;
            QueryRequest request = new QueryRequest
            {
                ObjectType = new ObjectTypeRef { ArtifactTypeID = _artifactTypeID },
                Fields = new[]
                    {
                        new FieldRef { Name = _COUNT_DESTINATION_FIELD }
                    }
            };

            Task<QueryResultSlim> taskForResult = _objectManagerClient.QuerySlimAsync(_workspaceId, request, 0, int.MaxValue);
            QueryResultSlim result = GetQueryResultFromTask(taskForResult);

            if (result.TotalCount > 0)
            {
                string extractedinfo = result.Objects[0].Values[0].ToString();
                if (extractedinfo.Contains("2"))
                {
                    state = true;
                }
            }

            return state;
        }
Exemplo n.º 2
0
        public async static Task <int> GetFieldArtifactID(string fieldName, IEHHelper helper, IAPILog logger)
        {
            int fieldArtifactId = 0;

            using (IObjectManager objectManager = helper.GetServicesManager().CreateProxy <IObjectManager>(ExecutionIdentity.System))
            {
                var queryRequest = new QueryRequest()
                {
                    ObjectType = new ObjectTypeRef()
                    {
                        Name = "Field"
                    },
                    Condition = $"'Name' == '{fieldName}' AND 'Object Type' == 'Document'"
                };

                var queryResult = await objectManager.QuerySlimAsync(helper.GetActiveCaseID(), queryRequest, 0, 1);

                if (queryResult.TotalCount > 0)
                {
                    fieldArtifactId = queryResult.Objects.Select(x => x.ArtifactID).FirstOrDefault();
                    logger.LogVerbose("Alert field artifactID: {fieldArtifactID}", fieldArtifactId);
                }
            }

            return(fieldArtifactId);
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <int> > ReadDocumentsInSavedSeach(IServicesMgr serviceManager, int workspaceId, int savedSearchArtifactId)
        {
            List <int> returnVal = new List <int>();

            const int indexOfFirstDocumentInResult = 1;  //1-based index of first document in query results to retrieve
            const int lengthOfResults = 100;             //max number of results to return in this query call.

            string searchCondition =
                "('Artifact ID' IN SAVEDSEARCH @savedSearchId)".Replace("@savedSearchId", savedSearchArtifactId.ToString());


            QueryRequest queryRequest = new QueryRequest()
            {
                ObjectType = new ObjectTypeRef {
                    Guid = Guids.Document.OBJECT_TYPE
                },
                Condition = searchCondition,                                                        //query condition syntax is used to build query condtion.  See Relativity's developer documentation for more details
                Fields    = new List <global::Relativity.Services.Objects.DataContracts.FieldRef>() //array of fields to return.  ArtifactId will always be returned.
                {
                    new FieldRef {
                        Name = "Artifact ID"
                    },
                },
                IncludeIDWindow         = false,
                RelationalField         = null,         //name of relational field to expand query results to related objects
                SampleParameters        = null,
                SearchProviderCondition = null,         //see documentation on building search providers
                QueryHint = "waitfor:5"
            };

            using (IObjectManager objectManager = serviceManager.CreateProxy <IObjectManager>(ExecutionIdentity.System))
            {
                QueryResultSlim queryResult = await objectManager.QuerySlimAsync(workspaceId, queryRequest, indexOfFirstDocumentInResult, lengthOfResults);

                if (queryResult.ResultCount > 0)
                {
                    foreach (RelativityObjectSlim resultObject in queryResult.Objects)
                    {
                        returnVal.Add(resultObject.ArtifactID);
                    }
                }
            }

            DocsInSearch = returnVal;

            return(returnVal);
        }
Exemplo n.º 4
0
        public static int GetWorkspaceId(string workspaceName, IObjectManager _client)
        {
            int workspaceArtifactId = 0;           

            try
            {
                QueryRequest queryRequest = new QueryRequest();
                queryRequest.ObjectType = new ObjectTypeRef { ArtifactTypeID = (int)ArtifactType.Case };
                queryRequest.Condition = $"('{WorkspaceFieldNames.Name}' IN ['{workspaceName}'])";
                QueryResultSlim results = _client.QuerySlimAsync(-1, queryRequest, 1, 1)
                    .ConfigureAwait(false)
                    .GetAwaiter()
                    .GetResult();
                workspaceArtifactId = results.Objects[0].ArtifactID;
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: {0}", ex.Message);
            }

            return workspaceArtifactId;
        }