当前位置: 首页 > news >正文

wordpress网站关键词设置模板网站更改

wordpress网站关键词设置,模板网站更改,苏州网站建设搜q479185700,建立网站如何推广在程序开发中经常需要将Office文件转换成PDF#xff0c;著名的Aspose的三大组件可以很容易完成这个功能#xff0c;但是Aspose的每个组件都单独收费#xff0c;而且每个都卖的不便宜。在老大的提示下#xff0c;换了一种思路来解决这个问题。环境dotNetCore:2.1CentOS:7.5D… 在程序开发中经常需要将Office文件转换成PDF著名的Aspose的三大组件可以很容易完成这个功能但是Aspose的每个组件都单独收费而且每个都卖的不便宜。在老大的提示下换了一种思路来解决这个问题。环境dotNetCore:2.1CentOS:7.5Docker:18.06.1-ce步骤1、Docker中安装libreoffice和dotNetCore2、编写转换程序3、程序以服务的方式部署在Docker中。配置Docker环境因为需要部署dotNetCore的程序开始的想法是依赖microsoft/dotnet:2.1-aspnetcore-runtime镜像创建容器然后在容器中安装libreoffice后来发现容器中没法执行yum命令可能是没找到方法。最后换了一种思路依赖centos镜像创建容器在容器中安装dotNetCore2.1和libreoffice。安装libreofiicieyum install libreoffice 安装dotnetCore2.1sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpmsudo yum updatesudo yum install aspnetcore-runtime-2.1sudo yum updatesudo yum install aspnetcore-runtime-2.1转换程序编写在C#中使用libreoffice转换office为pdf网上有很多的代码示例在这里还需要引入消息队列整个程序是一个消息队列的消费者。简单说就是用户上传了一个office文件上传成功后会发一个消息该程序中接收到消息就进行转换。消息监听    class Program    {        static IPowerPointConverter converter  new PowerPointConverter();        static void Main(string[] args)        {            var mqManager  new MQManager(new MqConfig            {                AutomaticRecoveryEnabled  true,                HeartBeat  60,                NetworkRecoveryInterval  new TimeSpan(60),                Host  ConfigurationManager.AppSettings[mqhostname],                 UserName  ConfigurationManager.AppSettings[mqusername],                Password  ConfigurationManager.AppSettings[mqpassword],                Port  ConfigurationManager.AppSettings[mqport]            });            if (mqManager ! null  mqManager.Connected)            {                Console.WriteLine(RabbitMQ连接初始化成功。);                Console.WriteLine(RabbitMQ消息接收中...);                mqManager.SubscribePowerPointConvertMessage(message                 {                    if (message ! null)                    {                        converter.OnWork(message);                        Console.WriteLine(message.FileInfo);                    }                });            }            else            {                Console.WriteLine(RabbitMQ连接初始化失败,请检查连接。);                Console.ReadLine();            }        }    }Program    {        static IPowerPointConverter converter  new PowerPointConverter();        static void Main(string[] args)        {            var mqManager  new MQManager(new MqConfig            {                AutomaticRecoveryEnabled  true,                HeartBeat  60,                NetworkRecoveryInterval  new TimeSpan(60),                Host  ConfigurationManager.AppSettings[mqhostname],                 UserName  ConfigurationManager.AppSettings[mqusername],                Password  ConfigurationManager.AppSettings[mqpassword],                Port  ConfigurationManager.AppSettings[mqport]            });            if (mqManager ! null  mqManager.Connected)            {                Console.WriteLine(RabbitMQ连接初始化成功。);                Console.WriteLine(RabbitMQ消息接收中...);                mqManager.SubscribePowerPointConvertMessage(message                 {                    if (message ! null)                    {                        converter.OnWork(message);                        Console.WriteLine(message.FileInfo);                    }                });            }            else            {                Console.WriteLine(RabbitMQ连接初始化失败,请检查连接。);                Console.ReadLine();            }        }    }文件转换        public bool OnWork(MQ.Messages Message)        {            PowerPointConvertMessage message  (PowerPointConvertMessage)Message;            string sourcePath  string.Empty;            string destPath  string.Empty;            try            {                if(message  null)                    return false;                Stream sourceStream  fileOperation.GetFile(message.FileInfo.FileId);                string filename  message.FileInfo.FileId;                string extension  System.IO.Path.GetExtension(message.FileInfo.FileName);                sourcePath  System.IO.Path.Combine(Directory.GetCurrentDirectory(), filename  extension);                destPath  System.IO.Path.Combine(Directory.GetCurrentDirectory(), string.Format({0}.pdf, filename));                if (!SaveToFile(sourceStream, sourcePath))                    return false;                var psi  new ProcessStartInfo(libreoffice, string.Format(--invisible --convert-to pdf  {0}, filename  extension)) { RedirectStandardOutput  true };                // 启动                var proc  Process.Start(psi);                if (proc  null)                {                    Console.WriteLine(不能执行.);                    return false;                }                else                {                    Console.WriteLine(-------------开始执行--------------);                    //开始读取                    using (var sr  proc.StandardOutput)                    {                        while (!sr.EndOfStream)                        {                            Console.WriteLine(sr.ReadLine());                        }                        if (!proc.HasExited)                        {                            proc.Kill();                        }                    }                    Console.WriteLine(---------------执行完成------------------);                    Console.WriteLine($退出代码  {proc.ExitCode});                }            }            catch (Exception ex)            {                Console.WriteLine(ex.Message);                return false;            }            finally            {                if (File.Exists(destPath))                {                    var destFileInfo  UploadFile(destPath, string.Format({0}.pdf, Path.GetFileNameWithoutExtension(message.FileInfo.FileName)));                }                if (File.Exists(destPath))                {                    System.IO.File.Delete(destPath);                }            }            return true;        }            PowerPointConvertMessage message  (PowerPointConvertMessage)Message;            string sourcePath  string.Empty;            string destPath  string.Empty;            try            {                if(message  null)                    return false;                Stream sourceStream  fileOperation.GetFile(message.FileInfo.FileId);                string filename  message.FileInfo.FileId;                string extension  System.IO.Path.GetExtension(message.FileInfo.FileName);                sourcePath  System.IO.Path.Combine(Directory.GetCurrentDirectory(), filename  extension);                destPath  System.IO.Path.Combine(Directory.GetCurrentDirectory(), string.Format({0}.pdf, filename));                if (!SaveToFile(sourceStream, sourcePath))                    return false;                var psi  new ProcessStartInfo(libreoffice, string.Format(--invisible --convert-to pdf  {0}, filename  extension)) { RedirectStandardOutput  true };                // 启动                var proc  Process.Start(psi);                if (proc  null)                {                    Console.WriteLine(不能执行.);                    return false;                }                else                {                    Console.WriteLine(-------------开始执行--------------);                    //开始读取                    using (var sr  proc.StandardOutput)                    {                        while (!sr.EndOfStream)                        {                            Console.WriteLine(sr.ReadLine());                        }                        if (!proc.HasExited)                        {                            proc.Kill();                        }                    }                    Console.WriteLine(---------------执行完成------------------);                    Console.WriteLine($退出代码  {proc.ExitCode});                }            }            catch (Exception ex)            {                Console.WriteLine(ex.Message);                return false;            }            finally            {                if (File.Exists(destPath))                {                    var destFileInfo  UploadFile(destPath, string.Format({0}.pdf, Path.GetFileNameWithoutExtension(message.FileInfo.FileName)));                }                if (File.Exists(destPath))                {                    System.IO.File.Delete(destPath);                }            }            return true;        }上面只是一些代码片段完整示例会上传到Github上文章末尾会给出地址。部署代码到Docker此程序是dotNetCore编写的控制台程序希望以服务的方式在后台运行下面介绍怎样将控制台程序以服务的方式运行1、将发布后的代码放在容器的/root/officetopdf/publish目录中2、在 /lib/systemd/system目录中创建文件officetopdf.service3、文件内容如下[Unit]Descriptionoffice to pdf service[Service]ExecStart/usr/bin/dotnet /root/officetopdf/publish/Office2PDF.dll[Install]WantedBydefault.targetDescriptionoffice to pdf service[Service]ExecStart/usr/bin/dotnet /root/officetopdf/publish/Office2PDF.dll[Install]WantedBydefault.target4、使用下面命令创建和启动服务systemctrl daemon-reloadsystemctrl start officetopdfsystemctrl start officetopdf示例https://github.com/oec2003/StudySamples/tree/master/Office2PDF
http://www.zqtcl.cn/news/821110/

