Пример #1
0
        private void NavigateXmlForUpdate(XmlNode rootNode, string idAmm)
        {
            XmlNodeList nodiRegistro = rootNode.SelectNodes("REGISTRO");

            // Estrazione dati e nodi sottostanti
            foreach (XmlNode node in nodiRegistro)
            {
                XmlAttribute attribute = node.Attributes["MODE"];
                string       mode      = "";
                if (attribute != null)
                {
                    mode = attribute.InnerText.ToUpper();
                }

                string codice      = this.GetXmlField("CODICE", node, false);
                string descrizione = this.GetXmlField("DESCRIZIONE", node, false);
                string automatico  = this.GetXmlField("AUTOMATICO", node, false);                //Celeste
                descrizione = DocsPaUtils.Functions.Functions.ReplaceApexes(descrizione);
                XmlNode email = node.SelectSingleNode("EMAIL");
                codice = codice.ToUpper();
                if (email == null)
                {
                    //logger.DebugAdm (true,"Indirizzo email non valido",null);
                    throw new Exception("Indirizzo email non valido");
                }
                string indirizzo = this.GetXmlField("INDIRIZZO", email, false);
                string utente    = this.GetXmlField("UTENTE", email, false);
                string password  = this.GetXmlField("PASSWORD", email, false);
                string smtp      = this.GetXmlField("SMTP", email, false);
                string pop       = this.GetXmlField("POP", email, false);
                string portaSmtp = this.GetXmlField("PORTASMTP", email, false);
                string portaPop  = this.GetXmlField("PORTAPOP", email, false);
                string usersmtp  = this.GetXmlField("USERSMTP", email, false);
                string pwdsmtp   = this.GetXmlField("PASSWORDSMTP", email, false);
                string ruoloRif  = this.GetXmlField("RUO_RIF", node, false);
                string utenteRif = this.GetXmlField("UT_RIF", node, false);

                DocsPaDB.Query_DocsPAWS.AmministrazioneXml amministrazioneXml = new DocsPaDB.Query_DocsPAWS.AmministrazioneXml();

                string idRegistro = null;

                if (mode == "CREATED")
                {
                    // Inserisci il registro
                    /* Celeste idRegistro=amministrazioneXml.NewRegistro(codice,descrizione indirizzo,utente, */
                    idRegistro = amministrazioneXml.NewRegistro(codice, descrizione, automatico, indirizzo, utente,
                                                                password,
                                                                smtp,
                                                                pop,
                                                                portaSmtp,
                                                                portaPop,
                                                                usersmtp,
                                                                pwdsmtp,
                                                                idAmm);
                    if (idRegistro == null)
                    {
                        logger.Debug("Errore nella creazione registro");
                        throw new Exception();
                    }
                }

                if (mode == "MODIFIED")
                {
                    // modifica il registro
                    /* Celeste if(!amministrazioneXml.UpdateRegistro(codice,descrizione,indirizzo,utente, */
                    if (!amministrazioneXml.UpdateRegistro(codice, descrizione, automatico, indirizzo, utente,
                                                           password,
                                                           smtp,
                                                           pop,
                                                           portaSmtp,
                                                           portaPop,
                                                           usersmtp,
                                                           pwdsmtp,
                                                           idAmm))
                    {
                        throw new Exception();
                    }
                    idRegistro = amministrazioneXml.GetRegByName(codice);
                }

                /*
                 * if(mode=="MODIFIED" || mode=="CREATED")
                 * {
                 *      if(idRegistro!=null && ruoloRif!=null)
                 *      {
                 *              string idRuolo=amministrazioneXml.GetRuoloUOByName(ruoloRif,idAmm);
                 *              if(idRuolo!=null)
                 *              {
                 *                      if(amministrazioneXml.UpdateRuoloRif(idRuolo,idRegistro)==false)
                 *                      {
                 *                              logger.Debug("Errore nella impostazione ruolo di riferimento registro");
                 *                              throw new Exception();
                 *                      }
                 *              }
                 *              string idGruppo=amministrazioneXml.GetGroupByName(ruoloRif);
                 *              string idUtente=amministrazioneXml.GetUserByName(utenteRif,idAmm);
                 *              if(idUtente!=null && idGruppo!=null)
                 *              {
                 *                      if(amministrazioneXml.UpdateUtenteRif(idUtente,idGruppo,idAmm)==false)
                 *                      {
                 *                              logger.Debug("Errore nella impostazione utente di riferimento registro");
                 *                              throw new Exception();
                 *                      }
                 *              }
                 *      }
                 * }*/

                if (mode == "DELETED")
                {
                    //TO DO
                    //cancellazione registro, da valutare
                }
            }
        }