コード例 #1
0
        public void SaveAlmPrintDetial(ALMRePrint objPlanModel)
        {
            if (objPlanModel != null)
            {
                var client  = new RestClient(IceCashRequestUrl + "SaveAlmPrintDetial");
                var request = new RestRequest(Method.POST);
                request.AddHeader("cache-control", "no-cache");
                request.AddHeader("content-type", "application/json");
                request.AddHeader("password", "Geninsure@123");
                request.AddHeader("username", "*****@*****.**");
                request.RequestFormat = DataFormat.Json;
                request.AddJsonBody(objPlanModel);

                //request.Timeout = 5000;
                //request.ReadWriteTimeout = 5000;
                IRestResponse response = client.Execute(request);
            }
        }
コード例 #2
0
        private void btnPdf_Click(object sender, EventArgs e)
        {
            if (txtLicPdfCode.Text == "" || txtLicPdfCode.Text == "Registration/Pdf Verification Code")
            {
                txtLicPdfCode.Focus();
                errorProvider1.SetError(txtLicPdfCode, "Registration/Pdf Verification Code");
                return;
            }
            else
            {
                errorProvider1.Clear();
            }

            if (IsSearchByVrn == true && (txtOtp.Text == "" || txtOtp.Text == "OTP"))
            {
                txtOtp.Focus();
                errorProvider1.SetError(txtOtp, "Please enter otp");
                return;
            }



            var vehicelDetails = new VehicleDetails();

            if (txtLicPdfCode.Text != "" && (txtOtp.Text != "" && txtOtp.Text != "OTP"))
            {
                var reprintDetial = GetAlmPrintDetialByCode(txtOtp.Text);
                if (reprintDetial != null && reprintDetial.Id != 0)
                {
                    ALMRePrint reprint = new ALMRePrint();
                    reprint.VRN       = txtLicPdfCode.Text;
                    reprint.IsActive  = true;
                    reprint.Id        = reprintDetial.Id;
                    reprint.CreatedOn = DateTime.Now;
                    SaveAlmPrintDetial(reprint);
                    PrintOutByVRN(txtLicPdfCode.Text);
                }
                else
                {
                    MyMessageBox.ShowBox("Certificate is not found for this code", "Message");
                }
            }
            else
            {
                vehicelDetails = GetVehicelDetialsByLicPdfCode(txtLicPdfCode.Text);
                if (vehicelDetails != null && vehicelDetails.VehicelId != 0)
                {
                    RequestToke token = Service_db.GetLatestToken();
                    if (ObjToken != null)
                    {
                        parternToken = token.Token;
                    }

                    pictureBox2.Visible    = true;
                    pictureBox2.WaitOnLoad = true;

                    String WebUrlPath       = WebConfigurationManager.AppSettings["WebUrlPath"];
                    string filePath         = WebUrlPath + "/" + "Documents/License/" + vehicelDetails.VehicelId + ".pdf";
                    string optionalFilePath = WebUrlPath + "/" + "Documents/License/" + vehicelDetails.RegistrationNo + ".pdf";
                    //urlPath
                    //var pdfPath = SavePdfFromUrl(filePath, optionalFilePath);
                    //// var pdfPath = @"F:\sample.pdf";
                    //PdfDocument doc = new PdfDocument();
                    //doc.LoadFromFile(pdfPath);
                    //doc.Pages.Insert(0);
                    //doc.Pages.Add();
                    //doc.Pages.RemoveAt(0);//Since First page have always Red Text if use Free Version.
                    //doc.SaveToFile(pdfPath);


                    string installedPath = @"C:\Users\Public\";
                    string fileName      = "Certificate" + ".pdf";

                    var destinationFileName = System.IO.Path.Combine(installedPath, System.IO.Path.GetFileName(fileName));


                    PdfReader  reader  = new PdfReader(filePath);
                    PdfStamper stamper = new PdfStamper(reader, new FileStream(destinationFileName, FileMode.Create));
                    int        total   = reader.NumberOfPages;
                    for (int pageNumber = total; pageNumber > 0; pageNumber--)
                    {
                        stamper.InsertPage(pageNumber, PageSize.A4);
                    }
                    stamper.Close();
                    reader.Close();


                    MyMessageBox.ShowBox("Please Print Licence Disk. ", "Print License Disk");

                    printPDFWithAcrobat(destinationFileName);
                    pictureBox2.Visible = false;

                    riskDetail = new RiskDetailModel {
                        CombinedID = vehicelDetails.CombinedID, LicenseId = vehicelDetails.LicenseId, RegistrationNo = vehicelDetails.RegistrationNo
                    };


                    this.Close();
                    WebCertificateSerial obj = new WebCertificateSerial(riskDetail, parternToken);
                    obj.Show();
                }
                else
                {
                    pictureBox2.Visible = false;
                    MyMessageBox.ShowBox("Certificate is not found for this code", "Message");
                }
            }

            pictureBox2.Visible = false;
        }