Exemplo n.º 1
0
        private void btnGetReport_Click(object sender, EventArgs e)
        {
            btnGetReport.Enabled = false;
            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", "18");
            _Forms.UniqueDataStructure.AcceptChanges();
            DataSet TheData = new DataSet();

            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);
                txtPDF.Text         = _PrintedForm.PDFLocation;
                txtFormPrintID.Text = _PrintedForm.PrintedFromID;
                if (_PrintedForm.Success)
                {
                    txtError.Text = "NO ERROR";
                }
                else
                {
                    txtError.Text = _PrintedForm.Error;
                }
            }
            catch (Exception error)
            {
                txtError.Text = error.Message;
            }
            btnGetReport.Enabled = true;
        }
Exemplo n.º 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();
            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))
                {
                    //    //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);
                    //i.CreateRibbon();
                    //jj.Width = 600;
                    //    jj.Height = 800;

                    //    jj.ShowIcon = false;
                    //    jj.Text = "OCR - DOCUMENT PREVIEW";
                    //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");

                    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);
                }
            }
            catch (Exception error)
            {
            }
        }
        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)
            {
            }
        }