private void btnFinalizar_Click(object sender, EventArgs e) { Controles.frmGauge gauge = new Controles.frmGauge(); gauge.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; gauge.pb.Minimum = 0; gauge.pb.Maximum = imagenesCapturadas.Images.Count - 1; gauge.pb.Value = 0; gauge.Show(); //Grabar y Cerrar el Formulario Cursor = Cursors.AppStarting; foreach (IScannedImage img in imagenesCapturadas.Images) { clsDocumento newDocumento = new clsDocumento("*"); newDocumento.idPadre = Convert.ToInt32(((Clases.clsNodoTiny)nodoActual.Tag).idNodo); newDocumento.idUnicoExpediente = Expediente.id; newDocumento.orden = 0; newDocumento.fijarImagen(img.GetImageBase64()); try { newDocumento.guardarDatos(Clases.vGlobales.id_User); } catch (InvalidOperationException er) { MessageBox.Show("Problemas al guardar Datos\n\r" + er.Message); Cursor = Cursors.Default; return; } try { newDocumento.guardarImagen(Clases.vGlobales.id_User); } catch (InvalidOperationException er) { MessageBox.Show("Problemas al guardar la Imagen\n\r" + er.Message); Cursor = Cursors.Default; return; } gauge.pb.PerformStep(); gauge.BringToFront(); System.Windows.Forms.Application.DoEvents(); } gauge.Close(); gauge.Dispose(); Cursor = Cursors.Default; bsalida = true; }
public bool Exportar(string archivo, DataTable images) { Controles.frmGauge gauge = new Controles.frmGauge(); gauge.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; gauge.pb.Minimum = 0; gauge.pb.Maximum = images.Rows.Count - 1; gauge.pb.Value = 0; gauge.Show(); var documento = new PdfDocument { PageLayout = PdfPageLayout.SinglePage }; documento.Info.Author = Autor; documento.Info.Subject = Subject; documento.Info.Creator = Creador; foreach (DataRow scannedImage in images.Rows) { using (MemoryStream stream = new MemoryStream(Convert.FromBase64String(scannedImage["Imagen"].ToString()))) using (Image image = Image.FromStream(stream)) using (var img = new Bitmap(image)) { float hAdjust = 72 / img.HorizontalResolution; float vAdjust = 72 / img.VerticalResolution; double realWidth = img.Width * hAdjust; double realHeight = img.Height * vAdjust; PdfPage newPage = documento.AddPage(); newPage.Width = (int)realWidth; newPage.Height = (int)realHeight; XGraphics gfx = XGraphics.FromPdfPage(newPage); //gfx.DrawImage(img, 0, 0, (int)realWidth, (int)realHeight); MemoryStream memoryStream = new MemoryStream(); img.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); //gfx.DrawImage(XImage.FromStream(memoryStream), 0, 0, (int)realWidth, (int)realHeight); gfx.DrawImage(XImage.FromStream(memoryStream), (double)0, (double)0, (double)realWidth, (double)realHeight); gauge.pb.PerformStep(); gauge.BringToFront(); System.Windows.Forms.Application.DoEvents(); } } documento.Save(archivo); gauge.Close(); gauge.Dispose(); return(true); }
private void Delete() { if (SelectedImages.ToList().Count < 1) { return; } if (MessageBox.Show(string.Format("Realmente desea borrar {0} imagenes?", SelectedImages.ToList().Count), "Borrar...", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Cursor = Cursors.AppStarting; Controles.frmGauge gauge = new Controles.frmGauge(); gauge.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; gauge.pb.Minimum = 0; gauge.pb.Maximum = SelectedImages.ToList().Count - 1; gauge.pb.Value = 0; gauge.Show(); // Se procede a elimiar las imagenes Seleccionadas de la B.D. foreach (IScannedImage scannedImage in SelectedImages.ToList()) { // Borrar o Desactivar de la B.D. parametros = "|V1=" + scannedImage.Tag.ToString() + "|C1=" + Clases.vGlobales.id_User + "|C3=" + Environment.UserName.ToString() + "/" + Environment.MachineName.ToString(); Datos = Acceso.ivkProcedimiento("sp_Datos_Documentos", "5", parametros, Clases.vGlobales.conexion, null); imagenesDB.Images.Remove(scannedImage); gauge.pb.PerformStep(); gauge.BringToFront(); System.Windows.Forms.Application.DoEvents(); } tblImagenes.UpdateImages(imagenesDB.Images); gauge.Close(); gauge.Dispose(); Cursor = Cursors.Default; } }
public bool Exportar(string archivo, string idExpediente) { Controles.frmGauge gauge = new Controles.frmGauge(); gauge.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; gauge.pb.Style = System.Windows.Forms.ProgressBarStyle.Marquee; gauge.Show(); gauge.BringToFront(); var documento = new PdfDocument { PageLayout = PdfPageLayout.SinglePage }; documento.Info.Author = Autor; documento.Info.Subject = Subject; documento.Info.Creator = Creador; documento.Info.Title = "Poliza JAPAC - " + idExpediente; // Opciones de Seguridad documento.SecuritySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted128Bit; //documento.SecuritySettings.UserPassword = "******"; documento.SecuritySettings.OwnerPassword = "******"; documento.SecuritySettings.PermitExtractContent = false; documento.SecuritySettings.PermitAccessibilityExtractContent = false; documento.SecuritySettings.PermitAnnotations = false; documento.SecuritySettings.PermitAssembleDocument = false; documento.SecuritySettings.PermitFormsFill = false; documento.SecuritySettings.PermitFullQualityPrint = false; documento.SecuritySettings.PermitModifyDocument = false; documento.SecuritySettings.PermitPrint = false; string parametros; string validar; WSD2014.cRetorno Datos; WSD2014.WSDatosSoapClient Acceso = new WSD2014.WSDatosSoapClient(); int pagina = 1; try { while (true) { parametros = "|V2=" + idExpediente + "|PA=" + pagina.ToString() + "|RP=25|"; validar = "411"; Datos = new WSD2014.cRetorno(); Datos = Acceso.ivkProcedimiento("sp_Datos_Documentos", validar, parametros, Clases.vGlobales.conexion, null); if (Datos.ds.Tables[0].Rows.Count == 0) { break; } foreach (DataRow scannedImage in Datos.ds.Tables[0].Rows) { double r = Convert.ToDouble(scannedImage["resolucion"].ToString()); using (MemoryStream stream = new MemoryStream(Convert.FromBase64String(scannedImage["Imagen"].ToString()))) using (Image image = Image.FromStream(stream)) using (var img = new Bitmap(image, new Size((int)(image.Size.Width * r), (int)(image.Size.Height * r)))) { float hAdjust = 72 / img.HorizontalResolution; float vAdjust = 72 / img.VerticalResolution; double realWidth = img.Width * hAdjust; double realHeight = img.Height * vAdjust; PdfPage newPage = documento.AddPage(); newPage.Width = (int)realWidth; newPage.Height = (int)realHeight; XGraphics gfx = XGraphics.FromPdfPage(newPage); MemoryStream memoryStream = new MemoryStream(); img.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); //gfx.DrawImage(XImage.FromStream(memoryStream), 0, 0, (int)realWidth, (int)realHeight); gfx.DrawImage(XImage.FromStream(memoryStream), (double)0, (double)0, (double)realWidth, (double)realHeight); memoryStream.Dispose(); gauge.BringToFront(); System.Windows.Forms.Application.DoEvents(); } } pagina++; Datos = null; GC.Collect(); } } catch (OutOfMemoryException e) { string m = e.Message; } finally { if (documento.Pages.Count > 0) { documento.Save(archivo); } } gauge.Close(); gauge.Dispose(); return(true); }
private void btnFinalizar_Click(object sender, EventArgs e) { Cursor = Cursors.AppStarting; //Mandar Grabar los elementos en la Base de Datos //Grabar los Datos de los Expediente Clases.clsExpediente newExpediente = new Clases.clsExpediente("*"); newExpediente.idLlave = iTXTidUnico.Text.ToString().Trim(); newExpediente.idPadre = nodoBD.id; newExpediente.idFormulario = nodoBD.idFormulario.ToString(); try { newExpediente.guardarDatos(Clases.vGlobales.id_User); } catch (InvalidOperationException er) { MessageBox.Show("Problemas al guardar Datos\n\r" + er.Message); Cursor = Cursors.Default; return; } //Grabar los Campos del Expediente foreach (PropertyGridEx.CustomProperty p in PGExpediente.Item) { if (p.Value.ToString().Trim().Length != 0) { Clases.clsCampoDato campo = new Clases.clsCampoDato(Clases.clsCampoDato.TipoCampo.Expediente, newExpediente.id.ToString(), p.Tag.ToString()); campo.valor = p.Value.ToString(); if (!campo.guardarDatos(Clases.vGlobales.id_User)) { MessageBox.Show(campo.msgError, "Error al Guardar datos del Campo " + p.Tag); } } } //Grabar las imagenes en la Base de Datos //Por los Tipos de Documentos //Recorrer El arbol con los Tipos de Documentos. foreach (TreeNode nDocumento in tvTiposDocumentos.Nodes) { // Control de Avance de grabación Controles.frmGauge gauge = new Controles.frmGauge(); gauge.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; gauge.pb.Minimum = 0; gauge.pb.Maximum = imagenesCapturadas[nDocumento.Index].Images.Count - 1; gauge.pb.Value = 0; gauge.Show(); foreach (IScannedImage img in imagenesCapturadas[nDocumento.Index].Images) { clsDocumento newDocumento = new clsDocumento("*"); newDocumento.idPadre = Convert.ToInt16(nDocumento.Tag.ToString()); newDocumento.idUnicoExpediente = newExpediente.id; newDocumento.orden = imagenesCapturadas[nDocumento.Index].Images.IndexOf(img) + 1; newDocumento.fijarImagen(img.GetImageBase64()); try { newDocumento.guardarDatos(Clases.vGlobales.id_User); } catch (InvalidOperationException er) { MessageBox.Show("Problemas al guardar Datos\n\r" + er.Message); Cursor = Cursors.Default; return; } try { newDocumento.guardarImagen(Clases.vGlobales.id_User); } catch (InvalidOperationException er) { MessageBox.Show("Problemas al guardar la Imagen\n\r" + er.Message); Cursor = Cursors.Default; return; } gauge.pb.PerformStep(); gauge.BringToFront(); System.Windows.Forms.Application.DoEvents(); } gauge.Close(); gauge.Dispose(); } Cursor = Cursors.Default; bsalida = true; }