/// <summary> /// /// </summary> /// <param name="idProf"></param> /// <param name="codiceAOO"></param> /// <param name="codiceAmministrazione"></param> /// <param name="data"></param> /// <param name="numeroRegistrazione"></param> /// <param name="anno"></param> /// <param name="logger"></param> /// <returns></returns> private static bool updateStatoInvio(string idProf, string codiceAOO, string codiceAmministrazione, string data, string numeroRegistrazione, int anno) { bool result = false; try { #region Codice Commentato /* * string updateString="UPDATE DPA_STATO_INVIO SET "; * updateString=updateString+"VAR_PROTO_DEST='"+numeroRegistrazione+"/"+codiceAOO+"/"+anno+"',"; * updateString=updateString+"DTA_PROTO_DEST="+DocsPaWS.Utils.dbControl.toDate(data,false); * * updateString=updateString+" WHERE ID_PROFILE="+idProf+" AND VAR_CODICE_AOO='"+codiceAOO+"' AND VAR_CODICE_AMM='"+codiceAmministrazione+"'"; * logger.Debug(updateString); * db.executeNonQuery(updateString); */ #endregion DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); result = obj.updStatoInvio(idProf, codiceAOO, codiceAmministrazione, data, numeroRegistrazione, anno); } catch (Exception e) { logger.Error("Eccezione: " + e.Message); result = false; } return(result); }
/// <summary> /// Trova un ID Documento (profile) da Codice AOO, Protocollo e anno /// </summary> /// <param name="codiceAOO"></param> /// <param name="numeroRegistrazione"></param> /// <param name="anno"></param> /// <returns></returns> public static string findIdProfile(string codiceAOO, string numeroRegistrazione, int anno) { DataSet ds; try { DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.findIdProf(out ds, codiceAOO, numeroRegistrazione, anno); if (ds.Tables["ID_DOC"].Rows.Count == 0) { return(null); } else { return(ds.Tables["ID_DOC"].Rows[0]["SYSTEM_ID"].ToString()); } } catch (Exception e) { logger.Error("Eccezione: " + e.Message); return(null); } }
private static DocsPaVO.documento.SchedaDocumento getDocumentoInUscitaByDocPredisposto(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.SchedaDocumento schedaDoc) { logger.Debug("getDocumentoInUscitaByDocPredisposto"); DataSet ds; DocsPaVO.documento.SchedaDocumento sd = new DocsPaVO.documento.SchedaDocumento(); try { DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); string sep = DocsPaDB.Utils.Personalization.getInstance(schedaDoc.registro.idAmministrazione).getSepSegnatura(); string[] protoMitt = ((DocsPaVO.documento.ProtocolloEntrata)(schedaDoc.protocollo)).descrizioneProtocolloMittente.Split(sep.ToCharArray(), 2); CultureInfo ci = new CultureInfo("it-IT"); string[] formati = { "dd/MM/yyyy", "yyyy-MM-dd", "DD/MM/YYYY hh:mm:ss", "DD/MM/YYYY hh.mm.ss", "DD/MM/YYYY HH.mm.ss", "DD/MM/YYYY HH:mm:ss" }; DateTime dataRegistrazione = DateTime.ParseExact(((DocsPaVO.documento.ProtocolloEntrata)(schedaDoc.protocollo)).dataProtocolloMittente, formati, ci.DateTimeFormat, DateTimeStyles.AllowWhiteSpaces); if (protoMitt != null && protoMitt.Length > 1) { string regProto = protoMitt[0]; string numProto = protoMitt[1]; int anno = dataRegistrazione.Year; DocsPaDB.Query_DocsPAWS.Interoperabilita interop = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti(); interop.getIdProtocolloUscitaOriginario(out ds, numProto, regProto, anno); if (ds != null && ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables["PROTOUSCITA"].Rows[0]; string docNumber = row["DOCNUMBER"].ToString(); if (docNumber != null && docNumber != "") { sd = doc.GetSchedaDocumentoByID(infoUtente, docNumber); } } } } catch (Exception e) { logger.Error(e.ToString()); logger.Error("Errore nella gestione dell'interoperabilità. (getDocumentoInUscitaByDocPredisposto", e); throw e; } return(sd); }
/// <summary> /// </summary> /// <param name="idMessage"></param> /// <param name="ragione"></param> /// <returns></returns> //modifica public static bool MailElaborata(string idMessage, string ragione, string id_registro, string docnumber, string email) { try { logger.Debug("mailElaborata"); DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.insMailElab(idMessage, ragione, id_registro, docnumber, email); logger.Debug("elaborazione della mail con id: " + idMessage + " avvenuta con successo"); return(true); } catch (Exception e) { logger.Error("elaborazione della mail con id: " + idMessage + " ha gerato il seguente errore" + e.Message); return(false); } }
private static bool updateStatoInvioAnnulla(string idProfile, string codiceAOO, string codiceAmministrazione, string data, string numeroRegistrazione, int anno, string motivoAnnulla, string provvedimento) { bool result = false; try { DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); result = obj.updStatoInvioAnnulla(idProfile, codiceAOO, codiceAmministrazione, data, numeroRegistrazione, anno, motivoAnnulla, provvedimento); } catch (Exception e) { logger.Error("Eccezione: " + e.Message); result = false; } return(result); }
/// <summary> /// Controlla se un documento è stato ricevuto tramite una casella configurata per mantenere le mail ricevute come pendenti. /// Serve per il frontend. /// Per gestione pendenti tramite PEC /// </summary> /// <param name="idDocument"></param> /// <returns></returns> public static bool isDocPecPendente(string idDocument) { bool retval = false; DataSet ds = new DataSet(); DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); retval = obj.getDocPECPendente(idDocument); //if (ds.Tables["REGISTRO"].Rows.Count > 0) //{ // DataRow regRow = ds.Tables["DOCUMENTO"].Rows[0]; // if (regRow["VAR_SOLO_MAIL_PEC"].ToString() != "1") // { // if (regRow["VAR_MAIL_RIC_PENDENTE"].ToString() == "1") retval = true; // } //} return(retval); }
/// <summary> /// Metodo che controlla se la mail è configurata per mantenere le mail ricevute come pendenti. /// Per gestione pendenti tramite PEC /// </summary> /// <param name="idregistro"></param> /// <param name="casella"></param> /// <returns></returns> public static bool MantieniMailRicevutePendenti(string idregistro, string casella) { bool retval = false; DataSet ds = new DataSet(); DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getVarMailRicPendenti(out ds, idregistro, casella); if (ds.Tables["REGISTRO"].Rows.Count > 0) { DataRow regRow = ds.Tables["REGISTRO"].Rows[0]; if (regRow["VAR_SOLO_MAIL_PEC"].ToString() != "1") { if (regRow["VAR_MAIL_RIC_PENDENTE"].ToString() == "1") { retval = true; } } } return(retval); }
/// <summary></summary> /// <param name="messageId"></param> /// <param name="userId"></param> /// <returns></returns> public static bool CheckId(string messageId, string userId, string id_registro) { if (messageId == null || messageId.Equals("")) { return(false); } DataSet dataSet; try { #region Codice Commentato //db.openConnection(); /* * string checkString="SELECT * FROM DPA_MAIL_ELABORATE WHERE VAR_MESSAGE='"+messageId+"'"; * db.fillTable(checkString,dataSet,"MAIL"); */ #endregion DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getMailElab(out dataSet, messageId, id_registro); if (dataSet.Tables["MAIL"].Rows.Count > 0) { return(false); } return(true); } catch (Exception e) { logger.Error(e.ToString()); return(false); } }
private static string getMailBody(string idProfile, DocsPaVO.utente.Registro reg, string separatore, DocsPaVO.documento.SchedaDocumento schedaDoc) { System.Data.DataSet ds; string mailBody = string.Empty; DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); try { obj.getMittSegn(out ds, idProfile); System.Data.DataRow mittRow = ds.Tables["INFO_MITT"].Rows[0]; char[] separator = { separatore.ToCharArray()[0] }; //si trova il codice amministrazione del mittente string codiceAmmMittString = ""; if (mittRow["CHA_TIPO_IE"].ToString().Equals("I")) { //mittente interno codiceAmmMittString = reg.codAmministrazione; } else { //mittente esterno codiceAmmMittString = mittRow["VAR_CODICE_AMM"].ToString(); } string codiceAOOMittString = ""; string numeroRegMittString = ""; string protoIn = mittRow["VAR_PROTO_IN"].ToString(); if (!string.IsNullOrEmpty(protoIn)) { codiceAOOMittString = protoIn.Split(separator)[0]; if (protoIn.Contains(separatore)) { numeroRegMittString = protoIn.Split(separator)[1]; } } mailBody += "Conferma di ricezione ''" + schedaDoc.oggetto.descrizione + "'' del " + System.Convert.ToDateTime(schedaDoc.dataCreazione).ToString("dd-MM-yyyy") + "<br>"; string dataRegMittString = ""; if (mittRow["DTA_PROTO_IN"] != null && !mittRow["DTA_PROTO_IN"].ToString().Equals("")) { dataRegMittString = System.Convert.ToDateTime(mittRow["DTA_PROTO_IN"]).ToString("yyyy-MM-dd"); } obj.getIdent(out ds, idProfile); System.Data.DataRow protoRow = ds.Tables["INFO_PROTO"].Rows[0]; string numeroRegString = protoRow["NUM_PROTO"].ToString(); string dataRegString = ""; if (protoRow["DTA_PROTO"] != null && !protoRow["DTA_PROTO"].ToString().Equals("")) { dataRegString = System.Convert.ToDateTime(protoRow["DTA_PROTO"]).ToString("yyyy-MM-dd"); } DocsPaVO.utente.Corrispondente mittente = ((DocsPaVO.documento.ProtocolloEntrata)schedaDoc.protocollo).mittente; mailBody += "<br>Segnatura: " + ((DocsPaVO.documento.Protocollo)schedaDoc.protocollo).segnatura + "<br>Codice Amministrazione: " + reg.codAmministrazione + "<br>Codice AOO: " + reg.codRegistro + "<br>Numero Protocollo: " + numeroRegString + "<br>Data Protocollo: " + dataRegString + //"<br><br>Protocollo Mittente" + "<br>Codice Amministrazione: " + codiceAmmMittString + "<br>Codice AOO: " + codiceAOOMittString + // "<br>Numero Protocollo: " + numeroRegMittString + "<br>Data Protocollo: " + dataRegMittString + "<br>Mittente: " + mittente.descrizione; } catch (Exception e) { logger.Error("Errore nella gestione dell'interoperabilità. (getMailBody)", e); mailBody = ""; } return(mailBody); }
/// <summary></summary> /// <param name="idProfile"></param> /// <param name="reg"></param> /// <param name="numRegMitt"></param> /// <param name="qco"></param> /// <param name="separatore"></param> /// <param name="filePath"></param> private static void costruisciXml(string idProfile, DocsPaVO.utente.Registro reg, ref string numRegMitt, ref DocsPaVO.addressbook.QueryCorrispondente qco, string separatore, string filePath) { System.Data.DataSet ds; DocsPaVO.utente.Registro registro = null; try { logger.Debug("costruisciXml"); logger.Debug("" + separatore); #region Codice Commentato //query per recuperare le info sul mittente della segnatura /* * string queryMittString="SELECT A.VAR_PROTO_IN, A.DTA_PROTO_IN, B.VAR_CODICE_AMM, B.CHA_TIPO_IE, B.VAR_COD_RUBRICA, B.ID_AMM FROM PROFILE A, DPA_CORR_GLOBALI B, DPA_DOC_ARRIVO_PAR C WHERE A.SYSTEM_ID="+idProfile; * queryMittString=queryMittString+" AND B.SYSTEM_ID=C.ID_MITT_DEST AND C.ID_PROFILE=A.SYSTEM_ID"; * logger.Debug(queryMittString); * db.fillTable(queryMittString,ds,"INFO_MITT"); */ #endregion DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getMittSegn(out ds, idProfile); System.Data.DataRow mittRow = ds.Tables["INFO_MITT"].Rows[0]; char[] separator = { separatore.ToCharArray()[0] }; //si trova il codice amministrazione del mittente string codiceAmmMittString = ""; if (mittRow["CHA_TIPO_IE"].ToString().Equals("I")) { //mittente interno codiceAmmMittString = reg.codAmministrazione; } else { //mittente esterno codiceAmmMittString = mittRow["VAR_CODICE_AMM"].ToString(); } string protoIn = mittRow["VAR_PROTO_IN"].ToString(); logger.Debug(protoIn + " " + protoIn.Split(separator).Length); string codiceAOOMittString = ""; string numeroRegMittString = ""; if (!string.IsNullOrEmpty(protoIn)) { codiceAOOMittString = protoIn.Split(separator)[0]; if (protoIn.Contains(separatore)) { numeroRegMittString = protoIn.Split(separator)[1]; } } numRegMitt = numeroRegMittString; //costruzione dell'oggetto per la richiesta mittente qco.codiceRubrica = mittRow["VAR_COD_RUBRICA"].ToString(); qco.idAmministrazione = mittRow["ID_AMM"].ToString(); qco.systemId = mittRow["SYSTEM_ID"].ToString(); if (mittRow["CHA_TIPO_IE"].ToString().Equals("I")) { qco.tipoUtente = DocsPaVO.addressbook.TipoUtente.INTERNO; } else { qco.tipoUtente = DocsPaVO.addressbook.TipoUtente.ESTERNO; } qco.getChildren = false; string dataRegMittString = ""; if (mittRow["DTA_PROTO_IN"] != null && !mittRow["DTA_PROTO_IN"].ToString().Equals("")) { dataRegMittString = System.Convert.ToDateTime(mittRow["DTA_PROTO_IN"]).ToString("yyyy-MM-dd"); } #region Codice Commentato //query per recuperare le info per l'identificatore /* * string queryProtoString="SELECT DTA_PROTO, NUM_PROTO FROM PROFILE WHERE SYSTEM_ID="+idProfile; * logger.Debug(queryProtoString); * db.fillTable(queryProtoString,ds,"INFO_PROTO"); */ #endregion obj.getIdent(out ds, idProfile); System.Data.DataRow protoRow = ds.Tables["INFO_PROTO"].Rows[0]; string numeroRegString = protoRow["NUM_PROTO"].ToString(); string dataRegString = ""; if (protoRow["DTA_PROTO"] != null && !protoRow["DTA_PROTO"].ToString().Equals("")) { dataRegString = System.Convert.ToDateTime(protoRow["DTA_PROTO"]).ToString("yyyy-MM-dd"); } //costruzione del file xml logger.Debug("Costruzione file xml"); XmlDocument xdoc = new XmlDocument(); //impostazione xdoc.XmlResolver = null; XmlDeclaration dec = xdoc.CreateXmlDeclaration("1.0", "UTF-8", null); xdoc.AppendChild(dec); //NON VALIDIAMO PIù CON LA DTD MA CON L'XSD //XmlDocumentType dtd = xdoc.CreateDocumentType("ConfermaRicezione", null, "Segnatura.dtd", null); //xdoc.AppendChild(dtd); //logger.Debug("dtd impostato"); //creazione della root XmlElement root = xdoc.CreateElement("ConfermaRicezione"); root.SetAttribute("xmlns", "http://www.digitPa.gov.it/protocollo/"); xdoc.AppendChild(root); //creazione dell'identificatore XmlElement identificatore = xdoc.CreateElement("Identificatore"); root.AppendChild(identificatore); XmlElement codiceAmm = xdoc.CreateElement("CodiceAmministrazione"); codiceAmm.InnerText = reg.codAmministrazione; identificatore.AppendChild(codiceAmm); XmlElement codiceAOO = xdoc.CreateElement("CodiceAOO"); //se è un RF, io devo comunque inviare la ricevuta dall'AOO. if (reg.chaRF != null && reg.chaRF == "1") { if (!string.IsNullOrEmpty(reg.idAOOCollegata)) { registro = BusinessLogic.Utenti.RegistriManager.getRegistro(reg.idAOOCollegata); } else { throw new Exception("Errore in costruiscixml conferma, l'RF " + reg.descrizione + " non ha una AOO collegata."); } } if (registro != null) { reg = registro; } codiceAOO.InnerText = reg.codRegistro; identificatore.AppendChild(codiceAOO); XmlElement codiceRegistro = xdoc.CreateElement("CodiceRegistro"); codiceRegistro.InnerText = reg.codRegistro; identificatore.AppendChild(codiceRegistro); XmlElement numeroReg = xdoc.CreateElement("NumeroRegistrazione"); numeroReg.InnerText = numeroRegString; identificatore.AppendChild(numeroReg); XmlElement dataReg = xdoc.CreateElement("DataRegistrazione"); dataReg.InnerText = dataRegString; identificatore.AppendChild(dataReg); //creazione dell'identificatore mittente; XmlElement messRicevuto = xdoc.CreateElement("MessaggioRicevuto"); XmlElement identificatoreMitt = xdoc.CreateElement("Identificatore"); XmlElement codiceAmmMitt = xdoc.CreateElement("CodiceAmministrazione"); codiceAmmMitt.InnerText = codiceAmmMittString; identificatoreMitt.AppendChild(codiceAmmMitt); XmlElement codiceAOOMitt = xdoc.CreateElement("CodiceAOO"); codiceAOOMitt.InnerText = codiceAOOMittString; identificatoreMitt.AppendChild(codiceAOOMitt); XmlElement codiceRegistroMitt = xdoc.CreateElement("CodiceRegistro"); codiceRegistroMitt.InnerText = string.Empty; identificatoreMitt.AppendChild(codiceRegistroMitt); XmlElement numeroRegMitt = xdoc.CreateElement("NumeroRegistrazione"); numeroRegMitt.InnerText = numeroRegMittString; identificatoreMitt.AppendChild(numeroRegMitt); XmlElement dataRegMitt = xdoc.CreateElement("DataRegistrazione"); dataRegMitt.InnerText = dataRegMittString; identificatoreMitt.AppendChild(dataRegMitt); messRicevuto.AppendChild(identificatoreMitt); root.AppendChild(messRicevuto); //salvataggio file System.IO.FileStream fs = new System.IO.FileStream(filePath + "\\conferma.xml", System.IO.FileMode.Create); xdoc.Save(fs); fs.Close(); } catch (Exception e) { logger.Error("Errore nella gestione dell'interoperabilità. (costruisciXml)", e); throw e; } }
/// <summary> /// </summary> /// <param name="idProfile"></param> /// <param name="reg"></param> public static void sendRicevutaRitorno(DocsPaVO.documento.SchedaDocumento schedaDoc, DocsPaVO.utente.Registro reg, DocsPaVO.utente.Ruolo ruolo, DocsPaVO.utente.InfoUtente infoUtente, out string messaggioErrore) { messaggioErrore = string.Empty; #region nuova gestione interop string err = ""; //todo da calcolare; try { // estrazione dati + controllo mittente est o int System.Data.DataSet dsMitt = null; System.Data.DataSet dsProto = null; DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getMittSegn(out dsMitt, schedaDoc.systemId); if (InteroperabilitaUtils.InteropIntNoMail && schedaDoc.interop != null && schedaDoc.interop == "I" && dsMitt != null && dsMitt.Tables[0].Rows.Count > 0 && dsMitt.Tables["INFO_MITT"].Rows[0]["CHA_TIPO_IE"] != null && !dsMitt.Tables["INFO_MITT"].Rows[0]["CHA_TIPO_IE"].Equals(System.DBNull.Value)) { obj.getDatiProtoSpedito(out dsProto, schedaDoc.systemId); string sep = DocsPaDB.Utils.Personalization.getInstance(reg.idAmministrazione).getSepSegnatura(); string codAmm = DocsPaDB.Utils.Personalization.getInstance(reg.idAmministrazione).getCodiceAmministrazione(); //string[] protoMitt=dsMitt.Tables["INFO_MITT"].Rows[0]["VAR_PROTO_IN"].ToString().Split(sep.ToCharArray(),2); int index = dsMitt.Tables["INFO_MITT"].Rows[0]["VAR_PROTO_IN"].ToString().LastIndexOf(sep); string[] protoMitt = new String[2]; protoMitt[0] = dsMitt.Tables["INFO_MITT"].Rows[0]["VAR_PROTO_IN"].ToString().Substring(0, index); protoMitt[1] = dsMitt.Tables["INFO_MITT"].Rows[0]["VAR_PROTO_IN"].ToString().Substring(index + 1);; string dataProtoMitt = dsMitt.Tables["INFO_MITT"].Rows[0]["DTA_PROTO_IN"].ToString(); string dataProto = dsProto.Tables["INFO_PROTO"].Rows[0]["DTA_PROTO"].ToString(); string numProto = dsProto.Tables["INFO_PROTO"].Rows[0]["NUM_PROTO"].ToString(); if (protoMitt != null && dataProtoMitt != null && protoMitt[0] != null && protoMitt[1] != null) { DocsPaVO.Interoperabilita.RicevutaRitorno ric = new DocsPaVO.Interoperabilita.RicevutaRitorno(); ric.codAmm = codAmm; ric.codAmm_Mitt = codAmm; //so che viene dalla stessa amm, ma in futuro posso valutarlo nelle multiamm, dalla dpa_stato_invio ?. ric.codAOO = reg.codRegistro; ric.codAOO_Mitt = protoMitt[0]; ric.dataRegistr_Mitt = dataProtoMitt.Substring(0, dataProtoMitt.IndexOf(" ")); ric.dataRegistrazione = dataProto.Substring(0, dataProtoMitt.IndexOf(" "));; ric.numeroRegistr_Mitt = protoMitt[1]; ric.numeroRegistrazione = numProto; BusinessLogic.Interoperabilità.InteroperabilitaControlloRicevute.processaRicevutaConferma(ric, out err); if (reg.autoInterop != null && reg.autoInterop != "0") { DocsPaVO.documento.SchedaDocumento schedaDocUscita = new DocsPaVO.documento.SchedaDocumento(); //ricavo il protocollo in uscita a partire dal protocollo //predisposto in arrivo schedaDocUscita = getDocumentoInUscitaByDocPredisposto(infoUtente, schedaDoc); // bool verificaRagioni; string message = ""; BusinessLogic.trasmissioni.TrasmProtoIntManager.TrasmissioneProtocolloAutomatico(schedaDoc, schedaDoc.registro.systemId, schedaDocUscita, ruolo, infoUtente, infoUtente.urlWA, false, out verificaRagioni, out message); } } dsMitt.Dispose(); dsProto.Dispose(); } else #endregion { sendRicRitorno(schedaDoc.systemId, reg, schedaDoc, out messaggioErrore); } } catch (Exception e) { if (string.IsNullOrEmpty(messaggioErrore)) { messaggioErrore = "errore nell' invio della ricevuta"; } logger.Error("Errore nella gestione dell'interoperabilità. (sendRicevutaRitorno)" + " ", e); throw e; } }
/// <summary> /// /// </summary> /// <param name="idProfile"></param> /// <param name="reg"></param> private static void sendRicRitorno(string idProfile, DocsPaVO.utente.Registro reg, DocsPaVO.documento.SchedaDocumento schedaDoc, out string messaggioErrore) { System.Data.DataSet ds; messaggioErrore = string.Empty; try { //BusinessLogic.Interoperabilità.InteroperabilitaControlloRicevute.processaRicevutaConferma(); DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getCampiReg(out ds, reg); System.Data.DataRow regRow = ds.Tables["REGISTRO"].Rows[0]; reg.codAmministrazione = regRow["VAR_CODICE_AMM"].ToString(); //inserimento dei files in una cartella temporanea string basePathFiles = ConfigurationManager.AppSettings["LOG_PATH"]; basePathFiles = basePathFiles.Replace("%DATA", DateTime.Now.ToString("yyyyMMdd")); basePathFiles = basePathFiles + "\\Invio_ricevuta_files\\" + Guid.NewGuid().ToString(); string pathFiles = basePathFiles + "\\" + regRow["VAR_CODICE"].ToString(); DocsPaUtils.Functions.Functions.CheckEsistenzaDirectory(pathFiles); // logger.Debug(""+regRow["CHA_STR_SEGNATURA"].ToString().ToCharArray().Length); //costruzione del file xml string numRegMitt = ""; DocsPaVO.addressbook.QueryCorrispondente qco = new DocsPaVO.addressbook.QueryCorrispondente(); //costruisciXml(idProfile, reg,ref numRegMitt,ref qco, regRow["CHA_STR_SEGNATURA"].ToString(),pathFiles); string separatore = DocsPaDB.Utils.Personalization.getInstance(reg.idAmministrazione).getSepSegnatura(); string mailMitt = string.Empty; if (schedaDoc.typeId.ToUpper().Trim() == "INTEROPERABILITA") { costruisciXml(idProfile, reg, ref numRegMitt, ref qco, separatore, pathFiles); } else { //costruzione dell'oggetto per la richiesta mittente System.Data.DataSet ds1; DocsPaDB.Query_DocsPAWS.Interoperabilita obj1 = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj1.getMittSegn(out ds1, idProfile); System.Data.DataRow mittRow = ds1.Tables["INFO_MITT"].Rows[0]; qco.codiceRubrica = mittRow["VAR_COD_RUBRICA"].ToString(); qco.idAmministrazione = mittRow["ID_AMM"].ToString(); qco.systemId = mittRow["SYSTEM_ID"].ToString(); if (mittRow["CHA_TIPO_IE"].ToString().Equals("I")) { qco.tipoUtente = DocsPaVO.addressbook.TipoUtente.INTERNO; } else { qco.tipoUtente = DocsPaVO.addressbook.TipoUtente.ESTERNO; } qco.getChildren = false; } //invio mail mailMitt = getMailAddress(qco, schedaDoc.interop, idProfile); if (string.IsNullOrEmpty(mailMitt)) { messaggioErrore = "Il Mittente non ha associata una mail."; logger.Error("Il Mittente non ha associata una mail."); throw new ApplicationException("Il Mittente non ha associata una mail."); } logger.Debug("Invio mail all'indirizzo " + mailMitt); string porta = null; if (regRow["NUM_PORTA_SMTP"] != null) { porta = regRow["NUM_PORTA_SMTP"].ToString(); } string smtp_user = (regRow["VAR_USER_SMTP"] != null && regRow["VAR_USER_SMTP"] != System.DBNull.Value) ? regRow["VAR_USER_SMTP"].ToString() : null; string smtp_pwd = (regRow["VAR_PWD_SMTP"] != null && regRow["VAR_PWD_SMTP"] != System.DBNull.Value) ? regRow["VAR_PWD_SMTP"].ToString() : null; //aggiunta la trim() per gestire la presenza di spazi bianchi nei campi VAR_USER_SMTP e VAR_PWD_SMTP if (smtp_user != null) { smtp_user = smtp_user.Trim(); } if (smtp_pwd != null) { smtp_pwd = smtp_pwd.Trim(); } // copia il file di segnatura //System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"xml\segnatura.dtd",pathFiles + "\\segnatura.dtd",true); string mailBody = getMailBody(idProfile, reg, separatore, schedaDoc); string subject_appo = "Conferma ricezione ''" + schedaDoc.oggetto.descrizione + "'' del " + System.Convert.ToDateTime(schedaDoc.dataCreazione).ToString("dd-MM-yyyy"); string subject = subject_appo; //= subject_appo.Substring(0, 256); if (subject_appo.Length > 256) { subject = subject_appo.Substring(0, 256); } //aggiunta del docnumber all'oggetto delal mail per la gestione delle ricevute pec if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["GESTIONE_RICEVUTE_PEC"]) && bool.Parse(ConfigurationManager.AppSettings["GESTIONE_RICEVUTE_PEC"])) { subject += "#" + schedaDoc.docNumber.ToString() + "#"; } //Crypter.Decode(smtp_pwd, smtp_user) creaMail(regRow["VAR_SERVER_SMTP"].ToString(), smtp_user, Crypter.Decode(smtp_pwd, smtp_user), regRow["VAR_EMAIL_REGISTRO"].ToString(), mailMitt, numRegMitt, pathFiles, porta, regRow["CHA_SMTP_SSL"].ToString(), regRow["CHA_POP_SSL"].ToString(), regRow["CHA_SMTP_STA"].ToString(), mailBody, subject); //old: System.IO.File.Delete(pathFiles+"\\confermaRicezione.xml"); System.IO.File.Delete(pathFiles + "\\conferma.xml"); //System.IO.File.Delete(pathFiles+"\\segnatura.dtd"); DocsPaUtils.Functions.Functions.CancellaDirectory(pathFiles); DocsPaUtils.Functions.Functions.CancellaDirectory(basePathFiles); } catch (Exception e) { if (string.IsNullOrEmpty(messaggioErrore)) { messaggioErrore = "Errore durante l'invio della ricevuta"; } logger.Error("Errore nella gestione dell'interoperabilità. (sendRicevutaRitorno)", e); throw e; } }
//GESTIONE SPEDIZIONI public static ArrayList getSpedizioni(string idProfile) { DocsPaDB.Query_DocsPAWS.Interoperabilita interop = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); return(interop.GetSpedizioni(idProfile)); }
/// <summary> /// </summary> /// <param name="idProfile"></param> /// <param name="reg"></param> public static bool sendNotificaAnnullamento(string idProfile, DocsPaVO.utente.Registro reg) { #region nuova gestione interop string err = ""; bool esito = true; //presume successo //todo da calcolare; try { // estrazione dati + controllo mittente est o int System.Data.DataSet dsMitt = null; System.Data.DataSet dsProto = null; DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getMittSegn(out dsMitt, idProfile); if ((InteroperabilitaUtils.InteropIntNoMail || InteroperabilitaSemplificataManager.IsDocumentReceivedWithIS(idProfile)) && dsMitt != null && dsMitt.Tables[0].Rows.Count > 0 && dsMitt.Tables["INFO_MITT"].Rows[0]["CHA_TIPO_IE"] != null && !dsMitt.Tables["INFO_MITT"].Rows[0]["CHA_TIPO_IE"].Equals(System.DBNull.Value)) { obj.getDatiProtoSpedito(out dsProto, idProfile); string sep = DocsPaDB.Utils.Personalization.getInstance(reg.idAmministrazione).getSepSegnatura(); string codAmm = DocsPaDB.Utils.Personalization.getInstance(reg.idAmministrazione).getCodiceAmministrazione(); string[] protoMitt = dsMitt.Tables["INFO_MITT"].Rows[0]["VAR_PROTO_IN"].ToString().Split(sep.ToCharArray(), 2); string dataProtoMitt = dsMitt.Tables["INFO_MITT"].Rows[0]["DTA_PROTO_IN"].ToString(); string dataProto = dsProto.Tables["INFO_PROTO"].Rows[0]["DTA_PROTO"].ToString(); string numProto = dsProto.Tables["INFO_PROTO"].Rows[0]["NUM_PROTO"].ToString(); string dataAnnulla = dsProto.Tables["INFO_PROTO"].Rows[0]["DTA_ANNULLA"].ToString(); string motivoAnnulla = dsProto.Tables["INFO_PROTO"].Rows[0]["VAR_AUT_ANNULLA"].ToString(); if (protoMitt != null && dataProtoMitt != null && protoMitt.Length > 1) { DocsPaVO.Interoperabilita.NotificaAnnullamento not = new DocsPaVO.Interoperabilita.NotificaAnnullamento(); not.codAmm = codAmm; not.codAmm_Mitt = codAmm; //so che viene dalla stessa amm, ma in futuro posso valutarlo nelle multiamm, dalla dpa_stato_invio ?. not.codAOO = reg.codRegistro; not.codAOO_Mitt = protoMitt[0]; not.dataRegistr_Mitt = dataProtoMitt.Substring(0, dataProtoMitt.IndexOf(" ")); not.dataRegistrazione = dataProto.Substring(0, dataProtoMitt.IndexOf(" "));; not.numeroRegistr_Mitt = protoMitt[1]; not.numeroRegistrazione = numProto; not.dataAnnullamento = dataAnnulla; not.motivoAnnullamento = motivoAnnulla; // Se il documento è stato ricevuto per interoperabilità semplificata, l'elaborazione // viene demandata al gestore dell'IS if (InteroperabilitaSemplificataManager.IsDocumentReceivedWithIS(idProfile)) { esito = BusinessLogic.interoperabilita.Semplificata.SimplifiedInteroperabilityRecordDroppedAndExceptionManager.SendDocumentDroppedOrExceptionProofToSender(not.motivoAnnullamento, idProfile, not.codAmm, true); } else { //ATTENZIONE SOSTITUIRE CON NUOVA PROCEDURA esito = BusinessLogic.Interoperabilità.InteroperabilitaNotificaAnnullamento.processaNotificaAnnullamento(not, out err); } } dsMitt.Dispose(); dsProto.Dispose(); } else #endregion { esito = sendNotificaAnnulla(idProfile, reg); } } catch (Exception e) { esito = false; logger.Debug("Errore nella gestione dell'interoperabilità. (sendRicevutaRitorno)" + " ", e); throw e; } return(esito); }
/// <summary></summary> /// <param name="idProfile"></param> /// <param name="reg"></param> /// <param name="numRegMitt"></param> /// <param name="qco"></param> /// <param name="separatore"></param> /// <param name="filePath"></param> private static void costruisciXml(string idProfile, DocsPaVO.utente.Registro reg, ref string numRegMitt, ref DocsPaVO.addressbook.QueryCorrispondente qco, string separatore, string filePath) { System.Data.DataSet ds; try { logger.Debug("costruisciXml"); logger.Debug("" + separatore); DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getMittSegn(out ds, idProfile); System.Data.DataRow mittRow = ds.Tables["INFO_MITT"].Rows[0]; char[] separator = { separatore.ToCharArray()[0] }; //si trova il codice amministrazione del mittente string codiceAmmMittString = ""; if (mittRow["CHA_TIPO_IE"].ToString().Equals("I")) { //mittente interno codiceAmmMittString = reg.codAmministrazione; } else { //mittente esterno codiceAmmMittString = mittRow["VAR_CODICE_AMM"].ToString(); } string protoIn = mittRow["VAR_PROTO_IN"].ToString(); logger.Debug(protoIn + " " + protoIn.Split(separator).Length); string codiceAOOMittString = protoIn.Split(separator)[0]; string numeroRegMittString = (protoIn.Split(separator).Length > 1 ? protoIn.Split(separator)[1] : string.Empty); numRegMitt = numeroRegMittString; //costruzione dell'oggetto per la richiesta mittente qco.codiceRubrica = mittRow["VAR_COD_RUBRICA"].ToString(); qco.idAmministrazione = mittRow["ID_AMM"].ToString(); if (mittRow["CHA_TIPO_IE"].ToString().Equals("I")) { qco.tipoUtente = DocsPaVO.addressbook.TipoUtente.INTERNO; } else { qco.tipoUtente = DocsPaVO.addressbook.TipoUtente.ESTERNO; } qco.getChildren = false; string dataRegMittString = (!string.IsNullOrEmpty(mittRow["DTA_PROTO_IN"].ToString()) ? System.Convert.ToDateTime(mittRow["DTA_PROTO_IN"]).ToString("yyyy-MM-dd") : string.Empty); obj.getIdent(out ds, idProfile); System.Data.DataRow protoRow = ds.Tables["INFO_PROTO"].Rows[0]; string numeroRegString = protoRow["NUM_PROTO"].ToString(); string dataRegString = ""; if (protoRow["DTA_PROTO"] != null && !protoRow["DTA_PROTO"].ToString().Equals("")) { dataRegString = System.Convert.ToDateTime(protoRow["DTA_PROTO"]).ToString("yyyy-MM-dd"); } string dataAnnullamento = ""; if (protoRow["DTA_ANNULLA"] != null && !protoRow["DTA_ANNULLA"].ToString().Equals("")) { dataAnnullamento = System.Convert.ToDateTime(protoRow["DTA_ANNULLA"]).ToString("yyyy-MM-dd"); } string motivoAnnullamento = protoRow["VAR_AUT_ANNULLA"].ToString(); //costruzione del file xml logger.Debug("Costruzione file xml"); XmlDocument xdoc = new XmlDocument(); //impostazione xdoc.XmlResolver = null; XmlDeclaration dec = xdoc.CreateXmlDeclaration("1.0", "UTF-8", null); xdoc.AppendChild(dec); //XmlDocumentType dtd = xdoc.CreateDocumentType("AnnullamentoProtocollazione", null, "Segnatura.dtd", null); //xdoc.AppendChild(dtd); //logger.Debug("dtd impostato"); //creazione della root XmlElement root = xdoc.CreateElement("AnnullamentoProtocollazione"); root.SetAttribute("xmlns", "http://www.digitPa.gov.it/protocollo/"); xdoc.AppendChild(root); //creazione dell'identificatore XmlElement identificatore = xdoc.CreateElement("Identificatore"); root.AppendChild(identificatore); XmlElement codiceAmm = xdoc.CreateElement("CodiceAmministrazione"); codiceAmm.InnerText = reg.codAmministrazione; identificatore.AppendChild(codiceAmm); XmlElement codiceAOO = xdoc.CreateElement("CodiceAOO"); //se è un RF, io devo comunque inviare la ricevuta dall'AOO. DocsPaVO.utente.Registro registro = new DocsPaVO.utente.Registro(); if (reg.chaRF != null && reg.chaRF == "1") { if (!string.IsNullOrEmpty(reg.idAOOCollegata)) { registro = BusinessLogic.Utenti.RegistriManager.getRegistro(reg.idAOOCollegata); } else { throw new Exception("Errore in costruiscixml conferma, l'RF " + reg.descrizione + " non ha una AOO collegata."); } } if (registro != null) { reg = registro; } codiceAOO.InnerText = reg.codRegistro; identificatore.AppendChild(codiceAOO); XmlElement codiceRegistro = xdoc.CreateElement("CodiceRegistro"); codiceRegistro.InnerText = reg.codRegistro; identificatore.AppendChild(codiceRegistro); XmlElement numeroReg = xdoc.CreateElement("NumeroRegistrazione"); numeroReg.InnerText = numeroRegString; identificatore.AppendChild(numeroReg); XmlElement dataReg = xdoc.CreateElement("DataRegistrazione"); dataReg.InnerText = dataRegString; identificatore.AppendChild(dataReg); //creazione motivo annullamento XmlElement motivoAnnulla = xdoc.CreateElement("Motivo"); motivoAnnulla.InnerText = motivoAnnullamento; root.AppendChild(motivoAnnulla); //creazione provvedimento annullamento XmlElement provvedimento = xdoc.CreateElement("Provvedimento"); provvedimento.InnerText = ""; root.AppendChild(provvedimento); /* NON E' RICHIESTO * //creazione dell'identificatore mittente; * XmlElement messRicevuto=xdoc.CreateElement("MessaggioRicevuto"); * XmlElement identificatoreMitt=xdoc.CreateElement("Identificatore"); * * XmlElement codiceAmmMitt=xdoc.CreateElement("CodiceAmministrazione"); * codiceAmmMitt.InnerText=codiceAmmMittString; * identificatoreMitt.AppendChild(codiceAmmMitt); * * * XmlElement codiceAOOMitt=xdoc.CreateElement("CodiceAOO"); * codiceAOOMitt.InnerText=codiceAOOMittString; * identificatoreMitt.AppendChild(codiceAOOMitt); * * XmlElement numeroRegMitt=xdoc.CreateElement("NumeroRegistrazione"); * numeroRegMitt.InnerText=numeroRegMittString; * identificatoreMitt.AppendChild(numeroRegMitt); * * XmlElement dataRegMitt=xdoc.CreateElement("DataRegistrazione"); * dataRegMitt.InnerText=dataRegMittString; * identificatoreMitt.AppendChild(dataRegMitt); * * messRicevuto.AppendChild(identificatoreMitt); * root.AppendChild(messRicevuto); */ //salvataggio file System.IO.FileStream fs = new System.IO.FileStream(filePath + "\\Annullamento.xml", System.IO.FileMode.Create); xdoc.Save(fs); fs.Close(); } catch (Exception e) { logger.Error("Errore nella gestione dell'interoperabilità. (costruisciXml)", e); throw e; } }
/// <summary> /// /// </summary> /// <param name="idProfile"></param> /// <param name="reg"></param> private static bool sendNotificaAnnulla(string idProfile, DocsPaVO.utente.Registro reg) { System.Data.DataSet ds; bool esito = true; //presume successo try { //BusinessLogic.Interoperabilità.InteroperabilitaControlloRicevute.processaRicevutaConferma(); DocsPaDB.Query_DocsPAWS.Interoperabilita obj = new DocsPaDB.Query_DocsPAWS.Interoperabilita(); obj.getCampiReg(out ds, reg); System.Data.DataRow regRow = ds.Tables["REGISTRO"].Rows[0]; reg.codAmministrazione = regRow["VAR_CODICE_AMM"].ToString(); //inserimento dei files in una cartella temporanea string basePathFiles = ConfigurationManager.AppSettings["LOG_PATH"]; basePathFiles = basePathFiles.Replace("%DATA", DateTime.Now.ToString("yyyyMMdd")); basePathFiles = basePathFiles + "\\Invio_notifica_annullamento_files"; string pathFiles = basePathFiles + "\\" + regRow["VAR_CODICE"].ToString(); DocsPaUtils.Functions.Functions.CheckEsistenzaDirectory(pathFiles); // logger.Debug(""+regRow["CHA_STR_SEGNATURA"].ToString().ToCharArray().Length); //costruzione del file xml string numRegMitt = ""; DocsPaVO.addressbook.QueryCorrispondente qco = new DocsPaVO.addressbook.QueryCorrispondente(); //costruisciXml(idProfile, reg,ref numRegMitt,ref qco, regRow["CHA_STR_SEGNATURA"].ToString(),pathFiles); string separatore = DocsPaDB.Utils.Personalization.getInstance(reg.idAmministrazione).getSepSegnatura(); costruisciXml(idProfile, reg, ref numRegMitt, ref qco, separatore, pathFiles); //invio mail string mailMitt = Interoperabilità.InteroperabilitaUtils.getMailAddress(qco, idProfile); logger.Debug("Invio mail all'indirizzo " + mailMitt); string porta = null; if (regRow["NUM_PORTA_SMTP"] != null) { porta = regRow["NUM_PORTA_SMTP"].ToString(); } string smtp_user = (regRow["VAR_USER_SMTP"] != null && regRow["VAR_USER_SMTP"] != System.DBNull.Value) ? regRow["VAR_USER_SMTP"].ToString() : null; string smtp_pwd; if (regRow["VAR_PWD_SMTP"] != null && regRow["VAR_PWD_SMTP"] != System.DBNull.Value && regRow["VAR_USER_SMTP"] != null && regRow["VAR_USER_SMTP"] != System.DBNull.Value) { smtp_pwd = Crypter.Decode(regRow["VAR_PWD_SMTP"].ToString(), regRow["VAR_USER_SMTP"].ToString()); } else { smtp_pwd = string.Empty; } //aggiunta la trim() per gestire la presenza di spazi bianchi nei campi VAR_USER_SMTP e VAR_PWD_SMTP if (smtp_user != null) { smtp_user = smtp_user.Trim(); } if (smtp_pwd != null) { smtp_pwd = smtp_pwd.Trim(); } // copia il file di segnatura //System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + @"xml\segnatura.dtd",pathFiles + "\\segnatura.dtd",true); creaMail(regRow["VAR_SERVER_SMTP"].ToString(), smtp_user, smtp_pwd, regRow["VAR_EMAIL_REGISTRO"].ToString(), mailMitt, numRegMitt, pathFiles, porta, regRow["CHA_SMTP_SSL"].ToString(), regRow["CHA_POP_SSL"].ToString(), regRow["CHA_SMTP_STA"].ToString()); System.IO.File.Delete(pathFiles + "\\Annullamento.xml"); DocsPaUtils.Functions.Functions.CancellaDirectory(pathFiles); DocsPaUtils.Functions.Functions.CancellaDirectory(basePathFiles); } catch (Exception e) { esito = false; logger.Error("Errore nella gestione dell'interoperabilità. (sendNotificaAnnullamento)", e); throw e; } return(esito); }