public DsMessage updFile(string NomeDocumento, List <DsKeyword> ChavesDocumento, List <DsKeyword> ChavesDocumentoAtualizar) { var docTypeId = ConvertTo.DocTypeId(NomeDocumento); if (!docTypeId.HasValue) { throw new InvalidCastException("Tipo de documento inválido!"); } if (docTypeId.Value == 65) { var resultadoUpdate = documentProxy.Update(new DS3Connector.DTO.UpdateDocument <BoxInfo>() { DocumentInfo = ConvertTo.BoxInfo(ChavesDocumento), NewDocumentInfo = ConvertTo.BoxInfo(ChavesDocumentoAtualizar) }); return(new DsMessage(resultadoUpdate.Message, (resultadoUpdate.Status == SUCCESS ? 0 : 404))); } else { var resultadoUpdate = documentProxy.Update(new DS3Connector.DTO.UpdateDocument <ProcessInfo>() { DocumentInfo = ConvertTo.ProcessInfo(ChavesDocumento), NewDocumentInfo = ConvertTo.ProcessInfo(ChavesDocumentoAtualizar) }); return(new DsMessage(resultadoUpdate.Message, (resultadoUpdate.Status == SUCCESS ? 0 : 404))); } }
public DsSearchDoc PesquisarArquivosObjeto(string NomeDocumento, List <DsKeyword> ChavesDocumento) { var docTypeId = ConvertTo.DocTypeId(NomeDocumento); if (!docTypeId.HasValue) { throw new InvalidCastException("Tipo de documento inválido!"); } if (docTypeId == 65) { var documentList = documentProxy.Search(new DS3Connector.DTO.SearchRequest <DTO.IBoxSearchRequest>() { DocumentInfo = ConvertTo.BoxSearchRequestInfo(ChavesDocumento) }); return(new DsSearchDoc(documentList.Message, (documentList.Status == SUCCESS && documentList.TotalFound > 0 ? 0 : 404), ConvertTo.DsDocumentoList(documentList.Data))); } else { var documentList = documentProxy.Search(new DS3Connector.DTO.SearchRequest <DTO.IProcessSearchRequest>() { DocumentInfo = ConvertTo.ProcessSearchRequestInfo(ChavesDocumento) }); return(new DsSearchDoc(documentList.Message, (documentList.Status == SUCCESS && documentList.TotalFound > 0 ? 0 : 404), ConvertTo.DsDocumentoList(documentList.Data))); } }
public DsMessage ExcluirArquivo(string NomeDocumento, List <DsKeyword> ChavesDocumento) { var docTypeId = ConvertTo.DocTypeId(NomeDocumento); if (!docTypeId.HasValue) { throw new InvalidCastException("Tipo de documento inválido!"); } //Apaga Documento if (docTypeId == 65) { var resultDelete = documentProxy.Delete(new DS3Connector.DTO.UpdateDocument <BoxInfo>() { DocumentInfo = ConvertTo.BoxInfo(ChavesDocumento) }); return(new DsMessage(resultDelete.Message, (resultDelete.Status == SUCCESS && resultDelete.TotalFound > 0 ? 0 : 404))); } else { var resultDelete = documentProxy.Delete(new DS3Connector.DTO.UpdateDocument <ProcessInfo>() { DocumentInfo = ConvertTo.ProcessInfo(ChavesDocumento) }); return(new DsMessage(resultDelete.Message, (resultDelete.Status == SUCCESS && resultDelete.TotalFound > 0 ? 0 : 404))); } }
public DsMessage EnviarArquivo(string NomeDocumento, List <DsKeyword> ChavesDocumento, DsFile arquivo) { var docTypeId = ConvertTo.DocTypeId(NomeDocumento); if (!docTypeId.HasValue) { throw new InvalidCastException("Tipo de documento inválido!"); } if (docTypeId.Value == 65) { var novoDocumento = documentProxy.Create( new DS3Connector.DTO.CreateDocument <BoxInfo>() { Attachments = new List <DS3Connector.DTO.CreateDocumentAttachment>() { new DS3Connector.DTO.CreateDocumentAttachment() { Base64 = System.Convert.ToBase64String(arquivo.FileData), } }, DocumentInfo = ConvertTo.BoxInfo(ChavesDocumento), } ); return(new DsMessage(novoDocumento.Message, (novoDocumento.Status == SUCCESS ? 0 : 500))); } else { var novoDocumento = documentProxy.Create( new DS3Connector.DTO.CreateDocument <ProcessInfo>() { Attachments = new List <DS3Connector.DTO.CreateDocumentAttachment>() { new DS3Connector.DTO.CreateDocumentAttachment() { Base64 = System.Convert.ToBase64String(arquivo.FileData), } }, DocumentInfo = ConvertTo.ProcessInfo(ChavesDocumento), } ); return(new DsMessage(novoDocumento.Message, (novoDocumento.Status == SUCCESS ? 0 : 500))); } }
public DsMessage updFile(string NomeDocumento, List <DsKeyword> ChavesDocumento, List <DsKeyword> ChavesDocumentoAtualizar, DsFile arquivo) { var docTypeId = ConvertTo.DocTypeId(NomeDocumento); if (!docTypeId.HasValue) { throw new InvalidCastException("Tipo de documento inválido!"); } //Searh Old Document if (docTypeId.Value == 65) { var documentList = documentProxy.Search(new DS3Connector.DTO.SearchRequest <IBoxSearchRequest>() { DocumentInfo = ConvertTo.BoxInfo(ChavesDocumento) }); if (documentList.Status == SUCCESS && documentList.Data != null && documentList.Data.Count > 0 && documentList.Data.First().Attachments.Count > 0) { for (var i = 0; i < documentList.Data.First().Attachments.Count; i++) { var resultDelete = attachProxy.Delete(new DS3Connector.DTO.EditAttach <BoxInfo>() { Id = documentList.Data.First().Attachments[i].Id }); if (resultDelete.Status != SUCCESS) { throw new ApplicationException(resultDelete.Message); } } } var resultadoUpdate = documentProxy.Update(new DS3Connector.DTO.UpdateDocument <BoxInfo>() { DocumentInfo = ConvertTo.BoxInfo(ChavesDocumento), NewDocumentInfo = ConvertTo.BoxInfo(ChavesDocumentoAtualizar), Attachments = new List <DS3Connector.DTO.CreateDocumentAttachment>() { new DS3Connector.DTO.CreateDocumentAttachment() { Base64 = System.Convert.ToBase64String(arquivo.FileData) } } }); return(new DsMessage(resultadoUpdate.Message, (resultadoUpdate.Status == SUCCESS ? 0 : 500))); } else { var documentList = documentProxy.Search(new DS3Connector.DTO.SearchRequest <IProcessSearchRequest>() { DocumentInfo = ConvertTo.ProcessInfo(ChavesDocumento) }); if (documentList.Status == SUCCESS && documentList.Data != null && documentList.Data.Count > 0 && documentList.Data.First().Attachments.Count > 0) { for (var i = 0; i < documentList.Data.First().Attachments.Count; i++) { var resultDelete = attachProxy.Delete(new DS3Connector.DTO.EditAttach <ProcessInfo>() { Id = documentList.Data.First().Attachments[i].Id }); if (resultDelete.Status != SUCCESS) { throw new ApplicationException(resultDelete.Message); } } } var resultadoUpdate = documentProxy.Update(new DS3Connector.DTO.UpdateDocument <ProcessInfo>() { DocumentInfo = ConvertTo.ProcessInfo(ChavesDocumento), NewDocumentInfo = ConvertTo.ProcessInfo(ChavesDocumentoAtualizar), Attachments = new List <DS3Connector.DTO.CreateDocumentAttachment>() { new DS3Connector.DTO.CreateDocumentAttachment() { Base64 = System.Convert.ToBase64String(arquivo.FileData) } } }); return(new DsMessage(resultadoUpdate.Message, (resultadoUpdate.Status == SUCCESS ? 0 : 500))); } }