Example #1
0
        private static SchedaDocumento CreateSchedaDocumentoFromAttestato(AttestatoVO att, InfoUtente infoUtente, Ruolo ruolo, string idRegistro)
        {
            SchedaDocumento sd  = DocManager.NewSchedaDocumento(infoUtente);
            Oggetto         ogg = new Oggetto();

            ogg.idRegistro  = idRegistro;
            ogg.descrizione = att.Oggetto;
            sd.oggetto      = ogg;
            // Impostazione del registro
            sd.registro = RegistriManager.getRegistro(idRegistro);
            // Impostazione del tipo atto
            sd.tipoProto                 = "";
            sd.template                  = ProfilazioneDocumenti.getTemplateById(att.IdTemplate);
            sd.tipologiaAtto             = new TipologiaAtto();
            sd.tipologiaAtto.descrizione = sd.template.DESCRIZIONE;
            sd.tipologiaAtto.systemId    = sd.template.SYSTEM_ID.ToString();
            sd.daAggiornareTipoAtto      = true;
            sd = DocSave.addDocGrigia(sd, infoUtente, ruolo);
            Allegato all = new Allegato();

            all.descrizione = "ALL1";
            all.docNumber   = sd.docNumber;
            all.version     = "0";
            string idPeopleDelegato = "0";

            if (infoUtente.delegato != null)
            {
                idPeopleDelegato = infoUtente.delegato.idPeople;
            }
            all.idPeopleDelegato = idPeopleDelegato;

            // Impostazione del repositoryContext associato al documento
            all.repositoryContext = sd.repositoryContext;
            all.position          = 1;
            Allegato resAll = AllegatiManager.aggiungiAllegato(infoUtente, all);

            sd.allegati = new ArrayList();
            sd.allegati.Add(resAll);
            return(sd);
        }
