示例#1
0
        private void _003CInitEvent_003Eb__a(object sender, EventArgs e)
        {
            Action action  = null;
            Action action2 = null;
            Action action3 = null;

            if (Singleton_PDFFactory.IsPDFInWork(fileItem.ID))
            {
                Dispatcher dispatcher = base.Dispatcher;
                if (action == null)
                {
                    action = new Action(_003CInitEvent_003Eb__b);
                }
                dispatcher.BeginInvoke(action);
            }
            else if (File.Exists(Path.Combine(fileItem.UnZipFilePath, "PDF.pdf")) && fileItem.FileType == MeetingFileType.已下載完成)
            {
                Dispatcher dispatcher2 = base.Dispatcher;
                if (action2 == null)
                {
                    action2 = new Action(_003CInitEvent_003Eb__c);
                }
                dispatcher2.BeginInvoke(action2);
            }
            else
            {
                Dispatcher dispatcher3 = base.Dispatcher;
                if (action3 == null)
                {
                    action3 = new Action(_003CInitEvent_003Eb__d);
                }
                dispatcher3.BeginInvoke(action3);
            }
        }
示例#2
0
        private void InitUI()
        {
            sb.Begin();
            if (Singleton_PDFFactory.IsPDFInWork(fileItem.ID))
            {
                sb.Begin();
            }
            else if (File.Exists(Path.Combine(fileItem.UnZipFilePath, "PDF.pdf")) && fileItem.FileType == MeetingFileType.已下載完成)
            {
                sb.Stop();
                pdfStatus      = PDFStatus.匯出成功;
                txtStatus.Text = pdfStatus.ToString();
            }
            else
            {
                sb.Stop();
                pdfStatus      = PDFStatus.尚未匯出;
                txtStatus.Text = pdfStatus.ToString();
            }
            PDFStatus pDFStatus = pdfStatus;

            if (pDFStatus == PDFStatus.匯出成功)
            {
                btnExport.Visibility   = Visibility.Visible;
                btnDownload.Visibility = Visibility.Visible;
            }
        }
示例#3
0
        private void InitUI()
        {
            //this.txtIndex.Text = index.ToString();
            //this.txtFileName.Text = fileItem.FileName;

            sb.Begin();
            if (Singleton_PDFFactory.IsPDFInWork(fileItem.ID) == true)
            {
                //PDFStatus.匯出中;
                sb.Begin();
            }
            else if (File.Exists(System.IO.Path.Combine(fileItem.UnZipFilePath, "PDF.pdf")) == true && fileItem.FileType == MeetingFileType.已下載完成)
            {
                sb.Stop();
                pdfStatus      = PDFStatus.匯出成功;
                txtStatus.Text = pdfStatus.ToString();
            }
            else
            {
                sb.Stop();
                pdfStatus      = PDFStatus.尚未匯出;
                txtStatus.Text = pdfStatus.ToString();
            }

            switch (pdfStatus)
            {
            case PDFStatus.匯出成功:
                btnExport.Visibility   = Visibility.Visible;
                btnDownload.Visibility = Visibility.Visible;
                break;
            }
        }
示例#4
0
        private void _003CInitEvent_003Eb__6()
        {
            btnExport.Visibility   = Visibility.Collapsed;
            btnDownload.Visibility = Visibility.Collapsed;
            sb.Begin();
            DataTable dataTable = MSCE.GetDataTable("select PDFFactoryParameterJson from FileRow where userid=@1 and id=@2", fileItem.UserID, fileItem.ID);

            if (dataTable.Rows.Count > 0)
            {
                PDFFactoryParameter pDFFactoryParameter = JsonConvert.DeserializeObject <PDFFactoryParameter>(dataTable.Rows[0][0].ToString());
                Home home = Enumerable.First(Enumerable.OfType <Home>(Application.Current.Windows));
                if (home.IsInSync)
                {
                    pDFFactoryParameter.UserAccount += "_Sync";
                }
                Singleton_PDFFactory.SavePDF(pDFFactoryParameter);
            }
        }
