/// <summary> /// Reperimento della descrizione dello stato associato al documento /// </summary> /// <param name="infoUtente"></param> /// <param name="infoDocumento"></param> /// <returns></returns> public static string GetDescrizioneStatoDocumento(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.InfoDocumento infoDocumento) { string descrizioneStato = string.Empty; if (!string.IsNullOrEmpty(infoDocumento.idTipoAtto)) { DocsPaVO.DiagrammaStato.Stato stato = BusinessLogic.DiagrammiStato.DiagrammiStato.getStatoDoc(infoDocumento.docNumber); if (stato != null) { descrizioneStato = stato.DESCRIZIONE; } } return(descrizioneStato); }
/// <summary> /// Mapping dell'oggetto /// </summary> /// <param name="logInfo"> /// Dati del log nel sistema documentale /// </param> /// <param name="ev"> /// Dati dell'evento generato /// </param> /// <returns> /// Oggetto dal pubblicare /// </returns> public virtual Subscriber.Proxy.PublishedObject Map(VtDocs.LogInfo logInfo, EventInfo ev) { string section = string.Empty; try { Subscriber.Proxy.PublishedObject retValue = null; this._infoUtente = Security.ImpersonateUser(logInfo); section = "Impersonate"; // Reperimento dati del fascicolo DocsPaVO.fascicolazione.Fascicolo project = this.GetProject(logInfo); section = "GetProject"; if (project != null) { // Mapping dei dati del fascicolo List <Subscriber.Proxy.Property> list = new List <Subscriber.Proxy.Property>(); if (project.apertura != null) { section = "AperturaFascicolo"; list.Add( new Subscriber.Proxy.Property { Name = "AperturaFascicolo", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = project.apertura, Hidden = true } ); } if (project.chiusura != null) { section = "ChiusuraFascicolo"; list.Add( new Subscriber.Proxy.Property { Name = "ChiusuraFascicolo", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = project.chiusura, Hidden = true } ); } if (project.noteFascicolo != null) { section = "NoteFascicolo"; if (project.noteFascicolo.Count() > 0) { if (!String.IsNullOrEmpty(project.noteFascicolo.FirstOrDefault().Testo)) { list.Add( new Subscriber.Proxy.Property { Name = "NoteFascicolo", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = project.noteFascicolo.FirstOrDefault().Testo, Hidden = true } ); } } } section = "CodiceFascicolo"; list.Add( new Subscriber.Proxy.Property { Name = "CodiceFascicolo", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = project.codice, Hidden = true } ); section = "DataCreazione"; list.Add( new Subscriber.Proxy.Property { Name = "DataCreazione", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = project.dataCreazione } ); if (project.template != null) { section = "Template"; foreach (DocsPaVO.ProfilazioneDinamica.OggettoCustom field in project.template.ELENCO_OGGETTI) { this.AddProperty(field, list); } } // Reperimento dello stato del fascicolo DocsPaVO.DiagrammaStato.Stato objectState = BusinessLogic.DiagrammiStato.DiagrammiStato.getStatoFasc(project.systemID); if (objectState != null) { section = "IDStato"; list.Add( new Subscriber.Proxy.Property { Name = "IDStato", Type = Subscriber.Proxy.PropertyTypesEnum.Numeric, Value = objectState.SYSTEM_ID, Hidden = true } ); section = "Stato"; list.Add( new Subscriber.Proxy.Property { Name = "Stato", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = objectState.DESCRIZIONE, Hidden = true } ); } retValue = new Subscriber.Proxy.PublishedObject { IdObject = project.systemID, Description = string.Format("{0} - {1}", project.codice, project.descrizione), ObjectType = "Fascicolo", TemplateName = project.template.DESCRIZIONE, Properties = list.ToArray() }; } section = "Finito"; return(retValue); } catch (Exception ex) { throw new PublisherException(ErrorCodes.UNHANDLED_ERROR, ex.Message + " Section: " + section); } }
/// <summary> /// /// </summary> /// <param name="userInfo"></param> /// <param name="idDocument"></param> /// <param name="toState"></param> /// <param name="bypassFinalStateCheck"> /// Se true, indica di non effettuare i controlli sul consolidamento di un documento in stato finale /// </param> /// <returns></returns> internal static DocsPaVO.documento.DocumentConsolidationStateInfo ConsolidateNoSecurity(DocsPaVO.utente.InfoUtente userInfo, string idDocument, DocsPaVO.documento.DocumentConsolidationStateEnum toState, bool bypassFinalStateCheck) { bool cont = true; //if (!HasDocumentConsolidationRights(userInfo)) // throw new ApplicationException(string.Format("L'utente {0} non dispone dei diritti necessari per effettuare l'operazione di consolidamento", userInfo.userId)); // Reperimento stato di consolidamento del documento richiesto DocsPaVO.documento.SchedaDocumento savedDocument = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(userInfo, idDocument); if (savedDocument.documentoPrincipale != null) { cont = false; } if (savedDocument.checkOutStatus != null) { cont = false; } // Verifica sei il documento si trova nello stato finale if (!bypassFinalStateCheck) { DocsPaVO.DiagrammaStato.Stato workflowState = BusinessLogic.DiagrammiStato.DiagrammiStato.getStatoDoc(savedDocument.docNumber); if (workflowState != null && workflowState.STATO_FINALE) { cont = false; } } //// Verifica dei diritti di lettura / scrittura sul documento //int accessRights; //Int32.TryParse(savedDocument.accessRights, out accessRights); //if (accessRights > 0 && accessRights < 63) // throw new ApplicationException(string.Format("L'utente {0} non dispone dei diritti di lettura / scrittura sul documento necessari per effettuare l'operazione di consolidamento", userInfo.userId)); DocsPaVO.documento.DocumentConsolidationStateInfo state = savedDocument.ConsolidationState; // Controllo sullo stato di destinazione if (toState <= state.State) { cont = false; } // Un documento predisposto alla protocollazione non può essere consolidato in quanto rappresenta uno stato intermedio if (savedDocument.predisponiProtocollazione) { cont = false; } if (cont) { using (DocsPaDB.TransactionContext transactionalContext = new DocsPaDB.TransactionContext()) { // Operazione di consolidamento DocsPaDB.Query_DocsPAWS.DocumentConsolidation consolidationDb = new DocsPaDB.Query_DocsPAWS.DocumentConsolidation(userInfo); state = consolidationDb.SetState(idDocument, toState); // Operazione di consolidamento sui singoli allegati del documento foreach (DocsPaVO.documento.Allegato attatchment in AllegatiManager.getAllegati(idDocument, string.Empty)) { DocsPaVO.documento.DocumentConsolidationStateInfo attState = null; attState = consolidationDb.SetState(attatchment.docNumber, toState); } transactionalContext.Complete(); } } return(state); }
/// <summary> /// /// </summary> /// <param name="userInfo"></param> /// <param name="idDocument"></param> /// <param name="toState"></param> /// <param name="bypassFinalStateCheck"> /// Se true, indica di non effettuare i controlli sul consolidamento di un documento in stato finale /// </param> /// <returns></returns> internal static DocsPaVO.documento.DocumentConsolidationStateInfo Consolidate(DocsPaVO.utente.InfoUtente userInfo, string idDocument, DocsPaVO.documento.DocumentConsolidationStateEnum toState, bool bypassFinalStateCheck) { if (!HasDocumentConsolidationRights(userInfo)) { throw new ApplicationException(string.Format("L'utente {0} non dispone dei diritti necessari per effettuare l'operazione di consolidamento", userInfo.userId)); } // Reperimento stato di consolidamento del documento richiesto DocsPaVO.documento.SchedaDocumento savedDocument = BusinessLogic.Documenti.DocManager.getDettaglio(userInfo, idDocument, idDocument); if (savedDocument.documentoPrincipale != null) { throw new ApplicationException("Il documento risulta un allegato di un altro documento, pertanto non può essere consolidato singolarmente"); } if (savedDocument.checkOutStatus != null) { throw new ApplicationException(string.Format("Il documento risulta bloccato dall'utente {0}, pertanto non può essere consolidato", savedDocument.checkOutStatus.UserName)); } if (BusinessLogic.LibroFirma.LibroFirmaManager.IsDocOrAllInLibroFirma(savedDocument.docNumber)) { throw new ApplicationException("Il documento o uno dei suoi allegati risulta coinvolto in un processo di firma, pertanto non può essere consolidato "); } // Verifica sei il documento si trova nello stato finale if (!bypassFinalStateCheck) { DocsPaVO.DiagrammaStato.Stato workflowState = BusinessLogic.DiagrammiStato.DiagrammiStato.getStatoDoc(savedDocument.docNumber); if (workflowState != null && workflowState.STATO_FINALE) { throw new ApplicationException("Il documento risulta in stato finale"); } } // Verifica dei diritti di lettura / scrittura sul documento int accessRights; Int32.TryParse(savedDocument.accessRights, out accessRights); if (accessRights > 0 && accessRights < 63) { throw new ApplicationException(string.Format("L'utente {0} non dispone dei diritti di lettura / scrittura sul documento necessari per effettuare l'operazione di consolidamento", userInfo.userId)); } DocsPaVO.documento.DocumentConsolidationStateInfo state = savedDocument.ConsolidationState; // Controllo sullo stato di destinazione if (toState <= state.State) { throw new ApplicationException(string.Format("Il documento è attualmente in stato '{1}'", idDocument, DocsPaVO.documento.DocumentConsolidationStateDescriptionAttribute.GetDescription(state.State))); } // Un documento predisposto alla protocollazione non può essere consolidato in quanto rappresenta uno stato intermedio if (savedDocument.predisponiProtocollazione) { throw new ApplicationException("Il documento risulta predisposto alla protocollazione e non può essere consolidato"); } using (DocsPaDB.TransactionContext transactionalContext = new DocsPaDB.TransactionContext()) { // Operazione di consolidamento DocsPaDB.Query_DocsPAWS.DocumentConsolidation consolidationDb = new DocsPaDB.Query_DocsPAWS.DocumentConsolidation(userInfo); state = consolidationDb.SetState(idDocument, toState); // Operazione di consolidamento sui singoli allegati del documento foreach (DocsPaVO.documento.Allegato attatchment in AllegatiManager.getAllegati(idDocument, string.Empty)) { DocsPaVO.documento.DocumentConsolidationStateInfo attState = null; attState = consolidationDb.SetState(attatchment.docNumber, toState); } transactionalContext.Complete(); } return(state); }
/// <summary> /// Mapping dell'oggetto /// </summary> /// <param name="logInfo"> /// Dati del log nel sistema documentale /// </param> /// <param name="ev"> /// Dati dell'evento generato /// </param> /// <returns> /// Oggetto dal pubblicare /// </returns> public virtual Subscriber.Proxy.PublishedObject Map(VtDocs.LogInfo logInfo, EventInfo ev) { try { Subscriber.Proxy.PublishedObject retValue = null; // Reperimento dati del documento DocsPaVO.documento.SchedaDocumento document = this.GetDocument(logInfo); if (document != null) { // Mapping dei dati del fascicolo List <Subscriber.Proxy.Property> list = new List <Subscriber.Proxy.Property>(); if (document.template != null) { foreach (DocsPaVO.ProfilazioneDinamica.OggettoCustom field in document.template.ELENCO_OGGETTI) { Subscriber.Proxy.Property p = this.MapProperty(field); if (p != null) { list.Add(p); } } } // Reperimento dello stato del fascicolo DocsPaVO.DiagrammaStato.Stato objectState = BusinessLogic.DiagrammiStato.DiagrammiStato.getStatoDoc(document.systemId); if (objectState != null) { list.Add( new Subscriber.Proxy.Property { Name = "IDStato", Type = Subscriber.Proxy.PropertyTypesEnum.Numeric, Value = objectState.SYSTEM_ID, Hidden = true } ); list.Add( new Subscriber.Proxy.Property { Name = "Stato", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = objectState.DESCRIZIONE, Hidden = true } ); } if (ev.LoadFileIfDocumentType) { // Caricamento ultima versione del documento DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)document.documenti[0]; if (fr.subVersion != "!") { DocsPaVO.documento.FileDocumento file = BusinessLogic.Documenti.FileManager.getFile(fr, Security.ImpersonateUser(logInfo)); if (file != null) { list.Add(new Subscriber.Proxy.Property { Name = "FileName", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = file.name, Hidden = true }); list.Add(new Subscriber.Proxy.Property { Name = "File", Type = Subscriber.Proxy.PropertyTypesEnum.BinaryContent, BinaryValue = file.content, Hidden = true }); list.Add(new Subscriber.Proxy.Property { Name = "FilePrintThumb", Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = DocsPaUtils.Security.CryptographyManager.CalcolaImpronta(file.content), Hidden = true }); } } //Gestione Allegati if (document.allegati != null) { int attNumber = 0; foreach (DocsPaVO.documento.Allegato allegato in document.allegati) { if (allegato.subVersion != "!") { DocsPaVO.documento.FileDocumento file = BusinessLogic.Documenti.FileManager.getFile((DocsPaVO.documento.FileRequest)allegato, Security.ImpersonateUser(logInfo)); list.Add(new Subscriber.Proxy.Property { Name = String.Format("AttachmentName_{0}", attNumber), Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = file.name, Hidden = true }); list.Add(new Subscriber.Proxy.Property { Name = String.Format("Attachment_{0}", attNumber), Type = Subscriber.Proxy.PropertyTypesEnum.BinaryContent, BinaryValue = file.content, Hidden = true }); list.Add(new Subscriber.Proxy.Property { Name = String.Format("AttachmentPrintThumb_{0}", attNumber), Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = DocsPaUtils.Security.CryptographyManager.CalcolaImpronta(file.content), Hidden = true }); attNumber++; } } } } /* user information that generated the event */ list.Add(new Subscriber.Proxy.Property { Name = "UserName", //UserName utente che ha generato la pubblicazione Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = logInfo.UserName, Hidden = true }); list.Add(new Subscriber.Proxy.Property { Name = "CodeAdm", // codice amministrazione Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = BusinessLogic.Amministrazione.AmministraManager.AmmGetInfoAmmCorrente(logInfo.IdAdmin.ToString()).Codice, Hidden = true }); list.Add(new Subscriber.Proxy.Property { Name = "RoleCode", //codice ruolo Type = Subscriber.Proxy.PropertyTypesEnum.String, Value = logInfo.RoleCode, Hidden = true }); /* end user information*/ string docName = string.Empty; if (document.tipoProto == "G") { docName = string.Format("ID: {0}", document.docNumber); } else if (document.protocollo != null) { docName = string.Format("Segnatura: {0}", document.protocollo.segnatura); } //document.protocollo.segnatura retValue = new Subscriber.Proxy.PublishedObject { IdObject = document.systemId, Description = docName, ObjectType = "Documento", TemplateName = document.template.DESCRIZIONE, Properties = list.ToArray() }; } return(retValue); } catch (Exception ex) { throw new PublisherException(ErrorCodes.UNHANDLED_ERROR, ex.Message); } }
public virtual bool BACHECA_cambiaStatoDoc(string idDoc, string statoDest, string idAmm, string idPeople, string idGruppo) { bool retVal = false; try { Utente utente = BusinessLogic.Utenti.UserManager.getUtenteById(idPeople); Ruolo ruolo = BusinessLogic.Utenti.UserManager.getRuoloByIdGruppo(idGruppo); InfoUtente infoUtente = new InfoUtente(utente, ruolo); DocsPaVO.documento.SchedaDocumento documento = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtente, idDoc, idDoc); if (documento != null) { if (documento.template != null) { int idDiagramma = 0; DocsPaVO.DiagrammaStato.DiagrammaStato diagramma = null; DocsPaVO.DiagrammaStato.Stato statoAttuale = null; idDiagramma = BusinessLogic.DiagrammiStato.DiagrammiStato.getDiagrammaAssociato(documento.template.SYSTEM_ID.ToString()); if (idDiagramma != 0) { diagramma = BusinessLogic.DiagrammiStato.DiagrammiStato.getDiagrammaById(idDiagramma.ToString()); if (diagramma != null) { if (diagramma.STATI != null && diagramma.STATI.Count > 0) { statoAttuale = BusinessLogic.DiagrammiStato.DiagrammiStato.getStatoDoc(documento.docNumber); if (statoAttuale == null) { foreach (DocsPaVO.DiagrammaStato.Stato stato in diagramma.STATI) { if (stato.DESCRIZIONE.ToUpper().Equals(statoDest.ToUpper())) { BusinessLogic.DiagrammiStato.DiagrammiStato.salvaModificaStato(documento.docNumber, stato.SYSTEM_ID.ToString(), diagramma, infoUtente.idPeople, infoUtente, string.Empty); retVal = true; break; } } } else { for (int i = 0; i < diagramma.PASSI.Count; i++) { DocsPaVO.DiagrammaStato.Passo step = (DocsPaVO.DiagrammaStato.Passo)diagramma.PASSI[i]; if (step.STATO_PADRE.SYSTEM_ID == statoAttuale.SYSTEM_ID) { for (int j = 0; j < step.SUCCESSIVI.Count; j++) { if (((DocsPaVO.DiagrammaStato.Stato)step.SUCCESSIVI[j]).DESCRIZIONE.ToUpper().Equals(statoDest.ToUpper())) { BusinessLogic.DiagrammiStato.DiagrammiStato.salvaModificaStato(documento.docNumber, ((DocsPaVO.DiagrammaStato.Stato)step.SUCCESSIVI[j]).SYSTEM_ID.ToString(), diagramma, infoUtente.idPeople, infoUtente, string.Empty); retVal = true; break; } } } } } if (!retVal) { throw new Exception("Stato del diagramma non trovato"); } } } } else { throw new Exception("Diagramma di stato non trovato"); } } else { throw new Exception("Tipologia non trovata"); } } else { throw new Exception("Documento non trovato"); } } catch (Exception ex) { logger.Error(ex.Message); } return(retVal); }