protected string FetchIdSupporto() { string filters = " A.ID_CONSERVAZIONE= '" + this._idConservazione + "' AND ( A.ID_TIPO_SUPPORTO = (SELECT system_id from dpa_tipo_supporto where var_tipo='REMOTO') ) and a.ID_CONSERVAZIONE = c.SYSTEM_ID and c.id_amm = " + this._infoUtente.idAmministrazione + " ORDER BY A.ID_CONSERVAZIONE DESC, A.COPIA ASC"; DocsPaConsManager dcmgr = new DocsPaConsManager(); DocsPaVO.areaConservazione.InfoSupporto[] supporti = dcmgr.RicercaInfoSupporto(filters); return(supporti.FirstOrDefault().SystemID); }
// MEV CS 1.5 - notifiche scadenza verifiche di leggibilità public static int GetCountNotificheLeggibilita(string codiceAmministrazione) { int totalCount = 0; // Reperimento dei supporti per cui è necessario effettuare l'integrità using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider()) { //int giorniConservazione = 10; //reperimento chiave di configurazione string q = string.Format("SELECT SYSTEM_ID FROM DPA_AMMINISTRA WHERE VAR_CODICE_AMM='{0}'", codiceAmministrazione); string idAmm = string.Empty; if (!dbProvider.ExecuteScalar(out idAmm, q)) { throw new Exception("Errore nel reperimento dell'id amministrazione"); } string value = DocsPaUtils.Configuration.InitConfigurationKeys.GetValue(idAmm, "BE_CONS_VER_LEG_GG_NOTIFICHE"); if (string.IsNullOrEmpty(value)) { //se non è definita la chiave? throw new Exception("Chiave di configurazione non definita."); } string queryDefinition = ""; if (DocsPaConsManager.supportiRimovibiliVerificabili()) { queryDefinition = "S_CONSERVAZIONE_GET_COUNT_NOTIFICHE_VERIFICHE_LEGG_SUPPORTI"; } else { queryDefinition = "S_CONSERVAZIONE_GET_COUNT_NOTIFICHE_VERIFICHE_LEGG_SUPPORTI_REMOTI"; } int giorniConservazione = Int32.Parse(value); DocsPaUtils.Query queryDef = DocsPaUtils.InitQuery.getInstance().getQuery(queryDefinition); queryDef.setParam("dataConfronto", DocsPaDbManagement.Functions.Functions.ToDate(DateTime.Today.AddDays(giorniConservazione).ToString("dd/MM/yyyy"))); queryDef.setParam("codiceAmministrazione", codiceAmministrazione); string commandText = queryDef.getSQL(); logger.InfoFormat("{1}: {0}", commandText, queryDefinition); string field; if (!dbProvider.ExecuteScalar(out field, commandText)) { throw new ApplicationException(dbProvider.LastExceptionMessage); } if (!string.IsNullOrEmpty(field)) { totalCount += Convert.ToInt32(field); } } return(totalCount); }
public static InfoNotifica[] GetNotificheLeggibilita(string idAmm) { List <InfoNotifica> list = new List <InfoNotifica>(); // Reperimento dei supporti per cui è necessario effettuare la verifica di leggibilità using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider()) { string queryDefinition = ""; if (DocsPaConsManager.supportiRimovibiliVerificabili()) { queryDefinition = "S_CONSERVAZIONE_GET_NOTIFICHE_VERIFICHE_LEGG_SUPPORTI"; } else { queryDefinition = "S_CONSERVAZIONE_GET_NOTIFICHE_VERIFICHE_LEGG_SUPPORTI_REMOTI"; } DocsPaUtils.Query queryDef = DocsPaUtils.InitQuery.getInstance().getQuery(queryDefinition); //int giorniConservazione = 10; string value = string.Empty; if (!string.IsNullOrEmpty(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue(idAmm, "BE_CONS_VER_LEG_GG_NOTIFICHE"))) { value = DocsPaUtils.Configuration.InitConfigurationKeys.GetValue(idAmm, "BE_CONS_VER_LEG_GG_NOTIFICHE"); } //else //value = System.Configuration.ConfigurationManager.AppSettings["CONSERVAZIONE_GG_NOTIFICHE"]; if (!string.IsNullOrEmpty(value)) { //Int32.TryParse(value, out giorniConservazione); } int giorniConservazione = Int32.Parse(value); queryDef.setParam("idAmm", idAmm); queryDef.setParam("dataConfronto", DocsPaDbManagement.Functions.Functions.ToDate(DateTime.Today.AddDays(giorniConservazione).ToString("dd/MM/yyyy"))); string commandText = queryDef.getSQL(); logger.InfoFormat("{1}: {0}", commandText, queryDefinition); using (IDataReader reader = dbProvider.ExecuteReader(commandText)) { while (reader.Read()) { list.Add(CreateInfoNotificaLeggibilitaSupporto(reader)); } } } return(list.OrderByDescending(e => e.GiorniScadenza).ToArray()); }
/* * //Codice inefficiente * /// <summary> * /// Converte un file in una stringa Esadicimale * /// </summary> * /// <param name="byte8In"></param> * /// <returns></returns> * private static string byteArrayToHexa(byte[] byte8In) * { * string retval = ""; * foreach (byte b in byte8In) * { * retval += String.Format("{0:X2}", b); * } * return retval; * } */ /// <summary> /// Aggiorna sul DB (nelle relative tabelle) i dati della marca /// </summary> /// <param name="marca"></param> /// <param name="dataMarca"></param> /// <param name="dataScadenzaMarca"></param> /// <param name="SystemID">id dell'istanza di conservazione</param> /// <returns></returns> public bool updateTimeStamp(string marca, string dataMarca, string dataScadenzaMarca, string SystemID, string progressivoMarca) { bool result = false; try { //parsing del timeStamp int anno = System.Convert.ToInt32(dataMarca.Substring(0, 4)); int mese = System.Convert.ToInt32(dataMarca.Substring(4, 2)); int giorno = System.Convert.ToInt32(dataMarca.Substring(6, 2)); int ora = System.Convert.ToInt32(dataMarca.Substring(8, 2)); int min = System.Convert.ToInt32(dataMarca.Substring(10, 2)); int sec = System.Convert.ToInt32(dataMarca.Substring(12, 2)); DateTime StartDate = new DateTime(anno, mese, giorno, ora, min, sec); dataMarca = StartDate.ToString("MM/dd/yyyy"); //parsing della data di scadenza DateTime outDate = new DateTime(); DateTime EndDate = new DateTime(); CultureInfo culture = new CultureInfo("en-US", true); if (DateTime.TryParse(dataScadenzaMarca, culture.DateTimeFormat, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out outDate)) { EndDate = DateTime.Parse(dataScadenzaMarca, culture.DateTimeFormat, System.Globalization.DateTimeStyles.AllowWhiteSpaces); } else { CultureInfo culture2 = new CultureInfo("it-IT"); dataScadenzaMarca = dataScadenzaMarca.Replace(".", ":"); EndDate = Convert.ToDateTime(dataScadenzaMarca, culture2); } dataScadenzaMarca = EndDate.ToString("MM/dd/yyyy"); string upInfoCons = " SET VAR_MARCA_TEMPORALE='" + marca + "' WHERE SYSTEM_ID='" + SystemID + "'"; //string upInfoSupp = " SET DATA_APPO_MARCA=TO_DATE('" + dataMarca + "','MM/DD/YYYY'), DATA_SCADENZA_MARCA=TO_DATE('" + dataScadenzaMarca + "','MM/DD/YYYY'), VAR_MARCA_TEMPORALE='" + marca + "' WHERE ID_CONSERVAZIONE='" + SystemID + "'"; DocsPaConsManager cm = new DocsPaConsManager(); //result = cm.UpdateInfoSupporto(upInfoSupp); result = cm.UpdateDatiTimeStampConservazione(SystemID, marca, dataMarca, dataScadenzaMarca, progressivoMarca); if (result && cm.UpdateInfoConservazione(upInfoCons)) { result = true; } else { result = false; } } catch (Exception exDate) { } return(result); }
private void jobVerifica(object sender, ScheduledEventArgs e) { // Esecuzione di ogni singolo task schedulato string AmmId = sender as String; //timer.EventStorage.ToString(); string[] istanze = new DocsPaConsManager().getIstanzeNonVerificate(AmmId); foreach (string s in istanze) { new DocsPaConsManager().VerificaAutomatica(s); } }
/// <summary> /// Restituisce la dimensione dell'equivalente file XML che rappresenta la serializzazione dell'oggetto /// passato come parametro /// </summary> /// <param name="schDoc">è l'oggetto scheda documento che dobbiamo serializzare</param> /// <returns></returns> public string serializeSchedaDoc(DocsPaVO.documento.SchedaDocumento schDoc) { string metadati = string.Empty; string result = "-1"; MemoryStream memoryWriter = null; try { Metadati dati = new Metadati(schDoc); //Sostituisco al system_id il nome e cognome if (dati.protocollatore != null) { if (!string.IsNullOrEmpty(dati.protocollatore.Nome_Cognome)) { DocsPaConsManager cm = new DocsPaConsManager(); dati.protocollatore.Nome_Cognome = cm.getFullName(dati.protocollatore.Nome_Cognome); } } if (dati.creatoreDocumento != null) { if (!string.IsNullOrEmpty(dati.creatoreDocumento.Nome_Cognome)) { DocsPaConsManager cm = new DocsPaConsManager(); dati.creatoreDocumento.Nome_Cognome = cm.getFullName(dati.creatoreDocumento.Nome_Cognome); } } memoryWriter = new MemoryStream(); XmlSerializer serializer = new XmlSerializer(typeof(Metadati)); serializer.Serialize(memoryWriter, dati); //Devo tornare all'inizio del MemoryStream per leggerne il contenuto!!! memoryWriter.Seek(0, SeekOrigin.Begin); result = memoryWriter.Length.ToString(); metadati = new StreamReader(memoryWriter).ReadToEnd(); } catch (Exception ex) { logger.Debug(ex.Message); } finally { if (memoryWriter != null) { memoryWriter.Flush(); memoryWriter.Close(); } } return(result); }
protected string FetchDataProssimaVerifica() { // Se l'istanza è stata creata tramite policy, riporta il numero dei mesi definiti nella stessa, altrimenti il default è 6 mesi // MEV CS 1.5 // il valore di default è quello della chiave di db BE_CONSERVAZIONE_INTERVALLO DocsPaConsManager dcmgr = new DocsPaConsManager(); DocsPaVO.Conservazione.Policy policy = dcmgr.GetPolicyByIdIstanzaConservazione(this._infoUtente, this._idConservazione); //int mesiDefault = 6; // recupero il valore dal db (espresso in GIORNI) int giorniVerifica = Convert.ToInt32(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue(this._infoUtente.idAmministrazione, "BE_CONSERVAZIONE_INTERVALLO")); if (policy != null) { // Istanza creata tramite policy: impostazione del numero di mesi definiti in essa int mesiPolicy; Int32.TryParse(policy.avvisoMesi, out mesiPolicy); //if (mesiPolicy == 0) // mesiPolicy = mesiDefault; //return DateTime.Today.AddMonths(mesiPolicy).ToString("dd/MM/yyyy"); // MEV CS 1.5 if (mesiPolicy == 0) { return(DateTime.Today.AddDays(giorniVerifica).ToString("dd/MM/yyyy")); } else { return(DateTime.Today.AddMonths(mesiPolicy).ToString("dd/MM/yyyy")); } } else { // Default: prossimo controllo a 6 mesi da oggi // return DateTime.Today.AddMonths(mesiDefault).ToString("dd/MM/yyyy"); // MEV CS 1.5 // restituisco il valore calcolato a partire dall'intervallo definito nel db return(DateTime.Today.AddDays(giorniVerifica).ToString("dd/MM/yyyy")); } }
/// <summary> /// /// </summary> /// <param name="result"></param> private void IniziaVerificaSupportoExecuted(IAsyncResult result) { //string esito ="0"; DocsPaVO.Logger.CodAzione.Esito logResponse = DocsPaVO.Logger.CodAzione.Esito.KO; if (result.IsCompleted) { VerificaSupportoRemoto cmd = (VerificaSupportoRemoto)result.AsyncState; // Notifica trasmissione al mittente DocsPaConsManager consManager = new DocsPaConsManager(); if (cmd._statoVerifica.Esito) { bool ret = consManager.TrasmettiNotifica(this._infoUtente, this._idConservazione); //logResponse = DocsPaVO.Logger.CodAzione.Esito.OK; //esito = "1"; } } }
/// <summary> /// Aggiornamento dello stato dell'istanza di conservazione e del supporto /// </summary> protected virtual void UpdateIstanzaConservazione() { string descrizione, codAzione; logger.Info("UpdateIstanzaConservazione"); if (this._statoVerifica.Esito) { string stato = string.Empty; int countSupportiRimovibiliRegistrati = DocsPaConsManager.GetCountSupportiRimovibiliRegistrati(this._idConservazione); int countSupportiRimovibili = DocsPaConsManager.GetCountSupportiRimovibili(this._idConservazione); logger.InfoFormat("UpdateIstanzaConservazione.countSupportiRimovibiliRegistrati: {0}", countSupportiRimovibiliRegistrati); logger.InfoFormat("UpdateIstanzaConservazione.countSupportiRimovibili: {0}", countSupportiRimovibili); // Modifica per scrittura Log e Registro di conservazione if (countSupportiRimovibiliRegistrati == countSupportiRimovibili) { stato = DocsPaConservazione.StatoIstanza.CHIUSA; descrizione = "Passaggio in stato CHIUSA dell’istanza " + _idConservazione; codAzione = "PASS_ISTANZA_CHIUSA"; } else { stato = DocsPaConservazione.StatoIstanza.CONSERVATA; descrizione = "Passaggio in stato CONSERVATA dell’istanza " + _idConservazione; codAzione = "PASS_ISTANZA_CONSERVATA"; } // Impostazione dello stato dell'istanza allo stato "CONSERVATO" DocsPaConsManager.UpdateStatoIstanzaConservazione(this._idConservazione, stato); //Scrive il log BusinessLogic.UserLog.UserLog.WriteLog(_infoUtente, codAzione, _idConservazione, descrizione, DocsPaVO.Logger.CodAzione.Esito.OK); // Scrive sul Registro di Conservazione DocsPaVO.Conservazione.RegistroCons regCons = new DocsPaVO.Conservazione.RegistroCons(); regCons.idAmm = _infoUtente.idAmministrazione; regCons.idIstanza = _idConservazione; regCons.tipoOggetto = "I"; regCons.tipoAzione = ""; regCons.userId = _infoUtente.userId; regCons.codAzione = codAzione; regCons.descAzione = descrizione; regCons.esito = "1"; RegistroConservazione rc = new RegistroConservazione(); rc.inserimentoInRegistroCons(regCons, _infoUtente); } else { logger.Debug("Si è verificato un errore durante lo spostamento dei file sullo storage remoto. L'istanza torna nello stato Firmata"); DocsPaConsManager.UpdateStatoIstanzaConservazione(_idConservazione, DocsPaConservazione.StatoIstanza.FIRMATA); } DocsPaConsManager.UpdateStatoSupportoRemoto(this._idConservazione, 100, (this._statoVerifica.Esito ? StatoSupporto.VERIFICATO : StatoSupporto.DANNEGGIATO)); logger.Info("UpdateIstanzaConservazione - END"); }
/// <summary> /// /// </summary> protected virtual void IniziaVerificaSupporto() { logger.Debug("BEGIN - IniziaVerificaSupporto"); bool hasError = false; string errorMessage = string.Empty; string dctmCServerAddressRoot = string.Empty; //Per rendere asincrona l'operazione di spostamento dei file Impostare a true //Questa operazione è da fare pure su esitoLeggibilita in Docspaconservazionews.asmx bool operazioneAsincrona = true; if (operazioneAsincrona) { FileManager fm = new FileManager(); fm.createZipFile(this._idConservazione); if (!fm.SubmitToRemoteFolder(this._idConservazione)) { logger.ErrorFormat("Errore inviando i file sullo starge remoto"); hasError = true; return; } else { BusinessLogic.UserLog.UserLog.WriteLog(this._infoUtente, "CREAZIONE_STORAGE", this._idConservazione, String.Format("Memorizzazione nel repository del sistema di conservazione dell’istanza {0}", this._idConservazione), DocsPaVO.Logger.CodAzione.Esito.OK); // Modifica scrittura Log e Registro di Conservazione per la scrittura della Creazione Storage DocsPaVO.Conservazione.RegistroCons regCons = new DocsPaVO.Conservazione.RegistroCons(); regCons.idAmm = this._infoUtente.idAmministrazione; regCons.idIstanza = this._idConservazione; regCons.tipoOggetto = "I"; regCons.tipoAzione = ""; regCons.userId = this._infoUtente.userId; regCons.codAzione = "CREAZIONE_STORAGE"; regCons.descAzione = "Memorizzazione nel repository del sistema di conservazione dell'istanza " + this._idConservazione; regCons.esito = "1"; RegistroConservazione rc = new RegistroConservazione(); rc.inserimentoInRegistroCons(regCons, this._infoUtente); } } try { // Impostazione del supporto in stato "InVerifica" DocsPaConsManager.UpdateStatoSupportoRemoto(this._idConservazione, 0, "I"); // 1. Reperimento path file chiusura XmlDocument xmlFile = new XmlDocument(); Stream fileChiusura; fileChiusura = new MemoryStream(new FileManager().getFileFromStore(this._idConservazione, "\\Chiusura\\file_chiusura.xml", false)); fileChiusura.Seek(0, SeekOrigin.Begin); xmlFile.Load(fileChiusura); XmlNodeList nodes = xmlFile.GetElementsByTagName("sincro:File"); this._statoVerifica.TotaleDocumenti = nodes.Count; foreach (XmlNode n in nodes) { if (this._interrompi) { throw new ApplicationException(string.Format("Verifica integrità interrotta. Verificati {0} documenti su {1}.", this._statoVerifica.DocumentiVerificati, this._statoVerifica.TotaleDocumenti)); } // 2. Estrazione dei documenti conservati da file di chiusura // Reperimento dei metadati dei file conservati dal file di chiusura string idDocumento = ((XmlNode)n.ChildNodes[0]).InnerText; string pathFile = ((XmlNode)n.ChildNodes[1]).InnerText; string hashSupporto = ((XmlNode)n.ChildNodes[2]).InnerText; // Caricamento hash da repository string hashDbRepository, hashFileRepository; this.LoadHashDocumento(idDocumento, out hashDbRepository, out hashFileRepository); byte[] content = new FileManager().getFileFromStore(this._idConservazione, pathFile, false); if (content != null) { string hashFileSupporto = this.GetHash256(content); if (hashFileSupporto != hashSupporto) { hashFileSupporto = this.GetHash128(content); if (hashFileSupporto != hashSupporto) { this._statoVerifica.DocumentiNonValidi++; } } } else { this._statoVerifica.DocumentiNonValidi++; } this._statoVerifica.DocumentiVerificati++; // Calcolo della percentuale per lo stato di avanzamento this._statoVerifica.Percentuale = (this._statoVerifica.DocumentiVerificati * 100 / nodes.Count); this._statoVerifica.Descrizione = string.Format("Verifica integrità documento {0} di {1} in corso...", this._statoVerifica.DocumentiVerificati, nodes.Count); // Impostazione del supporto in stato "InVerifica" DocsPaConsManager.UpdateStatoSupportoRemoto(this._idConservazione, this._statoVerifica.Percentuale, "I"); } } catch (Exception ex) { hasError = true; errorMessage = ex.Message; logger.ErrorFormat("Errore in VerificaSupportoRemoto.IniziaVerificaSupporto: {0}", ex.ToString()); } finally { if (hasError) { this._statoVerifica.Esito = false; this._statoVerifica.Percentuale = 0; this._statoVerifica.Descrizione = errorMessage; } else { this._statoVerifica.Esito = (this._statoVerifica.DocumentiVerificati == this._statoVerifica.TotaleDocumenti); if (this._statoVerifica.Esito) { this._statoVerifica.Percentuale = 100; this._statoVerifica.Descrizione = string.Format("Verifica integrità terminata. Verificati {0} su {1} documenti. Supporto valido.", this._statoVerifica.DocumentiVerificati, this._statoVerifica.TotaleDocumenti); } else { this._statoVerifica.Percentuale = 0; this._statoVerifica.Descrizione = string.Format("Verifica integrità terminata. Individuati {0} documenti non validi su {1}. Supporto corrotto.", this._statoVerifica.DocumentiNonValidi, this._statoVerifica.TotaleDocumenti); } } BusinessLogic.UserLog.UserLog.WriteLog(this._infoUtente, "INTEGRITA_STORAGE", this._idConservazione, String.Format("Esecuzione della verifica di integrità dei documenti dell’istanza {0}", this._idConservazione), (this._statoVerifica.Esito ? DocsPaVO.Logger.CodAzione.Esito.OK : DocsPaVO.Logger.CodAzione.Esito.KO)); DocsPaConsManager consManager = new DocsPaConsManager(); // Modifica per inserimento in dPA_CONS_VERIFICA consManager.RegistraEsitoVerificaSupportoRegistrato( this._infoUtente, this._idConservazione, FetchIdSupporto(), this._statoVerifica.Esito, "100", FetchDataProssimaVerifica(), "Verifica Integrità per chiusura", "C"); // Modifica scrittura Log e Registro di Conservazione per la scrittura della Creazione Storage DocsPaVO.Conservazione.RegistroCons regCons = new DocsPaVO.Conservazione.RegistroCons(); regCons.idAmm = this._infoUtente.idAmministrazione; regCons.idIstanza = this._idConservazione; regCons.tipoOggetto = "I"; regCons.tipoAzione = ""; regCons.userId = this._infoUtente.userId; regCons.codAzione = "INTEGRITA_STORAGE"; regCons.descAzione = "Esecuzione della verifica di integrità dei documenti istanza " + this._idConservazione; regCons.esito = (this._statoVerifica.Esito ? "1" : "0"); RegistroConservazione rc = new RegistroConservazione(); rc.inserimentoInRegistroCons(regCons, this._infoUtente); // Aggiornamento dello stato del supporto this.UpdateIstanzaConservazione(); } logger.Debug("END - IniziaVerificaSupporto"); }
/// <summary> /// Questo metodo costruisce il file XML generale che verrà sottoposto a firma del responsabile /// della conservazione /// </summary> /// <param name="objFileRequest"></param> /// <param name="path_relativo"></param> /// <param name="root_conservazione"></param> /// <param name="schDoc"></param> /// <param name="infoCons"></param> /// <param name="isAllegato"></param> /// <param name="codFasc"></param> /// <returns></returns> public bool setInfoFolderXml(DocsPaVO.documento.FileRequest objFileRequest, string path_relativo, string root_conservazione, DocsPaVO.documento.SchedaDocumento schDoc, DocsPaVO.areaConservazione.InfoConservazione infoCons, bool isAllegato, string codFasc) { bool result = false; // leggo l'impronta del documento associato alla FileRequest passata come parametro string impronta = ""; TextWriter textwriter = null; XmlTextWriter writer = null; TextWriter textwriter2 = null; try { DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti(); doc.GetImpronta(out impronta, objFileRequest.versionId, objFileRequest.docNumber); //Verifica dati string segnatura = string.Empty; if (schDoc.protocollo != null) { segnatura = schDoc.protocollo.segnatura; } string oggetto = string.Empty; if (schDoc.oggetto != null) { oggetto = schDoc.oggetto.descrizione; } bool flag = File.Exists(root_conservazione); if (!flag) { textwriter = new StreamWriter(root_conservazione, true, Encoding.UTF8); writer = new XmlTextWriter(textwriter); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("IDCONSERVAZIONE_" + infoCons.SystemID); writer.WriteElementString("DATA_SOTTOSCRIZIONE", infoCons.Data_Invio); writer.WriteElementString("NOTE", infoCons.Note); writer.WriteElementString("DESCRIZIONE", infoCons.Descrizione); writer.WriteElementString("TIPO_CONSERVAZIONE", infoCons.TipoConservazione); //writer.WriteStartElement("DOCNUMBER_" + objFileRequest.docNumber); writer.WriteStartElement("DOC"); //writer.WriteValue(objFileRequest.docNumber); writer.WriteElementString("NUMBER", objFileRequest.docNumber); writer.WriteElementString("Impronta", impronta); writer.WriteElementString("File", path_relativo); writer.WriteElementString("Segnatura", segnatura); writer.WriteElementString("Oggetto", oggetto); writer.WriteElementString("Codice_Fascicolo", codFasc); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); result = true; } else { XmlDocument docXML = new XmlDocument(); docXML.Load(root_conservazione); XmlNode root = docXML.DocumentElement; if (!isAllegato) { //XmlElement newDoc = docXML.CreateElement("DOCNUMBER_" + objFileRequest.docNumber); XmlElement newDoc = docXML.CreateElement("DOC"); XmlElement newData = docXML.CreateElement("NUMBER"); newData.InnerText = objFileRequest.docNumber; newDoc.AppendChild(newData); //XmlElement newData = docXML.CreateElement("Impronta"); newData = docXML.CreateElement("Impronta"); newData.InnerText = impronta; newDoc.AppendChild(newData); newData = docXML.CreateElement("File"); newData.InnerText = path_relativo; newDoc.AppendChild(newData); newData = docXML.CreateElement("Segnatura"); newData.InnerText = segnatura; newDoc.AppendChild(newData); newData = docXML.CreateElement("Oggetto"); newData.InnerText = oggetto; newDoc.AppendChild(newData); newData = docXML.CreateElement("Codice_Fascicolo"); newData.InnerText = codFasc; newDoc.AppendChild(newData); XmlNodeList rootList = docXML.SelectNodes("/IDCONSERVAZIONE_" + infoCons.SystemID); if (rootList.Count > 0) { rootList[0].AppendChild(newDoc); } } else { //Recupero l'oggetto dell'allegato DocsPaConsManager cm = new DocsPaConsManager(); string descrizione = cm.getDescrizioneAllegato(objFileRequest.docNumber); //Devo navigare fino ai nodi dove inserire gli allegati //string str_cerca = "/IDCONSERVAZIONE_" + infoCons.SystemID + "/DOCNUMBER_" + schDoc.docNumber; string str_cerca = "//IDCONSERVAZIONE_" + infoCons.SystemID + "/DOC[NUMBER = '" + schDoc.docNumber + "']"; XmlNodeList nodeList = docXML.SelectNodes(str_cerca); XmlNode nodoDoc = null; //Ciclo per inserire gli allegati nei relativi documenti for (int i = 0; i < nodeList.Count; i++) { nodoDoc = nodeList[i]; //XmlElement newAllegato = docXML.CreateElement("AllegatoNum_" + objFileRequest.docNumber); XmlElement newAllegato = docXML.CreateElement("Allegato"); XmlElement Dati = docXML.CreateElement("Numero"); Dati.InnerText = objFileRequest.docNumber; newAllegato.AppendChild(Dati); //XmlElement Dati = docXML.CreateElement("Impronta"); Dati = docXML.CreateElement("Impronta"); Dati.InnerText = impronta; newAllegato.AppendChild(Dati); Dati = docXML.CreateElement("Descrizione"); Dati.InnerText = descrizione; newAllegato.AppendChild(Dati); Dati = docXML.CreateElement("File"); Dati.InnerText = path_relativo; newAllegato.AppendChild(Dati); str_cerca = str_cerca + "/Allegato[Numero = '" + objFileRequest.docNumber + "']"; //Aggiungo l'allegato solo se non l'ho già fatto if (nodoDoc.SelectNodes(str_cerca).Count < 1) { nodoDoc.AppendChild(newAllegato); } } } textwriter2 = new StreamWriter(root_conservazione, false, Encoding.UTF8); docXML.Save(textwriter2); result = true; } } catch (Exception ex) { result = false; string err = "Errore nella scrittura del file XML dei metadati." + ex.Message; logger.Debug(err); } finally { if (textwriter != null) { writer.Flush(); textwriter.Flush(); writer.Close(); textwriter.Close(); } if (textwriter2 != null) { textwriter2.Flush(); textwriter2.Close(); } } return(result); }
/// <summary> /// Restituisce la dimensione dell'equivalente file XML che rappresenta la serializzazione dell'oggetto /// passato come parametro /// </summary> /// <param name="schDoc">è l'oggetto scheda documento che dobbiamo serializzare</param> /// <param name="systemID">id di esibizione</param> /// <returns></returns> public string serializeSchedaEsib(DocsPaVO.documento.SchedaDocumento schDoc, string systemID) { string metadati = string.Empty; string result = "-1"; MemoryStream memoryWriter = null; try { Metadati dati = new Metadati(schDoc); //Sostituisco al system_id il nome e cognome if (dati.protocollatore != null) { if (!string.IsNullOrEmpty(dati.protocollatore.Nome_Cognome)) { DocsPaConsManager cm = new DocsPaConsManager(); dati.protocollatore.Nome_Cognome = cm.getFullName(dati.protocollatore.Nome_Cognome); } } if (dati.creatoreDocumento != null) { if (!string.IsNullOrEmpty(dati.creatoreDocumento.Nome_Cognome)) { DocsPaConsManager cm = new DocsPaConsManager(); dati.creatoreDocumento.Nome_Cognome = cm.getFullName(dati.creatoreDocumento.Nome_Cognome); } } memoryWriter = new MemoryStream(); XmlSerializer serializer = new XmlSerializer(typeof(Metadati)); serializer.Serialize(memoryWriter, dati); //Devo tornare all'inizio del MemoryStream per leggerne il contenuto!!! memoryWriter.Seek(0, SeekOrigin.Begin); result = memoryWriter.Length.ToString(); metadati = new StreamReader(memoryWriter).ReadToEnd(); //Inserisco i metadati XML nel DB nel campo CLOB using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext()) { DBProvider dbProvider = new DBProvider(); if (!dbProvider.SetLargeText("DPA_ITEMS_ESIBIZIONE", systemID, "VAR_XML_METADATI", metadati)) { throw new Exception("Errore nell'inserimento dei metadati per esibizione nel DB"); } transactionContext.Complete(); } } catch (Exception ex) { logger.Debug(ex.Message); } finally { if (memoryWriter != null) { memoryWriter.Flush(); memoryWriter.Close(); } } return(result); }
public void PutInWorkingConservation() { DocsPaConsManager docsPaConsManager = new DocsPaConsManager(); docsPaConsManager.PutInWorkingConservation(); }
public void WorksConservationInstances() { DocsPaConsManager docsPaConsManager = new DocsPaConsManager(); docsPaConsManager.WorksConservationInstances(); }