Ejemplo n.º 1
0
 private void AggiungiInADL(List <string> listIdDocToAdd)
 {
     try
     {
         List <WorkingArea> listWorkingArea       = new List <WorkingArea>();
         WorkingArea        objectArea            = null;
         string             idDocumentoPrincipale = string.Empty;
         InfoDocumento      infoDocPrincipale;
         foreach (string id in listIdDocToAdd)
         {
             ElementoInLibroFirma elemento = (from e in this.ListaElementiFiltrati
                                              where e.InfoDocumento.Docnumber.Equals(id)
                                              select e).FirstOrDefault();
             if (elemento != null)
             {
                 objectArea            = new WorkingArea();
                 objectArea.ObjectType = AreaLavoroTipoOggetto.DOCUMENTO;
                 if (!string.IsNullOrEmpty(elemento.InfoDocumento.IdDocumentoPrincipale) &&
                     !ListIdDocumentSigned.Contains(elemento.InfoDocumento.IdDocumentoPrincipale))
                 {
                     idDocumentoPrincipale    = elemento.InfoDocumento.IdDocumentoPrincipale;
                     infoDocPrincipale        = UIManager.DocumentManager.GetInfoDocumento(idDocumentoPrincipale, idDocumentoPrincipale, this);
                     objectArea.IdObject      = idDocumentoPrincipale;
                     objectArea.TipoDocumento = infoDocPrincipale.tipoProto;
                     objectArea.IdRegistro    = infoDocPrincipale.idRegistro;
                     objectArea.Motivo        = Utils.Languages.GetLabelFromCode("SignatureSelectedItemAreaMotivoAllegato", UIManager.UserManager.GetUserLanguage());
                 }
                 else
                 {
                     objectArea.IdObject      = elemento.InfoDocumento.Docnumber;
                     objectArea.TipoDocumento = elemento.InfoDocumento.TipoProto;
                     objectArea.IdRegistro    = elemento.InfoDocumento.IdRegistro;
                     objectArea.Motivo        = Utils.Languages.GetLabelFromCode("SignatureSelectedItemAreaMotivo", UIManager.UserManager.GetUserLanguage());
                 }
                 listWorkingArea.Add(objectArea);
             }
         }
         if (listWorkingArea != null && listWorkingArea.Count > 0)
         {
             UIManager.DocumentManager.AddMassiveObjectInADL(listWorkingArea);
         }
     }
     catch (Exception e)
     {
     }
 }
