public FormForgotPass(string logUserId)
 {
     InitializeComponent();
     txtPassword.Enabled    = false;
     txtConfirmPass.Enabled = false;
     btnSave.Enabled        = false;
     sCode           = ConfigDB.LoadConfig(Config.ParamValues.RANDOM_CODE).CONF_VALUE;
     sUserId         = logUserId;
     this.isModified = false;
 }
Пример #2
0
        public static bool SendMail(string strPathFile, string strTo, string strDisplayName, string strBodyRandom)
        {
            try
            {
                string strHost = "";
                var    config  = ConfigDB.LoadConfig(Config.ParamValues.DOMINIO_MAIL);
                if (config.CONF_VALUE == null)
                {
                    throw new Exception("Dominio mail non valido");
                }
                strHost = config.CONF_VALUE;

                if (!Mail.IsValidEmail(strTo))
                {
                    MessageBox.Show("L'indirizzo mail del destinatario non è valido", "Indirizzo Mail Non Valido", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }

                config = ConfigDB.LoadConfig(Config.ParamValues.MITTENTE_MAIL);
                if (config.CONF_VALUE == null)
                {
                    throw new Exception("Indirizzo mail del mittente non è valido");
                }
                MailAddress from = new MailAddress(config.CONF_VALUE, config.CONF_VALUE);
                MailAddress to   = new MailAddress(strTo, strDisplayName);

                List <MailAddress> cc = new List <MailAddress>();
                //cc.Add(new MailAddress("*****@*****.**", "Name and stuff"));

                string strObject = "";
                string strBody   = strBodyRandom;

                if (string.IsNullOrEmpty(strBody))
                {
                    config = ConfigDB.LoadConfig(Config.ParamValues.OGGETTO_MAIL);
                    if (!string.IsNullOrEmpty(config.CONF_VALUE))
                    {
                        strObject = config.CONF_VALUE;
                    }

                    config = ConfigDB.LoadConfig(Config.ParamValues.TESTO_MAIL);
                    if (!string.IsNullOrEmpty(config.CONF_VALUE))
                    {
                        strBody = config.CONF_VALUE;
                    }
                }
                SendMail(strObject, strBody, strHost, strPathFile, from, to, cc);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Non è stato possibile inviare la mail.", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
        }
        public static void GetXML(Users user)
        {
            string strFilePath = FileService.CreateFolder(ConfigDB.LoadConfig(Config.ParamValues.DIRECTORY_XML).CONF_VALUE);

            //deve essere creata una nuova cartella dentro la quale andare a salvare il file chiamato sempre guest
            //string strFilePath = CaricaFileService.GetXMLPathFileToSave();
            if (string.IsNullOrEmpty(strFilePath))
            {
                return;
            }

            strFilePath = strFilePath + "\\Guest.xml";

            FileStream fileStream = new FileStream(strFilePath, FileMode.Create, FileAccess.Write);

            try
            {
                XmlSerializer     serializer = new XmlSerializer(typeof(EricsoftGuestData));
                EricsoftGuestData ericsofts  = LoadEricsoft(user);

                using (fileStream)
                {
                    XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                    ns.Add("", "");
                    serializer.Serialize(fileStream, ericsofts, ns);

                    if (serializer == null)
                    {
                        throw new SerializationException();
                    }
                }
                if (!File.Exists(strFilePath))
                {
                    throw new ApplicationException(" File non esistente. ");
                }

                MessageBox.Show("File è stato correttamente salvato nella directory: " + strFilePath, "Export File", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (ApplicationException e)
            {
                MessageBox.Show("Impossibile trovare il file nella posizione indicata. " + e.Message, "File non trovato", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (SerializationException e)
            {
                MessageBox.Show("Serializzazione fallita. Motivo: " + e.Message, "Export File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                fileStream.Close();
            }
        }
        private void btnWacom_Click(object sender, EventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("E' possibile aprire il programma Wacom Sign PRO PDF Vuoi continuare ?", "Creazione account", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                return;
            }

            try
            {
                var runCommand = ConfigDB.LoadConfig(Config.ParamValues.SIGN_PRO_PDF).CONF_VALUE;
                if (string.IsNullOrEmpty(runCommand))
                {
                    throw new Exception("stringa di configurazione per Wacom Sign Pro Pdf non settata correttamente.");
                }

                var process = Process.Start(runCommand);
                process.WaitForExit();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Errore: " + ex.Message, "Configurazione errata");
            }
        }
Пример #5
0
        private void btnFirma_Click(object sender, EventArgs e)
        {
            if (this.isModified)
            {
                if (DialogResult.No == MessageBox.Show("Per proseguire è necessario salvare i dati inseriti. Vuoi proseguire ?", "Firma documento", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    return;
                }

                if (!ValidateControls())
                {
                    return;
                }

                Save();
            }

            //if (DialogResult.No == MessageBox.Show("Selezionare una directory in cui salvare il documento." +  Environment.NewLine + "Vuoi proseguire ?", "Firma documento", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            //    return;

            //SaveFileDialog dlg = new SaveFileDialog
            //{
            //    Title = "Salvataggio Pdf",
            //    AddExtension = true,
            //    Filter = "PDF|*.pdf"
            //};

            //if (dlg.ShowDialog() != DialogResult.OK)
            //    return;

            //if (string.IsNullOrEmpty(dlg.FileName))
            //    return;

            if (cmbTemplate.SelectedIndex == 0)
            {
                MessageBox.Show("E' necessario selezionare un template valido !", "Firma documento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.isModified = false;
                return;
            }

            string strFileNameOutput = $"{FileHelper.GetPath("pdfElab")}{user.COGNOME}" + " " + $"{user.NOME}" + " " + $"{DateTime.Today:yyyyMMdd}" + ".pdf";
            string strFileName       = PDFManager.RunSignPro(strFileNameOutput, cmbTemplate.SelectedIndex, user);

            if (string.IsNullOrEmpty(strFileName))
            {
                return;
            }

            var pathString = FirmaInCloudDB.LoadTemplate(cmbTemplate.SelectedIndex, "").AsEnumerable().First();

            FileNameParser fileNameParser = new FileNameParser(strFileName);

            TemplateLinq templateLinq = new TemplateLinq
            {
                KEY_USER  = user.KEY_USER,
                DTSIGN    = DateTime.Now,
                PATH      = strFileName,
                DESCR     = fileNameParser.DESCR,
                KEY_TEMPL = Convert.ToInt32(pathString.ItemArray[0])
            };

            FirmaInCloudDB.SaveTemplate_Linq(templateLinq, user);

            ConfigDB.SaveConfig(Config.ParamValues.COUNT, (int.Parse(ConfigDB.LoadConfig(Config.ParamValues.COUNT).CONF_VALUE) + 1).ToString());

            LoadTemplate_Linq(templateLinq);

            if (DialogResult.No == MessageBox.Show("E' possibile inviare il documento appena firmato all'indirizzo mail: " + user.MAIL + Environment.NewLine + "Vuoi proseguire ?", "Firma documento", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                return;
            }

            Mail.SendMail(strFileName, txtMail.Text, user.NOME + " " + user.COGNOME, "");
        }
        private static string FillPdf(string strFileNameInput, string strFileNameOuput, Users user, int intKey)
        {
            try
            {
                //strFileNameInput = "C:\\Users\\Notebook\\source\\repos\\SDR_FirmaInCloud\\Template FirmaInCloud\\GrandePrivacy.pdf";

                string     jsonString    = System.IO.File.ReadAllText(".\\Pdf\\configApi.json");
                SignProApi signProConfig = JsonSerializer.Deserialize <SignProApi>(jsonString);

                string strFileOutPut = CreatePdf(strFileNameInput, strFileNameOuput, user, intKey);
                if (string.IsNullOrEmpty(strFileOutPut))
                {
                    return(null);
                }

                signProConfig.file.input.filesystem = strFileOutPut;

                FileInfo fileInfo = new FileInfo(strFileOutPut);

                signProConfig.file.output.filesystem = $"{FileHelper.GetPath("pdfElab")}{user.COGNOME}" + " " + $"{user.NOME}" + " " + $"{DateTime.Today:yyyyMMdd}" + "_Out_" + fileInfo.Extension;

                //strFileOutPut = signProConfig.file.output.filesystem;

                Signature signature = SetSignature(user.COGNOME + " " + user.NOME);

                signProConfig.signatures = new List <Signature>();
                signProConfig.signatures.Add(signature);

                jsonString = JsonSerializer.Serialize <SignProApi>(signProConfig);
                string b64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(jsonString));

                var runCommand = ConfigDB.LoadConfig(Config.ParamValues.SIGN_PRO_PDF).CONF_VALUE;
                if (string.IsNullOrEmpty(runCommand))
                {
                    throw new Exception("stringa di configurazione per Wacom Sign Pro Pdf non settata correttamente.");
                }

                //string runCommand = config.CONF_VALUE;//"C:\\Program Files (x86)\\Wacom sign pro PDF\\Sign Pro PDF.exe"; // - api signpro:< base64 - json >";

                var param = "-api signpro:" + b64;
                //Process.Start("C:\\Program Files (x86)\\Wacom sign pro PDF\\Sign Pro PDF.exe", param);


                ProcessStartInfo processStartInfo = new ProcessStartInfo(runCommand, param);
                Process          process          = new Process();
                process.StartInfo = processStartInfo;

                if (!process.Start())
                {
                    throw new InvalidOperationException(" configurazione errata - Wacom Sign Pro Pdf");
                }

                process.WaitForExit();
                if (System.IO.File.Exists(signProConfig.file.output.filesystem))
                {
                    return(signProConfig.file.output.filesystem);
                }
                else
                {
                    return(string.Empty);
                }
            }
            catch (InvalidOperationException invEx)
            {
                MessageBox.Show("Errore:" + invEx.Message, "Wacom Sign Pro Pdf", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                return(null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Errore: " + ex.Message, "Configurazione errata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }