第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

重構(gòu)代碼2

標(biāo)簽:
JavaScript

还有另外一段代码需要重构,原代码:

复制代码public string file;//显示生成完成的swf文件
        protected void Button1_Click(object sender, EventArgs e)
        {
            string UploadFilePath = Server.MapPath(this.HiddenField1.Value);//保存上传的PDF或者其他可以打印的文件(DOC,DOCX等) /UploadFile/系统分析师通过的经验.doc
            string NewUploadFilePath = string.Empty;//转换WPS文件路径
            string ext = Path.GetExtension(UploadFilePath);
            if ((".wps,.et,.pps,.dps,.pps").Contains(ext))
            {
                switch (ext)
                {
                    case ".wps"://wps文件
                        NewUploadFilePath = Path.ChangeExtension(UploadFilePath, ".doc");
                        File.Move(UploadFilePath, NewUploadFilePath);
                        break;

                    case ".et"://wps的表格文件
                        NewUploadFilePath = Path.ChangeExtension(UploadFilePath, ".xls");
                        File.Move(UploadFilePath, NewUploadFilePath);
                        break;

                    case ".pps":
                    case ".dps":
                        NewUploadFilePath = Path.ChangeExtension(UploadFilePath, ".ppt");
                        File.Move(UploadFilePath, NewUploadFilePath);
                        break;
                }
                try
                {
                    if (UploadFilePath != null)
                    {
                        string SwfFile = strType(UploadFilePath);//得到文件类型
                        if (SwfFile != null)
                        {
                            string file = NewUploadFilePath.Replace(SwfFile, ".swf");
                            if (!File.Exists(file))
                            {
                                bool isconvert = ConvertPdfToSwf(NewUploadFilePath, file.Replace("UploadFile", "SwfFolder"));//执行转换
                                if (isconvert == true)
                                {
                                    file = Path.GetFileName(file);
                                    string FlashView = "http://199.99.99.111:8011/FlashPrinter/Interface/FlashView.aspx";
                                    Response.Write(" <script> window.location.href= '" + FlashView + "?dFile=" + HttpUtility.UrlEncode(file) + "'; </script> ");
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }

            }
            else
            {
                try
                {
                    if (UploadFilePath != null)
                    {
                        string SwfFile = strType(UploadFilePath);//转换后的文件后缀名
                        if (SwfFile != null)
                        {
                            string file = UploadFilePath.Replace(SwfFile, ".swf");
                            if (!File.Exists(file))
                            {
                                bool isconvert = ConvertPdfToSwf(UploadFilePath, file.Replace("UploadFile", "SwfFolder"));//执行转换
                                if (isconvert == true)
                                {
                                    file = Path.GetFileName(file);
                                    string FlashView = "http://199.99.99.111:8011/FlashPrinter/Interface/FlashView.aspx";
                                    Response.Write(" <script> window.location.href= '" + FlashView + "?dFile=" + HttpUtility.UrlEncode(file) + "'; </script> ");
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }

            }
        }复制代码

 

Insus.NET重构之后,主方法变为:

复制代码 public string file;//显示生成完成的swf文件
    protected void Button1_Click(object sender, EventArgs e)
    {
        string UploadFilePath = Server.MapPath(this.HiddenField1.Value);//保存上传的PDF或者其他可以打印的文件(DOC,DOCX等) /UploadFile/系统分析师通过的经验.doc
        
        string ext = Path.GetExtension(UploadFilePath);

        if (ExtensionType().ContainsKey(ext))
        {
             MoveFile(ext, UploadFilePath);
        }
        else
        {
            ConvertFile(UploadFilePath);
        }
    }复制代码

 

扩展类型:

5acf071e0001405b00110016.jpgView Code  private Dictionary<string, string> ExtensionType()
    { 
         Dictionary<string, string> ex_type = new Dictionary<string, string>();
        ex_type.Add(".wps", ".doc");
        ex_type.Add(".et", ".xls");
        ex_type.Add(".pps", ".ppt");
        ex_type.Add(".dps", ".ppt");
        return ex_type;
    }

 

MoveFile()方法:

5acf071e0001405b00110016.jpgView Code  private void MoveFile(string ext, string uploadFilePath)
    {
        string NewUploadFilePath = string.Empty;//转换WPS文件路径

        if (ExtensionType().ContainsKey(ext))
        {
            NewUploadFilePath = Path.ChangeExtension(uploadFilePath, ExtensionType()[ext].ToString());
            File.Move(uploadFilePath, NewUploadFilePath);
        }

        ConvertFile(NewUploadFilePath);
    }

 

ConvertFile()方法:

5acf071e0001405b00110016.jpgView Code  private void ConvertFile(string uploadFilepath)
    {
        if (uploadFilepath == null) return;

        if (string.IsNullOrEmpty(strType(uploadFilepath))) return;

        string SwfFile = strType(uploadFilepath);
        string file = uploadFilepath.Replace(SwfFile, ".swf");
        if (!File.Exists(file)) return;

        try
        {
            bool isconvert = ConvertPdfToSwf(uploadFilepath, file.Replace("UploadFile", "SwfFolder"));
            if (isconvert)
            {
                file = Path.GetFileName(file);
                string FlashView = "http://199.99.99.111:8011/FlashPrinter/Interface/FlashView.aspx";
                Response.Write(" <script> window.location.href= '" + FlashView + "?dFile=" + HttpUtility.UrlEncode(file) + "'; </script> ");
            }
        }
        catch (Exception)
        {
            throw;
        }
    }

 

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評論
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報(bào)

0/150
提交
取消