Ejemplo n.º 2
0
        protected void SignatureSelectedItemsConfirm_Click(object sender, EventArgs e)
        {
            bool noDigitalSign = true;

            try
            {
                ReportSignatureSelected = new MassiveOperationReport();
                //MassiveOperationReport report = new MassiveOperationReport();
                MassiveOperationUtils.ItemsStatus = null;
                MassiveOperationReport.MassiveOperationResultEnum result;
                string             oggetto = string.Empty;
                string             details;
                string             popupCall     = string.Empty;
                List <FileRequest> fileReqToSign = new List <FileRequest>();
                this.ListIdDocumentSigned = new List <string>();
                Allegato  attach;
                Documento doc;

                #region AVANZAMENTO ITER
                List <ElementoInLibroFirma> listElementAdvancementProcess = (from i in this.ListaElementiLibroFirma
                                                                             where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.ADVANCEMENT_PROCESS) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE)
                                                                             select i).ToList();
                if (listElementAdvancementProcess != null && listElementAdvancementProcess.Count > 0)
                {
                    foreach (ElementoInLibroFirma element in listElementAdvancementProcess)
                    {
                        if (string.IsNullOrEmpty(element.InfoDocumento.IdDocumentoPrincipale))
                        {
                            doc = new Documento()
                            {
                                descrizione  = element.InfoDocumento.Oggetto,
                                docNumber    = element.InfoDocumento.Docnumber,
                                versionId    = element.InfoDocumento.VersionId,
                                version      = element.InfoDocumento.NumVersione.ToString(),
                                versionLabel = element.InfoDocumento.NumAllegato.ToString(),
                                inLibroFirma = true
                            };
                            fileReqToSign.Add(doc as FileRequest);
                        }
                        else
                        {
                            attach = new Allegato()
                            {
                                descrizione  = element.InfoDocumento.Oggetto,
                                docNumber    = element.InfoDocumento.Docnumber,
                                versionId    = element.InfoDocumento.VersionId,
                                version      = element.InfoDocumento.NumVersione.ToString(),
                                versionLabel = element.InfoDocumento.NumAllegato.ToString(),
                                inLibroFirma = true
                            };
                            fileReqToSign.Add(attach as FileRequest);
                        }
                    }
                    bool isAdvancementProcess      = true;
                    List <FirmaResult> firmaResult = LibroFirmaManager.PutElectronicSignatureMassive(fileReqToSign, isAdvancementProcess);

                    if (firmaResult != null)
                    {
                        foreach (FirmaResult r in firmaResult)
                        {
                            if (string.IsNullOrEmpty(r.errore))
                            {
                                result  = MassiveOperationReport.MassiveOperationResultEnum.OK;
                                details = "Avanzamento iter avvenuto con successo";
                                oggetto = r.fileRequest.descrizione;
                                ReportSignatureSelected.AddReportRow(
                                    oggetto,
                                    result,
                                    details);
                                ListIdDocumentSigned.Add(r.fileRequest.docNumber);
                            }
                            else
                            {
                                result  = MassiveOperationReport.MassiveOperationResultEnum.KO;
                                oggetto = r.fileRequest.descrizione;
                                details = String.Format(
                                    "Si sono verificati degli errori durante la procedura di avanzamento. {0}",
                                    r.errore);
                                ReportSignatureSelected.AddReportRow(
                                    oggetto,
                                    result,
                                    details);
                            }
                        }
                    }
                }
                #endregion

                #region SOTTOSCRIZIONE

                fileReqToSign.Clear();
                List <ElementoInLibroFirma> listElementSubscription = (from i in this.ListaElementiLibroFirma
                                                                       where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.VERIFIED) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE)
                                                                       select i).ToList();
                if (listElementSubscription != null && listElementSubscription.Count > 0)
                {
                    foreach (ElementoInLibroFirma element in listElementSubscription)
                    {
                        if (string.IsNullOrEmpty(element.InfoDocumento.IdDocumentoPrincipale))
                        {
                            doc = new Documento()
                            {
                                descrizione  = element.InfoDocumento.Oggetto,
                                docNumber    = element.InfoDocumento.Docnumber,
                                versionId    = element.InfoDocumento.VersionId,
                                version      = element.InfoDocumento.NumVersione.ToString(),
                                versionLabel = element.InfoDocumento.NumAllegato.ToString(),
                                tipoFirma    = element.TipoFirmaFile,
                                inLibroFirma = true
                            };
                            fileReqToSign.Add(doc as FileRequest);
                        }
                        else
                        {
                            attach = new Allegato()
                            {
                                descrizione  = element.InfoDocumento.Oggetto,
                                docNumber    = element.InfoDocumento.Docnumber,
                                versionId    = element.InfoDocumento.VersionId,
                                version      = element.InfoDocumento.NumVersione.ToString(),
                                versionLabel = element.InfoDocumento.NumAllegato.ToString(),
                                tipoFirma    = element.TipoFirmaFile,
                                inLibroFirma = true
                            };
                            fileReqToSign.Add(attach as FileRequest);
                        }
                    }
                    bool isAdvancementProcess      = false;
                    List <FirmaResult> firmaResult = LibroFirmaManager.PutElectronicSignatureMassive(fileReqToSign, isAdvancementProcess);

                    if (firmaResult != null)
                    {
                        foreach (FirmaResult r in firmaResult)
                        {
                            if (string.IsNullOrEmpty(r.errore))
                            {
                                result  = MassiveOperationReport.MassiveOperationResultEnum.OK;
                                details = "Sottoscrizione avvenuta con successo";
                                oggetto = r.fileRequest.descrizione;
                                ReportSignatureSelected.AddReportRow(
                                    oggetto,
                                    result,
                                    details);
                                ListIdDocumentSigned.Add(r.fileRequest.docNumber);
                            }
                            else
                            {
                                result  = MassiveOperationReport.MassiveOperationResultEnum.KO;
                                oggetto = r.fileRequest.descrizione;
                                details = String.Format(
                                    "Si sono verificati degli errori durante la procedura di sottoscrizione. {0}",
                                    r.errore);
                                ReportSignatureSelected.AddReportRow(
                                    oggetto,
                                    result,
                                    details);
                            }
                        }
                    }
                }

                #endregion

                #region DIGITALE
                ListCheck  = new Dictionary <String, String>();
                ListToSign = new Dictionary <string, FileToSign>();

                //FIRMA PADES
                fileReqToSign.Clear();
                List <ElementoInLibroFirma> listElementSignPADES = (from i in this.ListaElementiLibroFirma
                                                                    where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE)
                                                                    select i).ToList();
                string     idDocumento    = null;
                string     fileExstention = "PDF";
                FileToSign file           = null;
                String     isFirmato      = null;
                String     signType       = null;

                if (listElementSignPADES != null && listElementSignPADES.Count > 0)
                {
                    noDigitalSign = false;
                    foreach (ElementoInLibroFirma element in listElementSignPADES)
                    {
                        idDocumento = "P" + element.InfoDocumento.Docnumber;
                        ListCheck.Add(idDocumento, idDocumento);
                        isFirmato = element != null ? element.FileOriginaleFirmato : "0";
                        signType  = element != null ? element.TipoFirmaFile : TipoFirma.NESSUNA_FIRMA;
                        if (this.ListToSign != null)
                        {
                            if (!this.ListToSign.ContainsKey(idDocumento))
                            {
                                file = new FileToSign(fileExstention, isFirmato, signType);
                                this.ListToSign.Add(idDocumento, file);
                            }
                            else
                            {
                                file               = this.ListToSign[idDocumento];
                                file.signed        = isFirmato;
                                file.fileExtension = fileExstention;
                            }
                        }
                    }
                }

                //FIRMA CADES
                fileReqToSign.Clear();
                List <ElementoInLibroFirma> listElementSignCADES = (from i in this.ListaElementiLibroFirma
                                                                    where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.SIGN_CADES) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE)
                                                                    select i).ToList();
                if (listElementSignCADES != null && listElementSignCADES.Count > 0)
                {
                    noDigitalSign = false;
                    foreach (ElementoInLibroFirma element in listElementSignCADES)
                    {
                        idDocumento = "C" + element.InfoDocumento.Docnumber;
                        ListCheck.Add(idDocumento, idDocumento);
                        isFirmato = element != null ? element.FileOriginaleFirmato : "0";
                        signType  = element != null ? element.TipoFirmaFile : TipoFirma.NESSUNA_FIRMA;
                        if (this.ListToSign != null)
                        {
                            if (!this.ListToSign.ContainsKey(idDocumento))
                            {
                                isFirmato = element != null ? element.FileOriginaleFirmato : "0";
                                file      = new FileToSign(fileExstention, isFirmato, signType);
                                this.ListToSign.Add(idDocumento, file);
                            }
                            else
                            {
                                file               = this.ListToSign[idDocumento];
                                file.signed        = isFirmato;
                                file.fileExtension = fileExstention;
                                file.signType      = signType;
                            }
                        }
                    }
                }

                #endregion

                if (noDigitalSign)
                {
                    DigitalSignatureSelectedItem();
                }
                else
                {
                    switch (tipoSupportoFirma)
                    {
                    case "H":
                        HttpContext.Current.Session["CommandType"] = null;
                        popupCall = "ajaxModalPopupMassiveSignatureHSM();";
                        break;

                    case "L":
                        componentType = UserManager.getComponentType(Request.UserAgent);
                        if (componentType == Constans.TYPE_ACTIVEX || componentType == Constans.TYPE_SMARTCLIENT)
                        {
                            popupCall = "ajaxModalPopupMassiveDigitalSignature();";
                        }
                        else if (componentType == Constans.TYPE_APPLET)
                        {
                            HttpContext.Current.Session["CommandType"] = null;
                            popupCall = "ajaxModalPopupMassiveDigitalSignatureApplet();";
                        }
                        else if (componentType == Constans.TYPE_SOCKET)
                        {
                            HttpContext.Current.Session["CommandType"] = null;
                            popupCall = "ajaxModalPopupMassiveDigitalSignatureSocket();";
                        }
                        break;
                    }
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "MassiveSignatureHSM", popupCall, true);
                }
            }
            catch (System.Exception ex)
            {
                UIManager.AdministrationManager.DiagnosticError(ex);
                return;
            }
        }