Ext. Net 1. x_ext.net _ achieves the effect of Baidu Library

Source: Internet
Author: User

The project budget needs to upload a word instruction file for online viewing. After two days of hitting the nail, the code and process are finally completed. please correct me.
Upload and convert files:
Environment: flashpaper has been downloaded online to convert a document to SWF.
Upload:

Protected void uploadclick (Object sender, directeventargs e) {string TPL = "uploaded file: {0} size: {1} bytes"; string gsdm = httputility. urldecode (request. cookies ["Danwei"]. value ). tostring (); string bmdm = httputility. urldecode (request. cookies ["bumen"]. value ). tostring (); If (this. fileuploadfield1.hasfile) {string fileext = This. fileuploadfield1.postedfile. filename. substring (this. fileuploadfield1.postedfile. filename. lastindexof (". "); // file name use unit + department + year string filename ="/bmysdoc/"+ gsdm + ". "+ bmdm + ". "+ this. kjnd. text + fileext; string swffile = "/bmysswf/" + gsdm + ". "+ bmdm + ". "+ this. kjnd. text + ". SWF "; try {This. fileuploadfield1.postedfile. saveas (server. mappath (filename); converttoswf (server. mappath (filename), server. mappath (swffile); X. MSG. show (New messageboxconfig {buttons = MessageBox. button. OK, icon = MessageBox. icon. info, Title = "success", message = string. format (TPL, this. fileuploadfield1.postedfile. filename, this. fileuploadfield1.postedfile. contentlength)});} catch (exception exc) {X. MSG. show (New messageboxconfig {buttons = MessageBox. button. OK, icon = MessageBox. icon. error, Title = "fail", message = exc. tostring ()}) ;}} else {X. MSG. show (New messageboxconfig {buttons = MessageBox. button. OK, icon = MessageBox. icon. error, Title = "fail", message = "No File Uploaded "});}}
Public void converttoswf (string oldfile, string swffile) {system. diagnostics. process Pc = new system. diagnostics. process (); PC. startinfo. filename = @ "F: \ flashpaperdemo \ flashpaper2.2 \ flashprinter.exe"; // installation path PC. startinfo. arguments = string. format ("{0}-o {1}", oldfile, swffile); PC. startinfo. createnowindow = true; PC. startinfo. useshellexecute = false; PC. startinfo. redirectstandardinput = false; PC. startinfo. redirectstandardoutput = false; PC. startinfo. redirectstandarderror = true; PC. startinfo. windowstyle = system. diagnostics. processwindowstyle. hidden; PC. start (); PC. waitforexit (); PC. close (); PC. dispose ();}

In this way, the conversion is processed at the same time of the upload.
View online:

<Ext: button id = "button4" runat = "server" text = "文"" icon = "arrowrefreshsmall"> <directevents> <click onevent = "showswf"> </click> </ directevents> </ext: button>

Method:

Protected void showswf (Object sender, eventargs e) {string gsdm = httputility. urldecode (request. cookies ["Danwei"]. value ). tostring (); string bmdm = httputility. urldecode (request. cookies ["bumen"]. value ). tostring (); string swffile = "/bmysswf/" + gsdm + ". "+ bmdm + ". "+ this. kjnd. text + ". SWF "; if (file. exists (swffile) = false) {resourcemanager1.addscript ("window. open ('showswf. aspx? Swffile = "+ swffile +" '); ");} elsex. MessageBox. Alert (" prompt "," This Department document has not been found! "). Show ();}

Showswf. aspx code:

protected void Page_Load(object sender, EventArgs e){string SwfFile = Request.QueryString["SwfFile"];System.Text.StringBuilder html = new System.Text.StringBuilder();html.Append("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"" + "100%" + "\" height=\"" + "100%" + "\">");html.Append("<param name=\"movie\" value=\"" + SwfFile + "\" />");html.Append("</object>");Response.Write(html.ToString());}

Unsolved disadvantages:
1. The conversion process will appear in the window during conversion. It is a flash, and it is also uncomfortable. It will be better if you want to switch to cmd for further processing without testing.
2. If Baidu Library is not good-looking, you need to work hard.
From: http://ext.net.cn/thread-1373-1-1.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.