示例#1
0
        public void SerializaTblContenidoByNodo(ref DBConn oConn, string cPath, string cFile)
        {
            if (string.IsNullOrEmpty(cPath))
            {
                return;
            }

            try
            {
                CmsContenidos oContenidos = new CmsContenidos(ref oConn);
                oContenidos.CodNodo = pCodNodo;
                DataTable oData = oContenidos.Get();

                if (Directory.Exists(cPath) && !string.IsNullOrEmpty(cFile) && oData != null)
                {
                    IFormatter oBinFormat  = new BinaryFormatter();
                    Stream     oFileStream = new FileStream(cPath + cFile, FileMode.Create, FileAccess.Write);
                    oBinFormat.Serialize(oFileStream, oData);
                    oFileStream.Close();
                    oFileStream = null;
                    oData.Dispose();
                }
            }
            catch (Exception Ex)
            {
                //return Ex.Source + " - " + Ex.Message + " - " + Ex.StackTrace;
            }
        }
示例#2
0
        public string SerializaContenido(ref DBConn oConn, string cPath, string cFile)
        {
            if (string.IsNullOrEmpty(cPath))
            {
                return(string.Empty);
            }

            try
            {
                BinaryContenido oContenido  = new BinaryContenido();
                CmsContenidos   oContenidos = new CmsContenidos(ref oConn);
                oContenidos.CodContenido = pCodContenido;
                DataTable oData = oContenidos.Get();

                if (oData != null)
                {
                    if (oData.Rows.Count > 0)
                    {
                        oContenido.CodContenido     = oData.Rows[0]["cod_contenido"].ToString();
                        oContenido.CodNodo          = oData.Rows[0]["cod_nodo"].ToString();
                        oContenido.CodUsuario       = oData.Rows[0]["cod_usuario"].ToString();
                        oContenido.CodUsuarioRel    = oData.Rows[0]["cod_usuario_rel"].ToString();
                        oContenido.TituloContenido  = oData.Rows[0]["titulo_contenido"].ToString();
                        oContenido.TextoContenido   = oData.Rows[0]["texto_contenido"].ToString();
                        oContenido.DateContenido    = oData.Rows[0]["date_contenido"].ToString();
                        oContenido.EstContenido     = oData.Rows[0]["est_contenido"].ToString();
                        oContenido.PrvContendio     = oData.Rows[0]["prv_contendio"].ToString();
                        oContenido.DestContenido    = oData.Rows[0]["dest_contenido"].ToString();
                        oContenido.IndRss           = oData.Rows[0]["ind_rss"].ToString();
                        oContenido.ResumenContenido = oData.Rows[0]["resumen_contenido"].ToString();
                        oContenido.IpUsuario        = oData.Rows[0]["ip_usuario"].ToString();
                        oContenido.IndDenuncia      = oData.Rows[0]["ind_denuncia"].ToString();
                    }
                }
                oData.Dispose();
                oContenidos = null;

                if (Directory.Exists(cPath) && !string.IsNullOrEmpty(cFile))
                {
                    IFormatter oBinFormat  = new BinaryFormatter();
                    Stream     oFileStream = new FileStream(cPath + cFile, FileMode.Create, FileAccess.Write);
                    oBinFormat.Serialize(oFileStream, oContenido);
                    oFileStream.Close();

                    oFileStream = null;
                    oContenido  = null;
                }
                return(string.Empty);
            }
            catch (Exception Ex)
            {
                return(Ex.Source + " - " + Ex.Message + " - " + Ex.StackTrace);
            }
        }