public ActionResult PDF(int id) { try { var documento = (from doc in _db.Documento join fin in _db.Finiquito on doc.id_novedad equals fin.id_novedad join nov in _db.Novedad on fin.id_novedad equals nov.id_novedad where doc.id_doc == id select doc.id_doc).ToList(); if (!documento.Any()) { throw new Exception("No existe un documento asociado a ese registro"); } var id_doc = documento.First(); //var doc = Int32.Parse(id_doc); FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", id_doc.ToString() }, { "type", TIPO_OTROS }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", "" }, { "id_usu", "" }, { "encryptDocument", "S" } } }; return(getFile(filecode)); } catch (Exception e) { return(JsonError("ha ocurrido un problema con su solicitud", e)); } }
public ActionResult documentos(int id) { try { var documento = (from v in _db.Vacaciones join n in _db.Novedad on v.id_novedad equals n.id_novedad join d in _db.Documento on n.id_novedad equals d.id_novedad where v.id_vac == id select d.id_doc); if (!documento.Any()) { throw new Exception("No existe un documento asociado a ese registro"); } var id_doc = documento.First(); FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", id_doc.ToString() }, { "type", TIPO_OTROS }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", "" }, { "id_usu", "" }, { "encryptDocument", "S" } } }; return(getFile(filecode)); } catch (Exception err) { return(JsonError(err.Message, err)); } }
private UploadResponseDTO Upload_File(FileCode code) { UploadResponseDTO dto = null; if (ContextCurrent.Request.Files.Count == 0) { dto = new UploadResponseDTO(); return(dto); } var key = Guid.NewGuid().ToString("N"); var file = ContextCurrent.Request.Files[0]; var fileName = file.FileName; string imgUrl = UploadHelper.Save(file, code.ToString()); if (imgUrl == null) { dto = new UploadResponseDTO(); return(dto); } dto = new UploadResponseDTO(); dto.url = imgUrl; dto.original = fileName; dto.title = fileName; dto.state = UploadStateCode.Success; return(dto); }
public ActionResult PDF(string id) { try { var comp = Int32.Parse(id); var id_doc = _db.Documento.FirstOrDefault(item => item.id_usu == comp && item.categoria == "DOCUMCONTRA" && item.estado == 1).id_doc; FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", id_doc.ToString() }, { "type", TIPO_CONTRATO }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", "" }, { "id_usu", "" }, { "encryptDocument", "S" } } }; return(getFile(filecode)); } catch (Exception e) { return(JsonError("oops ocurrió un problema con su solicitud", e)); } }
public static void GenericDefaultTest() { var ins = new FileCode <uint>(); Console.WriteLine(FileCode <uint> .TypeSupportsPacking); Console.WriteLine(FileCode <string> .TypeSupportsPacking); }
public ActionResult PDF(string id) { try { var id_doc = Int32.Parse(id); var rev = _db.Documento.FirstOrDefault(x => x.id_doc == id_doc); FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", id_doc.ToString() }, { "type", rev.categoria }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", "" }, { "id_usu", "" }, { "encryptDocument", "S" } } }; //int id_doc, string type, string client, string fecha, string id_usu) return(getFile(filecode)); } catch (Exception e) { return(JsonError("oops ocurrió un problema con su solicitud", e)); } }
public void FactMethodName() { var fooFileCode = new FileCode("foo"); var barFileCode = new FileCode("bar"); var kernel = new StandardKernel(); kernel .Bind <IFileProcessorFactory>() .To <FileProcessorFactory>(); kernel .Bind <IThing>() .To <ThingFoo>() .WhenFileCode(fooFileCode); kernel .Bind <IThing>() .To <ThingBar>() .WhenFileCode(barFileCode); kernel .Bind <IOtherThing>() .To <OtherThingFoo>() .WhenFileCode(fooFileCode); kernel .Bind <IOtherThing>() .To <OtherThingBar>() .WhenFileCode(barFileCode); var fileProcessor = kernel.Get <IFileProcessorFactory>().Create(barFileCode); fileProcessor.Thing.Should().BeOfType <ThingBar>(); fileProcessor.Thing.FileCode.Should().Be(barFileCode); fileProcessor.OtherThingWrapper.OtherThing.Should().BeOfType <OtherThingBar>(); fileProcessor.OtherThingWrapper.OtherThing.FileCode.Should().Be(barFileCode); }
/// <summary> ///升级程序 /// </summary> /// <param name="sender"></param> /// <param name="code"></param> private void UpdateApp(BaseCommunication sender, Code code) { FileCode fileCode = code as FileCode; if (fileCode != null) { string fileName = fileCode.SavePath; tempFile = GetSystemTempDir() + fileName + ".tmp"; System.Console.WriteLine("下载更新包:" + tempFile); fileCode.SavePath = tempFile; ICanSeeYou.Common.IO.SaveFile(sender, fileCode); int index = appName.IndexOf("."); //获取服务端线程名 string process = appName.Substring(0, index); System.Console.WriteLine("关闭当前服务端线程:" + process); bool cankill = false; cankill = CloseApplication(process); System.Console.WriteLine("正在关闭服务端线程..."); System.Threading.Thread.Sleep(500); if (cankill) { string savedFile = Directory.GetCurrentDirectory() + "\\" + fileName; System.Console.WriteLine("更新文件:" + savedFile); Updatefile(tempFile, savedFile); System.Console.WriteLine("重新启动服务端程序:" + Directory.GetCurrentDirectory() + "\\" + appName); restart(Directory.GetCurrentDirectory() + "\\" + appName); } else { System.Console.WriteLine("无法关闭低版本的服务端程序!"); } System.Console.WriteLine("关闭升级程序!"); CloseMe(sender); } }
/// <summary> /// 发送文件 /// </summary> /// <param name="code"></param> public static void UploadFile(BaseCommunication sender, FileCode code) { code.Head = CodeHead.SEND_FILE; code.readFile(); if (sender != null) { sender.SendCode(code); } }
/// <summary> /// 保存文件 /// </summary> /// <param name="fileMng"></param> public static void SaveFile(BaseCommunication sender, FileCode fileMng) { fileMng.SaveFile(); if (sender != null) { BaseCode code = new BaseCode(); code.Head = CodeHead.FILE_TRAN_END; sender.SendCode(code); } }
public static IBindingInNamedWithOrOnSyntax <T> WhenFileCode <T>( this IBindingWhenSyntax <T> syntax, FileCode fileCode) { return(syntax.When(req => req .Parameters .OfType <FileCodeParameter>() .Single() .FileCode.Value == fileCode.Value)); }
/// <summary> /// 远程获取文件 /// </summary> /// <param name="fileName"></param> public static void DownloadFile(BaseCommunication sender, string fileName, string savepath) { FileCode fileMng = new FileCode(fileName); fileMng.Head = CodeHead.GET_FILE; fileMng.SavePath = savepath; if (sender != null) { sender.SendCode(fileMng); } }
public override void Write(BinaryWriter writer, IShapefileHeader value, WordCount origin) { FileCode.Write(writer, FileCodeValue, origin); //TODO: ShapefileHeader should be constructed with this const value... then we write the property value. Unused1.Write(writer, UnusedValue, origin); //TODO: ShapefileHeader should be constructed with this const value... then we write the property value. Unused2.Write(writer, UnusedValue, origin); //TODO: ShapefileHeader should be constructed with this const value... then we write the property value. Unused3.Write(writer, UnusedValue, origin); //TODO: ShapefileHeader should be constructed with this const value... then we write the property value. Unused4.Write(writer, UnusedValue, origin); //TODO: ShapefileHeader should be constructed with this const value... then we write the property value. Unused5.Write(writer, UnusedValue, origin); //TODO: ShapefileHeader should be constructed with this const value... then we write the property value. FileLength.Write(writer, value.FileLength, origin); Version.Write(writer, VersionValue, origin); //TODO: ShapefileHeader should be constructed with this const value... then we write the property value. ShapeType.Write(writer, value.ShapeType, origin); BoxMin.Write(writer, value.BoundingBox.Min, origin); BoxMax.Write(writer, value.BoundingBox.Max, origin); }
public override IShapefileHeader Read(BinaryReader reader, WordCount origin) { return(new ShapefileHeader() { BoundingBox = new BoundingBox <IPointZ>() { Min = BoxMin.Read(reader, origin), Max = BoxMax.Read(reader, origin) }, FileCode = FileCode.Read(reader, origin), FileLength = FileLength.Read(reader, origin), ShapeType = (ShapeType)ShapeType.Read(reader, origin), Version = Version.Read(reader, origin) }); }
private ListResponseDTO List_File(FileCode code) { //ListResponseDTO dto = new ListResponseDTO(); //var list = OSSHelper.List(code); //return new ListResponseDTO //{ // list = list.Select(x => new ImageUrlDTO // { // url = x // }).ToList(), // start = 0, // total = list.Count, // state = UploadStateCode.Success, //}; return(null); }
public ActionResult PDF() { FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", "0" }, { "type", TIPO_CERTIFICADO_ANTIGUEDAD }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", "" }, { "id_usu", "" }, } }; return(getFile(filecode)); }
public ActionResult Liquidacion(string fecha) { FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", "0" }, { "type", TIPO_LIQUIDACION }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", fecha }, { "id_usu", "" }, { "encryptDocument", "S" } } }; return(getFile(filecode)); }
private async Task <Tuple <string, byte[]> > getDictionaryData(string fecha) { string aux = fecha; FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", "0" }, { "type", TIPO_LIQUIDACION }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", fecha }, { "id_usu", "" }, { "encryptDocument", "S" } } }; filecode.Encode(); var archivo = await Task.Run(() => getFileData(filecode.Token)); return(new Tuple <string, byte[]>(fecha, (archivo as FileContentResult).FileContents)); }
public string RunCSharpCode(string namespaces, string codeContent) { string className = "a" + string.Format(@"{0}", Math.Abs(Guid.NewGuid().GetHashCode())); string fileName = className + ".cs"; var lines = codeContent.Split('\n'); for (int i = 0; i < lines.Length; i++) { lines[i] = "\t" + lines[i]; } codeContent = String.Join("\n", lines); string fileContent = namespaces + "\npublic class " + className + "\n{\n" + codeContent + "\n}"; FileCode.Create(fileName, ConfigurationDocker.StoragePathInHost, fileContent); CompileCSharpCodeWithMono compile = new CompileCSharpCodeWithMono(ConfigurationDocker.MonoContainerName, ConfigurationDocker.StoragePathInContainer + "/" + fileName); var outputCompile = compile.Compile(); if (outputCompile != "") { return(outputCompile); } var outputRun = compile.Run(); FileCode.Delete(fileName, ConfigurationDocker.StoragePathInHost); var fileNameExe = fileName.Substring(0, fileName.Length - 2) + "exe"; FileCode.Delete(fileNameExe, ConfigurationDocker.StoragePathInHost); return(outputRun); }
public ActionResult PDF(string id) { try { var doc = Int32.Parse(id); FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", doc.ToString() }, { "type", TIPO_OTROS }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", "" }, { "id_usu", "" }, { "encryptDocument", "S" } } }; return(getFile(filecode)); } catch (Exception e) { return(JsonError("ha ocurrido un problema con su solicitud", e)); } }
public ActionResult getFile(string id_doc) { int _id_doc = 0; if (!Int32.TryParse(id_doc, out _id_doc)) { return(null); } ; FileCode filecode = new FileCode() { values = new System.Collections.Generic.Dictionary <string, string>() { { "id_doc", _id_doc.ToString() }, { "type", TIPO_OTROS }, { "client", SesionCliente().Nom_cor_emp }, { "fecha", "" }, { "id_usu", "" }, { "encryptDocument", "N" } } }; return(getFile(filecode)); }
protected ActionResult getFile(FileCode fileCode)//int id_doc, string type, string client, string fecha, string id_usu) { fileCode.Encode(); ViewBag.fileCode = fileCode; return(View("getFile")); }
protected OtherThing(FileCode fileCode) { FileCode = fileCode; }
public override int GetHashCode() { return(FileCode.GetHashCode()); }
public OtherThingFoo(FileCode fileCode) : base(fileCode) { }
public OtherThingBar(FileCode fileCode) : base(fileCode) { }
public ActionResult getFileData(string Token) { using (var db = new Db_Entities()) { FileCode FileCode = new FileCode() { Token = Token }; FileCode.Decode(); int id_doc = Int32.Parse(FileCode.values["id_doc"]); string type = FileCode.values["type"]; string fecha = FileCode.values["fecha"]; int id_usu = 0;// SesionLogin().id; Int32.TryParse(FileCode.values["id_usu"], out id_usu); string encryptDocument = "S"; FileCode.values.TryGetValue("encryptDocument", out encryptDocument); MemoryStream ms = new MemoryStream(); PdfReader pdfReader; PdfStamper pdfStamper; AcroFields pdfFormFields; Usuario usuario = id_usu == 0 ? SesionLogin() : db.Usuario.FirstOrDefault(p => p.id == id_usu); Cliente cliente = id_usu == 0 ? SesionCliente() : db.Cliente.FirstOrDefault(p => p.id_cliente == usuario.id_cliente); try { if (type == TIPO_LIQUIDACION) { var fecha_set = new string((from c in fecha where char.IsLetterOrDigit(c) select c).ToArray()); var fec_sp = DateTime.ParseExact(fecha_set, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-dd"); pdfReader = new PdfReader(System.Web.Hosting.HostingEnvironment.MapPath(db.Documento.FirstOrDefault(p => p.categoria == "DOCUMLIQUI" && p.estado == 1 && p.id_cliente == usuario.id_cliente).ruta)); pdfStamper = new PdfStamper(pdfReader, ms); pdfFormFields = pdfStamper.AcroFields; var periodo = PeriodoVigente(new List <SqlParameter>() { new SqlParameter("@Fecha", SqlDbType.Date) { Value = fecha }, new SqlParameter("@NOM_CLIENTE_DB", SqlDbType.VarChar) { Value = cliente.Nom_cor_emp }, new SqlParameter("@VALOR_RET", SqlDbType.Int) { Value = 0 } }); var datos_liquidacion = MultiLoadDataToDictionary(new List <SqlParameter>() { new SqlParameter("@USU_ID", SqlDbType.VarChar) { Value = usuario.id_usu }, new SqlParameter("@NOM_CLIENTE_DB", SqlDbType.VarChar) { Value = cliente.Nom_cor_emp }, new SqlParameter("@Mes_consul", SqlDbType.VarChar) { Value = periodo }, new SqlParameter("@Fecha", SqlDbType.VarChar) { Value = fec_sp }, }, "pa_selDatosLiquidacion"); var ficha = usuario.id_usu; if (encryptDocument == "S") { pdfStamper.SetEncryption(Encoding.ASCII.GetBytes(ficha), Encoding.ASCII.GetBytes("PERMICONTRATOS"), PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA); } var campo = LoadData("select tag, campo,label,id_cliente, orden from configPDF where (id_cliente = -1 or id_cliente =" + cliente.id_cliente + ") order by tag, orden asc").ToList(); Fill_pdf(datos_liquidacion, campo, pdfFormFields, fecha); // funcion para llenado de pdf //Estampar imagen de cliente dinamicamente if (SesionLogin().id_cliente != 1) { var estampoImg = pdfStamper.GetOverContent(1); iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(System.Web.Hosting.HostingEnvironment.MapPath(db.Documento.FirstOrDefault(p => p.categoria == "DOCUMLOGOCLI" && p.estado == 1 && p.id_cliente == usuario.id_cliente).ruta)); image.SetAbsolutePosition(25, 730); float percentage = 0.0f; percentage = 100 / image.Width; image.ScalePercent(percentage * 120); estampoImg.AddImage(image); } pdfStamper.FormFlattening = false; pdfStamper.MoreInfo = new Dictionary <string, string>() { { "Title", "Liquidación_" + DateTime.Now.ToString("dd-MM-yyyy") + ".pdf" } }; pdfStamper.Close(); pdfReader.Close(); Response.AppendHeader("Content-Disposition", "inline; filename=Liquidación_" + DateTime.Now.ToString("dd-MM-yyyy") + ".pdf"); return(File(ms.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf)); } else if (type == TIPO_CERTIFICADO_ANTIGUEDAD) { pdfReader = new PdfReader(System.Web.Hosting.HostingEnvironment.MapPath(db.Documento.FirstOrDefault(p => p.categoria == "DOCUMCERTANT" && p.estado == 1 && p.id_cliente == usuario.id_cliente).ruta)); pdfStamper = new PdfStamper(pdfReader, ms); pdfFormFields = pdfStamper.AcroFields; var datosCertAntiguedad = LoadData("EXEC [dbo].[pa_selDatosCertAntiguedad] @USU_ID = N'" + usuario.id_usu + "',@NOM_CLIENTE_DB = N'" + cliente.Nom_cor_emp + "' "); var Texto_Super = helper.Get_TextCertificado("C_ANTIGUEDAD", datosCertAntiguedad, usuario); var fec_actu = DateTime.Now.ToString("dd MMMM yyyy"); var pie_qr = "CERTIFICADO EMITIDO POR PAYROLL MANAGEMENT SYSTEM\nLa institución o persona ante quien se presente este certificado\npodrá validar su autenticidad mediante el escaneo del codigo QR."; fec_actu = "En Santiago, " + fec_actu; pdfFormFields.SetField("Texto_Super", Texto_Super); pdfFormFields.SetField("fec_actu", fec_actu); pdfFormFields.SetField("pie_qr", pie_qr); var pdfContentByte2 = pdfStamper.GetOverContent(1); iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(System.Web.Hosting.HostingEnvironment.MapPath(db.Documento.FirstOrDefault(p => p.categoria == "DOCUMLOGOCLI" && p.estado == 1 && p.id_cliente == usuario.id_cliente).ruta)); image.SetAbsolutePosition(20, 730); float percentage = 0.0f; percentage = 100 / image.Width; image.ScalePercent(percentage * 150); pdfContentByte2.AddImage(image); if (id_usu == 0) { var fechaQR = DateTime.Now.ToString("yyyyMMddHHmmssffff"); var mod11 = Helper.digitoVerificador(Int64.Parse(fechaQR)); var cadena = fechaQR + "_" + "o" + "_" + mod11 + "_" + usuario.id_usu + "_" + cliente.Nom_cor_emp; var encriptado = SeguridadUtilidades.Encriptar(cadena); string url = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port); var QRfinal = url + "/" + "ValidaDocumento" + "/" + "validaQR" + "?" + "token=" + HttpUtility.UrlEncode(encriptado); QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.M); QrCode qrcode = new QrCode(); qrEncoder.TryEncode(QRfinal, out qrcode); GraphicsRenderer Renderder = new GraphicsRenderer(new FixedCodeSize(50, QuietZoneModules.Zero), Brushes.Black, Brushes.White); MemoryStream MS = new MemoryStream(); Renderder.WriteToStream(qrcode.Matrix, ImageFormat.Jpeg, MS); var imagentemporal = new Bitmap(MS); var pdfContentByte = pdfStamper.GetOverContent(1); iTextSharp.text.Image QR = iTextSharp.text.Image.GetInstance(imagentemporal, ImageFormat.Jpeg); QR.SetAbsolutePosition(500, 40); pdfContentByte.AddImage(QR); } pdfStamper.FormFlattening = false; pdfStamper.MoreInfo = new Dictionary <string, string>() { { "Title", "Certificado_" + DateTime.Now.ToString("dd-MM-yyyy") + ".pdf" } }; pdfStamper.Close(); pdfReader.Close(); Response.AppendHeader("Content-Disposition", "inline; filename=" + "Certificado_" + DateTime.Now.ToString("dd-MM-yyyy") + ".pdf"); return(File(ms.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf)); } if (type == TIPO_OTROS) { var documento = db.Documento.FirstOrDefault(p => p.id_doc == id_doc); Response.AppendHeader("Content-Disposition", "inline; filename=" + documento.nombre_original); using (FileStream file = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath(documento.ruta), FileMode.Open, FileAccess.Read)) { byte[] bytes = new byte[file.Length]; file.Read(bytes, 0, (int)file.Length); ms.Write(bytes, 0, (int)file.Length); } return(File(ms.ToArray(), MimeMapping.GetMimeMapping(System.Web.Hosting.HostingEnvironment.MapPath(documento.ruta)))); } if (type == TIPO_CONTRATO_ANEXO || type == TIPO_CONTRATO || type == TIPO_CONTRATO_OFERTA) { var doc = db.Documento.FirstOrDefault(p => p.id_doc == id_doc && p.categoria == type); var contraseña = db.Usuario.FirstOrDefault(p => p.id == doc.id_usu).id_usu; Response.AppendHeader("Content-Disposition", "inline; filename=" + doc.nombre_original); return(File(pdfDocEncrypt(doc.ruta, contraseña, encryptDocument).ToArray(), MimeMapping.GetMimeMapping(System.Web.Hosting.HostingEnvironment.MapPath(doc.ruta)))); } else { return(null); } } catch (Exception e) { return(JsonError("Ocurrió un problema con su solicitud, por favor contacte a IT", e)); } } }
public override bool Equals(object obj) { InputHistory site = obj as InputHistory; return(site == null ? false : FileCode.Equals(site.FileCode)); }
public FileCodeParameter(FileCode fileCode) { this.fileCode = fileCode; }
protected Thing(FileCode fileCode) { FileCode = fileCode; }