private string procesarReplica(string nProyecto, string nPSN, string sProy, string strDatos)
    {
        string sResul = "";
        //DataSet ds;
        //int nCount = 0, idNodoAuxDestino=0, idNodoAuxManiobra = 0, idNodoAuxManiobra3=0, nCountSubnodosNoManiobra = 0;
        int  idSubNodoGrabar = 0;
        int  nAux            = 0;
        int  idNodo          = -1;
        int  nResponsablePSN = 0;
        bool bReintentar     = true;

        #region apertura de conexión y transacción
        try
        {
            oConn = Conexion.Abrir();
            tr    = Conexion.AbrirTransaccionSerializable(oConn);
        }
        catch (Exception ex)
        {
            if (oConn.State == ConnectionState.Open)
            {
                Conexion.Cerrar(oConn);
            }
            sResul = "Error@#@" + Errores.mostrarError("Error al abrir la conexión", ex);
            return(sResul);
        }
        #endregion

        try
        {
            string[] aNodo = Regex.Split(strDatos, "///");

            foreach (string oNodo in aNodo)
            {
                if (oNodo == "")
                {
                    continue;
                }

                //nCount = 0;
                //idNodoAuxManiobra = 0;
                //idNodoAuxManiobra3 = 0;
                //nCountSubnodosNoManiobra = 0;
                //idNodoAuxDestino = 0;
                idSubNodoGrabar = 0;

                string[] aValores = Regex.Split(oNodo, "##");
                //0. idNodo
                //1. tiporeplica
                //2. idGestor
                idNodo = int.Parse(aValores[0]);
                if (!PROYECTOSUBNODO.ExisteProyectoSubNodo(tr, int.Parse(nProyecto), idNodo))
                {
                    nResponsablePSN = (aValores[2] == "") ? 0 : int.Parse(aValores[2]);
                    #region Cálculo de subnodo destino OLD

                    /*
                     * nCount = 0;
                     * ds = PROYECTOSUBNODO.ObtenerSubnodosParaReplicar(tr, int.Parse(aValores[0]));
                     * foreach (DataRow oFila in ds.Tables[0].Rows)
                     * {
                     *  //Maniobra=3 es el defecto para replicar
                     *  if ((byte)oFila["t304_maniobra"] == 3)
                     *  {
                     *      idNodoAuxManiobra3 = (int)oFila["t304_idsubnodo"];
                     *  }
                     *  else
                     *  {
                     *      if ((byte)oFila["t304_maniobra"] == 1)
                     *      {
                     *          nCount++;
                     *          idNodoAuxManiobra = (int)oFila["t304_idsubnodo"];
                     *      }
                     *      else
                     *      {
                     *          nCountSubnodosNoManiobra++;
                     *          idNodoAuxDestino = (int)oFila["t304_idsubnodo"];
                     *      }
                     *  }
                     * }
                     *
                     * if (nCountSubnodosNoManiobra == 1) //si solo hay un subnodo en el nodo, que la réplica se haga a ese subnodo.
                     * {
                     *  idSubNodoGrabar = idNodoAuxDestino;
                     * }
                     * else
                     * {
                     *  if (idNodoAuxManiobra3 != 0)
                     *  {
                     *      idSubNodoGrabar = idNodoAuxManiobra3;
                     *  }
                     *  else
                     *  {
                     *      if (nCount == 0)
                     *      {
                     *          NODO oNodo2 = NODO.SelectEnTransaccion(tr, int.Parse(aValores[0]));
                     *          nResponsablePSN = oNodo2.t314_idusuario_responsable;
                     *          //crear subnodo maniobra
                     *          idSubNodoGrabar = SUBNODO.Insert(tr, "Proyectos a reasignar", int.Parse(aValores[0]), 0, true, 1, oNodo2.t314_idusuario_responsable, null);
                     *      }
                     *      else
                     *      {
                     *          if (nCount > 1)
                     *          {
                     *              bReintentar = false;
                     *              ds.Dispose();
                     *              throw (new Exception("El número de subnodos de maniobra es " + nCount.ToString() + " en el nodo " + aValores[0] + ". Por favor avise al administrador."));
                     *          }
                     *
                     *          if (ds.Tables[0].Rows.Count - 1 > 1 || ds.Tables[0].Rows.Count - 1 == 0)
                     *          {
                     *              idSubNodoGrabar = idNodoAuxManiobra;
                     *          }
                     *          else
                     *          {
                     *              idSubNodoGrabar = idNodoAuxDestino;
                     *          }
                     *      }
                     *  }
                     * }
                     * ds.Dispose();
                     */
                    #endregion
                    idSubNodoGrabar = SUPER.Capa_Negocio.PROYECTOSUBNODO.ObtenerSubnodoDestinoReplica(tr, idNodo);

                    if (nResponsablePSN == 0)
                    {
                        NODO oNodo3 = NODO.SelectEnTransaccion(tr, idNodo);
                        nResponsablePSN = oNodo3.t314_idusuario_responsable;
                    }
                    nAux = PROYECTOSUBNODO.Insert(tr, int.Parse(nProyecto), idSubNodoGrabar, false, aValores[1], false, nResponsablePSN,
                                                  sProy, "X", "X", false, false, false, false, false, "", "", "", null, null, null, null,
                                                  null, null, false, 0);
                }
            }

            SEGMESPROYECTOSUBNODO.GenerarMesEnTransaccion(tr, int.Parse(nProyecto));

            Conexion.CommitTransaccion(tr);

            sResul = "OK@#@";
        }
        catch (Exception ex)
        {
            Conexion.CerrarTransaccion(tr);
            sResul = "Error@#@" + Errores.mostrarError("Error al procesar la réplica del proyecto.", ex, bReintentar);
        }
        finally
        {
            Conexion.Cerrar(oConn);
        }

        return(sResul);
    }