public void GeneratesOdsTemplate() { var asm = Assembly.GetExecutingAssembly(); using (var stream = asm.GetManifestResourceStream("TestProject.OdsContent.xml")) { if (stream == null) { return; } var reader = new StreamReader(stream); _content = reader.ReadToEnd(); } _odtDocumentInformation = new DocumentInformation( OdfHandlerService.FileType.Ods, new byte[0], _content, new OdfMetadata(typeof(object))); _xDocumentParserService.Setup(x => x.Parse(It.IsAny <string>())).Returns(XDocument.Parse(_content)); _sut.GenerateTemplate(_odtDocumentInformation, _xmlNamespaceService, _xDocumentParserService.Object); _xDocumentParserService.Verify(x => x.Parse(It.IsAny <string>())); }
internal PdfDocument(ILog log, IInputBytes inputBytes, HeaderVersion version, CrossReferenceTable crossReferenceTable, bool isLenientParsing, ParsingCachingProviders cachingProviders, IPageFactory pageFactory, Catalog catalog, DocumentInformation information, EncryptionDictionary encryptionDictionary, IPdfTokenScanner pdfScanner, IFilterProvider filterProvider, AcroFormFactory acroFormFactory) { this.log = log; this.inputBytes = inputBytes; this.version = version ?? throw new ArgumentNullException(nameof(version)); this.isLenientParsing = isLenientParsing; this.cachingProviders = cachingProviders ?? throw new ArgumentNullException(nameof(cachingProviders)); this.encryptionDictionary = encryptionDictionary; this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner)); this.filterProvider = filterProvider ?? throw new ArgumentNullException(nameof(filterProvider)); Information = information ?? throw new ArgumentNullException(nameof(information)); pages = new Pages(log, catalog, pageFactory, isLenientParsing, pdfScanner); Structure = new Structure(catalog, crossReferenceTable, pdfScanner); documentForm = new Lazy <AcroForm>(() => acroFormFactory.GetAcroForm(catalog)); }
internal PdfDocument(ILog log, IInputBytes inputBytes, HeaderVersion version, CrossReferenceTable crossReferenceTable, ParsingCachingProviders cachingProviders, IPageFactory pageFactory, Catalog catalog, DocumentInformation information, EncryptionDictionary encryptionDictionary, IPdfTokenScanner pdfScanner, ILookupFilterProvider filterProvider, AcroFormFactory acroFormFactory, BookmarksProvider bookmarksProvider, bool clipPaths) { this.log = log; this.inputBytes = inputBytes; this.version = version ?? throw new ArgumentNullException(nameof(version)); this.cachingProviders = cachingProviders ?? throw new ArgumentNullException(nameof(cachingProviders)); this.encryptionDictionary = encryptionDictionary; this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner)); this.filterProvider = filterProvider ?? throw new ArgumentNullException(nameof(filterProvider)); this.bookmarksProvider = bookmarksProvider ?? throw new ArgumentNullException(nameof(bookmarksProvider)); this.clipPaths = clipPaths; Information = information ?? throw new ArgumentNullException(nameof(information)); pages = new Pages(catalog, pageFactory, pdfScanner); Structure = new Structure(catalog, crossReferenceTable, pdfScanner); Advanced = new AdvancedPdfDocumentAccess(pdfScanner, filterProvider, catalog); documentForm = new Lazy <AcroForm>(() => acroFormFactory.GetAcroForm(catalog)); }
public DocumentInformation UploadDocument(DocumentInformation info) { _dbContext.DocumentInformations.Add(info); Save(); var doc = _dbContext.DocumentInformations.Where(a => a.Name == info.Name && a.SubmissionDate == info.SubmissionDate).Single(); return(doc); }
private void SaveSettings() { #region Document information DocumentInformation info = control.Document.Information; info.Author = this.documentInformation1.Author; info.Title = this.documentInformation1.Title; info.Description = this.documentInformation1.Description; #endregion }
private void ExecuteInformationCommand() { var di = new DocumentInformation(_pdfComponent) { Owner = _view.Window, }; di.ShowDialog(); }
private void LoadData() { #region Document information DocumentInformation info = control.Document.Information; this.documentInformation1.Author = info.Author; this.documentInformation1.Title = info.Title; this.documentInformation1.CreationDate = DateTime.Parse(info.CreationDate); this.documentInformation1.Description = info.Description; #endregion }
DocumentInformation GetDocumentInformation(Document doc) { DocumentInformation docInfo = new DocumentInformation(); docInfo.Name = doc.ProjectInformation.Document.PathName; docInfo.Number = doc.ProjectInformation.Number; docInfo.Status = doc.ProjectInformation.Status; docInfo.Address = doc.ProjectInformation.Address; docInfo.ClientName = doc.ProjectInformation.ClientName; return(docInfo); }
public async Task <IActionResult> UploadFileOnAzureBlob(IFormFile file, string connection) { if (file != null) { //Getting FileName var fileName = Path.GetFileName(file.FileName); var obj = new DocumentInformation() { Name = fileName, FileType = file.ContentType, SubmissionDate = DateTime.Now }; DocumentInformation doc = _documentRepository.UploadDocument(obj); string blobstorageconnection = connection; byte[] dataFiles; // Retrieve storage account from connection string. CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(blobstorageconnection); // Create the blob client. CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); // Retrieve a reference to a container. CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference("filescontainers"); BlobContainerPermissions permissions = new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }; string systemFileName = string.Format(file.FileName, doc.DocumentId); await cloudBlobContainer.SetPermissionsAsync(permissions); await using (var target = new MemoryStream()) { file.CopyTo(target); dataFiles = target.ToArray(); } // This also does not make a service call; it only creates a local object. CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(systemFileName); await cloudBlockBlob.UploadFromByteArrayAsync(dataFiles, 0, dataFiles.Length); } return(new OkResult()); }
public static async Task <List <DocumentInformation> > GetSharePointDocuments(string rootSiteUrl, string searchAPIUrl) { List <DocumentInformation> documents = new List <DocumentInformation>(); var accessToken = await GetAccessTokenForResource(rootSiteUrl); StringBuilder requestUri = new StringBuilder().Append(rootSiteUrl).Append(searchAPIUrl); HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri.ToString()); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml")); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); HttpResponseMessage response = await client.SendAsync(request); string responseString = await response.Content.ReadAsStringAsync(); XElement root = XElement.Parse(responseString); List <XElement> items = root.Descendants(d + "PrimaryQueryResult") .Elements(d + "RelevantResults") .Elements(d + "Table") .Elements(d + "Rows") .Elements(d + "element") .ToList(); foreach (var item in items) { DocumentInformation document = new DocumentInformation(); document.Title = item.Element(d + "Cells").Descendants(d + "Key").First(a => a.Value == "Title").Parent.Element(d + "Value").Value; // document.AuthorInformation.DisplayName = item.Element(d + "Cells").Descendants(d + "Key").First(a => a.Value == "Author").Parent.Element(d + "Value").Value; document.Url = item.Element(d + "Cells").Descendants(d + "Key").First(a => a.Value == "Path").Parent.Element(d + "Value").Value; DateTime modifiedDate = Convert.ToDateTime(item.Element(d + "Cells").Descendants(d + "Key").First(a => a.Value == "LastModifiedTime").Parent.Element(d + "Value").Value); document.ModifiedDate = modifiedDate; string docExtension = item.Element(d + "Cells").Descendants(d + "Key").First(a => a.Value == "FileExtension").Parent.Element(d + "Value").Value; document.IconUrl = docExtension.ToFileIconUrl(); string originalpath = item.Element(d + "Cells").Descendants(d + "Key").First(a => a.Value == "OriginalPath").Parent.Element(d + "Value").Value; document.Url = originalpath; documents.Add(document); } return(documents); }
/// Algo ///1. Document Information. ///2. List of Resource Information /// 2.a. String Information /// 2.a.i. Removal Information public List <DocumentInformation> GetAllEnglishStrings(EnglishStringPayload payload) { m_payload = payload; List <DocumentInformation> documentInformationList = new List <DocumentInformation>(); try { m_removalStringList = m_functionService.Udf_GetRemovedStrings(payload.BranchId.Value, payload.ModifiedDateUTC); foreach (var resourceId in payload.ResourceIds) { ///DocumentContent DocumentInformation documentInformation = new DocumentInformation { DocumentContent = m_functionService.GetDocumentContent(resourceId), VoScriptIds = m_dbContext.TVoscript .Where(x => x.BranchId == payload.BranchId) .Where(x => x.ParentResourceId == resourceId) .Where(x => x.IsActive) .Select(x => x.VoscriptId) .ToList() }; var resourceVersionIdList = new List <int> { documentInformation.DocumentContent.ResourceVersionId }; foreach (var resourceVersionId in resourceVersionIdList) { ParentResource parentResource = new ParentResource { LocalizationResourceId = resourceId, //parentResourceAttributes.ResourceID, LocalizationResourceVersionId = resourceVersionId //resourceVersionId, }; documentInformation.ResourceInformation.AddRange(GetTextInformation(resourceVersionId, parentResource)); } documentInformationList.Add(documentInformation); } } catch (Exception ex) { m_loggerService.LogError(ex.Message); } return(documentInformationList); }
internal PdfDocument(ILog log, IRandomAccessRead reader, HeaderVersion version, CrossReferenceTable crossReferenceTable, bool isLenientParsing, ParsingCachingProviders cachingProviders, IPageFactory pageFactory, IPdfObjectParser pdfObjectParser, Catalog catalog, DocumentInformation information) { this.log = log; this.reader = reader ?? throw new ArgumentNullException(nameof(reader)); this.version = version ?? throw new ArgumentNullException(nameof(version)); this.crossReferenceTable = crossReferenceTable ?? throw new ArgumentNullException(nameof(crossReferenceTable)); this.isLenientParsing = isLenientParsing; this.cachingProviders = cachingProviders ?? throw new ArgumentNullException(nameof(cachingProviders)); Information = information ?? throw new ArgumentNullException(nameof(information)); Catalog = catalog ?? throw new ArgumentNullException(nameof(catalog)); Pages = new Pages(log, Catalog, pdfObjectParser, pageFactory, reader, isLenientParsing); }
public void processResponse(IInteraction queryResponse) { DocumentDetailQueryResponse response = (DocumentDetailQueryResponse)queryResponse; var realmCodes = response.GetRealmCode(); foreach (Realm realm in realmCodes) { Console.WriteLine("Realm Code: " + realm.CodeValue); } if (response.ControlActEvent.Subject != null) { foreach (RefersTo <DocumentInformation> refersTo in response.ControlActEvent.Subject) { DocumentInformation documentInformation = refersTo.Act; if (documentInformation != null) { Console.WriteLine("Document title: " + documentInformation.Title); Console.WriteLine("Document text follws. "); byte[] data = Convert.FromBase64String(documentInformation.Text.Content); string decodedString = System.Text.Encoding.Default.GetString(data); Console.WriteLine(decodedString); CAABTranscribedReportsDocument encapsulatedDocument = (CAABTranscribedReportsDocument)this.ProcessDocumentXml(decodedString, SpecificationVersion.CDA_AB_SHR); // Console.WriteLine(this.ConvertMessageObjectToXML(encapsulatedDocument, SpecificationVersion.CDA_AB_SHR)); if (encapsulatedDocument != null) { Console.WriteLine("Title from document: " + encapsulatedDocument.Title); foreach (Author author in encapsulatedDocument.Author) { PersonName authorName = author.AssignedAuthor.AssignedPersonName; Console.WriteLine("Document author: " + authorName.GivenName + " " + authorName.FamilyName); } Console.WriteLine(encapsulatedDocument.Component.NonXMLBodyText.Content); } } } } }
internal PdfDocument(ILog log, IInputBytes inputBytes, HeaderVersion version, CrossReferenceTable crossReferenceTable, bool isLenientParsing, ParsingCachingProviders cachingProviders, IPageFactory pageFactory, Catalog catalog, DocumentInformation information, IPdfTokenScanner pdfScanner) { this.log = log; this.inputBytes = inputBytes; this.version = version ?? throw new ArgumentNullException(nameof(version)); this.isLenientParsing = isLenientParsing; this.cachingProviders = cachingProviders ?? throw new ArgumentNullException(nameof(cachingProviders)); this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner)); Information = information ?? throw new ArgumentNullException(nameof(information)); pages = new Pages(log, catalog, pageFactory, isLenientParsing, pdfScanner); Structure = new Structure(catalog, crossReferenceTable, pdfScanner); }
public Message UpdateUserInformation(User user, HttpPostedFileBase httpPostedFileBase, bool updateImageOnly = false) { Message message; try { using (var scope = new TransactionScope()) { _dbContext.SqlConnection.Open(); var isExist = _iUserRepository.Get(new User { UserId = user.UserId }); var affectedRow = 0; Guid guid; guid = Guid.NewGuid(); HttpPostedFileBase file = httpPostedFileBase; var target = new MemoryStream(); var documentInformatio = new DocumentInformation(); if (isExist == null) { return(SetMessage.SetInformationMessage("User information not found.")); } if (!updateImageOnly) { isExist.FirstName = user.FirstName; isExist.LastName = user.LastName; isExist.MobileNo = user.MobileNo; affectedRow = _iUserRepository.Update(isExist); message = affectedRow > 0 ? SetMessage.SetSuccessMessage("Information has been updated successfully.") : SetMessage.SetInformationMessage("No data has been updated."); } if (httpPostedFileBase != null) { file.InputStream.CopyTo(target); } byte[] byteData = target.ToArray(); var imageUtility = new ImageUtility(); #region Insert Document Information if (httpPostedFileBase != null) { var size = imageUtility.GetPreferredImageSize(ImageDimensions.Common); byte[] byteAfterResize = imageUtility.EnforceResize(size.Width, size.Height, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName)); documentInformatio.DocumentName = guid + Path.GetExtension(httpPostedFileBase.FileName); documentInformatio.DocumentByte = byteAfterResize; documentInformatio.DocumentSize = byteAfterResize.Length; _iDocumentInformationRepository.InsertWithoutIdentity(documentInformatio); if (documentInformatio.GlobalId > 0) { if (updateImageOnly) { isExist.PhotoFileName = (guid + Path.GetExtension(httpPostedFileBase.FileName)); isExist.GlobalId = documentInformatio.GlobalId > 0 ? documentInformatio.GlobalId : 0; affectedRow = _iUserRepository.Update(isExist); } else { user.PhotoFileName = (guid + Path.GetExtension(httpPostedFileBase.FileName)); user.GlobalId = documentInformatio.GlobalId > 0 ? documentInformatio.GlobalId : 0; affectedRow = _iUserRepository.Update(user); } } string folderPath = HttpContext.Current.Server.MapPath(Constants.ImagePath.ImageFolderPath); bool isUpload = imageUtility.ImageSaveToPath(folderPath, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName), ImageDimensions.Common); } #endregion message = SetMessage.SetSuccessMessage("Information has been updated successfully."); scope.Complete(); } } catch (Exception exception) { return(SetMessage.SetErrorMessage(exception.Message)); } finally { _dbContext.SqlConnection.Close(); } return(message); }
public Message Register(User user, HttpPostedFileBase httpPostedFileBase) { Message message; try { using (var scope = new TransactionScope()) { _dbContext.SqlConnection.Open(); var isExist = _iUserRepository.GetUser(user.Email); var affectedRow = 0; Guid guid; guid = Guid.NewGuid(); HttpPostedFileBase file = httpPostedFileBase; var target = new MemoryStream(); var documentInformatio = new DocumentInformation(); int loggedInUserId = WebHelper.CurrentSession.Content.LoggedInUser != null ? WebHelper.CurrentSession.Content.LoggedInUser.UserId : 0; if (isExist == null) { //User password encryption user.Password = CryptographyHelper.Encrypt(user.Password); //By default user will be active user.IsActive = true; // Registration time globalId 0 user.GlobalId = 0; if (loggedInUserId > 0) { user.CreatedBy = loggedInUserId; user.UserType = user.UserType; } else { user.UserType = Convert.ToInt32(AppUsers.User); } affectedRow = _iUserRepository.InsertWithoutIdentity(user); message = affectedRow > 0 ? SetMessage.SetSuccessMessage("Information has been saved successfully.") : SetMessage.SetInformationMessage("No data has been saved."); } else { user.IsActive = true; user.UserId = isExist.UserId; user.Password = isExist.Password; affectedRow = _iUserRepository.Update(user); message = affectedRow > 0 ? SetMessage.SetSuccessMessage("Information has been updated successfully.") : SetMessage.SetInformationMessage("No data has been updated."); } if (httpPostedFileBase != null) { file.InputStream.CopyTo(target); } byte[] byteData = target.ToArray(); var imageUtility = new ImageUtility(); #region Insert Document Information if (httpPostedFileBase != null) { var size = imageUtility.GetPreferredImageSize(ImageDimensions.Common); byte[] byteAfterResize = imageUtility.EnforceResize(size.Width, size.Height, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName)); documentInformatio.DocumentName = guid + Path.GetExtension(httpPostedFileBase.FileName); documentInformatio.DocumentByte = byteAfterResize; documentInformatio.DocumentSize = byteAfterResize.Length; _iDocumentInformationRepository.InsertWithoutIdentity(documentInformatio); if (documentInformatio.GlobalId > 0) { user.PhotoFileName = (httpPostedFileBase != null ? guid + Path.GetExtension(httpPostedFileBase.FileName) : null); user.GlobalId = documentInformatio.GlobalId > 0 ? documentInformatio.GlobalId : 0; affectedRow = _iUserRepository.Update(user); } } #endregion #region Image Resize and Save To Path string folderPath = HttpContext.Current.Server.MapPath(Constants.ImagePath.ImageFolderPath); if (httpPostedFileBase != null) { bool isUpload = imageUtility.ImageSaveToPath(folderPath, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName), ImageDimensions.Common); } #endregion scope.Complete(); } } catch (Exception exception) { return(SetMessage.SetErrorMessage(exception.Message)); } finally { _dbContext.SqlConnection.Close(); } return(message); }
public ActionResult Index() { try { DocumentInformation model = new DocumentInformation(); model.Tokens = new List <string>(); var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); using (var ctx = spContext.CreateUserClientContextForSPHost()) { LogHelper.Log("ctx is null " + (ctx == null)); ListItem DocumentItem = null; string FileContent = FileHelper.GetFileContent( ctx, new Guid(HttpContext.Request.QueryString["SPListId"]), Convert.ToInt32(HttpContext.Request.QueryString["SPListItemId"]), out DocumentItem); Dictionary <string, int> tokens = AutoTaggingHelper.Tokenize(FileContent); var SortedTokens = tokens.OrderByDescending(x => x.Value); foreach (var token in SortedTokens) { model.Tokens.Add(string.Concat(token.Key, " (", token.Value, " ) | ")); } System.Text.StringBuilder locations = new System.Text.StringBuilder(); System.Text.StringBuilder organizations = new System.Text.StringBuilder(); System.Text.StringBuilder persons = new System.Text.StringBuilder(); Dictionary <string, int> entities = NlpHelper.GetNamedEntititesForText(FileContent, false); LogHelper.Log("entities : " + entities.Count); foreach (KeyValuePair <string, int> entity in entities) { switch (entity.Value) { case 1: //location locations.AppendFormat("{0} - ", entity.Key); break; case 2: //person persons.AppendFormat("{0} - ", entity.Key); break; case 3: //org organizations.AppendFormat("{0} - ", entity.Key); break; } } model.Locations = locations.ToString(); model.Persons = persons.ToString(); model.Organizations = organizations.ToString(); } return(View(model)); } catch (Exception ex) { LogHelper.Log(ex.Message + ex.StackTrace, LogSeverity.Error); throw; } }
public Message InsertOrUpdateWithoutIdentity(Test test, HttpPostedFileBase httpPostedFileBase) { Message message; try { using (var scope = new TransactionScope()) { _dbContext.SqlConnection.Open(); if (test.NoOfQuestion != test.TestWiseQuestions.Count()) { return(SetMessage.SetErrorMessage("No of question not match! Please select (" + test.NoOfQuestion + ")question from question list")); } var isExist = _iTestRepository.Get(test); var affectedRow = 0; var guid = Guid.NewGuid(); var file = httpPostedFileBase; var target = new MemoryStream(); var documentInformatio = new DocumentInformation(); if (isExist == null) { test.IsActive = true; affectedRow = _iTestRepository.InsertWithoutIdentity(test); foreach (var testWiseQuestions in test.TestWiseQuestions) { testWiseQuestions.TestId = test.TestId; _iTestWiseQuestionRepository.InsertWithoutIdentity(testWiseQuestions); } message = affectedRow > 0 ? SetMessage.SetSuccessMessage("Information has been saved successfully.") : SetMessage.SetInformationMessage("No data has been saved."); } else { affectedRow = _iTestRepository.Update(test); _iTestWiseQuestionRepository.DeleteByTestId(test.TestId); foreach (var testWiseQuestions in test.TestWiseQuestions) { testWiseQuestions.TestId = test.TestId; _iTestWiseQuestionRepository.InsertWithoutIdentity(testWiseQuestions); } message = affectedRow > 0 ? SetMessage.SetSuccessMessage("Information has been updated successfully.") : SetMessage.SetInformationMessage("No data has been updated."); } if (httpPostedFileBase != null) { file.InputStream.CopyTo(target); } byte[] byteData = target.ToArray(); var imageUtility = new ImageUtility(); #region Insert Document Information if (httpPostedFileBase != null) { var size = imageUtility.GetPreferredImageSize(ImageDimensions.Common); byte[] byteAfterResize = imageUtility.EnforceResize(size.Width, size.Height, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName)); documentInformatio.DocumentName = guid + Path.GetExtension(httpPostedFileBase.FileName); documentInformatio.DocumentByte = byteAfterResize; documentInformatio.DocumentSize = byteAfterResize.Length; _iDocumentInformationRepository.InsertWithoutIdentity(documentInformatio); if (documentInformatio.GlobalId > 0) { test.TestIconName = (httpPostedFileBase != null ? guid + Path.GetExtension(httpPostedFileBase.FileName) : null); test.GlobalId = documentInformatio.GlobalId > 0 ? documentInformatio.GlobalId : 0; affectedRow = _iTestRepository.Update(test); } } #endregion #region Image Resize and Save To Path string folderPath = HttpContext.Current.Server.MapPath(Constants.ImagePath.ImageFolderPath); if (httpPostedFileBase != null) { bool isUpload = imageUtility.ImageSaveToPath(folderPath, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName), ImageDimensions.Common); } #endregion scope.Complete(); } } catch (Exception exception) { return(SetMessage.SetErrorMessage(exception.Message)); } finally { _dbContext.SqlConnection.Close(); } return(message); }
public void TestNPC() { ExcelDocsCreator ec = new ExcelDocsCreator(); ProjectCompany pc0 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ", State = State.Domestic }; DocumentInformation di1 = new DocumentInformation() { IssueDate = DateTime.Parse("05.05.1991"), IssuePlace = "г.Москва", SeriesAndNumber = "123 989 89 89 " }; DocumentInformation di2 = new DocumentInformation() { IssueDate = DateTime.Parse("05.05.1992"), IssuePlace = "г.Москва", SeriesAndNumber = "456 989 89 89 " }; DocumentInformation di3 = new DocumentInformation() { IssueDate = DateTime.Parse("05.05.1993"), IssuePlace = "г.Москва", SeriesAndNumber = "789 989 89 89 " }; DocumentInformation di4 = new DocumentInformation() { IssueDate = DateTime.Parse("05.05.1994"), IssuePlace = "г.Москва", SeriesAndNumber = "0987 989 89 89 " }; IndividualCompany ic1 = new IndividualCompany() { AppartamentNumber = "100", BirthDate = DateTime.Parse("05.05.1990"), BirthPlace = "город москва", BuildingNumber = "строение 1", CitizenshipCodeId = 1, City = "Москва", CityType = "город", ConfirmedPersonalityDocInfo = di1, INN = 09876543210, Name = "Василий", MiddleName = "Иванович", Surname = "Пупкин", GenderCodeId = 1, PostIndex = "495980", RegionCode = new RegionCode() { Id = 77 }, District = "Московская", Street = "Ленина", HouseNumber = "10", VerifedPersonalityDocInfo = di4 }; IndividualCompany ic2 = new IndividualCompany() { AppartamentNumber = "200", BirthDate = DateTime.Parse("05.05.1980"), BirthPlace = "город москва", BuildingNumber = "строение 2", CitizenshipCodeId = 1, City = "Питер", CityType = "город", ConfirmedPersonalityDocInfo = di2, INN = 1234567890, Name = "Иван", MiddleName = "Петрович", Surname = "Сидоров", GenderCodeId = 1, PostIndex = "495980", RegionCode = new RegionCode() { Id = 47 }, District = "Омская", Street = "Ленина", HouseNumber = "1000", VerifedPersonalityDocInfo = di3 }; IndividualCompany ic3 = new IndividualCompany() { AppartamentNumber = "300", BirthDate = DateTime.Parse("05.05.1970"), BirthPlace = "город москва", BuildingNumber = "строение 43", CitizenshipCodeId = 1, City = "Омск", CityType = "город", ConfirmedPersonalityDocInfo = di3, INN = 1334567890, Name = "Пётр", MiddleName = "Сидорович", Surname = "Иванов", GenderCodeId = 1, PostIndex = "495980", RegionCode = new RegionCode() { Id = 05 }, District = "Омская", Street = "Ленина", HouseNumber = "10/4", VerifedPersonalityDocInfo = di2 }; IndividualCompany ic4 = new IndividualCompany() { AppartamentNumber = "400", BirthDate = DateTime.Parse("05.05.1960"), BirthPlace = "город москва", BuildingNumber = "строение 143", CitizenshipCodeId = 1, City = "Ленинград", CityType = "город", ConfirmedPersonalityDocInfo = di4, INN = 1134567890, Name = "Алексей", MiddleName = "Иванович", Surname = "Петров", GenderCodeId = 1, PostIndex = "495980", RegionCode = new RegionCode() { Id = 98 }, District = "Ленинградская", Street = "Ленина", HouseNumber = "108", VerifedPersonalityDocInfo = di1 }; ProjectCompany pc1 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ40", State = State.Individual, IndividualCompany = ic1 }; ProjectCompany pc2 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ41", State = State.Individual, IndividualCompany = ic2 }; ProjectCompany pc3 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ42", State = State.Individual, IndividualCompany = ic3 }; ProjectCompany pc4 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ43", State = State.Individual, IndividualCompany = ic4 }; ForeignCompany fc1 = new ForeignCompany() { FullName = "ООО Иностранная компания 1", Name = "ИК1", Address = "г. Москва 1ый Волоколамский проезд дом 3", CountryCodeId = 1, TaxPayerCodeId = 1, RegistrationNumber = "123" }; ForeignCompany fc2 = new ForeignCompany() { FullName = "ООО Иностранная компания 2", Name = "ИК2", Address = "г. Москва 2ый Волоколамский проезд дом 4", CountryCodeId = 1, TaxPayerCodeId = 1, RegistrationNumber = "21222223" }; ForeignCompany fc3 = new ForeignCompany() { FullName = "ООО Иностранная компания 3", Name = "ИК3", Address = "г. Москва 3ий Волоколамский проезд дом 5", CountryCodeId = 5, TaxPayerCodeId = 1, RegistrationNumber = "31222243522223" }; ForeignCompany fc4 = new ForeignCompany() { FullName = "ООО Иностранная компания 4", Name = "ИК4", Address = "г. Москва 4ый Волоколамский проезд дом 6", CountryCodeId = 5, TaxPayerCodeId = 1, RegistrationNumber = "421222243522223" }; ProjectCompany pc5 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ30", State = State.Foreign, ForeignCompany = fc1 }; ProjectCompany pc6 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ31", State = State.Foreign, ForeignCompany = fc2 }; ProjectCompany pc7 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ32", State = State.Foreign, ForeignCompany = fc3 }; ProjectCompany pc8 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ33", State = State.Foreign, ForeignCompany = fc4 }; ForeignLightCompany fcl1 = new ForeignLightCompany() { EnglishName = "FOREGIN LIGHT COMPANY 1 FOREGIN LIGHT COMPANY 1 FOREGIN LIGHT COMPANY 1 FOREGIN LIGHT COMPANY 1", RussianName = "ООО Иностранная компания БОЮЛ 1", CountryCodeId = 5, FoundDate = DateTime.Parse("05.12.1997"), Number = "1423", ForeignOrganizationalFormCodeId = 4, RequisitesEng = "DESC NUM 3 DESC NUM 2 DESC NUM 1", RegNumber = "123123123", RequisitesRus = "Реквизит1, 2 ,3 ,5 10 реквизиты", OtherInfo = "Дополнительная информация 1" }; ForeignLightCompany fcl2 = new ForeignLightCompany() { EnglishName = "FOREGIN LIGHT COMPANY 2", RussianName = "ООО Иностранная компания БОЮЛ 2", CountryCodeId = 5, FoundDate = DateTime.Parse("05.12.1998"), Number = "1234", ForeignOrganizationalFormCodeId = 3, RequisitesEng = "DESC NUM 3 DESC NUM 2 DESC NUM 1", RegNumber = "123123123", RequisitesRus = "Реквизит1, 2 ,3 ,5 10 реквизиты", OtherInfo = "Дополнительная информация 2" }; ForeignLightCompany fcl3 = new ForeignLightCompany() { EnglishName = "FOREGIN LIGHT COMPANY 3", RussianName = "ООО Иностранная компания БОЮЛ 3", CountryCodeId = 6, FoundDate = DateTime.Parse("05.12.1999"), Number = "1235", ForeignOrganizationalFormCodeId = 2, RequisitesEng = "DESC NUM 3 DESC NUM 2 DESC NUM 1", RegNumber = "123123123", RequisitesRus = "Реквизит1, 2 ,3 ,5 10 реквизиты", OtherInfo = "Дополнительная информация 3 " }; ForeignLightCompany fcl4 = new ForeignLightCompany() { EnglishName = "FOREGIN LIGHT COMPANY 4", RussianName = "ООО Иностранная компания БОЮЛ 4", CountryCodeId = 8, FoundDate = DateTime.Parse("05.12.2005"), Number = "1236", ForeignOrganizationalFormCodeId = 1, RequisitesEng = "DESC NUM 3 DESC NUM 2 DESC NUM 1", RegNumber = "123123123", RequisitesRus = "Реквизит1, 2 ,3 ,5 10 реквизиты", OtherInfo = "Дополнительная информация 4" }; ProjectCompany pc9 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ20", State = State.ForeignLight, ForeignLightCompany = fcl1 }; ProjectCompany pc10 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ21", State = State.ForeignLight, ForeignLightCompany = fcl2 }; ProjectCompany pc11 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ22", State = State.ForeignLight, ForeignLightCompany = fcl3 }; ProjectCompany pc12 = new ProjectCompany() { Name = "ООО ЛЮКСОФТ ПРОФЕШОНАЛ23", State = State.ForeignLight, ForeignLightCompany = fcl4 }; ProjectCompanyShare share1 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc1.Id, DependentProjectCompany = pc1, SharePart = 50.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share2 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc2.Id, DependentProjectCompany = pc2, SharePart = 20.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share3 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc3.Id, DependentProjectCompany = pc3, SharePart = 10.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share4 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc4.Id, DependentProjectCompany = pc4, SharePart = 5.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share5 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc5.Id, DependentProjectCompany = pc5, SharePart = 10.10, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share6 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc6.Id, DependentProjectCompany = pc6, SharePart = 10.03, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share7 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc7.Id, DependentProjectCompany = pc7, SharePart = 10.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share8 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc8.Id, DependentProjectCompany = pc8, SharePart = 10.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share9 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc9.Id, DependentProjectCompany = pc9, SharePart = 10.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share10 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc10.Id, DependentProjectCompany = pc10, SharePart = 10.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share11 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc11.Id, DependentProjectCompany = pc11, SharePart = 10.20, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share12 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc12.Id, DependentProjectCompany = pc12, SharePart = 10.13, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share01 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc1.Id, DependentProjectCompany = pc1, SharePart = 50.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share02 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc2.Id, DependentProjectCompany = pc2, SharePart = 20.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share03 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc3.Id, DependentProjectCompany = pc3, SharePart = 10.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; ProjectCompanyShare share04 = new ProjectCompanyShare() { OwnerProjectCompanyId = pc0.Id, DependentProjectCompanyId = pc4.Id, DependentProjectCompany = pc4, SharePart = 5.00, ShareType = ShareType.Direct, ShareStartDate = DateTime.Parse("05.12.2005") }; //List<ProjectCompanyShare> fd = new List<ProjectCompanyShare> { share1, share2, share3, share4, share5, share6, share7, share8, share9, share10, share11, share12 }; List <ProjectCompanyShare> fd = new List <ProjectCompanyShare> { share7, share11 }; // List<ProjectCompanyShare> fdd = new List<ProjectCompanyShare> { share01, share02, share03, share04}; //pc1.DependentProjectCompanyShares = new List<ProjectCompanyShare>{share1,share2,share3,share4,share5, share6, share7, share8, share9, share10,share11, share12}; //pc1.OwnerProjectCompanyShares = new List<ProjectCompanyShare> { share1, share2, share3, share4, share5, share6, share7, share8, share9, share10, share11, share12 }; FactShareCalculation fc = new FactShareCalculation(); var smplList = fc.GetFactShares(GetShares()).Where(s => s.ShareFactPart > 0); ////Граф //var graphModel = new AdjacencyGraph<int, TaggedEdge<int, double>>(); ////Вершины //IList<int> vecities = GetOrderedIds(smplList); //foreach (var v in vecities) //{ // graphModel.AddVertex(v); //} ////Ребра и Веса //foreach (var share in smplList) //{ // graphModel.AddEdge(new TaggedEdge<int, double>(share.DependentProjectCompanyId, share.OwnerProjectCompanyId, share.ShareFactPart)); //} ////Граф //var shareGraph = new BidirectionalGraph<int, Edge<int>>(); ////Вершины(Vertices) Ребра(Edge) и Веса (a Tag) //foreach (var share in smplList) //{ // shareGraph.AddVerticesAndEdge(new TaggedEdge<int, double>(share.OwnerProjectCompanyId, share.DependentProjectCompanyId, share.ShareFactPart)); //}; ////откуда //int Source = 1; ////Куда //int Target = 2; ////Ограничение на кол-во путей //int pathCount = 10; //// e- edgesWeights //foreach (IEnumerable<Edge<int>> paths in shareGraph.RankedShortestPathHoffmanPavley(e => 0, Source, Target, pathCount)) //{ // Console.WriteLine("Path Exmple:"); // foreach (TaggedEdge<int, double> path in paths) // { // Console.WriteLine(path.Source + " > " + path.Target + "Costs: " + path.Tag); // } //} //var graphModel1 = new AdjacencyGraph<int, TaggedEdge<int, double>>(); //foreach (var share in smplList) //{ // graphModel1.AddVerticesAndEdge(new TaggedEdge<int, double>(share.DependentProjectCompanyId, share.OwnerProjectCompanyId, share.ShareFactPart)); //} //var edges = new SEdge<int>[] { new SEdge<int>(1, 2), new SEdge<int>(0, 1) }; //var graph = edges.ToAdjacencyGraph<int, SEdge<int>>(true); //var factShareLsit = fc.GetFactShares(fd); //string path = @"C:\Users\FyodorSt\Source\Repos\WebKIK\KPMG.WebKik.DocumentProcessing\Templates\UU.xlsx"; //var nn = ec.GetFilledNotificationOfParticipation(path, pc0, fd, factShareLsit.ToList()); //nn.SaveAs("NN"+ pc0.Name+".xlsx"); }
private static PdfDocument OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, ILog log, bool isLenientParsing, IReadOnlyList <string> passwords, bool clipPaths) { var filterProvider = DefaultFilterProvider.Instance; CrossReferenceTable crossReferenceTable = null; var xrefValidator = new XrefOffsetValidator(log); // We're ok with this since our intent is to lazily load the cross reference table. // ReSharper disable once AccessToModifiedClosure var locationProvider = new ObjectLocationProvider(() => crossReferenceTable, inputBytes); var pdfScanner = new PdfTokenScanner(inputBytes, locationProvider, filterProvider, NoOpEncryptionHandler.Instance); var crossReferenceStreamParser = new CrossReferenceStreamParser(filterProvider); var crossReferenceParser = new CrossReferenceParser(log, xrefValidator, crossReferenceStreamParser); var version = FileHeaderParser.Parse(scanner, isLenientParsing, log); var crossReferenceOffset = FileTrailerParser.GetFirstCrossReferenceOffset(inputBytes, scanner, isLenientParsing) + version.OffsetInFile; // TODO: make this use the scanner. var validator = new CrossReferenceOffsetValidator(xrefValidator); crossReferenceOffset = validator.Validate(crossReferenceOffset, scanner, inputBytes, isLenientParsing); crossReferenceTable = crossReferenceParser.Parse(inputBytes, isLenientParsing, crossReferenceOffset, version.OffsetInFile, pdfScanner, scanner); var(rootReference, rootDictionary) = ParseTrailer(crossReferenceTable, isLenientParsing, pdfScanner, out var encryptionDictionary); var encryptionHandler = encryptionDictionary != null ? (IEncryptionHandler) new EncryptionHandler(encryptionDictionary, crossReferenceTable.Trailer, passwords) : NoOpEncryptionHandler.Instance; pdfScanner.UpdateEncryptionHandler(encryptionHandler); var cidFontFactory = new CidFontFactory(pdfScanner, filterProvider); var encodingReader = new EncodingReader(pdfScanner); var type1Handler = new Type1FontHandler(pdfScanner, filterProvider, encodingReader); var fontFactory = new FontFactory(log, new Type0FontHandler(cidFontFactory, filterProvider, pdfScanner), new TrueTypeFontHandler(log, pdfScanner, filterProvider, encodingReader, SystemFontFinder.Instance, type1Handler), type1Handler, new Type3FontHandler(pdfScanner, filterProvider, encodingReader)); var resourceContainer = new ResourceStore(pdfScanner, fontFactory); DocumentInformation information = null; try { information = DocumentInformationFactory.Create(pdfScanner, crossReferenceTable.Trailer); } catch { } var catalog = CatalogFactory.Create(rootReference, rootDictionary, pdfScanner, isLenientParsing); var pageFactory = new PageFactory(pdfScanner, resourceContainer, filterProvider, new PageContentParser(new ReflectionGraphicsStateOperationFactory()), log); var caching = new ParsingCachingProviders(resourceContainer); var acroFormFactory = new AcroFormFactory(pdfScanner, filterProvider, crossReferenceTable); var bookmarksProvider = new BookmarksProvider(log, pdfScanner); return(new PdfDocument(log, inputBytes, version, crossReferenceTable, caching, pageFactory, catalog, information, encryptionDictionary, pdfScanner, filterProvider, acroFormFactory, bookmarksProvider, clipPaths)); }
public IList <ProjectCompany> GetCompanies(IList <Project> projects) { var p = projects[0]; var modifiedDate = new DateTime(2016, 12, 06); var docInfo = new DocumentInformation { DocumentCodeId = 11, SeriesAndNumber = "4513105699", IssueDate = DateTime.UtcNow, IssuePlace = "УФМС России по гор.Москве по району Басманный" }; var ic = new IndividualCompany { INN = 1212121333, Surname = "Иванов", Name = "Иван", MiddleName = "Иванович", BirthDate = new DateTime(1970, 1, 1), GenderCodeId = 1, BirthPlace = "Москва", VerifedPersonalityDocInfo = docInfo, ConfirmedPersonalityDocInfo = docInfo, RussianLocationCodeId = 1, RegionCodeId = 77, PostIndex = "105094", District = "Басманный", City = "Москва", CityType = "", Street = "Госпитальная набережная", HouseNumber = "4", BuildingNumber = "1а", AppartamentNumber = "125", ForeignCountryCodeId = 185, ForeignAddress = "" }; var flc = new ForeignLightCompany { Number = "ИО4", ForeignOrganizationalFormCodeId = 5, EnglishName = "International company", RussianName = "Интернейшнл кампани", FoundDate = new DateTime(2010, 12, 12), RequisitesEng = "Regulation 45", RequisitesRus = "Устав 45", CountryCodeId = 39, RegNumber = "1212121", OtherInfo = "-" }; var dc1 = new DomesticCompany { Number = "РО1", FullName = "Управляющая компания", OGRN = 3333333333333, INN = 3333333333333, KPP = "333333333", IsPublic = false }; var dc2 = new DomesticCompany { Number = "РО2", FullName = "Публичное акционерное общество Группа компаний", OGRN = 22222222, INN = 222222222222, KPP = "222222222", IsPublic = true }; var dc3 = new DomesticCompany { Number = "РО3", FullName = "Торговая компания", OGRN = 3333333333, INN = 333333333, KPP = "333333333", IsPublic = false }; var fc1 = new ForeignCompany { CountryCodeId = 29, Number = "ИО1", Name = "Finance Company BVI", FullName = "Файненс Кампани БиВиАй", RegistrationNumber = "123456", Address = "BVI, Ridge Rd 340" }; var fc2 = new ForeignCompany { CountryCodeId = 57, Number = "ИО2", Name = "Cyprus Investments limited", FullName = "Сайпрус Инвестментс лимитед", RegistrationNumber = "55555555", Address = "Limassol, Odos Troyas 34" }; var fc3 = new ForeignCompany { CountryCodeId = 39, Number = "ИО3", Name = "Cayman company", FullName = "Каймаг Лоджистик кампани", RegistrationNumber = "122222", Address = "Cayman Iceland, Bodden town 61" }; return(new List <ProjectCompany>() { new ProjectCompany { Project = p, ModifiedDate = modifiedDate, Name = "Управляющая компания", State = State.Domestic, IsResident = true, IsControlCompany = true, IsKIKCompany = true, DomesticCompany = dc1 }, new ProjectCompany { Project = p, ModifiedDate = modifiedDate, Name = "Finance Company BVI", State = State.Foreign, IsResident = false, IsControlCompany = false, IsKIKCompany = true, ForeignCompany = fc1 }, new ProjectCompany { Project = p, ModifiedDate = modifiedDate, Name = "Cyprus Investments Ltd", State = State.Foreign, IsResident = false, IsControlCompany = false, IsKIKCompany = true, ForeignCompany = fc2 }, new ProjectCompany { Project = p, ModifiedDate = modifiedDate, Name = "Cayman Company", State = State.Foreign, IsResident = false, IsControlCompany = false, IsKIKCompany = true, ForeignCompany = fc3 }, new ProjectCompany { Project = p, ModifiedDate = modifiedDate, Name = "International company", State = State.ForeignLight, IsResident = false, IsControlCompany = false, IsKIKCompany = true, ForeignLightCompany = flc }, new ProjectCompany { Project = p, ModifiedDate = modifiedDate, Name = "Иванов И.И.", State = State.Individual, IsResident = true, IsControlCompany = true, IsKIKCompany = true, IndividualCompany = ic }, new ProjectCompany { Project = p, ModifiedDate = modifiedDate, Name = "ПАО ГК", State = State.Domestic, IsResident = true, IsControlCompany = true, IsKIKCompany = true, DomesticCompany = dc2 }, new ProjectCompany { Project = p, ModifiedDate = modifiedDate, Name = "Торговая компания", State = State.Domestic, IsResident = true, IsControlCompany = true, IsKIKCompany = true, DomesticCompany = dc3 }, }); }
public void TestInitialize() { m_doc = new Document(); m_doc.Pages.Add(new Page(PaperFormat.A4)); m_docInfo = m_doc.DocumentInfo; }
public void RestoreFromZippedFile(ZipArchive zipFile, Altaxo.Serialization.Xml.XmlStreamDeserializationInfo info) { var errorText = new System.Text.StringBuilder(); foreach (var zipEntry in zipFile.Entries) { try { if (zipEntry.FullName.StartsWith("Tables/")) { using (var zipinpstream = zipEntry.Open()) { info.BeginReading(zipinpstream); object readedobject = info.GetValue("Table", null); if (readedobject is Altaxo.Data.DataTable) { _dataTables.Add((Altaxo.Data.DataTable)readedobject); } info.EndReading(); } } else if (zipEntry.FullName.StartsWith("Graphs/")) { using (var zipinpstream = zipEntry.Open()) { info.BeginReading(zipinpstream); object readedobject = info.GetValue("Graph", null); if (readedobject is Graph.Gdi.GraphDocument) { _graphs.Add((Graph.Gdi.GraphDocument)readedobject); } info.EndReading(); } } else if (zipEntry.FullName.StartsWith("Graphs3D/")) { using (var zipinpstream = zipEntry.Open()) { info.BeginReading(zipinpstream); object readedobject = info.GetValue("Graph", null); if (readedobject is Graph.Graph3D.GraphDocument) { _graphs3D.Add((Graph.Graph3D.GraphDocument)readedobject); } info.EndReading(); } } else if (zipEntry.FullName.StartsWith("Texts/")) { using (var zipinpstream = zipEntry.Open()) { info.BeginReading(zipinpstream); object readedobject = info.GetValue("Text", null); if (readedobject is Text.TextDocument noteDoc) { _textDocuments.Add(noteDoc); } info.EndReading(); } } else if (zipEntry.FullName.StartsWith("TableLayouts/")) { using (var zipinpstream = zipEntry.Open()) { info.BeginReading(zipinpstream); object readedobject = info.GetValue("WorksheetLayout", null); if (readedobject is Altaxo.Worksheet.WorksheetLayout) { _tableLayouts.Add((Altaxo.Worksheet.WorksheetLayout)readedobject); } info.EndReading(); } } else if (zipEntry.FullName.StartsWith("FitFunctionScripts/")) { using (var zipinpstream = zipEntry.Open()) { info.BeginReading(zipinpstream); object readedobject = info.GetValue("FitFunctionScript", null); if (readedobject is Altaxo.Scripting.FitFunctionScript) { _fitFunctionScripts.Add((Altaxo.Scripting.FitFunctionScript)readedobject); } info.EndReading(); } } else if (zipEntry.FullName.StartsWith("FolderProperties/")) { using (var zipinpstream = zipEntry.Open()) { info.BeginReading(zipinpstream); object readedobject = info.GetValue("FolderProperty", null); if (readedobject is Altaxo.Main.Properties.ProjectFolderPropertyDocument) { _projectFolderProperties.Add((Altaxo.Main.Properties.ProjectFolderPropertyDocument)readedobject); } info.EndReading(); } } else if (zipEntry.FullName == "DocumentInformation.xml") { using (var zipinpstream = zipEntry.Open()) { info.BeginReading(zipinpstream); object readedobject = info.GetValue("DocumentInformation", null); if (readedobject is DocumentInformation) { _documentInformation = (DocumentInformation)readedobject; } info.EndReading(); } } } catch (Exception exc) { errorText.Append("Error deserializing "); errorText.Append(zipEntry.Name); errorText.Append(", "); errorText.Append(exc.ToString()); } } try { info.AnnounceDeserializationEnd(this, false); } catch (Exception exc) { errorText.Append(exc.ToString()); } if (errorText.Length != 0) { throw new ApplicationException(errorText.ToString()); } }
/// <summary> /// Builds a PDF document from the current content of this builder and its pages. /// </summary> /// <returns>The bytes of the resulting PDF document.</returns> public byte[] Build() { var fontsWritten = new Dictionary <Guid, ObjectToken>(); using (var memory = new MemoryStream()) { // Header WriteString("%PDF-1.7", memory); // Files with binary data should contain a 2nd comment line followed by 4 bytes with values > 127 memory.WriteText("%"); memory.WriteByte(169); memory.WriteByte(205); memory.WriteByte(196); memory.WriteByte(210); memory.WriteNewLine(); // Body foreach (var font in fonts) { var fontObj = font.Value.FontProgram.WriteFont(font.Value.FontKey.Name, memory, context); fontsWritten.Add(font.Key, fontObj); } foreach (var image in images) { var streamToken = new StreamToken(image.Value.StreamDictionary, image.Value.StreamData); context.WriteObject(memory, streamToken, image.Value.ObjectNumber); } var procSet = new List <NameToken> { NameToken.Create("PDF"), NameToken.Text, NameToken.ImageB, NameToken.ImageC, NameToken.ImageI }; var resources = new Dictionary <NameToken, IToken> { { NameToken.ProcSet, new ArrayToken(procSet) } }; if (fontsWritten.Count > 0) { var fontsDictionary = new DictionaryToken(fontsWritten.Select(x => (fonts[x.Key].FontKey.Name, (IToken) new IndirectReferenceToken(x.Value.Number))) .ToDictionary(x => x.Item1, x => x.Item2)); var fontsDictionaryRef = context.WriteObject(memory, fontsDictionary); resources.Add(NameToken.Font, new IndirectReferenceToken(fontsDictionaryRef.Number)); } var reserved = context.ReserveNumber(); var parentIndirect = new IndirectReferenceToken(new IndirectReference(reserved, 0)); var pageReferences = new List <IndirectReferenceToken>(); foreach (var page in pages) { var individualResources = new Dictionary <NameToken, IToken>(resources); var pageDictionary = new Dictionary <NameToken, IToken> { { NameToken.Type, NameToken.Page }, { NameToken.MediaBox, RectangleToArray(page.Value.PageSize) }, { NameToken.Parent, parentIndirect } }; if (page.Value.Resources.Count > 0) { foreach (var kvp in page.Value.Resources) { // TODO: combine resources if value is dictionary or array, otherwise overwrite. individualResources[kvp.Key] = kvp.Value; } } pageDictionary[NameToken.Resources] = new DictionaryToken(individualResources); if (page.Value.Operations.Count > 0) { var contentStream = WriteContentStream(page.Value.Operations); var contentStreamObj = context.WriteObject(memory, contentStream); pageDictionary[NameToken.Contents] = new IndirectReferenceToken(contentStreamObj.Number); } var pageRef = context.WriteObject(memory, new DictionaryToken(pageDictionary)); pageReferences.Add(new IndirectReferenceToken(pageRef.Number)); } var pagesDictionaryData = new Dictionary <NameToken, IToken> { { NameToken.Type, NameToken.Pages }, { NameToken.Kids, new ArrayToken(pageReferences) }, { NameToken.Count, new NumericToken(pageReferences.Count) } }; var pagesDictionary = new DictionaryToken(pagesDictionaryData); var pagesRef = context.WriteObject(memory, pagesDictionary, reserved); var catalogDictionary = new Dictionary <NameToken, IToken> { { NameToken.Type, NameToken.Catalog }, { NameToken.Pages, new IndirectReferenceToken(pagesRef.Number) } }; if (ArchiveStandard != PdfAStandard.None) { Func <IToken, ObjectToken> writerFunc = x => context.WriteObject(memory, x); PdfABaselineRuleBuilder.Obey(catalogDictionary, writerFunc, DocumentInformation, ArchiveStandard); switch (ArchiveStandard) { case PdfAStandard.A1A: PdfA1ARuleBuilder.Obey(catalogDictionary); break; case PdfAStandard.A2B: break; case PdfAStandard.A2A: PdfA1ARuleBuilder.Obey(catalogDictionary); break; } } var catalog = new DictionaryToken(catalogDictionary); var catalogRef = context.WriteObject(memory, catalog); var informationReference = default(IndirectReference?); if (IncludeDocumentInformation) { var informationDictionary = DocumentInformation.ToDictionary(); if (informationDictionary.Count > 0) { var dictionary = new DictionaryToken(informationDictionary); informationReference = context.WriteObject(memory, dictionary).Number; } } TokenWriter.WriteCrossReferenceTable(context.ObjectOffsets, catalogRef, memory, informationReference); return(memory.ToArray()); } }
///<summary> ///Default constructor. Creates a new document and, hence, a new model with one default page and one default layer. ///</summary> public Document() { mModel = new Model(); mInformation = new DocumentInformation(); }
///<summary> ///Default constructor. Creates a new document and, hence, a new model with one default page and one default layer. ///</summary> public Document() { mModel = new Model(); mInformation = new DocumentInformation(); }
/// <summary> /// Builds a PDF document from the current content of this builder and its pages. /// </summary> /// <returns>The bytes of the resulting PDF document.</returns> public byte[] Build() { var context = new BuilderContext(); var fontsWritten = new Dictionary <Guid, ObjectToken>(); using (var memory = new MemoryStream()) { // Header WriteString("%PDF-1.7", memory); // Files with binary data should contain a 2nd comment line followed by 4 bytes with values > 127 memory.WriteText("%"); memory.WriteByte(169); memory.WriteByte(205); memory.WriteByte(196); memory.WriteByte(210); memory.WriteNewLine(); // Body foreach (var font in fonts) { var fontObj = font.Value.FontProgram.WriteFont(font.Value.FontKey.Name, memory, context); fontsWritten.Add(font.Key, fontObj); } var resources = new Dictionary <NameToken, IToken> { { NameToken.ProcSet, new ArrayToken(new [] { NameToken.Create("PDF"), NameToken.Create("Text") }) } }; if (fontsWritten.Count > 0) { var fontsDictionary = new DictionaryToken(fontsWritten.Select(x => (fonts[x.Key].FontKey.Name, (IToken) new IndirectReferenceToken(x.Value.Number))) .ToDictionary(x => x.Item1, x => x.Item2)); var fontsDictionaryRef = context.WriteObject(memory, fontsDictionary); resources.Add(NameToken.Font, new IndirectReferenceToken(fontsDictionaryRef.Number)); } var reserved = context.ReserveNumber(); var parentIndirect = new IndirectReferenceToken(new IndirectReference(reserved, 0)); var pageReferences = new List <IndirectReferenceToken>(); foreach (var page in pages) { var pageDictionary = new Dictionary <NameToken, IToken> { { NameToken.Type, NameToken.Page }, { NameToken.Resources, new DictionaryToken(resources) }, { NameToken.MediaBox, RectangleToArray(page.Value.PageSize) }, { NameToken.Parent, parentIndirect } }; if (page.Value.Operations.Count > 0) { var contentStream = WriteContentStream(page.Value.Operations); var contentStreamObj = context.WriteObject(memory, contentStream); pageDictionary[NameToken.Contents] = new IndirectReferenceToken(contentStreamObj.Number); } var pageRef = context.WriteObject(memory, new DictionaryToken(pageDictionary)); pageReferences.Add(new IndirectReferenceToken(pageRef.Number)); } var pagesDictionary = new DictionaryToken(new Dictionary <NameToken, IToken> { { NameToken.Type, NameToken.Pages }, { NameToken.Kids, new ArrayToken(pageReferences) }, { NameToken.Count, new NumericToken(pageReferences.Count) } }); var pagesRef = context.WriteObject(memory, pagesDictionary, reserved); var catalog = new DictionaryToken(new Dictionary <NameToken, IToken> { { NameToken.Type, NameToken.Catalog }, { NameToken.Pages, new IndirectReferenceToken(pagesRef.Number) } }); var catalogRef = context.WriteObject(memory, catalog); var informationReference = default(IndirectReference?); if (IncludeDocumentInformation) { var informationDictionary = DocumentInformation.ToDictionary(); if (informationDictionary.Count > 0) { var dictionary = new DictionaryToken(informationDictionary); informationReference = context.WriteObject(memory, dictionary).Number; } } TokenWriter.WriteCrossReferenceTable(context.ObjectOffsets, catalogRef, memory, informationReference); return(memory.ToArray()); } }
public Message InsertOrUpdateWithoutIdentity(Question question, HttpPostedFileBase httpPostedFileBase) { Message message; try { using (var scope = new TransactionScope()) { _dbContext.SqlConnection.Open(); var isExistQuestion = _iQuestionRepository.Get(question); var affectedRow = 0; var guid = Guid.NewGuid(); if (isExistQuestion == null) { affectedRow = _iQuestionRepository.InsertWithoutIdentity(question); #region Question Answer Option - Insert foreach (var answerOption in question.QuestionAnswerOptionList) { answerOption.QuestionId = question.QuestionId; _iQuestionAnswerOptionRepository.InsertWithoutIdentity(answerOption); } #endregion message = affectedRow > 0 ? SetMessage.SetSuccessMessage("Information has been saved successfully.") : SetMessage.SetInformationMessage("No data has been saved."); } else { affectedRow = _iQuestionRepository.Update(question); #region Question Answer Option - Update foreach (var answerOption in question.QuestionAnswerOptionList) { answerOption.QuestionId = question.QuestionId; _iQuestionAnswerOptionRepository.Update(answerOption); } #endregion message = affectedRow > 0 ? SetMessage.SetSuccessMessage("Information has been updated successfully.") : SetMessage.SetInformationMessage("No data has been updated."); } #region Question Answer Image if (httpPostedFileBase != null) { var file = httpPostedFileBase; var target = new MemoryStream(); var documentInformatio = new DocumentInformation(); file.InputStream.CopyTo(target); byte[] byteData = target.ToArray(); ImageUtility imageUtility = new ImageUtility(); if (isExistQuestion == null) { #region Insert Document Information var size = imageUtility.GetPreferredImageSize(ImageDimensions.Common); byte[] byteAfterResize = imageUtility.EnforceResize(size.Width, size.Height, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName)); documentInformatio.DocumentName = guid + Path.GetExtension(httpPostedFileBase.FileName); documentInformatio.DocumentByte = byteAfterResize; documentInformatio.DocumentSize = byteAfterResize.Length; _iDocumentInformationRepository.InsertWithoutIdentity(documentInformatio); #region Question - GlobalId Update question.QuestionImageName = (httpPostedFileBase != null ? guid + Path.GetExtension(httpPostedFileBase.FileName) : null); question.GlobalId = documentInformatio.GlobalId > 0 ? documentInformatio.GlobalId : 0; affectedRow = _iQuestionRepository.Update(question); #endregion #endregion } else { #region Update Document Information var isExistDocumentInformatio = _iDocumentInformationRepository.Get(new DocumentInformation { GlobalId = isExistQuestion.GlobalId }); if (isExistDocumentInformatio != null) { var size = imageUtility.GetPreferredImageSize(ImageDimensions.Common); byte[] byteAfterResize = imageUtility.EnforceResize(size.Width, size.Height, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName)); isExistDocumentInformatio.DocumentName = guid + Path.GetExtension(httpPostedFileBase.FileName); isExistDocumentInformatio.DocumentByte = byteAfterResize; isExistDocumentInformatio.DocumentSize = byteAfterResize.Length; _iDocumentInformationRepository.Update(isExistDocumentInformatio); } #endregion } #region Image Resize and Save To Path string folderPath = HttpContext.Current.Server.MapPath(Constants.ImagePath.ImageFolderPath); if (httpPostedFileBase != null) { bool isUpload = imageUtility.ImageSaveToPath(folderPath, byteData, guid + Path.GetExtension(httpPostedFileBase.FileName), ImageDimensions.Common); } #endregion } #endregion scope.Complete(); } } catch (Exception exception) { return(SetMessage.SetErrorMessage(exception.Message)); } finally { _dbContext.SqlConnection.Close(); } return(message); }
public static void SerializeDocumentInformation(DocumentInformation value, IFhirWriter writer) { writer.WriteStartComplexContent(); // Serialize element's localId attribute if (value.InternalId != null && !String.IsNullOrEmpty(value.InternalId.Contents)) { writer.WriteRefIdContents(value.InternalId.Contents); } // Serialize element extension if (value.Extension != null && value.Extension.Count > 0) { writer.WriteStartArrayElement("extension"); foreach (var item in value.Extension) { writer.WriteStartArrayMember("extension"); ExtensionSerializer.SerializeExtension(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element id if (value.Id != null) { writer.WriteStartElement("id"); IdentifierSerializer.SerializeIdentifier(value.Id, writer); writer.WriteEndElement(); } // Serialize element versionId if (value.VersionId != null) { writer.WriteStartElement("versionId"); IdentifierSerializer.SerializeIdentifier(value.VersionId, writer); writer.WriteEndElement(); } // Serialize element created if (value.Created != null) { writer.WriteStartElement("created"); InstantSerializer.SerializeInstant(value.Created, writer); writer.WriteEndElement(); } // Serialize element class if (value.Class != null) { writer.WriteStartElement("class"); CodingSerializer.SerializeCoding(value.Class, writer); writer.WriteEndElement(); } // Serialize element type if (value.Type != null) { writer.WriteStartElement("type"); CodeableConceptSerializer.SerializeCodeableConcept(value.Type, writer); writer.WriteEndElement(); } // Serialize element title if (value.Title != null) { writer.WriteStartElement("title"); FhirStringSerializer.SerializeFhirString(value.Title, writer); writer.WriteEndElement(); } // Serialize element confidentiality if (value.Confidentiality != null) { writer.WriteStartElement("confidentiality"); CodingSerializer.SerializeCoding(value.Confidentiality, writer); writer.WriteEndElement(); } // Serialize element subject if (value.Subject != null) { writer.WriteStartElement("subject"); ResourceReferenceSerializer.SerializeResourceReference(value.Subject, writer); writer.WriteEndElement(); } // Serialize element author if (value.Author != null && value.Author.Count > 0) { writer.WriteStartArrayElement("author"); foreach (var item in value.Author) { writer.WriteStartArrayMember("author"); ResourceReferenceSerializer.SerializeResourceReference(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element attester if (value.Attester != null && value.Attester.Count > 0) { writer.WriteStartArrayElement("attester"); foreach (var item in value.Attester) { writer.WriteStartArrayMember("attester"); DocumentInformationSerializer.SerializeDocumentInformationAttesterComponent(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element custodian if (value.Custodian != null) { writer.WriteStartElement("custodian"); ResourceReferenceSerializer.SerializeResourceReference(value.Custodian, writer); writer.WriteEndElement(); } // Serialize element event if (value.Event != null) { writer.WriteStartElement("event"); DocumentInformationSerializer.SerializeDocumentInformationEventComponent(value.Event, writer); writer.WriteEndElement(); } // Serialize element encounter if (value.Encounter != null) { writer.WriteStartElement("encounter"); ResourceReferenceSerializer.SerializeResourceReference(value.Encounter, writer); writer.WriteEndElement(); } // Serialize element facilityType if (value.FacilityType != null) { writer.WriteStartElement("facilityType"); CodeableConceptSerializer.SerializeCodeableConcept(value.FacilityType, writer); writer.WriteEndElement(); } // Serialize element practiceSetting if (value.PracticeSetting != null) { writer.WriteStartElement("practiceSetting"); CodeableConceptSerializer.SerializeCodeableConcept(value.PracticeSetting, writer); writer.WriteEndElement(); } writer.WriteEndComplexContent(); }
/// <summary> /// Parse DocumentInformation /// </summary> public static DocumentInformation ParseDocumentInformation(IFhirReader reader, ErrorList errors, DocumentInformation existingInstance = null) { DocumentInformation result = existingInstance != null ? existingInstance : new DocumentInformation(); try { string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { // Parse element extension if (ParserUtils.IsAtFhirElement(reader, "extension")) { result.Extension = new List <Extension>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "extension")) { result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); } reader.LeaveArray(); } // Parse element internalId else if (reader.IsAtRefIdElement()) { result.InternalId = Id.Parse(reader.ReadRefIdContents()); } // Parse element id else if (ParserUtils.IsAtFhirElement(reader, "id")) { result.Id = IdentifierParser.ParseIdentifier(reader, errors); } // Parse element versionId else if (ParserUtils.IsAtFhirElement(reader, "versionId")) { result.VersionId = IdentifierParser.ParseIdentifier(reader, errors); } // Parse element created else if (ParserUtils.IsAtFhirElement(reader, "created")) { result.Created = InstantParser.ParseInstant(reader, errors); } // Parse element class else if (ParserUtils.IsAtFhirElement(reader, "class")) { result.Class = CodingParser.ParseCoding(reader, errors); } // Parse element type else if (ParserUtils.IsAtFhirElement(reader, "type")) { result.Type = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element title else if (ParserUtils.IsAtFhirElement(reader, "title")) { result.Title = FhirStringParser.ParseFhirString(reader, errors); } // Parse element confidentiality else if (ParserUtils.IsAtFhirElement(reader, "confidentiality")) { result.Confidentiality = CodingParser.ParseCoding(reader, errors); } // Parse element subject else if (ParserUtils.IsAtFhirElement(reader, "subject")) { result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element author else if (ParserUtils.IsAtFhirElement(reader, "author")) { result.Author = new List <ResourceReference>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "author")) { result.Author.Add(ResourceReferenceParser.ParseResourceReference(reader, errors)); } reader.LeaveArray(); } // Parse element attester else if (ParserUtils.IsAtFhirElement(reader, "attester")) { result.Attester = new List <DocumentInformation.DocumentInformationAttesterComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "attester")) { result.Attester.Add(DocumentInformationParser.ParseDocumentInformationAttesterComponent(reader, errors)); } reader.LeaveArray(); } // Parse element custodian else if (ParserUtils.IsAtFhirElement(reader, "custodian")) { result.Custodian = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element event else if (ParserUtils.IsAtFhirElement(reader, "event")) { result.Event = DocumentInformationParser.ParseDocumentInformationEventComponent(reader, errors); } // Parse element encounter else if (ParserUtils.IsAtFhirElement(reader, "encounter")) { result.Encounter = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element facilityType else if (ParserUtils.IsAtFhirElement(reader, "facilityType")) { result.FacilityType = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element practiceSetting else if (ParserUtils.IsAtFhirElement(reader, "practiceSetting")) { result.PracticeSetting = CodeableConceptParser.ParseCodeableConcept(reader, errors); } else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); } catch (Exception ex) { errors.Add(ex.Message, reader); } return(result); }