public Document(String attachmentFile, String originalName, String saveToPath, String batchNumber, long emailID, DocumentSource source) { Fields = new Dictionary <String, String>(); this.saveToPath = saveToPath; this.batchNumber = batchNumber; this.emailID = emailID; OriginalName = originalName; RelativePath = Path.GetFileName(saveToPath); AttachmentFile = attachmentFile; Extension = Path.GetExtension(attachmentFile).Trim('.', ' ').ToLower(); Source = source; ErrorHandling = new ErrorHandling(); options = new ImageConversionOptions(saveToPath, RelativePath); Complete = false; Success = false; IsBody = (source == DocumentSource.Body); ShouldRetry = true; Fields.Add("%Document.Source", source.ToString()); Fields.Add("%Document.IsBody", IsBody.ToString()); Fields.Add("%Document.Extension", Extension); Fields.Add("%Document.AttachmentFileName", OriginalName); Fields.Add("%Document.FailureReason", String.Empty); }
/// <summary> /// Open attachments /// </summary> /// <returns></returns> private async Task GetDocumentsAsync() { DocumentSource senderSource = LocalTask.Source switch { TOriginTask.ManagementCenterPrevious => DocumentSource.MgCenterEventTask, TOriginTask.ManagementCenterDuring => DocumentSource.MgCenterEventTask, TOriginTask.ManagementCenterPost => DocumentSource.MgCenterEventTask, TOriginTask.Assignment => DocumentSource.MgCenterDirectTask, TOriginTask.Instruction => DocumentSource.MgCenterInstructionTask, TOriginTask.ManagementCenterRequest => DocumentSource.MgCenterRequestTask, TOriginTask.PersonalAgenda => DocumentSource.AgendaTask, TOriginTask.CommunicativeAction => DocumentSource.CummunicationalTask, TOriginTask.GovernmentActionProgram => DocumentSource.GoalTask, TOriginTask.Task => DocumentSource.AgendaTask, _ => DocumentSource.None }; var mainViewModel = MainViewModel.GetInstance(); mainViewModel.Attachments = new AttachmentsViewModel( this.LocalTask.Id, this.LocalTask.Instrument, senderSource); await App.Navigator.PushAsync(new AttachmentsPage() { Title = Languages.Attachments }); }
/// <summary> /// Begins the work. /// </summary> protected override void BeginWork() { BootParameters.ShouldNotBe(null); base.BeginWork(); _documentSource = (DocumentSource)XmlUtility.DeserializeObject(BootParameters, typeof(DocumentSource)); }
/// <summary> /// Parses the document /// </summary> private void ParseDocument() { InitialContainer root = this; MatchCollection tags = Parser.Match(Parser.HtmlTag, DocumentSource); CssBox curBox = root; int lastEnd = -1; foreach (Match tagmatch in tags) { string text = tagmatch.Index > 0 ? DocumentSource.Substring(lastEnd + 1, tagmatch.Index - lastEnd - 1) : string.Empty; if (!string.IsNullOrEmpty(text.Trim())) { CssAnonymousBox abox = new CssAnonymousBox(curBox) { Text = text }; } else if (text != null && text.Length > 0) { CssAnonymousSpaceBox sbox = new CssAnonymousSpaceBox(curBox) { Text = text }; } HtmlTag tag = new HtmlTag(tagmatch.Value); if (tag.IsClosing) { curBox = FindParent(tag.TagName, curBox); } else if (tag.IsSingle) { CssBox foo = new CssBox(curBox, tag); } else { curBox = new CssBox(curBox, tag); } lastEnd = tagmatch.Index + tagmatch.Length - 1; } string finaltext = DocumentSource.Substring((lastEnd > 0 ? lastEnd + 1 : 0), DocumentSource.Length - lastEnd - 1 + (lastEnd == 0 ? 1 : 0)); if (!string.IsNullOrEmpty(finaltext)) { CssAnonymousBox abox = new CssAnonymousBox(curBox) { Text = finaltext }; } }
private async void PrintWithoutPdfViewButton_Click(object sender, RoutedEventArgs e) { var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri ("ms-appx:///Assets/pdfs/PSPDFKit.pdf")); var documentSource = DocumentSource.CreateFromStorageFile(file); var printHelper = await PrintHelper.CreatePrintHelperFromSourceAsync(documentSource, this, "PrintCanvas", "PrintWithoutUI"); await printHelper.ShowPrintUIAsync(); }
public NSwagClientAttribute(DeclarationType type, DocumentSource documentSource, string documentPath) { Source = documentSource; if (documentPath == null) { throw new ArgumentNullException(nameof(documentPath)); } DocumentPath = documentPath; Type = type; }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual DocumentSource GetDocumentSource([NotNull] IEntityType entityType) { if (!_documentCollections.TryGetValue(entityType, out var documentSource)) { _documentCollections.Add( entityType, documentSource = new DocumentSource(entityType, this)); } return(documentSource); }
/// <summary> /// Generates the message. /// </summary> /// <returns></returns> protected override bool GenerateMessage() { DocumentSource docSource = GetJobParams(BootParameters); var analyticIndex = new AnalyticalIndex(); docSource.ShouldNotBe(null); analyticIndex.ProgressChanged += IndexDocumentsProgressChanged; analyticIndex.IndexDocuments(docSource, WorkAssignment.JobId, WorkAssignment.ScheduleCreatedBy); return(true); }
public DecodingAsyncTask(DocumentSource docSource, string password, int[] userPages, PdfView pdfView, PdfiumCore pdfiumCore) { this.docSource = docSource; this.userPages = userPages; this.cancelled = false; this.pdfView = pdfView; this.password = password; this.pdfiumCore = pdfiumCore; token = tokenSource.Token; }
static object GetKeyValue(DocumentSource source) { if (source.Key is ContentNumber n) { return(new long?(decimal.ToInt64(n.Value))); } if (source.Key is ContentText t) { return(t.Value); } throw new NotSupportedException("Key type not supported"); }
public void Load(DocumentSource docSource, string password, int[] userPages) { if (!IsRecycled) { throw new IllegalStateException("Don't call load on a PDF View without recycling it first."); } IsRecycled = false; // Start decoding document decodingAsyncTask = new DecodingAsyncTask(docSource, password, userPages, this, pdfiumCore); decodingAsyncTask.Run(); }
static string GetKeyFieldName(DocumentSource source) { if (source.Key is ContentNumber) { return(nameof(DbDoc.SourceIdNumber)); } if (source.Key is ContentText) { return(nameof(DbDoc.SourceIdString)); } throw new NotSupportedException("Key type not supported"); }
} // getColumnBuilder() // @Override public void offerSource(DocumentSource documentSource) { while (getObservationCount() < MAX_SAMPLE_SIZE) { Document map = documentSource.next(); if (map == null) { return; } addObservation(map); } }
/// <summary> /// Parses the document /// </summary> private void ParseDocument() { var root = this; var tags = Parser.Match(Parser.HtmlTag, DocumentSource); CssBox curBox = root; var lastEnd = -1; foreach (Match tagmatch in tags) { var text = tagmatch.Index > 0 ? DocumentSource.Substring(lastEnd + 1, tagmatch.Index - lastEnd - 1) : string.Empty; if (!string.IsNullOrEmpty(text.Trim())) { var abox = new CssAnonymousBox(curBox); abox.Text = text; } else if (text != null && text.Length > 0) { var sbox = new CssAnonymousSpaceBox(curBox); sbox.Text = text; } var tag = new HtmlTag(tagmatch.Value); if (tag.IsClosing) { curBox = FindParent(tag.TagName, curBox); } else if (tag.IsSingle) { var foo = new CssBox(curBox, tag); } else { curBox = new CssBox(curBox, tag); } lastEnd = tagmatch.Index + tagmatch.Length - 1; } var finaltext = DocumentSource.Substring(lastEnd > 0 ? lastEnd + 1 : 0, DocumentSource.Length - lastEnd - 1 + (lastEnd == 0 ? 1 : 0)); if (!string.IsNullOrEmpty(finaltext)) { var abox = new CssAnonymousBox(curBox); abox.Text = finaltext; } }
/// <summary> /// Take the file and call the conroller to open the document. /// </summary> /// <param name="file">File to open.</param> internal async void OpenFile(StorageFile file) { try { await _controller.ShowDocumentAsync(DocumentSource.CreateFromStorageFile(file)); } catch (Exception e) { // Show a dialog with the exception message. var dialog = new MessageDialog(e.Message); await dialog.ShowAsync(); } }
public double P_c(CategoryProbabilityDistribution trainingDistribution, DocumentSource testData, int n, double prob_c) { var result = Math.Log10(prob_c); var source = testData.LanguageSegments.ToArray(); for (int i = 0; i <= source.Length - n; i++) { string[] ngram = source.GetNGram(i, n); var logProb = Math.Log10(trainingDistribution.GetProbability(ngram)); result += logProb; } return(result); }
/// <summary> /// Open a PDF with a password without any UI interaction to provide the password. /// </summary> public async void OpenPdfViaApi() { PDFView.Controller.OnRequestPassword += Controller_OnRequestPassword; var file = await StorageFile.GetFileFromApplicationUriAsync( new Uri ("ms-appx:///Assets/pdfs/PSPDFKit_password_pspdfkit.pdf")); var documentSource = DocumentSource.CreateFromStorageFile(file); // Set the password in the document source. documentSource.Password = "******"; await PDFView.Controller.ShowDocumentAsync(documentSource); }
static Expression CreateKeyComparison(DocumentSource source, ParameterExpression p) { Expression lhs, rhs; lhs = Expression.PropertyOrField(p, nameof(DbDoc.SourceType)); rhs = Expression.Constant(source.Type.Name); var t1 = Expression.Equal(lhs, rhs); lhs = Expression.PropertyOrField(p, GetKeyFieldName(source)); rhs = Expression.Constant(GetKeyValue(source), source.Key is ContentNumber ? typeof(long?) : typeof(string)); var t2 = Expression.Equal(lhs, rhs); return(Expression.AndAlso(t1, t2)); }
public void MapppingOk() { TypeAdapterFactory.SetCurrent(GetRequiredService <ITypeAdapterFactory>()); var emails = new List <string> { "*****@*****.**", "*****@*****.**" }; var source = new DocumentSource { Name = "Say may name", Emails = emails }; var result = source.MapTo <DocumentTarget>(); result.Name.Should().Be(source.Name); result.Emails.Should().Equal(source.Emails, (o1, o2) => string.Compare(o1, o2, StringComparison.InvariantCultureIgnoreCase) == 0); }
public async void OpenPdfPicker() { try { PDFView.Controller.OnRequestPassword += Controller_OnRequestPassword; var file = await StorageFile.GetFileFromApplicationUriAsync( new Uri ("ms-appx:///Assets/pdfs/PSPDFKit_password_pspdfkit.pdf")); await PDFView.Controller.ShowDocumentAsync(DocumentSource.CreateFromStorageFile(file)); } catch (Exception e) { var messageDialog = new MessageDialog(e.Message); await messageDialog.ShowAsync(); } finally { PDFView.Controller.OnRequestPassword -= Controller_OnRequestPassword; } }
} // getMainSchemaName() public override DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) { DocumentConverter documentConverter = _schemaBuilder.getDocumentConverter(table); SelectItem[] selectItems = MetaModelHelper.createSelectItems(columns); DataSetHeader header = new CachingDataSetHeader(selectItems); DocumentSource documentSource = getDocumentSourceForTable(table.getName()); DataSet dataSet = new DocumentSourceDataSet(header, documentSource, documentConverter); if (maxRows > 0) { dataSet = new MaxRowsDataSet(dataSet, maxRows); } return(dataSet); } // materializeMainSchemaTable()
public async void LoadDocument(object obj) { try { DocumentSource = await Common.LoadCamara("document"); DocumentResource = ImageSource.FromStream(() => { var stPassport = DocumentSource.GetStream(); return(stPassport); }); } catch (Exception ex) { Debug.WriteLine("Camera error: " + ex.Message); } }
static void Main(string[] args) { var documentSource = new DocumentSource() .AsLoggable( new ConsoleLogger(), new LoggingData { Name = "Department", Value = "A" }) .ApplyRetryAspect( numberOfRetries: 3, waitTimeBetweenRetries: TimeSpan.FromSeconds(5)); var result = documentSource.GetDocuments("docx"); Console.ReadLine(); }
/// <summary> /// Take the file and call the conroller to open the document. /// </summary> /// <param name="file">File to open.</param> internal async Task OpenFileAsync(StorageFile file) { _fileToOpen = file; if (_pdfViewInitialised) { try { await PDFView.Controller.ShowDocumentAsync(DocumentSource.CreateFromStorageFile(file)); } catch (Exception e) { // Show a dialog with the exception message. var dialog = new MessageDialog(e.Message); await dialog.ShowAsync(); } } }
} // offerSources() protected void offerDocumentSource(DocumentSource documentSource) { try { while (true) { Document document = documentSource.next(); if (document == null) { break; } String tableName = determineTable(document); addObservation(tableName, document); } } finally { documentSource.close(); } } // offerDocumentSource()
static DbDoc FindDocument(IEnumerable <DbDoc> docs, DocumentSource source) { var docsWithType = docs.Where(d => d.SourceType == source.Type.Name); if (source.Key is ContentNumber n) { var v = decimal.ToInt64(n.Value); docsWithType = docsWithType.Where(d => d.SourceIdNumber == v); } else if (source.Key is ContentText t) { docsWithType = docsWithType.Where(d => d.SourceIdString == t.Value); } else { throw new NotSupportedException("Document has a key of type that is not supported"); } return(docsWithType.FirstOrDefault()); }
} // constructor // @Override public void offerSources(DocumentSourceProvider documentSourceProvider) { DocumentSource document_source = documentSourceProvider.getMixedDocumentSourceForSampling(); try { while (true) { Document document = document_source.next(); if (document == null) { break; } string tableName = determineTable(document); addObservation(tableName, document); } } finally { document_source.close(); } } // offerSources()
private bool SaveDocument() { var urli = string.Format("https://api.onfido.com/v2/applicants/{0}/documents", ApplicationId); var httpContents = new List <ParameterEntity>() { new ParameterEntity { httpContent = new StringContent(DocumentType), Name = "\"type\"" } }; var fileContent = new StreamContent(DocumentSource.GetStream()); fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "file", FileName = "documentReview.png" }; fileContent.Headers.ContentType = new MediaTypeHeaderValue("image/png"); httpContents.Add(new ParameterEntity { httpContent = fileContent }); var authorization = string.Format("Token token={0}", Token); var response = Common.SendRequest(urli, httpContents, authorization, HttpMethod.Post); if (response) { return(true); } else { return(false); } }
public static List <Image> Scan(WIAScanQuality scanQuality, WIAPageSize pageSize, DocumentSource source) { WIA.ICommonDialog dialog = new WIA.CommonDialog(); WIA.Device device = dialog.ShowSelectDevice(WIA.WiaDeviceType.UnspecifiedDeviceType, true, false); if (device != null) { return(Scan(device.DeviceID, 1, scanQuality, pageSize, source)); } else { throw new Exception("You must select a device for scanning."); } }
/// <summary> /// Use scanner to scan an image (scanner is selected by its unique id). /// </summary> /// <param name="scannerName"></param> /// <returns>Scanned images.</returns> public static List <Image> Scan(string scannerId, int pages, WIAScanQuality quality, WIAPageSize pageSize, DocumentSource source) { List <Image> images = new List <Image>(); bool hasMorePages = true; int numbrPages = pages; while (hasMorePages) { // select the correct scanner using the provided scannerId parameter WIA.DeviceManager manager = new WIA.DeviceManager(); WIA.Device device = null; foreach (WIA.DeviceInfo info in manager.DeviceInfos) { if (info.DeviceID == scannerId) { // connect to scanner device = info.Connect(); break; } } // device was not found if (device == null) { // enumerate available devices string availableDevices = ""; foreach (WIA.DeviceInfo info in manager.DeviceInfos) { availableDevices += info.DeviceID + "\n"; } // show error with available devices throw new Exception("The device with provided ID could not be found. Available Devices:\n" + availableDevices); } SetWIAProperty(device.Properties, WIA_DEVICE_PROPERTY_PAGES_ID, 1); SetWIAProperty(device.Properties, WIA_DEVICE_SOURCE_SELECT_ID, source); WIA.Item item = device.Items[1] as WIA.Item; // adjust the scan settings int dpi; int width_pixels; int height_pixels; switch (quality) { case WIAScanQuality.Final: dpi = 300; break; default: throw new Exception("Unknown WIAScanQuality: " + quality.ToString()); } switch (pageSize) { case WIAPageSize.A4: width_pixels = (int)(8.3f * dpi); height_pixels = (int)(11.7f * dpi); break; case WIAPageSize.Letter: width_pixels = (int)(8.5f * dpi); height_pixels = (int)(11f * dpi); break; case WIAPageSize.Legal: width_pixels = (int)(8.5f * dpi); height_pixels = (int)(14f * dpi); break; default: throw new Exception("Unknown WIAPageSize: " + pageSize.ToString()); } AdjustScannerSettings(item, dpi, 0, 0, width_pixels, height_pixels, 0, 0, 1); try { // scan image WIA.ICommonDialog wiaCommonDialog = new WIA.CommonDialog(); WIA.ImageFile image = (WIA.ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatBMP, false); // save to temp file string fileName = Path.GetTempFileName(); File.Delete(fileName); image.SaveFile(fileName); image = null; // add file to output list images.Add(Image.FromFile(fileName)); } catch (Exception exc) { throw exc; } finally { item = null; //determine if there are any more pages waiting WIA.Property documentHandlingSelect = null; WIA.Property documentHandlingStatus = null; foreach (WIA.Property prop in device.Properties) { if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_SELECT) { documentHandlingSelect = prop; } if (prop.PropertyID == WIA_PROPERTIES.WIA_DPS_DOCUMENT_HANDLING_STATUS) { documentHandlingStatus = prop; } } // assume there are no more pages hasMorePages = false; // may not exist on flatbed scanner but required for feeder if (documentHandlingSelect != null) { // check for document feeder if ((Convert.ToUInt32(documentHandlingSelect.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER) != 0) { hasMorePages = ((Convert.ToUInt32(documentHandlingStatus.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_STATUS.FEED_READY) != 0); } } } numbrPages -= 1; if (numbrPages > 0) { hasMorePages = true; } else { hasMorePages = false; } } return(images); }
public DocumentBuilder FromFile (string fileName) { this.fileName = fileName; documentSource = new FileDocumentSource (fileName); return this; }
public DocumentBuilder FromStream (Stream contentStream, DocumentType type) { documentSource = new StreamDocumentSource (contentStream); fileName = DocumentTypeUtility.NormalizeName (type, name); return this; }
/// <summary> /// Add a new document source to the context /// </summary> /// <param name="source"></param> public void Add(DocumentSource source) { if (source == null) { throw new ArgumentNullException("source"); } string fieldValue = source.ToString(); this.Add(FieldNames.DocumentSource, fieldValue); }