private RicercheHtml[] orderIndex(ArrayList listaContatori, string tipoRicerca) { ArrayList list = new ArrayList(); Contatore cont = null; for (int i = 0; i < listaContatori.Count; i++) { try { ArrayList appo = (ArrayList)listaContatori[i]; cont = ((Contatore)appo[0]); } catch { cont = (Contatore)listaContatori[i]; } finally { RicercheHtml ric = new RicercheHtml(cont, tipoRicerca); list.Add(ric); } } list.Sort(); return((RicercheHtml[])list.ToArray(typeof(RicercheHtml))); }
public RicercheHtml(Contatore contatore, string tipo) { switch (tipo) { case "tipoContatore": itemsCons = contatore.items; tipoRicerca = "contatore"; titoloRicerca = "contatore"; valoreRicerca = contatore.descContatore; descContatore = contatore.descContatore; tipoContatore = valoreRicerca; //contatore.valoreContatore; tipologiaDoc = contatore.tipoDoc; tipoRicerca = tipo; break; } }
protected void creaContatori(RicercheHtml ric, ref ArrayList tipologieDoc, bool concatena) { ArrayList arrayContatori = new ArrayList(); ArrayList lista = new ArrayList(); int index = tipologieDoc.Count; if (ric.itemsCons.template != null) { lista = ric.itemsCons.template.ELENCO_OGGETTI; if (lista.Count == 0) { Contatore contatore = new Contatore(); contatore.items = (ItemsConservazione)ric.itemsCons.Clone(); contatore.tipoDoc = ric.valoreRicerca; contatore.descContatore = "non valorizzati"; contatore.valoreContatore = ""; contatore.segnatura = "non valorizzati"; contatore.items.segnaturaContatore = "non valorizzati"; arrayContatori.Add(contatore); } else { foreach (DocsPaVO.ProfilazioneDinamica.OggettoCustom oggettoCustom in lista) { if (oggettoCustom.TIPO.DESCRIZIONE_TIPO == "Contatore") { if (oggettoCustom.FORMATO_CONTATORE != "") { if (oggettoCustom.VALORE_DATABASE != null && oggettoCustom.VALORE_DATABASE != "") { Contatore contatore = new Contatore(); contatore.segnatura = oggettoCustom.FORMATO_CONTATORE; contatore.items = (ItemsConservazione)ric.itemsCons.Clone(); contatore.items.descContatore = oggettoCustom.DESCRIZIONE; contatore.tipoDoc = ric.valoreRicerca; contatore.descContatore = oggettoCustom.DESCRIZIONE; contatore.valoreContatore = oggettoCustom.VALORE_DATABASE; contatore.segnatura = contatore.segnatura.Replace("ANNO", oggettoCustom.ANNO); contatore.segnatura = contatore.segnatura.Replace("CONTATORE", oggettoCustom.VALORE_DATABASE); if (oggettoCustom.ID_AOO_RF != null && oggettoCustom.ID_AOO_RF != "0") { DocsPaVO.utente.Registro reg = BusinessLogic.Utenti.RegistriManager.getRegistro(oggettoCustom.ID_AOO_RF); if (reg != null) { contatore.segnatura = contatore.segnatura.Replace("RF", reg.codRegistro); contatore.segnatura = contatore.segnatura.Replace("AOO", reg.codRegistro); } } contatore.items.segnaturaContatore = contatore.segnatura; arrayContatori.Add(contatore); } } } } if (arrayContatori.Count == 0) { Contatore contatore = new Contatore(); contatore.items = (ItemsConservazione)ric.itemsCons.Clone(); contatore.tipoDoc = ric.valoreRicerca; contatore.descContatore = "non valorizzati"; contatore.valoreContatore = ""; contatore.segnatura = "non valorizzati"; contatore.items.segnaturaContatore = "non valorizzati"; arrayContatori.Add(contatore); } } } else { Contatore contatore = new Contatore(); contatore.items = (ItemsConservazione)ric.itemsCons.Clone(); contatore.tipoDoc = ric.valoreRicerca; contatore.descContatore = "non valorizzati"; contatore.valoreContatore = ""; contatore.segnatura = "non valorizzati"; contatore.items.segnaturaContatore = "non valorizzati"; arrayContatori.Add(contatore); } if (!concatena) { tipologieDoc.Add(arrayContatori); } else { ((ArrayList)tipologieDoc[index - 1]).Add(arrayContatori); } }
/// <summary> /// Questo metodo crea i files Html con i dati contenuti negli items ordinandoli per tipo di ricerca /// </summary> /// <param name="items"></param> /// <param name="HtmlPath"></param> /// <param name="tipoRic"></param> /// <returns></returns> protected bool createHTML(ItemsConservazione[] items, string HtmlPath, string tipoRic) { RicercheHtml[] Ricerche = orderIndex(items, tipoRic); bool result = false; TextWriter twriter = null; //HtmlPath = Path.Combine(HtmlPath, "index.html"); string paragrafo = string.Empty; try { if (!File.Exists(HtmlPath)) { twriter = new StreamWriter(HtmlPath, false, Encoding.UTF8); twriter.WriteLine("<HTML>"); twriter.WriteLine("<HEAD>"); twriter.WriteLine("<TITLE> Ricerca per " + Ricerche[0].titoloRicerca + " </TITLE>"); twriter.WriteLine("<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"../static/main.css\" />"); twriter.WriteLine("</HEAD>"); twriter.WriteLine("<BODY class=\"content\">"); twriter.WriteLine("<h3 align=center> Ricerca per " + Ricerche[0].titoloRicerca + " </h3>"); twriter.WriteLine("<br><br>"); twriter.WriteLine("<ol type='1'>"); //twriter.WriteLine("<HTML>"); //twriter.WriteLine("<font face='Verdana' size=2>"); //twriter.WriteLine("<HEAD>"); //twriter.WriteLine("<TITLE> Ricerca per " + Ricerche[0].titoloRicerca + " </TITLE>"); //twriter.WriteLine("</HEAD>"); //twriter.WriteLine("<BODY>"); //twriter.WriteLine("<h3 align=center> Ricerca per " + Ricerche[0].titoloRicerca + " </h3>"); //twriter.WriteLine("<br><br>"); //twriter.WriteLine("<ol type='1'>"); ArrayList arrayTipologia = new ArrayList(); for (int i = 0; i < Ricerche.Length; i++) { //i tag <ul> e <li> lo chiudo e lo riapro in questo punto dopo aver controllato se il paragrafo //è diverso da quello appena scritto!!! //SE è IL PRIMO ELEMENTO NON DEVO METTERE I TAG DI CHIUSURA ALL'INIZIO!!!!! switch (tipoRic) { case "tipologiaDocumento": if (paragrafo.ToUpper() != Ricerche[i].valoreRicerca.ToUpper()) { string path_relativo = "." + '\u002F'.ToString() + namePageHtml + Ricerche[i].valoreRicerca + ".html"; twriter.WriteLine("</ul>"); twriter.WriteLine("</li>"); //twriter.WriteLine("<li><b><a href='" + html_Path + "\\html\\" + namePageHtml + Ricerche[i].valoreRicerca + ".html'>" + Ricerche[i].valoreRicerca + "</a></b>"); twriter.WriteLine("<li><b><a target=\"_blank\" href='" + path_relativo + "'>" + Ricerche[i].valoreRicerca + "</a></b>"); twriter.WriteLine("<ul type='disc'>"); this.creaContatori((RicercheHtml)Ricerche[i], ref arrayTipologia, false); } else { this.creaContatori((RicercheHtml)Ricerche[i], ref arrayTipologia, true); } paragrafo = Ricerche[i].valoreRicerca; break; default: if (i > 0 && paragrafo != Ricerche[i].valoreRicerca) { twriter.WriteLine("</ul>"); twriter.WriteLine("</li>"); twriter.WriteLine("<li><b>" + Ricerche[i].valoreRicerca + "</b>"); twriter.WriteLine("<ul type='disc'>"); paragrafo = Ricerche[i].valoreRicerca; } else { if (i == 0) { twriter.WriteLine("<li><b>" + Ricerche[i].valoreRicerca + "</b>"); if ((Ricerche[i].itemsCons.ID_Project != string.Empty) && (tipoRic == "fascicolo")) { twriter.WriteLine("<br/><b>File metadati Fascicolo: </b><a target=\"_blank\" href='../Fascicoli/" + Ricerche[i].valoreRicerca + "/" + Ricerche[i].itemsCons.ID_Project.Replace('\u005C', '\u002F') + ".xml'> \\Fascicoli\\" + Ricerche[i].valoreRicerca + "\\" + Ricerche[i].itemsCons.ID_Project + ".xml</a>"); } twriter.WriteLine("<ul type='disc'>"); paragrafo = Ricerche[i].valoreRicerca; } } if (Ricerche[i].itemsCons.pathCD != string.Empty) { twriter.WriteLine("<li><a target=\"_blank\" href='.." + Ricerche[i].itemsCons.pathCD.Replace('\u005C', '\u002F') + "'>" + Ricerche[i].itemsCons.pathCD + "</a></li>"); twriter.WriteLine("<li type='circle'><b>File metadati: </b><a target=\"_blank\" href='.." + Ricerche[i].itemsCons.pathCD.Replace('\u005C', '\u002F') + ".xml'>" + Ricerche[i].itemsCons.pathCD + ".xml</a></li>"); } if (Ricerche[i].itemsCons.timestampDoc != null && Ricerche[i].itemsCons.timestampDoc.Count > 0) { for (int t = 0; t < Ricerche[i].itemsCons.timestampDoc.Count; t++) { DocsPaVO.documento.TimestampDoc times = (DocsPaVO.documento.TimestampDoc)Ricerche[i].itemsCons.timestampDoc[t]; string percorso = Ricerche[i].itemsCons.pathTimeStamp + '\u005C'.ToString() + "TS" + times.DOC_NUMBER + "-" + times.NUM_SERIE; twriter.WriteLine("<li type='circle'><b>Timestamp: </b><a target=\"_blank\" href='.." + percorso.Replace('\u005C', '\u002F') + ".tsr'>" + percorso + ".tsr</a></li>"); } } if (Ricerche[i].itemsCons.path_allegati != null) { for (int j = 0; j < Ricerche[i].itemsCons.path_allegati.Count; j++) { string[] app = Ricerche[i].itemsCons.path_allegati[j].ToString().Split('@'); twriter.WriteLine("<ul type='square'>"); twriter.WriteLine("<li><b>File allegato: </b><a target=\"_blank\" href='.." + app[0].Replace('\u005C', '\u002F') + "'>" + app[0].ToString() + "</a></li>"); for (int a = 1; a < app.Length; a++) { string allegato = app[0].Substring(0, app[0].Length - 4) + '\u005C'.ToString() + app[a]; twriter.WriteLine("<li type='circle'><b>Timestamp: </b><a target=\"_blank\" href='.." + allegato.Replace('\u005C', '\u002F') + "'>" + allegato + "</a></li>"); } twriter.WriteLine("</ul>"); } } break; } } if (tipoRic == "tipologiaDocumento") { for (int j = 0; j < arrayTipologia.Count; j++) { ArrayList contatori = ((ArrayList)arrayTipologia[j]); Contatore cont = (Contatore)contatori[0]; createHTML((ArrayList)arrayTipologia[j], html_Path + "\\html\\" + namePageHtml + cont.tipoDoc + ".html"); } } twriter.WriteLine("</ol>"); twriter.WriteLine("</BODY>"); twriter.WriteLine("</HTML>"); } result = true; } catch (Exception exHtml) { string err = "Errore nella creazione della pagina " + HtmlPath + " : " + exHtml.Message; logger.Debug(err); result = false; } finally { if (twriter != null) { twriter.Flush(); twriter.Close(); } } return(result); }