Example #1
0
        private void NavigateXmlForUpdate(XmlNode rootNode)
        {
            DocsPaUtils.LogsManagement.ProgressLogger pl = DocsPaUtils.LogsManagement.ProgressLogger.getInstance(false);

            try
            {
                /*XmlNode servers= rootNode.SelectSingleNode("SERVERS");
                 * if(servers!=null)
                 * {
                 *      int idMessage=pl.NewMessage("Caricamento Servers di Posta");
                 *      ServerXml serverXml = new ServerXml();
                 *
                 *      if(!serverXml.UpdateStructure(servers))
                 *      {
                 *              pl.UpdateMessage(idMessage,null,true,true);
                 *              logger.Debug("Errore aggiornamento servers");
                 *              throw new Exception();
                 *      }
                 *      pl.UpdateMessage(idMessage,null,true,false);
                 * }*/

                // Funzioni
                XmlNode funzioni = rootNode.SelectSingleNode("TIPIFUNZIONE");
                if (funzioni != null)
                {
                    int idMessage = pl.NewMessage("Caricamento Tipi Funzione");
                    logger.Debug("Caricamento Tipi Funzione...");

                    FunzioniXml funzioniXml = new FunzioniXml();

                    if (!funzioniXml.UpdateStructure(funzioni))
                    {
                        pl.UpdateMessage(idMessage, null, true, true);
                        logger.Debug("Errore aggiornamento tipi funzione");
                        throw new Exception();
                    }
                    pl.UpdateMessage(idMessage, null, true, false);
                }


                XmlNodeList nodiAmministrazione = rootNode.SelectNodes("AMMINISTRAZIONE");

                // Estrazione dati e nodi sottostanti
                foreach (XmlNode node in nodiAmministrazione)
                {
                    XmlNode dati = node.SelectSingleNode("DATI");
                    if (dati == null)
                    {
                        logger.Debug("Errore mancanza corpo DATI amministrazione");
                        //logger.DebugAdm(true,"Errore mancanza corpo DATI tag Amministrazione",null);
                        throw new Exception();
                    }

                    DocsPaDB.Query_DocsPAWS.AmministrazioneXml amministrazioneXml = new DocsPaDB.Query_DocsPAWS.AmministrazioneXml();
                    string       idAmm     = "";
                    string       mode      = "";
                    XmlAttribute attribute = node.Attributes["MODE"];
                    if (attribute != null)
                    {
                        mode = attribute.InnerText.ToUpper();
                    }

                    string codice        = this.GetXmlField("CODICE", dati);
                    string descrizione   = this.GetXmlField("DESCRIZIONE", dati);
                    string libreria      = this.GetXmlField("LIBRERIA", dati);
                    string segnatura     = this.GetXmlField("SEGNATURA", dati);
                    string fascicolatura = this.GetXmlField("FASCICOLATURA", dati);
                    string dominio       = this.GetXmlField("DOMINIO", dati);
                    string serversmtp    = this.GetXmlField("SERVERSMTP", dati);
                    string portasmtp     = this.GetXmlField("PORTASMTP", dati);
                    if (portasmtp == null || portasmtp == "")
                    {
                        portasmtp = "NULL";
                    }
                    string usersmtp      = this.GetXmlField("USERSMTP", dati);
                    string pwdsmtp       = this.GetXmlField("PASSWORDSMTP", dati);
                    string protocolloInt = this.GetXmlField("PROTOCOLLO_INTERNO", dati);
                    if (protocolloInt != null && protocolloInt != "")
                    {
                        protocolloInt = "1";
                    }
                    string ragioneTO = this.GetXmlField("RAGIONE_TO", dati);
                    string ragioneCC = this.GetXmlField("RAGIONE_CC", dati);

                    codice      = codice.ToUpper();
                    descrizione = DocsPaUtils.Functions.Functions.ReplaceApexes(descrizione);

                    int idMessage = pl.NewMessage("Caricamento Amministrazione: " + codice);
                    logger.Debug("Caricamento Amministrazione: " + codice);

                    if (mode == "CREATED")
                    {
                        //aggiunge la nuova amministrazione
                        idAmm = amministrazioneXml.NewAmministrazione(codice, descrizione, libreria, segnatura, fascicolatura, dominio, serversmtp, portasmtp, protocolloInt, ragioneTO, ragioneCC, usersmtp, pwdsmtp);
                        if (idAmm == null)
                        {
                            pl.UpdateMessage(idMessage, null, true, true);
                            logger.Debug("Errore nella creazione nuova amministrazione");
                            throw new Exception();
                        }
                        DocsPaDB.Utils.Personalization.Reset();
                    }
                    else if (mode == "MODIFIED")
                    {
                        //modifica i dati della amministrazione
                        idAmm = amministrazioneXml.GetAdminByName(codice);
                        if (!amministrazioneXml.UpdateAmministrazione(codice, descrizione, libreria, segnatura, fascicolatura, dominio, serversmtp, portasmtp, protocolloInt, ragioneTO, ragioneCC, usersmtp, pwdsmtp))
                        {
                            pl.UpdateMessage(idMessage, null, true, true);
                            logger.Debug("Errore aggiornamento nuova amministrazione");
                            throw new Exception();
                        }
                        DocsPaDB.Utils.Personalization.Reset();
                    }
                    else if (mode == "DELETED")
                    {
                        //TO DO - > cancellazione della amministrazione
                    }
                    else
                    {
                        //in a4ltri casi (mode="") seleziona l'id
                        idAmm = amministrazioneXml.GetAdminByName(codice);
                        if (idAmm == null)
                        {
                            pl.UpdateMessage(idMessage, null, true, true);
                            logger.Debug("Amministrazione: " + codice + " sconosciuta");
                            //logger.DebugAdm(true,"Amministrazione: " + codice + " sconosciuta",null);
                            throw new Exception();
                        }
                    }

                    //si analizza il contenuto della amministrazione solo se non รจ stata cancellata
                    if (mode != "DELETED")
                    {
                        // Ragioni Trasmissione

                        XmlNode ragioni = node.SelectSingleNode("RAGIONITRASMISSIONE");
                        if (ragioni != null)
                        {
                            int idMessageAmm = pl.NewMessage("Caricamento Ragioni Trasmissione");
                            logger.Debug("Caricamento Ragioni Trasmissione...");

                            RagioniTrasmissioneXml ragioniTrasmissioneXml = new RagioniTrasmissioneXml();

                            if (!ragioniTrasmissioneXml.UpdateStructure(ragioni, idAmm))
                            {
                                pl.UpdateMessage(idMessageAmm, null, true, true);
                                logger.Debug("Errore aggiornamento ragioni trasmissione");
                                throw new Exception();
                            }
                            pl.UpdateMessage(idMessageAmm, null, true, false);
                        }

                        // Registri
                        XmlNode registri = node.SelectSingleNode("REGISTRI");
                        if (registri != null)
                        {
                            int idMessageAmm = pl.NewMessage("Caricamento Registri");
                            logger.Debug("Caricamento Registri...");

                            RegistriXml registriXml = new RegistriXml();

                            if (!registriXml.UpdateStructure(registri, idAmm))
                            {
                                pl.UpdateMessage(idMessageAmm, null, true, true);
                                logger.Debug("Errore aggiornamento registri");
                                throw new Exception();
                            }
                            pl.UpdateMessage(idMessageAmm, null, true, false);
                        }

//						// Funzioni
//						XmlNode funzioni = node.SelectSingleNode("TIPIFUNZIONE");
//						if(funzioni!=null)
//						{
//							FunzioniXml funzioniXml = new FunzioniXml();
//
//							if(!funzioniXml.UpdateStructure(funzioni, idAmm))
//							{
//								logger.Debug("Errore aggiornamento tipi funzione");
//								throw new Exception();
//							}
//						}

                        // Tipi Ruolo
                        XmlNode ruoli = node.SelectSingleNode("RUOLI");
                        if (ruoli != null)
                        {
                            int idMessageAmm = pl.NewMessage("Caricamento Ruoli");
                            logger.Debug("Caricamento Tipo Ruoli...");

                            RuoliXml ruoliXml = new RuoliXml();

                            if (!ruoliXml.UpdateStructure(ruoli, idAmm))
                            {
                                pl.UpdateMessage(idMessageAmm, null, true, true);
                                logger.Debug("Errore aggiornamento ruoli");
                                throw new Exception();
                            }
                            pl.UpdateMessage(idMessageAmm, null, true, false);
                        }

                        // Utenti

//						XmlNode utenti = node.SelectSingleNode("UTENTI");
//						if(utenti!=null)
//						{
//							int idMessageAmm=pl.NewMessage("Caricamento Utenti");
//							UtentiXml utentiXml = new UtentiXml();
//
//							if(!utentiXml.UpdateStructure(utenti, idAmm))
//							{
//								pl.UpdateMessage(idMessageAmm,null,true,true);
//								logger.Debug("Errore aggiornamento utenti");
//								throw new Exception();
//							}
//							pl.UpdateMessage(idMessageAmm,null,true,false);
//						}

                        // Organigramma
//						XmlNode organigramma = node.SelectSingleNode("ORGANIGRAMMA");
//						if(organigramma!=null)
//						{
//							int idMessageAmm=pl.NewMessage("Caricamento Organigramma");
//							OrganigrammaXml organigrammaXml = new OrganigrammaXml();
//
//							if(!organigrammaXml.UpdateStructure(organigramma, idAmm))
//							{
//								pl.UpdateMessage(idMessageAmm,null,true,true);
//								logger.Debug("Errore aggiornamento organigramma");
//								throw new Exception();
//							}
//							pl.UpdateMessage(idMessageAmm,null,true,false);
//						}
                    }
                    pl.UpdateMessage(idMessage, null, true, false);
                }
            }
            catch (Exception e)
            {
                logger.Debug("Errore durante la navigazione ricorsiva per aggiornamento", e);
            }
        }