相关文章:

  • 天津协会网站建设学计算机的做网站的叫什么工作
  • 商城网站建设缺点淘宝店铺怎么免费推广
  • 利于优化的网站模板360建筑网密码忘了
  • 商务网站建设找哪家网页设计商品页面制作
  • 连云港网站建设方案大型门户网站多少钱
  • win7 iis设置网站首页网站建设攵金手指科杰壹陆
  • 阿里巴巴网站建设的功能定位手机在线制作图片加字
  • 网站联系我们的地图怎么做的电子商务网站建设完整案例教程
  • 北京学习网站建设湖北省建设厅政务公开网站
  • 推广做网站联系方式贵州省领导班子名单一览表
  • 厦门的网站建设公司徐州城乡建设局网站
  • 天津圣辉友联网站建设南昌本地生活网站有哪些
  • 境外社交网站上做推广上海网站建设的价格低
  • 山西专业网站建设大全高校网站群建设研究
  • 网络营销网站建设流程网站功能设计指什么
  • 企业网络推广网站琼海市建设局网站
  • 移动网站搭建网页设计页面设计
  • 建设网站进行商品营销的重要性恢复正常百度
  • 美容会所网站模板下载jsp网站开发实现增删改查
  • 注册网站需要注意什么深圳建站公司兴田德润官网多少
  • 广东网站优化布吉做棋牌网站建设有哪些公司
  • 联邦快递的网站建设图书馆建设网站注意点
  • 西安好的皮肤管理做团购网站wordpress stats
  • 文山 网站建设 滇icp卡盟网站顶图怎么做
  • 北京网站建设公司哪些好电商建站
  • 沈阳百度广告广州营销seo
  • 营销型企业网站建设步骤做网站怎样和客户沟通
  • 多媒体教学网站开发的一般步骤网络公司网站赏析
  • 阿里云手机网站建设多少钱wordpress幻灯片制作
  • 个人博客网站下载公司邮箱免费注册