public async Task <IActionResult> OnGetAsync(Guid documentId) { Document = _documentRepository.Find(documentId); if (Document == null) { return(new NotFoundResult()); } var authorizationResult = await _authorizationService .AuthorizeAsync(User, Document, Operations.Read); if (authorizationResult.Succeeded) { return(Page()); } else if (User.Identity.IsAuthenticated) { return(new ForbidResult()); } else { return(new ChallengeResult()); } }
public async Task <string> SaveDocument(string id, [FromBody] Models.Document doc) { EmailService es = new EmailService(); es.SendEmail(); return(await AppUtilsServices.Put("/jeevehmarket/" + id, doc)); }
public override Models.Document LoadDocument(FileIOInfo info) { if (info == null) { return(null); } TiffBitmapDecoder tiff = new TiffBitmapDecoder(info.Stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); Models.Document doc = new Models.Document(); Models.Page page; for (int i = 0; i < tiff.Frames.Count; i++) //foreach (BitmapFrame frame in tiff.Frames) { page = new Models.Page(); page.fName = info.FullFileName; page.image = TiffFrameToBitmapImage(tiff.Frames[i]); page.number = i + 1; page.imageStream = (MemoryStream)page.image.StreamSource; doc.pages.Add(new ViewModels.PageViewModel(page)); } return(doc); }
public async Task <Models.Document> GetDocument(int value) { Models.Document document = null;; string controllerAction; controllerAction = String.Format("curriculum/document/{0}", value); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseUrl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(controllerAction); if (response.IsSuccessStatusCode) { var json = response.Content.ReadAsStringAsync().Result; document = JsonConvert.DeserializeObject <Models.Document>(json); } } return(document); }
public PdfDocument(Models.Document documentTemplate, string outputFile) { // Create Colors foreach (Models.Typography.Color bColor in documentTemplate.Colors) { Color itextColor = new Color(bColor); Colors.Add(itextColor); } // Create Fonts foreach (Models.Typography.Font bFont in documentTemplate.Fonts) { foreach (Models.Typography.FontStyle bFontStyle in bFont.Styles) { FontStyle itextFontStyle = new FontStyle(bFontStyle); Fonts.Add(itextFontStyle); } } try { CreatePages(documentTemplate, outputFile); SetDocumentProperties(documentTemplate); _itextDocument.Close(); _itextPDFWriter.Close(); } catch (IOException iox) { throw; } }
public Document(Models.Document documentTemplate, string outputFile) { foreach (Models.Page bPage in documentTemplate.Pages) { Page pPage = new Page(bPage); } }
public static ViewModels.Document GetDto(Models.Document entity) { var result = new ViewModels.Document(); FillDto(entity, result); return(result); }
public async Task <FileStreamResult> Download(long documentId, string clientId, string secret, string userId) { //Validate clientId & secret if ((!Repository.AppManagement.IsValidUser(userId)) || (!Repository.AppManagement.IsValidClientSecret(clientId, secret))) { return(null); } Models.Document document = Repository.Documents.Get(documentId); AzureBlobStorage azure = new AzureBlobStorage(); using (MemoryStream memStream = new MemoryStream()) { MemoryStream output = await azure.DownloadSingleFileAsync(document); byte[] file = memStream.ToArray(); if (output != null) { output.Write(file, 0, file.Length); output.Position = 0; HttpContext.Response.AddHeader("content-disposition", "attachment; filename=" + document.Name); return(File(output, MIMEAssistant.GetMIMEType(document.Name))); } else { //What to do here? If Azure blob storage connection settings are not valid then this is where code will land return(null); } } }
/// <summary> /// Render the header of document /// </summary> /// <param name="footer"></param> /// <param name="document"></param> /// <param name="mainDocumentPart"></param> /// <param name="context"></param> /// <param name="formatProvider"></param> public static void Render(this Models.Footer footer, Models.Document document, MainDocumentPart mainDocumentPart, ContextModel context, IFormatProvider formatProvider) { var footerPart = mainDocumentPart.AddNewPart <FooterPart>(); footerPart.Footer = new Footer(); foreach (var element in footer.ChildElements) { element.InheritFromParent(footer); element.Render(document, footerPart.Footer, context, footerPart, formatProvider); } string footerPartId = mainDocumentPart.GetIdOfPart(footerPart); if (!mainDocumentPart.Document.Body.Descendants <SectionProperties>().Any()) { mainDocumentPart.Document.Body.AppendChild(new SectionProperties()); } foreach (var section in mainDocumentPart.Document.Body.Descendants <SectionProperties>()) { section.PrependChild(new FooterReference() { Id = footerPartId, Type = (DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues)(int) footer.Type }); } if (footer.Type == HeaderFooterValues.First) { mainDocumentPart.Document.Body.Descendants <SectionProperties>().First().PrependChild(new TitlePage()); } }
/// <summary> /// Upload document from a document library /// </summary> /// <param name="fileStream"></param> /// <param name="document"></param> /// <param name="SPDocLibrary"></param> /// <param name="fileName"></param> /// <param name="contentType"></param> /// <returns></returns> public async Task <AzureFile> UploadDocumentAsync(Stream fileStream, Models.Document document, Models.DocumentLibrary SPDocLibrary, string fileName, string contentType) { string fileFullPath = null; string blobContainerName = _DefaultAzureContainer; try { // NOTE: Azure Blob container names must be all lowercase and cannot start with numbers if (SPDocLibrary != null && SPDocLibrary.DocumentLibraryId != 0) { blobContainerName = _SharePointDocLibPrefix + SPDocLibrary.DocumentLibraryId.ToString(); } fileFullPath = await SaveAzureDocumentBlob(contentType, fileName, blobContainerName, fileStream); } catch (Exception ex) { // TODO: handle this exception and bubble up to the interface?? return(new AzureFile(document, false, ex.Message)); } document.Url = fileFullPath; document.Uploaded = DateTime.UtcNow; return(new AzureFile(document, true, null)); }
public SdfDocumentViewModel(Models.Document _model, bool loadNow) { model = _model; if (loadNow) { Load(); } }
public bool SaveFile(Models.Document document) { if (document.Type == null) { document.Type = "default"; } return(TransformAnnotationDocument(document)); }
public void Create(HttpPostedFileBase upload) { // client to interact with elasticSearch client = ElasticSearchConfig.GetClient(); //Most of Avaloq's document filenames follow the format of ID-ReleaseNum-ClientNum-Subtype-Subtitle.pdf //The service checks if the given file follows the same format, and if so, retrieves the metadata. using (var dc = new DocuContext()) { var document = new Models.Document { }; var fileName = upload.FileName; String[] metadata = fileName.Split('-'); if (upload != null && upload.ContentLength > 0 && metadata.Length >= 5) { document.SubType = metadata[3]; document.DocuID = Convert.ToInt32(metadata[0]); if (metadata[1].Equals("en")) { document.Release = "Release Independent"; } else { document.Release = "Release " + metadata[1]; } document.LastModified = DateTime.Today.Date; document.FileSize = upload.ContentLength; document.Title = upload.FileName; document.Subtitle = metadata[4]; var filepath = new Models.FilePath { FileName = Path.GetFileName(upload.FileName), }; document.FilePath = filepath; } else if (upload != null && upload.ContentLength > 0) { document.SubType = "null"; document.DocuID = 0; document.Release = "null"; document.LastModified = DateTime.Today.Date; document.FileSize = upload.ContentLength; document.Title = upload.FileName; document.Subtitle = "null"; var filepath = new Models.FilePath { FileName = Path.GetFileName(upload.FileName), }; document.FilePath = filepath; } dc.Documents.Add(document); dc.SaveChanges(); document.FilePath = null; var result = client.Index(document); } }
internal static void ManageFooterRow(Models.Document document, Models.Table table, Table wordTable, TableLook tableLook, ContextModel context, OpenXmlPart documentPart, IFormatProvider formatProvider) { // add footer row if (table.FooterRow != null) { wordTable.AppendChild(table.FooterRow.Render(document, wordTable, context, documentPart, false, false, formatProvider)); tableLook.LastRow = OnOffValue.FromBoolean(true); } }
public static object Delete(Models.Document document) { using (var db = new Context.SqlContext()) { db.Entry(document).State = document.DocumentId.Equals(0) ? EntityState.Unchanged : EntityState.Deleted; var ret = db.SaveChanges(); return(ret); } }
public List <Document> getDocument(int docuID) // this is for cart // User docuID from Order.getOrders // its return type is list but return only one doc { List <Document> listDoc = new List <Document>(); MySqlConnection conn = null; using (conn = new MySqlConnection(db.getConnString())) { conn.Open(); using (MySqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM document WHERE docuID == " + docuID + ";"; using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Document doc = new Models.Document(); doc.docuID = reader.GetInt32(0); doc.docuName = reader.GetString(1); if (!reader.IsDBNull(2)) { doc.regularPrice = reader.GetFloat(2); } else { doc.regularPrice = -1; } if (!reader.IsDBNull(3)) { doc.expressPrice = reader.GetFloat(3); } else { doc.expressPrice = -1; } doc.type = reader.GetString(4); listDoc.Add(doc); doc = new Models.Document(); } if (!reader.HasRows) { listDoc = null; } } } } conn.Close(); return(listDoc); }
private DocumentViewModel AddNewDoc(Models.Document doc) { int nextIndex = (SelectedDocument != null ? Documents.IndexOf(SelectedDocument) : -1) + 1; DocumentViewModel docVM = new DocumentViewModel(doc); Documents.Insert(nextIndex, docVM); //SelectedDocument = docVM; return(docVM); }
public DocumentViewModel(Models.Document document) { if (document == null) { throw new ArgumentNullException("document"); } _doc = document; Pages = new ObservableCollection <PageViewModel>(_doc.pages); Pages.CollectionChanged += OnPagesChanged; }
/// <summary> /// Create domain model from web model /// </summary> public static Document CreateFrom(this Models.Document source) { return(new Document { DocumentId = source.DocumentId, DocumentCode = source.DocumentCode, DocumentName = source.DocumentName, DocumentDescription = source.DocumentDescription, DocumentGroupId = source.DocumentGroupId, }); }
public static void FillDto(Models.Document entity, ViewModels.Document document) { document.Id = entity.Id; document.DocumentTypeId = entity.DocumentTypeId; document.FileTypeId = entity.FileTypeId; document.FileUrl = entity.FileUrl; document.Title = entity.Title; document.ParentId = entity.ParentId; document.SysUrl = entity.SysUrl; document.FileType = entity.FileType; }
public static void Fill(Models.Document entity, ViewModels.Document document) { entity.Id = document.Id; entity.DocumentTypeId = document.DocumentTypeId; entity.FileTypeId = document.FileTypeId; entity.FileUrl = document.FileUrl; entity.Title = document.Title; entity.ParentId = document.ParentId; entity.SysUrl = document.SysUrl; entity.FileType = document.FileType; }
private ViewModels.DocumentViewModel CreateViewModelDocument(Models.Document document) { var documentViewModel = new ViewModels.DocumentViewModel(); documentViewModel.Id = document.Id; documentViewModel.Title = document.Title; documentViewModel.Link = document.Link; documentViewModel.Description = document.Description; documentViewModel.IconStyle = IconsList.GetIconTypeName(document.Type); return(documentViewModel); }
private string GetNameLocale(Models.Document item) { var culture = CultureHelper.GetCurrentCulture(); var name = item.Translations[culture]?.Name; if (string.IsNullOrEmpty(name)) { name = item.name; } return(name); }
private string GetDescriptionLocale(Models.Document item) { var culture = CultureHelper.GetCurrentCulture(); var description = item.Translations[culture]?.Description; if (string.IsNullOrEmpty(description)) { description = item.description; } return(description); }
internal static void ManageBeforeAfterRows(Models.Document document, Models.Table table, IList <Models.Row> rows, Table wordTable, ContextModel context, OpenXmlPart documentPart, IFormatProvider formatProvider) { // After rows : if (rows != null && rows.Count > 0) { foreach (var row in rows) { row.InheritFromParent(table); wordTable.AppendChild(row.Render(document, wordTable, context, documentPart, false, false, formatProvider)); } } }
public ViewResult Delete(int documentId) { Models.Document document = Repository.DocumentRepository().GetById(documentId); if (document != null) { return(View(document)); } else { return(View("Index", Repository.DocumentRepository().GetAll().ToList())); } }
public async Task <RespContainer <DocumentResponse> > Handle(AddDocumentCommand request, CancellationToken cancellationToken) { Models.Document document = _documentMapper.Map(request.Data); Models.Document result = _documentRespository.Add(document); int modifiedRecords = await _documentRespository.UnitOfWork.SaveChangesAsync(); _logger.LogInformation(Events.Add, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords); _logger.LogInformation(Events.Add, Messages.ChangesApplied_id, result?.Id); return(RespContainer.Ok(_documentMapper.Map(result), "Document Created")); }
public List <Document> getAllDocuments() // All Documents { List <Document> listDoc = new List <Document>(); MySqlConnection conn = null; using (conn = new MySqlConnection(db.getConnString())) { conn.Open(); using (MySqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM document;"; using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Document doc = new Models.Document(); doc.docuID = reader.GetInt32(0); doc.docuName = reader.GetString(1); if (!reader.IsDBNull(2)) { doc.regularPrice = reader.GetFloat(2); } else { doc.regularPrice = -1; } if (!reader.IsDBNull(3)) { doc.expressPrice = reader.GetFloat(3); } else { doc.expressPrice = -1; } doc.type = reader.GetString(4); listDoc.Add(doc); doc = new Models.Document(); } if (!reader.HasRows) { listDoc = null; } } } } conn.Close(); return(listDoc); }
public ActionResult <Models.Document> Update(Models.Document document) { bool result = liteDbDocumentService.UpdateDocument(document); if (result) { return(NoContent()); } else { return(NotFound()); } }
public ActionResult <Models.Document> Insert(Models.Document document) { int id = liteDbDocumentService.InsertDocument(document); if (id != default) { return(CreatedAtAction("GetDocument", liteDbDocumentService.GetDocument(id))); } else { return(BadRequest()); } }