Example #2
0
        public static ImportAttestatiResponse ImportAttestati(ImportAttestatiRequest request)
        {
            ImportAttestatiResponse resp            = new ImportAttestatiResponse();
            InfoUtente             iu               = null;
            Ruolo                  role             = null;
            List <SchedaDocumento> docsTrasmissione = new List <SchedaDocumento>();

            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                try
                {
                    iu               = request.InfoUtente.InfoUtente;
                    role             = UserManager.getRuolo(request.Ruolo.Id);
                    iu.idGruppo      = role.idGruppo;
                    iu.idCorrGlobali = role.systemId;
                    AttestatiListVO attestati = request.Attestati;
                    //lock del documento principale
                    logger.Debug("lock del documento principale, doc number : " + attestati.DocNumber);
                    //creazione schede
                    foreach (AttestatoVO att in attestati.Attestati)
                    {
                        SchedaDocumento sd = CreateSchedaDocumentoFromAttestato(att, iu, role, request.IdRegistro);
                        AcquireFileAndAllegato(att, sd, iu);
                        docsTrasmissione.Add(sd);
                    }
                    //set dello stato del doc principale
                    SchedaDocumento attList = DocManager.getDettaglio(iu, null, request.Attestati.DocNumber);
                    OggettoCustom   oc      = attList.template.ELENCO_OGGETTI.Cast <OggettoCustom>().Single(e => request.Attestati.StatusTemplate.StatusTemplateFieldName.Equals(e.DESCRIZIONE));
                    oc.VALORE_DATABASE = request.Attestati.StatusTemplate.StatusProcessedValue;
                    bool daAggiornareUffRef;
                    DocSave.save(iu, attList, false, out daAggiornareUffRef, role);
                    //unlock del documento principale
                    transactionContext.Complete();
                }
                catch (Exception e)
                {
                    resp.Code         = ImportAttestatiResponseCode.KO;
                    resp.ErrorMessage = e.Message;
                    return(resp);
                }
            }
            if (request.Trasmissione == null)
            {
                logger.Debug("Nessuna trasmissione da eseguire");
                resp.Code = ImportAttestatiResponseCode.OK;
                return(resp);
            }
            else
            {
                try
                {
                    logger.Debug("Esegui trasmissioni");
                    EseguiTrasmissioni(request.Trasmissione, docsTrasmissione, iu, role);
                    resp.Code = ImportAttestatiResponseCode.OK;
                    return(resp);
                }
                catch (Exception e)
                {
                    resp.ErrorMessage = e.Message;
                    resp.Code         = ImportAttestatiResponseCode.WARNING;
                    return(resp);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Creazione del documento nel sistema
        /// </summary>
        /// <param name="settings">Impostazioni relative al registro su cui creare il documento</param>
        /// <param name="senderInfo">Informazioni sul mittente della richiesta</param>
        /// <param name="interoperabilityMessage">Messaggio con le informazioni sulla richiesta di interoperabilità</param>
        /// <param name="userRole">Ruolo dell'utente da utilizzare per la creazione del documento</param>
        /// <param name="user">Utente da utilizzare per la creazione del documento</param>
        /// <returns>Scheda del documento creato</returns>
        private static SchedaDocumento CreateDocument(InteroperabilitySettings settings, Corrispondente senderInfo, InteroperabilityMessage interoperabilityMessage, Ruolo userRole, Utente user, String messageId)
        {
            // Recupero delle informazioni sull'utente da utilizzare come creatore del documento
            InfoUtente userInfo = UserManager.GetInfoUtente(user, userRole);

            // Creazione della scheda documento da restituire
            SchedaDocumento document = DocManager.NewSchedaDocumento(userInfo);

            // Recupero del registro su cui creare il predisposto
            Registro registry = RegistriManager.getRegistro(settings.RegistryId);

            // Recupero del mezzo di spedizione
            MezzoSpedizione channel = InfoDocManager.GetMezzoSpedizioneDaCodice("SIMPLIFIEDINTEROPERABILITY");

            // Impostazione delle proprietà del documento
            try
            {
                if (!String.IsNullOrEmpty(interoperabilityMessage.MainDocument.FileName))
                {
                    document.appId = InteroperabilitaSegnatura.getApp(interoperabilityMessage.MainDocument.FileName).application;
                }
            }
            catch (Exception e) {}

            document.idPeople = user.idPeople;
            document.userId   = user.userId;
            document.oggetto  = new Oggetto()
            {
                descrizione = interoperabilityMessage.Record.Subject
            };
            document.predisponiProtocollazione = true;
            document.registro            = registry;
            document.tipoProto           = "A";
            document.typeId              = "SIMPLIFIEDINTEROPERABILITY";
            document.mezzoSpedizione     = channel.IDSystem;
            document.descMezzoSpedizione = channel.Descrizione;
            document.interop             = "S";
            document.protocollatore      = new Protocollatore(userInfo, userRole);
            document.privato             = interoperabilityMessage.IsPrivate ? "1" : "0";

            // Se la gestione dell'interoperabilità è manuale con mantenimento
            // del documento pendente, il documento viene creato privato e subito dopo
            // la creazione viene rimarcato come non privato
            if (settings.ManagementMode == ManagementType.M && settings.KeepPrivate)
            {
                document.privato = "1";
            }

            // Preparazione dell'oggetto protocollo entrata
            ProtocolloEntrata proto = new ProtocolloEntrata();

            proto.mittente = senderInfo;
            proto.dataProtocolloMittente        = interoperabilityMessage.Record.RecordDate.ToString("dd/MM/yyyy HH:mm:ss");
            proto.descrizioneProtocolloMittente = String.Format("{0}{1}{2}",
                                                                interoperabilityMessage.Record.AOOCode,
                                                                DocsPaDB.Utils.Personalization.getInstance(registry.idAmministrazione).getSepSegnatura(),
                                                                interoperabilityMessage.Record.RecordNumber);
            document.protocollo = proto;

            // Se per l'amministrazione è configurata l'aggiunta di una nota visibile a tutti,
            // ne viene aggiunta una
            String value = DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_NOTE_IN_SEGNATURA");

            if (!String.IsNullOrEmpty(value) && value == "1" && !String.IsNullOrEmpty(interoperabilityMessage.Note))
            {
                document.noteDocumento = new List <DocsPaVO.Note.InfoNota>()
                {
                    new DocsPaVO.Note.InfoNota(interoperabilityMessage.Note, userInfo.idPeople, userInfo.idGruppo, DocsPaVO.Note.TipiVisibilitaNotaEnum.Tutti, String.Empty)
                    {
                        DaInserire = true
                    }
                }
            }
            ;

            // Salvataggio del documento
            try
            {
                document = DocSave.addDocGrigia(document, userInfo, userRole);

                // Associazione del canale di spedizione al documento
                ProtoManager.collegaMezzoSpedizioneDocumento(userInfo, channel.IDSystem, document.systemId);
            }
            catch (Exception e)
            {
                SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(String.Empty, true, e.Message + " Id messaggio: " + messageId);
                throw new CreatingDocumentException("Errore durante la creazione del documento");
            }
            // Se tutto è andato bene, la scheda documento ha ora il campo system id popolato, quindi viene aggiunta
            // una voce al log e viene aggiornato l'id profile per la voce nel registro dei messaggi ricevuti
            SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(document.systemId, false,
                                                                            String.Format("Documento relativo alla richiesta con id {0}, creato correttamente.", messageId));
            SimplifiedInteroperabilityLogAndRegistryManager.SetIdProfileForMessage(messageId, document.systemId);

            // Impostazione delle informazioni aggiuntive e salvataggio del documento
            ((Documento)document.documenti[0]).dataArrivo = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
            bool toUpdate;

            document = DocSave.save(userInfo, document, false, out toUpdate, userRole);
            string errPutFile = "";

            try
            {
                // Associazione dell'immagine al documento
                String      err     = String.Empty;
                FileRequest request = document.documenti[0] as FileRequest;
                logger.DebugFormat("IS - Associa documento. Versionid {0}, Versionlabel {1}, version {2}",
                                   request.versionId, request.versionLabel, request.version);

                if (!String.IsNullOrEmpty(interoperabilityMessage.MainDocument.FileName))
                {
                    SimplifiedInteroperabilityFileManager.DownloadFile(
                        interoperabilityMessage.MainDocument,
                        interoperabilityMessage.Sender.AdministrationId,
                        request,
                        userInfo,
                        interoperabilityMessage.Sender.FileManagerUrl,
                        out errPutFile);
                }
                if (!string.IsNullOrEmpty(errPutFile))
                {
                    throw new Exception("Errore durante l'associazione dell'immagine al documento principale");
                }
            }
            catch (Exception e)
            {
                SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(
                    document.systemId,
                    true,
                    String.Format("Errore durante l'associazione dell'immagine per il documento principale. Messaggio eccezione: {0}",
                                  e.Message));
                if (!string.IsNullOrEmpty(errPutFile) && errPutFile.Contains("formato file"))
                {
                    throw new DownloadDocumentException("Errore durante l'associazione dell'immagine al documento principale." + errPutFile + " destinataria.");
                }
                else
                {
                    throw new DownloadDocumentException("Errore durante l'associazione dell'immagine al documento principale");
                }
            }
            AddAttachments(document.docNumber, interoperabilityMessage.Attachments, userInfo, interoperabilityMessage.Sender.AdministrationId, interoperabilityMessage.Sender.FileManagerUrl);
            // Restituzione del documento salvato
            return(document);
        }