private void GetReport(string FormsID)
        {
            string GetReportRL = string.Format(@"/api/Report/GetReport/");
            var    client      = new ClientConnect();
            var    param       = new Dictionary <string, string>();
            var    header      = new Dictionary <string, string>();

            param.Add("FormsID", FormsID);
            _Forms.UniqueDataStructure.AcceptChanges();
            DataSet TheData = new DataSet();

            TheData.Tables.Clear();
            TheData.Tables.Add(_Forms.UniqueDataStructure);
            string JSOResult;

            JSOResult = JsonConvert.SerializeObject(TheData, Formatting.Indented);
            try
            {
                //this.pdfViewer1.LoadDocument(@"..\..\Report.pdf"

                var response = Task.Run(() => client.PostWithBodyAndParameters(GetReportRL, param, JSOResult)).Result;
                _PrintedForm = JsonConvert.DeserializeObject <PrintedForm>(response);
                string txtPDF = _PrintedForm.PDFLocation;

                if (File.Exists(@_PrintedForm.PDFLocation))
                {
                    if (MoveToProdind)
                    {
                        //Process.Start("explorer.exe", _PrintedForm.PDFLocation);
                        PdfViewer i = new PdfViewer();
                        DevExpress.XtraEditors.XtraForm jj = new DevExpress.XtraEditors.XtraForm();
                        i.LoadDocument(@_PrintedForm.PDFLocation);
                        i.Dock     = DockStyle.Fill;
                        i.ZoomMode = PdfZoomMode.FitToWidth;
                        i.NavigationPanePageVisibility = PdfNavigationPanePageVisibility.None;
                        jj.Controls.Add(i);
                        jj.Width  = 600;
                        jj.Height = 800;
                        jj.Show();
                        jj.ShowIcon = false;
                        jj.Text     = "OCR - DOCUMENT PREVIEW";
                        i.CreateRibbon();
                        // PdfPrinterSettings ps = new PdfPrinterSettings();
                        // i.Print(ps);
                    }
                    else
                    {
                        PdfViewer i = new PdfViewer();
                        DevExpress.XtraEditors.XtraForm jj = new DevExpress.XtraEditors.XtraForm();
                        i.LoadDocument(@_PrintedForm.PDFLocation);
                        i.Dock     = DockStyle.Fill;
                        i.ZoomMode = PdfZoomMode.FitToWidth;
                        i.NavigationPanePageVisibility = PdfNavigationPanePageVisibility.None;
                        jj.Controls.Add(i);
                        jj.Width  = 600;
                        jj.Height = 800;
                        jj.Show();
                        jj.ShowIcon = false;
                        jj.Text     = "CHECKLIST EXAMPLE - CANNOT BE PRINTED";
                    }
                }
            }
            catch (Exception error)
            {
            }
        }
Пример #2
0
        private void GetReport(string FormsID)
        {
            string GetReportRL = string.Format(@"/api/Report/GetReport/");
            var    client      = new ClientConnect();
            var    param       = new Dictionary <string, string>();
            var    header      = new Dictionary <string, string>();

            param.Add("FormsID", FormsID);
            _Forms.UniqueDataStructure.AcceptChanges();
            DataSet TheData = new DataSet();

            TheData.Tables.Clear();
            if (_Forms.UniqueDataStructure.DataSet != null)
            {
                DataSet dss = _Forms.UniqueDataStructure.DataSet;
                dss.Tables.Remove(_Forms.UniqueDataStructure);
            }

            TheData.Tables.Add(_Forms.UniqueDataStructure);
            string JSOResult;

            JSOResult = JsonConvert.SerializeObject(TheData, Formatting.Indented);
            try
            {
                var response = Task.Run(() => client.PostWithBodyAndParameters(GetReportRL, param, JSOResult)).Result;
                _PrintedForm = JsonConvert.DeserializeObject <PrintedForm>(response);
                string txtPDF = _PrintedForm.PDFLocation;

                if (File.Exists(@_PrintedForm.PDFLocation))
                {
                    if (MoveToProdind)
                    {
                        ////Process.Start("explorer.exe", _PrintedForm.PDFLocation);
                        //PdfViewer i = new PdfViewer();
                        //DevExpress.XtraEditors.XtraForm jj = new DevExpress.XtraEditors.XtraForm();
                        //i.LoadDocument(@_PrintedForm.PDFLocation);
                        //i.Dock = DockStyle.Fill;
                        //i.ZoomMode = PdfZoomMode.FitToWidth;
                        //i.NavigationPanePageVisibility = PdfNavigationPanePageVisibility.None;
                        //jj.Controls.Add(i);
                        //jj.Width = 600;
                        //jj.Height = 800;

                        //jj.ShowIcon = false;
                        //jj.Text = "OCR - DOCUMENT PREVIEW";
                        //i.CreateRibbon();
                        //jj.ShowDialog();
                        ////if (barCheckItem1.Checked == true)
                        ////{
                        ////    PdfPrinterSettings ps = new PdfPrinterSettings();
                        ////    i.Print(ps);
                        ////}

                        DateTime i            = DateTime.Now;
                        string   newFolder    = "Mineware_OCR";
                        string   newFolderDay = newFolder + @"\" + i.ToString("yyyy'_'MM'_'dd") + "_BulkPrint";

                        string path = System.IO.Path.Combine(
                            Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                            newFolder
                            );

                        if (!System.IO.Directory.Exists(path))
                        {
                            try
                            {
                                System.IO.Directory.CreateDirectory(path);
                            }
                            catch (IOException ie)
                            {
                                Console.WriteLine("IO Error: " + ie.Message);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("General Error: " + e.Message);
                            }
                        }

                        string pathDay = System.IO.Path.Combine(
                            Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                            newFolderDay
                            );

                        if (!System.IO.Directory.Exists(pathDay))
                        {
                            try
                            {
                                System.IO.Directory.CreateDirectory(pathDay);
                            }
                            catch (IOException ie)
                            {
                                Console.WriteLine("IO Error: " + ie.Message);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("General Error: " + e.Message);
                            }
                        }

                        string sourceFile = System.IO.Path.Combine(Path.GetDirectoryName(@_PrintedForm.PDFLocation), Path.GetFileName(@_PrintedForm.PDFLocation));
                        string destFile   = System.IO.Path.Combine(pathDay, Path.GetFileName(@_PrintedForm.PDFLocation));
                        System.IO.File.Copy(sourceFile, destFile, true);
                    }
                    else
                    {
                        PdfViewer i = new PdfViewer();
                        DevExpress.XtraEditors.XtraForm jj = new DevExpress.XtraEditors.XtraForm();
                        i.LoadDocument(@_PrintedForm.PDFLocation);
                        i.Dock     = DockStyle.Fill;
                        i.ZoomMode = PdfZoomMode.FitToWidth;
                        i.NavigationPanePageVisibility = PdfNavigationPanePageVisibility.None;
                        jj.Controls.Add(i);
                        jj.Width  = 600;
                        jj.Height = 800;

                        jj.ShowIcon = false;
                        jj.Text     = "CHECKLIST EXAMPLE - CANNOT BE PRINTED";
                        jj.ShowDialog();
                        //if (i.PageCount / Convert.ToInt32(_PrintedForm.PrintedFromID.Count().ToString())==1)
                        //    { }
                    }
                }
            }
            catch (Exception error)
            {
            }
        }