예제 #1
0
        public static SelectedESignProperties selectESignProperties(ESign_Util.ESignUtil esignUtil)
        {
            SelectedESignProperties selectedESignProperties = null;

            using (SmartCardForms.frmSmartCardSelector frm = new SmartCardForms.frmSmartCardSelector(esignUtil))
            {
                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    selectedESignProperties = frm.SelectedESignProperties;
                }
            }
            return(selectedESignProperties);
        }
예제 #2
0
파일: frmMain.cs 프로젝트: poolsoft/eimza-1
        private void btnSignFile_Click(object sender, EventArgs e)
        {
            string fileName      = dtData.Rows[0]["FileName"].ToString();
            string fileExtension = new FileInfo(fileName).Extension.ToLower();
            string tempFile      = Application.StartupPath + "\\tmpFile.pdf";

            if (".pdf".Equals(fileExtension))
            {
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }

                FileServices.WSFileManagerSoapClient client = new FileServices.WSFileManagerSoapClient();
                byte[] fileBytes = client.getFileBytes(documentId, dtData.Rows[0]["SessionId"].ToString());

                if (fileBytes != null)
                {
                    FileStream fs = new FileStream(tempFile, FileMode.OpenOrCreate);
                    fs.Write(fileBytes, 0, fileBytes.Length);
                    fs.Flush();
                    fs.Close();


                    Classes.SelectedESignProperties selectedESignProperties = Classes.SmartCardUtils.selectESignProperties(esignUtil);
                    if (selectedESignProperties == null)
                    {
                        return;
                    }
                    string       terminal = selectedESignProperties.SelectedTerminal;
                    ECertificate cert     = selectedESignProperties.SelectedCertificate;
                    string       pinCode  = selectedESignProperties.EnteredPinCode;
                    try
                    {
                        byte[] signedFileBytes = esignUtil.signPdfWithSmartCard(terminal, cert, pinCode, tempFile);
                        if (client.uploadSignedFile(documentId, signedFileBytes))
                        {
                            MessageBox.Show(resMan.GetString("msgSignCompleted"));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show(resMan.GetString("msgJustPdfFileCanSign"));
            }
        }