예제 #1
0
        /// <summary>
        /// 下载功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DownBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                STTemplate summarize = (sender as System.Windows.Documents.Hyperlink).Tag as STTemplate;
                if (summarize == null)
                {
                    return;
                }
                string guid = summarize.GUID;

                STTemplate sTTemplateFile = new STTemplate();
                BeOperationInvoker.Invoke <I_CO_IA_ActivitySummarize>(channel =>
                {
                    sTTemplateFile = channel.GetSummarizeTemplateFile(guid);
                });

                byte[]         file           = sTTemplateFile.FILEDOC;
                string         docstr         = summarize.NAME.Substring(summarize.NAME.LastIndexOf('.'));
                string         serviceDocPath = ByteConvertDocService(file, summarize.NAME);
                WebClient      webClient      = new WebClient();
                SaveFileDialog dlg            = new SaveFileDialog();
                dlg.FileName = summarize.NAME;
                //dlg.Reset();
                if (docstr == ".doc" || docstr == ".docx")
                {
                    dlg.Filter += "Word 文件|*.doc;*.docx";
                }
                else if (docstr == ".xls" || docstr == ".xlsx")
                {
                    dlg.Filter += "Excel 文件|*.xls;*.xlsx";
                }
                // dlg.Filter = "Office Files|*.doc;*.docx;*.xls;*.xlsx";
                if (dlg.ShowDialog() == true)
                {
                    try
                    {
                        webClient.DownloadFile(serviceDocPath, dlg.FileName);
                        MessageBox.Show("文件下载成功!");
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.GetExceptionMessage());
            }
        }
예제 #2
0
        private string downLoadTemplate(string guid)
        {
            try
            {
                STTemplate sTTemplateFile = new STTemplate();
                BeOperationInvoker.Invoke <I_CO_IA_ActivitySummarize>(channel =>
                {
                    sTTemplateFile = channel.GetSummarizeTemplateFile(guid);
                });

                byte[]    file           = sTTemplateFile.FILEDOC;
                string    docstr         = sTTemplateFile.NAME.Substring(sTTemplateFile.NAME.LastIndexOf('.'));
                string    serviceDocPath = ByteConvertDocService(file, sTTemplateFile.NAME);
                WebClient webClient      = new WebClient();
                //SaveFileDialog dlg = new SaveFileDialog();
                //dlg.FileName = sTTemplateFile.NAME;
                //dlg.Reset();
                //if (docstr == ".doc" || docstr == ".docx")
                //{
                //    dlg.Filter += "Word 文件|*.doc;*.docx";
                //}
                //else if (docstr == ".xls" || docstr == ".xlsx")
                //{
                //    dlg.Filter += "Excel 文件|*.xls;*.xlsx";
                //}
                // dlg.Filter = "Office Files|*.doc;*.docx;*.xls;*.xlsx";

                webClient.DownloadFile(serviceDocPath, sTTemplateFile.NAME);
                //if (dlg.ShowDialog() == true)
                //{
                //    try
                //    {
                //        webClient.DownloadFile(serviceDocPath, dlg.FileName);
                //    }
                //    catch (Exception)
                //    {
                //        return "";
                //    }
                //}
                return(serviceDocPath);
            }
            catch (Exception ex)
            {
                return("");
                //MessageBox.Show(ex.GetExceptionMessage());
            }
        }