Exemplo n.º 1
0
        private void CreateFileValidationResult(bool isMissing, string fileType)
        {
            try
            {
                var fvResult = new DTOs.RDO();
                fvResult.ArtifactTypeGuids.Add(new Guid(MainApp.Helper.Constant.OBJECT_TYPE_FILE_VALIDATIOM_RESULT_GUID));

                DTOs.FieldValueList <DTOs.Document> docObjects = new DTOs.FieldValueList <DTOs.Document>();
                var doc = new DTOs.Document(ArtifactID);
                docObjects.Add(doc);

                fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_NAME), DateTime.UtcNow.ToString("MM-dd-yyyy HH:mm:ss")));
                fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_DOCUMENT), docObjects));
                fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_VALIDATION_DATE), DateTime.UtcNow));
                fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_EXIST), isMissing));
                fvResult.Fields.Add(new DTOs.FieldValue(new Guid(MainApp.Helper.Constant.FIELD_FR_TYPE), fileType));

                DTOs.WriteResultSet <DTOs.RDO> writeResults = Connection.Repositories.RDO.Create(fvResult);

                if (!writeResults.Success)
                {
                    throw new Exception(string.Format("An error occurred in result creation: {0}", writeResults.Results[0].Message));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public KeyValuePair <byte[], kCura.Relativity.Client.FileMetadata> DownloadDocumentNative(int documentId)
        {
            kCura.Relativity.Client.DTOs.Document doc = new kCura.Relativity.Client.DTOs.Document(documentId);
            byte[] documentBytes;

            KeyValuePair <DownloadResponse, Stream> documentNativeResponse = new KeyValuePair <DownloadResponse, Stream>();

            using (IRSAPIClient proxy = CreateProxy())
            {
                try
                {
                    documentNativeResponse = invokeWithRetryService.InvokeWithRetry(() => proxy.Repositories.Document.DownloadNative(doc));
                }
                catch (Exception ex)
                {
                    throw new ProxyOperationFailedException("Failed in method: " + System.Reflection.MethodInfo.GetCurrentMethod(), ex);
                }
            }

            using (MemoryStream ms = (MemoryStream)documentNativeResponse.Value)
            {
                documentBytes = ms.ToArray();
            }

            return(new KeyValuePair <byte[], FileMetadata>(documentBytes, documentNativeResponse.Key.Metadata));
        }
        public void ToRelativityObject_ObjectArtifactIdSet_ReturnsCorrectArtifactIdSet()
        {
            //ARRANGE
            var doc = new kCura.Relativity.Client.DTOs.Document(123);

            //ACT
            var result = doc.ToRelativityObject();

            //ASSERT
            Assert.Equal(123, result.ArtifactId);
        }
        public void ToRelativityObject_FieldValueHasArtifactId_ReturnsArtifactIdSet()
        {
            //ARRANGE
            var doc = new kCura.Relativity.Client.DTOs.Document();

            doc.Fields = new System.Collections.Generic.List <kCura.Relativity.Client.DTOs.FieldValue>();
            doc.Fields.Add(new kCura.Relativity.Client.DTOs.FieldValue(123));

            //ACT
            var result = doc.ToRelativityObject();

            //ASSERT
            Assert.NotEmpty(result.FieldValues);
            Assert.NotNull(result.FieldValues.SingleOrDefault()?.Field);
            Assert.Equal(123, result.FieldValues.Single().Field.ArtifactId);
        }
        public void ToRelativityObject_FieldValueHasValue_ReturnsValueSet()
        {
            //ARRANGE
            var doc = new kCura.Relativity.Client.DTOs.Document();

            doc.Fields = new System.Collections.Generic.List <kCura.Relativity.Client.DTOs.FieldValue>();
            doc.Fields.Add(new kCura.Relativity.Client.DTOs.FieldValue("field Name", "this field"));

            //ACT
            var result = doc.ToRelativityObject();

            //ASSERT
            Assert.NotEmpty(result.FieldValues);
            Assert.NotNull(result.FieldValues.FirstOrDefault()?.Field);
            Assert.Equal("this field", result.FieldValues.First().Value);
        }
Exemplo n.º 6
0
        public bool Update(int artifactId, Entities.Document artifact)
        {
            bool result = false;

            DTOs.Document document = new DTOs.Document(artifactId);
            document.TextIdentifier = artifact.Name;
            document.ParentArtifact = new DTOs.Artifact(artifact.ParentArtifactId);
            try
            {
                client.Repositories.Document.UpdateSingle(document);
                result = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Exemplo n.º 7
0
        public int Create(Entities.Document artifact)
        {
            int result = 0;

            DTOs.Document documentToCreate = new DTOs.Document();
            documentToCreate.RelativityNativeFileLocation = artifact.RelativityNativeFileLocation;
            documentToCreate.TextIdentifier = artifact.Name;
            documentToCreate.ParentArtifact = new DTOs.Artifact(artifact.ParentArtifactId);

            try

            {
                result = client.Repositories.Document.CreateSingle(documentToCreate);
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Exemplo n.º 8
0
 public Entities.Document Get(int artifactId)
 {
     Entities.Document document = new Entities.Document();
     try
     {
         DTOs.Document           documentDTO = client.Repositories.Document.ReadSingle(artifactId);
         List <Entities.Comment> comments    = new List <Entities.Comment>();
         CommentRepositoryRSAPI  cr          = new CommentRepositoryRSAPI(this.client);
         DTOs.FieldValue         f1          = new DTOs.FieldValue();
         document.amountComments = 0;
         foreach (var f in documentDTO.Fields)
         {
             if (f.Name == "Commens - Document")
             {
                 if (f.Value != null)
                 {
                     DTOs.FieldValueList <DTOs.Artifact> list = (DTOs.FieldValueList <DTOs.Artifact>)f.Value;
                     document.amountComments = list.Count;
                     foreach (var field in list)
                     {
                         comments.Add(cr.Get(field.ArtifactID));
                     }
                 }
             }
         }
         document.ArtifactId = documentDTO.ArtifactID;
         document.Name       = documentDTO.TextIdentifier;
         document.Comments   = comments;
         Entities.Artifact user = new Entities.Artifact(documentDTO.SystemCreatedBy.ArtifactID);
         user.Name          = documentDTO.SystemCreatedBy.FullName;
         document.CreatedBy = user;
     }
     catch (Exception)
     {
         throw;
     }
     return(document);
 }