Example #2
0
        /// <summary>
        /// Procedura per la lettura dell'XML
        /// </summary>
        /// <param name="rootNode"></param>
        private void NavigateXml(XmlNode rootNode)
        {
            // Servers

            /*
             * XmlNode servers= rootNode.SelectSingleNode("SERVERS");
             *
             * DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(1, 10, "Import dei server.");
             *
             * if(servers!=null)
             * {
             *      ServerXml serverXml = new ServerXml();
             *
             *      if(!serverXml.CreateStructure(servers))
             *      {
             *              logger.Debug("Errore creazione servers");
             *              throw new Exception();
             *      }
             * }*/

            XmlNodeList nodiAmministrazione = rootNode.SelectNodes("AMMINISTRAZIONE");

            // Estrazione dati e nodi sottostanti
            foreach (XmlNode node in nodiAmministrazione)
            {
                DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(2, 10, "Creazione amministrazioni.");

                //legge l'attributo dropAll ed esegue il drop dell'amministrazione se richiesto
                dropChildren = false;
                XmlAttribute attribute = node.Attributes["dropAll"];
                if (attribute != null)
                {
                    bool dropAll = Boolean.Parse(attribute.InnerText);
                    if (dropAll)
                    {
                        this.DropAll();
                        dropChildren = true;
                    }
                }

                XmlNode dati = node.SelectSingleNode("DATI");
                if (dati == null)
                {
                    logger.Debug("Errore mancanza corpo DATI amministrazione");
                    throw new Exception();
                }

                string codice        = this.GetXmlField("CODICE", dati);
                string descrizione   = this.GetXmlField("DESCRIZIONE", dati);
                string libreria      = this.GetXmlField("LIBRERIA", dati);
                string segnatura     = this.GetXmlField("SEGNATURA", dati);
                string fascicolatura = this.GetXmlField("FASCICOLATURA", dati);
                string dominio       = this.GetXmlField("DOMINIO", dati);
                string serversmtp    = this.GetXmlField("SERVERSMTP", dati);
                string portasmtp     = this.GetXmlField("PORTASMTP", dati);
                string usersmtp      = this.GetXmlField("USERSMTP", dati);
                string pwdsmtp       = this.GetXmlField("PASSWORDSMTP", dati);
                if (portasmtp == null || portasmtp == "")
                {
                    portasmtp = "NULL";
                }
                string protocolloInt = this.GetXmlField("PROTOCOLLO_INTERNO", dati);
                if (protocolloInt != null && protocolloInt != "")
                {
                    protocolloInt = "1";
                }
                string ragioneTO = this.GetXmlField("RAGIONE_TO", dati);
                string ragioneCC = this.GetXmlField("RAGIONE_CC", dati);

                codice = codice.ToUpper();

                DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(3, 10, "Import amministrazione: " + codice);

                DocsPaDB.Query_DocsPAWS.AmministrazioneXml amministrazioneXml = new DocsPaDB.Query_DocsPAWS.AmministrazioneXml();
                string idAmm = amministrazioneXml.NewAmministrazione(codice, descrizione, libreria, segnatura, fascicolatura, dominio, serversmtp, portasmtp, protocolloInt, ragioneTO, ragioneCC, usersmtp, pwdsmtp);

                if (idAmm == null)
                {
                    logger.Debug("Errore nella creazione nuova amministrazione");
                    throw new Exception();
                }

                // Ragioni Trasmissione
                DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(4, 10, "Import ragioni trasmissione dell'amministrazione: " + codice);

                XmlNode ragioni = node.SelectSingleNode("RAGIONITRASMISSIONE");
                RagioniTrasmissioneXml ragioniTrasmissioneXml = new RagioniTrasmissioneXml();

                if (!ragioniTrasmissioneXml.CreateStructure(ragioni, idAmm, dropChildren))
                {
                    logger.Debug("Errore nella creazione delle ragioni trasmissione");
                    throw new Exception();
                }

                // Registri
                DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(5, 10, "Import registri dell'amministrazione: " + codice);
                XmlNode     registri    = node.SelectSingleNode("REGISTRI");
                RegistriXml registriXml = new RegistriXml();

                if (!registriXml.CreateStructure(registri, idAmm, dropChildren))
                {
                    logger.Debug("Errore nella creazione dei registri");
                    throw new Exception();
                }

                // Funzioni
                DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(6, 10, "Import funzioni dell'amministrazione: " + codice);
                XmlNode     funzioni    = node.SelectSingleNode("TIPIFUNZIONE");
                FunzioniXml funzioniXml = new FunzioniXml();

                if (!funzioniXml.CreateStructure(funzioni, idAmm, dropChildren))
                {
                    logger.Debug("Errore nella creazione dei tipi funzione");
                    throw new Exception();
                }

                // Tipi Ruolo
                DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(7, 10, "Import tipi ruolo dell'amministrazione: " + codice);
                XmlNode  ruoli    = node.SelectSingleNode("RUOLI");
                RuoliXml ruoliXml = new RuoliXml();

                if (!ruoliXml.CreateStructure(ruoli, idAmm, dropChildren))
                {
                    logger.Debug("Errore nella creazione dei ruoli");
                    throw new Exception();
                }

//				// Utenti
//				DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(8, 10, "Import utenti dell'amministrazione: " + codice);
//				XmlNode utenti = node.SelectSingleNode("UTENTI");
//				UtentiXml utentiXml = new UtentiXml();
//
//				if(!utentiXml.CreateStructure(utenti, idAmm, dropChildren))
//				{
//					logger.Debug("Errore nella creazione degli utenti");
//					throw new Exception();
//				}
//
//				// Organigramma
//				DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(9, 10, "Import organigramma dell'amministrazione: " + codice);
//				XmlNode organigramma = node.SelectSingleNode("ORGANIGRAMMA");
//				OrganigrammaXml organigrammaXml = new OrganigrammaXml();
//
//				if(!organigrammaXml.CreateStructure(organigramma, idAmm, dropChildren))
//				{
//					logger.Debug("Errore nella creazione dell'organigramma");
//					throw new Exception();
//				}

                DocsPaUtils.LogsManagement.ImportExportLogger.getInstance("import", 0).SetMessage(10, 10, "Import dell'amministrazione completo");
            }
        }