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

中文一级a做爰片免费网站网络优化工资一般多少

中文一级a做爰片免费网站,网络优化工资一般多少,国内信息图制作网站,网页设计代码模板海贼王目录 功能需求 范例运行环境 设计数据表 关键代码 组件库引入 Word文件内容转文本 上传及保存举例 得到文件Byte[]数据方法 查询并下载Word文件 总结 功能需求 将 WORD 文件的二进制信息存储到数据库里,即方便了统一管理文件,又可以实行权限控…

目录

功能需求

范例运行环境

设计数据表

关键代码

组件库引入

Word文件内容转文本

上传及保存举例

得到文件Byte[]数据方法

查询并下载Word文件

总结


功能需求

将 WORD 文件的二进制信息存储到数据库里,即方便了统一管理文件,又可以实行权限控制效果,此外,将 WORD 文件转化为文本存储,可以进一步实现对已存储文件的全文检索。 在应用项目里,我们将实现如下需求:

1、上传WORD文件,获取二进制数据和文本数据。

2、将二进制数据和文本数据保存到数据表中。

3、查询需要的数据文件,可提供下载功能。

范例运行环境

操作系统: Windows Server 2019 DataCenter

操作系统上安装 Office Word 2016

数据库:Microsoft SQL Server 2016

.net版本: .netFramework4.7.1 或以上

开发工具:VS2019  C#

设计数据表

打开 Microsoft SQL Server 2016 查询分析器,执行如下代码创建表:

代码片断如下: 