示例#5
0
 private void _003CInitEvent_003Eb__5()
 {
     Singleton_PDFFactory.AddBookInPDFWork(fileItem.ID);
     base.Dispatcher.BeginInvoke(new Action(_003CInitEvent_003Eb__6));
     Singleton_PDFFactory.RemoveBookInPDFWork(fileItem.ID);
 }
示例#6
0
        private void InitEvent()
        {
            btnExport.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnExport.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnExport.MouseLeftButtonDown += (sender, e) =>
            {
                Task.Factory.StartNew(() => {
                    Singleton_PDFFactory.AddBookInPDFWork(fileItem.ID);
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        btnExport.Visibility   = Visibility.Collapsed;
                        btnDownload.Visibility = Visibility.Collapsed;
                        sb.Begin();
                        DataTable dt = MSCE.GetDataTable("select PDFFactoryParameterJson from FileRow where userid=@1 and id=@2"
                                                         , fileItem.UserID
                                                         , fileItem.ID);
                        if (dt.Rows.Count > 0)
                        {
                            PDFFactoryParameter pdfFactoryParameter = JsonConvert.DeserializeObject <PDFFactoryParameter>(dt.Rows[0][0].ToString());
                            Home home = Application.Current.Windows.OfType <Home>().First();

                            if (home.IsInSync == true)
                            {
                                pdfFactoryParameter.UserAccount += "_Sync";
                            }

                            Singleton_PDFFactory.SavePDF(pdfFactoryParameter);
                        }
                    }));
                    Singleton_PDFFactory.RemoveBookInPDFWork(fileItem.ID);
                });
            };

            btnDownload.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnDownload.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnDownload.MouseLeftButtonDown += (sender, e) =>
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                //Environment.SpecialFolder.MyDocuments
                //This cannot be found as it is not a valid path, so nothing gets selected.
                dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                dlg.FileName         = FileNameTool.PureFileName(fileItem.FileName); // Default file name
                dlg.DefaultExt       = ".pdf";                                       // Default file extension
                dlg.Filter           = "PDF documents (.pdf)|*.pdf";                 // Filter files by extension
                // Show save file dialog box
                Nullable <bool> result = dlg.ShowDialog();
                // Process save file dialog box results
                if (result == true)
                {
                    // Save document
                    string srcFilePath  = System.IO.Path.Combine(fileItem.UnZipFilePath, "PDF.pdf");
                    string saveFilePath = dlg.FileName;
                    if (File.Exists(srcFilePath) == true)
                    {
                        File.Copy(srcFilePath, saveFilePath, true);
                    }
                }
            };


            //偵測是否轉檔中
            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(1100);
            timer.Tick    += (sender, e) =>
            {
                if (Singleton_PDFFactory.IsPDFInWork(fileItem.ID) == true)
                {
                    //this.Dispatcher.BeginInvoke(new Action(() =>
                    //    {
                    //        //Console.Write(sb.GetIsPaused());
                    //        //sb.Begin();
                    //    }));
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        pdfStatus              = PDFStatus.匯出中;
                        btnExport.Visibility   = Visibility.Collapsed;
                        btnDownload.Visibility = Visibility.Collapsed;
                        txtStatus.Text         = pdfStatus.ToString();
                    }));
                }
                else if (File.Exists(System.IO.Path.Combine(fileItem.UnZipFilePath, "PDF.pdf")) == true && fileItem.FileType == MeetingFileType.已下載完成)
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        sb.Stop();
                        pdfStatus              = PDFStatus.匯出成功;
                        btnExport.Visibility   = Visibility.Visible;
                        btnDownload.Visibility = Visibility.Visible;
                        txtStatus.Text         = pdfStatus.ToString();
                    }));
                }
                else
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        sb.Stop();
                        pdfStatus              = PDFStatus.尚未匯出;
                        btnExport.Visibility   = Visibility.Collapsed;
                        btnDownload.Visibility = Visibility.Collapsed;
                        txtStatus.Text         = pdfStatus.ToString();
                    }));
                }
            };
            timer.Start();
        }