public async void GetByIdAsync_Should_Return_Correct_Data() { const string id = "123"; //arrange var mockedRepo = new Mock <IGenericRepository <SubmissionVM> >(); var mockedServiceBusService = new Mock <IServiceBusService>(); var mockedJobClient = new Mock <IBackgroundJobClient>(); var mockedConfigRepo = new Mock <IGenericRepository <ConfigVM> >(); var mockedConfig = new Mock <IAppConfiguration <ConfigVM> >(); var mockedAppSettings = new Mock <IConfiguration>(); //var mockedIdGenerator = new Mock<IUidGeneratorService>(); var sut = new SubmissionService(mockedRepo.Object, mockedServiceBusService.Object, mockedJobClient.Object); //, mockedConfigRepo.Object, mockedConfig.Object, mockedAppSettings.Object); var submissionVm = new SubmissionVM { Id = id }; var doc = new DocumentResponse <SubmissionVM>(submissionVm); mockedRepo.Setup(x => x.GetByIdAsync(It.IsAny <string>())).ReturnsAsync(doc); //act var result = await sut.GetByIdAsync(id); //assert result.Id.Should().Be(id); }
public static void Run() { // ExStart:1 PdfApi pdfApi = new PdfApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "sample-svg.pdf"; String templateFile = "Sample.epub"; String dataFile = ""; String templateType = "epub"; String storage = ""; String folder = ""; try { // Upload source file to aspose cloud storage storageApi.PutCreate(templateFile, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + templateFile)); // Invoke Aspose.PDF Cloud SDK API to create pdf from SVG DocumentResponse apiResponse = pdfApi.PutCreateDocument(fileName, templateFile, dataFile, templateType, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Create PDF from SVG, Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public DocumentResponse GetDocument(Guid docID) { DocumentResponse retval = default; try { var param = _SQLDAL.GetParameter("DocID", docID); var dataset = _SQLDAL.ExecSPQuery("GetDocument", con, param); if (dataset.Tables[0].Rows.Count != 0) { retval = new DocumentResponse() { documentDTO = new List <DocumentDTO>() }; retval.documentDTO.Add(new DocumentDTO() { DocID = dataset.Tables[0].Rows[0].Field <Guid>("DocID"), DocName = dataset.Tables[0].Rows[0].Field <string>("DocName"), ImageURL = dataset.Tables[0].Rows[0].Field <string>("ImageURL"), UserID = dataset.Tables[0].Rows[0].Field <string>("UserId") }); } } catch (Exception e) { //log } return(retval); }
public DocumentResponse GetDocumentsForUser(DocumentRequestGetForUser request) { DocumentResponse retval = default; try { var param = _paramConverter.ConvertToParameter(request, "UserID"); var dataset = _SQLDAL.ExecSPQuery("GetDocumentsForUser", con, param); if (dataset.Tables[0].Rows.Count != 0) { retval = new DocumentResponse() { documentDTO = new List <DocumentDTO>() }; var docList = dataset.Tables[0].AsEnumerable().Select(dataRow => new DocumentDTO { DocName = dataRow.Field <string>("DocName"), ImageURL = dataRow.Field <string>("ImageURL"), UserID = dataRow.Field <string>("UserID"), DocID = dataRow.Field <Guid>("DocID") }).ToList(); retval.documentDTO = docList; } var sharing = _DocumentSharingDAL.GetShareForUser(new DocumentSharingRequestGetForUser() { userID = request.UserID }); List <DocumentDTO> sharedDocs = new List <DocumentDTO>(); if (sharing.DocumentSharingDTO != null && sharing.DocumentSharingDTO.Count != 0) { foreach (var item in sharing.DocumentSharingDTO) { var doc = GetDocument(item.DocID); if (doc.documentDTO[0].UserID != request.UserID) { sharedDocs.Add(doc.documentDTO[0]); } } if (retval == null) { retval = new DocumentResponse() { documentDTO = new List <DocumentDTO>() }; } retval.documentDTO.AddRange(sharedDocs); } if (retval == null) { retval = new DocumentResponseEmpty(); } } catch (Exception e) { //log } return(retval); }
protected virtual void SetMissingIdFromRequestUri(DocumentResponse response, HttpRequestMessage request) { if (string.IsNullOrWhiteSpace(response.Id) && request.Method != HttpMethod.Post) { response.Id = request.ExtractIdFromUri(false); } }
public DocumentResponse AddDocument(DocumentRequest req) { DocumentResponse retval = default; try { var parameters = _paramConverter.ConvertToParameters(req.documentDTO); var dataset = _SQLDAL.ExecSPQuery("CreateDocument", con, parameters); if (dataset.Tables[0].Rows.Count != 0) { retval = new DocumentResponseAddOK() { documentDTO = new List <DocumentDTO>() { new DocumentDTO() { DocID = dataset.Tables[0].Rows[0].Field <Guid>("DocID") } } }; } } catch (Exception e) { retval = new DocumentResponseDontAdd(); //log } return(retval); }
protected async virtual void OnSuccessfulResponse(DocumentResponse response, HttpResponseMessage httpResponse) { using (var content = await httpResponse.Content.ReadAsStreamAsync().ForAwait()) { if (ContentShouldHaveIdAndRev(httpResponse.RequestMessage)) { PopulateDocumentHeaderFromResponseStream(response, content); } else { PopulateMissingIdFromRequestUri(response, httpResponse); PopulateMissingRevFromRequestHeaders(response, httpResponse); } content.Position = 0; var sb = new StringBuilder(); using (var reader = new StreamReader(content, MyCouchRuntime.DefaultEncoding)) { while (!reader.EndOfStream) { sb.Append(reader.ReadLine()); } } response.Content = sb.ToString(); sb.Clear(); } }
protected virtual void SetMissingRevFromResponseHeaders(DocumentResponse response, HttpResponseHeaders responseHeaders) { if (string.IsNullOrWhiteSpace(response.Rev)) { response.Rev = responseHeaders.GetETag(); } }
public async Task <ExportJobOutcome> GetExportJobByIdAsync(string id, CancellationToken cancellationToken) { EnsureArg.IsNotNullOrWhiteSpace(id, nameof(id)); try { DocumentResponse <CosmosExportJobRecordWrapper> cosmosExportJobRecord = await _documentClientScope.Value.ReadDocumentAsync <CosmosExportJobRecordWrapper>( UriFactory.CreateDocumentUri(DatabaseId, CollectionId, id), new RequestOptions { PartitionKey = new PartitionKey(CosmosDbExportConstants.ExportJobPartitionKey) }, cancellationToken); var outcome = new ExportJobOutcome(cosmosExportJobRecord.Document.JobRecord, WeakETag.FromVersionId(cosmosExportJobRecord.Document.ETag)); return(outcome); } catch (DocumentClientException dce) { if (dce.StatusCode == HttpStatusCode.TooManyRequests) { throw new RequestRateExceededException(dce.RetryAfter); } else if (dce.StatusCode == HttpStatusCode.NotFound) { throw new JobNotFoundException(string.Format(Core.Resources.JobNotFound, id)); } _logger.LogError(dce, "Failed to get an export job by id."); throw; } }
public string TimbraYEnviaServicioDeImpuesto(string ruc, string usuario, string usuarioPassword, DocumentoVentaGP documentoGP) { var docWs = ArmaDocumentoEnviarWS(documentoGP); DocumentResponse response = ServicioWS.Enviar("89ab70d025c1cb8c5bac3f5ac319a94728e42e3a", "3cfb75199b5d14cdb706a55555a055488b1fad6c", docWs, "0"); if (response.codigo == 200) { byte[] converbyte = Convert.FromBase64String(response.xml.ToString()); return(System.Text.Encoding.UTF8.GetString(converbyte)); } else { string docSerializado = string.Empty; XmlSerializer xml = new XmlSerializer(typeof(FacturaGeneral)); using (StringWriter sw = new StringWriter()) { xml.Serialize(sw, docWs); docSerializado = sw.ToString(); } //if (response.codigo == 202 || response.codigo == 207) // throw new ArgumentException(response.codigo.ToString() + " - " + response.mensaje + " - " + response.mensajesValidacion.ToString()); //else throw new TimeoutException("Excepción al conectarse con el Web Service de Facturación [TimbraYEnviaServicioDeImpuesto] " + response.codigo.ToString() + " - " + response.mensaje + Environment.NewLine + response.mensajesValidacion.ToString() + Environment.NewLine + docSerializado); } }
protected virtual void OnSuccessfulResponse(DocumentResponse response, HttpResponseMessage httpResponse) { using (var content = httpResponse.Content.ReadAsStream()) { if (ContentShouldHaveIdAndRev(httpResponse.RequestMessage)) PopulateDocumentHeaderFromResponseStream(response, content); else { PopulateMissingIdFromRequestUri(response, httpResponse); PopulateMissingRevFromRequestHeaders(response, httpResponse); } content.Position = 0; var sb = new StringBuilder(); using (var reader = new StreamReader(content, MyCouchRuntime.DefaultEncoding)) { while (!reader.EndOfStream) { sb.Append(reader.ReadLine()); } } response.Content = sb.ToString(); sb.Clear(); } }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------ /// <summary> /// Actiunea ce intoarce un fisier XML, avand ca date timeline-ul documenutlui impreuna cu /// relatiile dintre personaje / relatii etc. /// </summary> /// <param name="id">Id-ul documentului.</param> public ActionResult TimeLine(int?id) { /*verificam daca a fost specificat documentul*/ if (id == null) { return(View("Index", "Home")); } /*modelul ce il intorcem*/ DocumentResponse ret = new DocumentResponse(); /*documentul propriuzis*/ DocumentResponse doc = new DocumentResponse(); /*luam documentul cautat*/ try { doc.Content = this._documentManager.GetDocument(id ?? 0, DocumentManager.TypeTimeline); doc.State = (doc.Content != null) ? DocumentResponse.Status.Finished : DocumentResponse.Status.Parsing; } catch (DocumentException) { doc.State = DocumentResponse.Status.NotFound; } return(new XmlResult(doc)); }
public IHttpActionResult Get(int id) { if (!DocumentStore.Documents.ContainsKey(id)) { return(Content(HttpStatusCode.NotFound, @"Document does not exsist")); } return(Content(HttpStatusCode.OK, DocumentResponse.FromDocument(DocumentStore.Documents[id], GetUserEmail()))); }
public DocumentResponse GetDocument(long id) { DocumentResponse response = new DocumentResponse(); DocumentRepository documentRepository = DmsUnitOfWork.DocumentRepository; var query = documentRepository.GetDocumentByKey(id); response.Document = query.ToDto <Document, DocumentDto>(); return(response); }
public DocumentResponse InsertDocument(DocumentRequest request) { DocumentResponse response = new DocumentResponse(); DocumentDto documentDto = request.DocumentDto; DocumentRepository documentRepository = dmsUnitOfWork.DocumentRepository; EntityEntry <Document> document = documentRepository.Add(documentDto.ToEntity <DocumentDto, Document>()); response.Document = document.Entity.ToDto <Document, DocumentDto>(); return(response); }
public async Task <T> ReadByIdAsync <T>(string id) where T : IIdentifiable { Guard.IsNullOrWhiteSpace(id, nameof(id)); Uri documentUri = UriFactory.CreateDocumentUri(_databaseName, _collectionName, id); DocumentResponse <DocumentEntity <T> > response = await _documentClient.ReadDocumentAsync <DocumentEntity <T> >(documentUri); return(response.Document.Content); }
public DocumentResponse RemoveDocument(DocumentRequestRemove docID) { DocumentResponse retval = default; if (docID != null) { retval = _DAL.Removedocument(docID); } return(retval); }
public DocumentResponse GetDocument(Guid docID) { DocumentResponse retval = default; if (docID != null) { retval = _DAL.GetDocument(docID); } return(retval); }
public async Task <TDocument> GetDocumentByIdAsync <TDocument>( string dbName, string collName, string documentId, object partitionKey = null) { Uri documentUri = UriFactory.CreateDocumentUri(dbName, collName, documentId); DocumentResponse <TDocument> response = await this.documentClient .ReadDocumentAsync <TDocument>(documentUri, GetStandardRequestOptions(partitionKey)) .ConfigureAwait(false); return(response.Document); }
public DocumentResponse Map(Document document) { if (document == null) { return(null); } ; DocumentResponse response = new DocumentResponse { Id = document.Id, CompanyTextDocument = document.CompanyTextDocument, CompanyTextDelivery = document.CompanyTextDelivery, CompanyTextInvoice = document.CompanyTextInvoice, Number = document.Number, DocumentType = document.DocumentType, SubType = document.SubType, TypeName = document.TypeName, ValueBias = document.ValueBias, Status = document.Status, PrintDate = document.PrintDate, ReminderDate = document.ReminderDate, PrintCount = document.PrintCount, NetPriceSum = document.NetPriceSum, PriceGross = document.PriceGross, IsArchived = document.IsArchived, TextStartId = (Guid)document.TextStartId, TextStart = _fagTextMapper.Map(document.TextStart), TextHeadId = (Guid)document.TextHeadId, TextHead = _fagTextMapper.Map(document.TextHead), TextPaymentTermsId = (Guid)document.TextPaymentTermsId, TextPaymentTerms = _fagTextMapper.Map(document.TextPaymentTerms), TextDeliveryId = (Guid)document.TextDeliveryId, TextDelivery = _fagTextMapper.Map(document.TextDelivery), TextEndId = (Guid)document.TextEndId, TextEnd = _fagTextMapper.Map(document.TextEnd), DocumentPersonId = (Guid)document.DocumentPersonId, DocumentPerson = _personMapper.Map(document.DocumentPerson), DocumentCompanyId = (Guid)document.DocumentCompanyId, DocumentCompany = _addressMapper.Map(document.DocumentCompany), DeliveryPersonId = (Guid)document.DeliveryPersonId, DeliveryPerson = _personMapper.Map(document.DeliveryPerson), DeliveryCompanyId = (Guid)document.DeliveryCompanyId, DeliveryCompany = _addressMapper.Map(document.DeliveryCompany), InvoicePersonId = (Guid)document.InvoicePersonId, InvoicePerson = _personMapper.Map(document.InvoicePerson), InvoiceCompanyId = (Guid)document.InvoiceCompanyId, InvoiceCompany = _addressMapper.Map(document.InvoiceCompany), }; return(response); }
void _ListDocuments() { DocusignResponse response = new DocusignResponse(); SendRestRequest(response, HttpMethod.Get, "envelopes/" + mEnvelopeId + "/documents", null).Wait(); if (response.IsError) { response.Throw(); } resObj = response.GetData <DocumentResponse>(); }
public IActionResult InsertDocument([FromBody] DocumentRequest request) { DocumentResponse response = TransactionProcessor <DmsContext> .Execute ( documentTransactions.InsertDocument, request, unitOfWork ); return(new JsonResult(response)); }
public DocumentResponse GetDocumentForUser(DocumentRequestGetForUser request) { DocumentResponse retval = default; if (request.UserID != "" && request.UserID != null) { retval = _DAL.GetDocumentsForUser(request); } return(retval); }
public CompanyResponse(int id, DocumentResponse document, EmailResponse email, AddressResponse address, string companyName, string fantasyName, List <EmployeeResponse> employees) { Id = id; Email = email; Address = address; Document = document; Employees = employees; FantasyName = fantasyName; CompanyName = companyName; }
public void GetSlidesDocumentRequest() { DocumentResponse response = null; try { DocumentApi api = new DocumentApi(AppSID, SecretKey); GetSlidesDocumentRequest request = createGetSlidesDocumentRequest(); response = api.GetSlidesDocument(request); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void PutSlidesSlideSizeExample() { DocumentResponse response = null; try { PutSlidesSlideSizeRequest request = createPutSlidesSlideSizeRequest(); response = api.PutSlidesSlideSize(request); Console.WriteLine(response.Code); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public EmployeeResponse(int id, NameResponse name, DocumentResponse document, EmailResponse email, AddressResponse address, string registerCode, CompanyResponse company, EmployeePositionResponse employeePositionResponse) { Id = id; Name = name; Email = email; Company = company; Address = address; Document = document; RegisterCode = registerCode; EmployeePosition = employeePositionResponse; }
public DocumentResponse GetTransitListDocumentsPaged(string archiveName, int skip, int take) { var ret = new DocumentResponse { TotalRecords = 0, Documents = new BindingList <Document>(), }; if (!string.IsNullOrEmpty(archiveName)) { ret = DocumentService.GetDocumentInTransitoByArchive(archiveName, take, skip); //if (retval.Error == null) // return retval.Documents; } return(ret); }
public void putPresentationMergeExample() { DocumentResponse response = null; try { PutPresentationMergeRequest request = createPutPresentationMergeRequest(); response = api.PutPresentationMerge(request); Console.WriteLine(response); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Retrieve the specified document. /// </summary> /// <typeparam name="TDocument"></typeparam> /// <param name="client"></param> /// <param name="documentUri"></param> /// <param name="requestOptions"></param> /// <param name="logger"></param> /// <returns>Null if the document does not exist.</returns> public static async Task <DocumentResponse <TDocument> > TryReadDocumentAsync <TDocument>(this DocumentClient client, Uri documentUri, RequestOptions requestOptions = null, ILogger logger = null) where TDocument : class, new() { DocumentResponse <TDocument> result = null; try { result = await client.ReadDocumentAsync <TDocument>(documentUri, requestOptions).ConfigureAwait(false); } catch (DocumentClientException dcex) when(dcex.StatusCode == HttpStatusCode.NotFound) { logger?.LogTrace($"Document '{documentUri.OriginalString}' does not exist"); } return(result); }
public async void GetByIdAsync_Should_Throw_Exception() { //arrange const string id = "123"; var pfSurveyVm = new PfSurveyVM { Id = id }; var doc = new DocumentResponse <PfSurveyVM>(pfSurveyVm); mockedRepo.Setup(x => x.GetByIdAsync(It.IsAny <string>())).Throws(new Exception()); // Act Action action = () => sut.GetByIdAsync(id); // Assert action.Should().Throw <Exception>(); }
protected virtual void OnSuccessfulDocumentResponseContentMaterializer(HttpResponseMessage response, DocumentResponse result) { using (var content = response.Content.ReadAsStream()) { if (ContentShouldHaveIdAndRev(response.RequestMessage)) ResponseMaterializer.PopulateDocumentHeaderResponse(result, content); else { AssignMissingIdFromRequestUri(response, result); AssignMissingRevFromRequestHeaders(response, result); } content.Position = 0; using (var reader = new StreamReader(content, MyCouchRuntime.DefaultEncoding)) { result.Content = reader.ReadToEnd(); } } }
public virtual async void Materialize(DocumentResponse response, HttpResponseMessage httpResponse) { if(response.RequestMethod != HttpMethod.Get) throw new ArgumentException(GetType().Name + " only supports materializing GET responses for raw documents."); using (var content = await httpResponse.Content.ReadAsStreamAsync().ForAwait()) { response.Content = content.ReadAsString(); content.Position = 0; var t = Serializer.Deserialize<Temp>(content); response.Id = t._id; response.Rev = t._rev; response.Conflicts = t._conflicts; SetMissingIdFromRequestUri(response, httpResponse.RequestMessage); SetMissingRevFromRequestHeaders(response, httpResponse.Headers); } }
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ /// <summary> /// Actiunea ce intoarce un fisier XML, avand ca date rezumatul documentului impreuna cu alte /// informatii generate asupra documentului. /// </summary> /// <param name="id">Id-ul documentului.</param> public ActionResult Summary(int? id) { /*verificam daca a fost specificat documentul*/ if (id == null) return View("Index", "Home"); /*documentul propriuzis*/ DocumentResponse doc = new DocumentResponse(); /*luam documentul cautat*/ try { doc.Content = this._documentManager.GetDocument(id ?? 0, DocumentManager.TypeSummary); doc.State = (doc.Content != null) ? DocumentResponse.Status.Finished : DocumentResponse.Status.Parsing; } catch (DocumentException) { doc.State = DocumentResponse.Status.NotFound; } return new XmlResult(doc); }
protected virtual void SetMissingRevFromRequestHeaders(DocumentResponse response, HttpResponseHeaders responseHeaders) { if (string.IsNullOrWhiteSpace(response.Rev)) response.Rev = responseHeaders.GetETag(); }
protected virtual void SetMissingIdFromRequestUri(DocumentResponse response, HttpRequestMessage request) { if (string.IsNullOrWhiteSpace(response.Id) && request.Method != HttpMethod.Post) response.Id = request.ExtractIdFromUri(false); }