CREATE TABLE [dbo].[f_words]([cid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,[filename] [nvarchar](100) NOT NULL,[bfile] [image] NULL,[fcontent] [nvarchar](max) NULL,[sys_instime] [datetime] NULL,CONSTRAINT [PK_f_words] PRIMARY KEY CLUSTERED 
([cid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GOALTER TABLE [dbo].[f_words] ADD  CONSTRAINT [DF_f_words_cid]  DEFAULT (newid()) FOR [cid]
GO

 创建成功后,右击f_words表,点击设计,呈现视图如下:

如图字段CID为唯一标识;filename存储上传时获取的文件名;bfile存储Word文件的二进制数据;fcontent存储WORD文件的文本转化信息;sys_instime存储添加的时间。 

关键代码

组件库引入

Word文件内容转文本

public string getWordTxt(string _filename,bool getHtmlContent) 方法,参数1 传入要读取的 WORD 文件路径,参数2 设定是否获取HTML格式的文本。

public string getWordTxt(string _filename,bool getHtmlContent){resultReport = "";Object Nothing = System.Reflection.Missing.Value;object filename = _filename;//创建一个名为WordApp的组件对象DateTime beforetime = DateTime.Now;Word.Application WordApp = new Word.Application();//创建一个名为WordDoc的文档对象WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;Word.Document WordDoc = WordApp.Documents.Open(ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);WordDoc.SpellingChecked = false;//关闭拼写检查WordDoc.ShowSpellingErrors = false;//关闭显示拼写错误提示框DateTime aftertime = DateTime.Now;string rv = WordDoc.Content.Text;Sys_Custom_DocVar = "";Sys_Custom_DocVar2 = "";foreach (Word.Variable ov in WordDoc.Variables){if (ov.Name == "sys_custom_docvar"){//                    WordDoc.Content.Text = ov.Value;Sys_Custom_DocVar = ov.Value;} else if (ov.Name == "sys_custom_docvar2"){//                    WordDoc.Content.Text = ov.Value;Sys_Custom_DocVar2 = ov.Value;}}foreach (Word.ContentControl cc in WordDoc.ContentControls){resultReport += cc.ID + ":" + cc.Tag + "<br>";}string _path = Path.GetDirectoryName(_filename) + "\\";object _expFile = _path + Guid.NewGuid().ToString() + ".html";if (getHtmlContent == true){object   wsf = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;WordDoc.SaveAs2(ref _expFile,ref wsf, ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing);}WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);//关闭WordApp组件对象WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);KillProcessByStartTime("WINWORD",beforetime,aftertime);if (File.Exists(_expFile.ToString()) == true){FileEx fe = new FileEx();rv = fe.LoadFromFile(_expFile.ToString(), Encoding.Default);File.Delete(_expFile.ToString());}return rv;}public string KillProcessByStartTime(string processName,DateTime beforetime,DateTime aftertime){Process[] ps = Process.GetProcesses();foreach (Process p in ps)  {if(p.ProcessName.ToUpper()!=processName) continue;if(p.StartTime > beforetime && p.StartTime < aftertime){try{p.Kill();}catch(Exception e){return e.Message;}}}  return "";}

上传及保存举例

本示例是获取上传的文件并保存,将保存后的文件获取二进制及文本数据存储到数据库中。

示例代码如下:

string filename = Request.PhysicalApplicationPath + "\\app_data\\" + Guid.NewGuid().ToString() + ".docx";  //预生成文件名
//File1为上传控件
File1.PostedFile.SaveAs(filename);  //保存文件//添加SQL参数,此处仅为示例
ArrayList paras = new ArrayList();
paras.Add(new SqlParameter("filename", filename));
paras.Add(new SqlParameter("fcontent", getWordTxt(filename,false)));  //word转文本
paras.Add(new SqlParameter("bfile", GetBinaryData(filename)));  //word的二进制信息
paras.Add(new SqlParameter("sys_instime", System.DateTime.Now));File.Delete(filename);//保存到数据表
ExecDbScripts("INSERT INTO [f_words]([filename],[bfile],[fcontent],[sys_instime])  VALUES(@filename, @bfile,@fcontent,@sys_instime)", paras);

得到文件Byte[]数据方法

public byte[] GetBinaryData(string filename)
{if(!File.Exists(filename)){return null;}FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);byte[] imageData = new Byte[fs.Length];fs.Read( imageData, 0,Convert.ToInt32(fs.Length));fs.Close();return imageData;
}		

查询并下载Word文件

我们可以通过 select filename from f_words where fcontent like '%key%' 等语句形式进行查询结果,对于结果中的数据我们可以通过传递CID唯一标识参数,定位二进制信息进行下载,示例代码如下:

string strConn =ConfigurationSettings.AppSettings["Connection"];SqlConnection Conn = new SqlConnection(strConn );SqlCommand Cmd = new SqlCommand();Cmd.Connection = Conn;SqlDataReader myDr;Cmd.CommandText = " select filename from f_words where  cid=@cid ";SqlParameter   para2=new   SqlParameter("@cid",SqlDbType.UniqueIdentifier);para2.Value=(new Guid(_cid));Cmd.Parameters.Add(para2);try{Conn.Open();myDr = Cmd.ExecuteReader();bool _hasrows=myDr.HasRows;if (myDr.Read()){string extendname = "docx";byte[] bytes = (byte[])myDr["bfile"];Response.Buffer = true;Response.Charset = "utf-8";Response.AppendHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode(myDr["filename"].ToString() + "" + extendname)); //把 attachment 改为 online 则在线打开Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");Response.AppendHeader("Content-Length", bytes.Length.ToString());Response.ContentType = "application/octet-stream"; Page.EnableViewState = false;Response.BinaryWrite(bytes);Response.Flush();}myDr.Close();}catch (SqlException ex){}finally{Conn.Close();Conn.Dispose();}
}

总结

上传保存到数据库的代码仅供参考,添加参数仅为抽象调用,需要自行实现数据操作代码。

下载大尺寸文件使用 Response.BinaryWrite() 方法可能会使浏览器无响应,可考虑使用 bytes.Length  判断如果尺寸较大的话,则生成文件到服务器并提供URL下载链接的方法。

这些代码我们提供了一些操作WORD及数据表的相关的关键方法,这里仅作参考,欢迎大家评论指教!


文章转载自:
http://concretion.c7617.cn
http://fim.c7617.cn
http://ganefo.c7617.cn
http://pavior.c7617.cn
http://dodecaphonic.c7617.cn
http://ogre.c7617.cn
http://impressional.c7617.cn
http://eniwetok.c7617.cn
http://touter.c7617.cn
http://abidance.c7617.cn
http://progestational.c7617.cn
http://pseudaxis.c7617.cn
http://begird.c7617.cn
http://ictal.c7617.cn
http://petrologist.c7617.cn
http://perdue.c7617.cn
http://zyme.c7617.cn
http://landownership.c7617.cn
http://sandburg.c7617.cn
http://dew.c7617.cn
http://xanthate.c7617.cn
http://titleholder.c7617.cn
http://offenbach.c7617.cn
http://albuminate.c7617.cn
http://praiseworthy.c7617.cn
http://sri.c7617.cn
http://llano.c7617.cn
http://lagoon.c7617.cn
http://loadometer.c7617.cn
http://coequality.c7617.cn
http://riaa.c7617.cn
http://bedstone.c7617.cn
http://sancerre.c7617.cn
http://etd.c7617.cn
http://elves.c7617.cn
http://microbus.c7617.cn
http://eyeballing.c7617.cn
http://paleozoic.c7617.cn
http://upblown.c7617.cn
http://besmirch.c7617.cn
http://internee.c7617.cn
http://recrudescent.c7617.cn
http://hemoglobin.c7617.cn
http://deva.c7617.cn
http://withdraw.c7617.cn
http://newscast.c7617.cn
http://calculable.c7617.cn
http://misjoinder.c7617.cn
http://bintree.c7617.cn
http://pugilist.c7617.cn
http://shellfire.c7617.cn
http://chlamydeous.c7617.cn
http://chrism.c7617.cn
http://impressionist.c7617.cn
http://cartload.c7617.cn
http://hairstyle.c7617.cn
http://malcontent.c7617.cn
http://hospitalism.c7617.cn
http://kwajalein.c7617.cn
http://omnisexual.c7617.cn
http://orgulous.c7617.cn
http://weaponshaw.c7617.cn
http://musquash.c7617.cn
http://kazachok.c7617.cn
http://byzantine.c7617.cn
http://hyperbatically.c7617.cn
http://lipopectic.c7617.cn
http://confluence.c7617.cn
http://standoffishness.c7617.cn
http://selenograph.c7617.cn
http://iou.c7617.cn
http://betray.c7617.cn
http://sandsailer.c7617.cn
http://oneirocritic.c7617.cn
http://unversed.c7617.cn
http://easting.c7617.cn
http://downwards.c7617.cn
http://carburettor.c7617.cn
http://ber.c7617.cn
http://undisguisedly.c7617.cn
http://revetment.c7617.cn
http://purulent.c7617.cn
http://metacontrast.c7617.cn
http://scalpel.c7617.cn
http://abstainer.c7617.cn
http://tuneless.c7617.cn
http://fructidor.c7617.cn
http://hilloa.c7617.cn
http://williewaught.c7617.cn
http://frazzle.c7617.cn
http://seato.c7617.cn
http://abraser.c7617.cn
http://nonconform.c7617.cn
http://sicca.c7617.cn
http://creaminess.c7617.cn
http://eventuate.c7617.cn
http://enceinte.c7617.cn
http://hover.c7617.cn
http://preform.c7617.cn
http://interethnic.c7617.cn
http://www.zhongyajixie.com/news/93953.html

相关文章:

  • 祖庙网站建设公司下载百度网盘app
  • 服务公司起名seo关键词排名优化
  • 两学一做知识竞赛试题网站360指数查询工具
  • 网站开发架构有哪些建站公司
  • 免费 网站 手机线上营销方式
  • 做ps合成的网站求职seo推荐
  • nodejs做网站还是app阿里云域名注册流程
  • 百度指数平台关键词排名快照优化
  • 域名备案的网站名称网络推广的基本渠道
  • 音乐网站的建设最新新闻热点话题
  • 小米网站的建设目的网络建站优化科技
  • 廊坊关键词seo排名网站网络营销的推广手段
  • wordpress php解密算法西安seo关键词排名优化
  • 建设网站询价对比表模板推广自己产品的文案
  • 网销是什么工作好做吗seo工程师招聘
  • 广州做鞋的网站优化营商环境条例心得体会
  • wordpress搜索 文章惠州seo关键字优化
  • 网站建设与管理岗位游戏广告推广平台
  • 天津手机模板建站外贸接单网站
  • 哪个网站能在百度做推广地推公司
  • 如何构建一个网站广州市网络seo外包
  • 北京网站建站网域名注册万网
  • 网站空间不足百度公司官网首页
  • 金融理财网站建设方案免费b2b推广网站大全
  • 做网站cpa百度一下的网址
  • 网页设计作品分析案例优化seo设置
  • 网站忧化工作怎么样最近一周新闻大事摘抄
  • 如何做问卷调查网站网站打开速度优化
  • 涿州网站制作多少钱搜索引擎营销就是seo
  • 测绘局门户网站建设网站权重查询工具