Esempio n. 1
0
        private FileGruppoFile[] ParseIndexFile(Ipda ipda)
        {
            PdaAttributo[] attrs = ipda.pda.extraInfo.metadati.attributoList;

            XmlDocument           indiceXml = new XmlDocument();
            List <FileGruppoFile> files     = new List <FileGruppoFile>();

            indiceXml.Load(Path.Combine(Path.GetDirectoryName(this.closeFilepath), this.xmlIndexFilepath));

            XmlNodeList nList = indiceXml.SelectNodes("//File");

            foreach (XmlNode node in nList)
            {
                string id = GetNodeAttribute(node, ipda.xmlFieldId);

                string fileHash = "";
                fileHash = GetNodeAttribute(node, "ImprontaFileSHA1");
                if (fileHash == "")
                {
                    fileHash = GetNodeAttribute(node, "ImprontaFileSHA256");
                }

                List <FgAttributo> attrList = attrs.Select(p => new FgAttributo
                {
                    nome   = p.nome,
                    valore = GetNodeAttribute(node, PatchAttributeName(p.nome))
                }).ToList();

                files.Add(new FileGruppoFile
                {
                    id        = id,
                    impronta  = fileHash,
                    extraInfo = new FgExtraInfo
                    {
                        metadati = new FgMetadati
                        {
                            attributoList = attrList.ToArray()
                        }
                    }
                });
            }

            return(files.ToArray());
        }
Esempio n. 2
0
        public IpdaDocument[] GenerateDocuments(Ipda ipda)
        {
            List <IpdaDocument> docList   = new List <IpdaDocument>();
            CultureInfo         provider  = CultureInfo.CreateSpecificCulture("it-IT");
            XmlDocument         indiceXml = new XmlDocument();

            indiceXml.Load(this.xmlIndexFilepath);

            string[] soggettoFields = ipda.processo.soggetto.soggettoID.ToString().Split(new string[] { "C.F." }, StringSplitOptions.None);

            XmlNodeList nList = indiceXml.SelectNodes("//File");

            foreach (XmlNode node in nList)
            {
                IpdaDocument doc = new IpdaDocument();

                doc.iddocumento      = GetNodeAttribute(node, ipda.xmlFieldId);
                doc.datachiusura     = DateTime.Parse(ipda.processo.tempo.rifTemporale, provider);
                doc.oggettodocumento = doc.iddocumento;

                doc.soggettoproduttore = new SoggettoProduttore
                {
                    nome          = "",
                    cognome       = soggettoFields[0].Trim(),
                    codicefiscale = soggettoFields[1].Trim()
                };

                doc.destinatario = new Destinatario
                {
                    nome          = "",
                    cognome       = GetNodeAttribute(node, "Denominazione"),
                    codicefiscale = GetNodeAttribute(node, "PIVA")
                };

                docList.Add(doc);
            }

            return(docList.ToArray());
        }
Esempio n. 3
0
        public Ipda ConvertCloseFile(string closeFilepath, string fieldId)
        {
            if (!File.Exists(closeFilepath))
            {
                return(null);
            }

            this.closeFilepath = closeFilepath;
            Ipda ipda = new Ipda();

            string closeContents = "";

            using (System.IO.StreamReader sr = new System.IO.StreamReader(closeFilepath))
            {
                closeContents = sr.ReadToEnd();
            }

            string[] lines = closeContents.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            this.indexFilepath    = GetString(lines, "Nome File Indice:");
            this.xmlIndexFilepath = indexFilepath.Replace(".txt", ".xml");
            this.xslIndexFilepath = indexFilepath.Replace(".txt", ".xsl");

            string dataChiusura = GetString(lines, "Generato il ");

            ipda.descGenerale = new DescGenerale
            {
                id           = GetString(lines, "File di chiusura dei documenti elencati nel percorso:"),
                applicazione = new DescApplicazione
                {
                    nome       = "Biblos Document Server",
                    produttore = "Dgroove Srl",
                    versione   = "2015.0"
                }
            };

            ipda.descGenerale.extraInfo = new DgExtraInfo
            {
                metadatiIntegrati   = ParseMetadatiIntegrati(lines),
                metadatiEsterniList = ParseMedatiEsterni(lines)
            };

            ipda.pda = new Pda
            {
                id        = Path.GetFileNameWithoutExtension(this.indexFilepath),
                extraInfo = new PdaExtraInfo
                {
                    metadati = new PdaMetadati
                    {
                        attributoList = ParseAttributi(lines).Select(p => new PdaAttributo {
                            nome = PatchAttributeName(p)
                        }).ToArray()
                    }
                }
            };

            ipda.xmlFieldId = fieldId;

            FileGruppoFile[] files = ParseIndexFile(ipda);
            ipda.fileGruppo = new FileGruppo
            {
                files = files
            };

            //processo
            ipda.processo = new Processo
            {
                soggetto = new Soggetto
                {
                    soggettoID = GetString(lines, "Responsabile Conservazione:")
                },
                tempo = new Tempo
                {
                    rifTemporale = GetString(lines, "Generato il").Replace(" alle", "")
                },
                rifNormativo = ""
            };

            return(ipda);
        }