protected void InsertUpdateFileField(BaseDto objectToInsert, int parentId)
        {
            foreach (var propertyInfo in objectToInsert.GetType().GetProperties().Where(c => c.GetCustomAttribute <RelativityObjectFieldAttribute>() != null))
            {
                RelativityObjectFieldAttribute attributeValue = propertyInfo.GetCustomAttribute <RelativityObjectFieldAttribute>();
                if (attributeValue.FieldType == (int)RdoFieldType.File)
                {
                    RelativityFile relativityFile = propertyInfo.GetValue(objectToInsert) as RelativityFile;
                    if (relativityFile != null)
                    {
                        if (relativityFile.FileValue != null)
                        {
                            if (relativityFile.FileValue.Path != null)
                            {
                                using (IRSAPIClient proxyToWorkspace = CreateProxy())
                                {
                                    var uploadRequest = new UploadRequest(proxyToWorkspace.APIOptions);
                                    uploadRequest.Metadata.FileName       = relativityFile.FileValue.Path;
                                    uploadRequest.Metadata.FileSize       = new FileInfo(uploadRequest.Metadata.FileName).Length;
                                    uploadRequest.Overwrite               = true;
                                    uploadRequest.Target.FieldId          = relativityFile.ArtifactTypeId;
                                    uploadRequest.Target.ObjectArtifactId = parentId;

                                    try
                                    {
                                        invokeWithRetryService.InvokeVoidMethodWithRetry(() => proxyToWorkspace.Upload(uploadRequest));
                                    }
                                    catch (Exception ex)
                                    {
                                        throw ex;
                                    }
                                }
                            }
                            else if (string.IsNullOrEmpty(relativityFile.FileMetadata.FileName) == false)
                            {
                                string tempPath = Path.GetTempPath();
                                string fileName = tempPath + relativityFile.FileMetadata.FileName;

                                using (IRSAPIClient proxyToWorkspace = CreateProxy())
                                {
                                    System.IO.File.WriteAllBytes(fileName, relativityFile.FileValue.Data);

                                    var uploadRequest = new UploadRequest(proxyToWorkspace.APIOptions);
                                    uploadRequest.Metadata.FileName       = fileName;
                                    uploadRequest.Metadata.FileSize       = new FileInfo(uploadRequest.Metadata.FileName).Length;
                                    uploadRequest.Overwrite               = true;
                                    uploadRequest.Target.FieldId          = relativityFile.ArtifactTypeId;
                                    uploadRequest.Target.ObjectArtifactId = parentId;

                                    try
                                    {
                                        invokeWithRetryService.InvokeVoidMethodWithRetry(() => proxyToWorkspace.Upload(uploadRequest));

                                        invokeWithRetryService.InvokeVoidMethodWithRetry(() => System.IO.File.Delete(fileName));
                                    }
                                    catch (Exception)
                                    {
                                        invokeWithRetryService.InvokeVoidMethodWithRetry(() => System.IO.File.Delete(fileName));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        protected void InsertUpdateFileField(RelativityFile relativityFile, int parentId)
        {
            if (relativityFile != null)
            {
                if (relativityFile.FileValue != null)
                {
                    if (relativityFile.FileValue.Path != null)
                    {
                        using (IRSAPIClient proxyToWorkspace = CreateProxy())
                        {
                            var uploadRequest = new UploadRequest(proxyToWorkspace.APIOptions);
                            uploadRequest.Metadata.FileName       = relativityFile.FileValue.Path;
                            uploadRequest.Metadata.FileSize       = new FileInfo(uploadRequest.Metadata.FileName).Length;
                            uploadRequest.Overwrite               = true;
                            uploadRequest.Target.FieldId          = relativityFile.ArtifactTypeId;
                            uploadRequest.Target.ObjectArtifactId = parentId;

                            try
                            {
                                invokeWithRetryService.InvokeVoidMethodWithRetry(() => proxyToWorkspace.Upload(uploadRequest));
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                    }
                    else if (string.IsNullOrEmpty(relativityFile.FileMetadata.FileName) == false)
                    {
                        string tempPath = Path.GetTempPath();
                        string fileName = tempPath + relativityFile.FileMetadata.FileName;

                        using (IRSAPIClient proxyToWorkspace = CreateProxy())
                        {
                            System.IO.File.WriteAllBytes(fileName, relativityFile.FileValue.Data);

                            var uploadRequest = new UploadRequest(proxyToWorkspace.APIOptions);
                            uploadRequest.Metadata.FileName       = fileName;
                            uploadRequest.Metadata.FileSize       = new FileInfo(uploadRequest.Metadata.FileName).Length;
                            uploadRequest.Overwrite               = true;
                            uploadRequest.Target.FieldId          = relativityFile.ArtifactTypeId;
                            uploadRequest.Target.ObjectArtifactId = parentId;

                            try
                            {
                                invokeWithRetryService.InvokeVoidMethodWithRetry(() => proxyToWorkspace.Upload(uploadRequest));

                                invokeWithRetryService.InvokeVoidMethodWithRetry(() => System.IO.File.Delete(fileName));
                            }
                            catch (Exception)
                            {
                                invokeWithRetryService.InvokeVoidMethodWithRetry(() => System.IO.File.Delete(fileName));
                            }
                        }
                    }
                }
            }
        }