public static IList <YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO> getListadoVideoMensajeNoticia()
        {
            Regex YoutubeVideoRegex = new Regex(@"youtu(?:\.be|be\.com)/(?:(.*)v(/|=)|(.*/)?)([a-zA-Z0-9-_]+)", RegexOptions.IgnoreCase);

            IList <YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO> IVideoMensajeNoticia = new List <YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO>();

            DataTable pobjDataTable = new DataTable();

            if (YouCom.Mensajeria.DAL.Video.VideoMensajeNoticiaDAL.getListadoVideoMensajeNoticia(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    string vCode;
                    string vUrl;

                    Match youtubeMatch = YoutubeVideoRegex.Match(wobjDataRow["UrlVideoMensajePropietario"].ToString());

                    if (youtubeMatch.Success)
                    {
                        YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO video_mensaje_noticia = new YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO();

                        video_mensaje_noticia.IdVideoMensajeNoticia = decimal.Parse(wobjDataRow["IdVideoMensajeNoticia"].ToString());

                        YouCom.DTO.Mensajeria.MensajeNoticiaDTO myMensajeNoticiaDTO = new YouCom.DTO.Mensajeria.MensajeNoticiaDTO();
                        myMensajeNoticiaDTO.IdMensajeNoticia       = decimal.Parse(wobjDataRow["idMensajeNoticia"].ToString());
                        video_mensaje_noticia.TheMensajeNoticiaDTO = myMensajeNoticiaDTO;

                        video_mensaje_noticia.TituloVideoMensajeNoticia = wobjDataRow["TituloVideoMensajeNoticia"].ToString();
                        video_mensaje_noticia.UrlVideoMensajeNoticia    = wobjDataRow["UrlVideoMensajeNoticia"].ToString();

                        vCode = video_mensaje_noticia.UrlVideoMensajeNoticia.Substring((video_mensaje_noticia.UrlVideoMensajeNoticia.LastIndexOf("v=") + 2));

                        if (vCode.Contains("&"))
                        {
                            vCode = vCode.Substring(0, vCode.LastIndexOf("&"));
                        }

                        vUrl = @"http://www.youtube.com/v/{0}&autoplay=0\";

                        string video = string.Format(vUrl, vCode);

                        video_mensaje_noticia.UrlWatchVideoMensajeNoticia = video;

                        IVideoMensajeNoticia.Add(video_mensaje_noticia);
                    }
                }
            }

            return(IVideoMensajeNoticia);
        }
Example #2
0
        public static bool Update(YouCom.DTO.Mensajeria.Video.VideoMensajeNoticiaDTO myVideoMensajeNoticiaDTO)
        {
            bool retorno = false;

            YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper();

            try
            {
                //Seteo ParĂ¡metros.
                //====================================================================================
                wobjSQLHelper.SetParametro("@pIdVideoMensajeNoticia", SqlDbType.Decimal, -1, myVideoMensajeNoticiaDTO.IdVideoMensajeNoticia);
                wobjSQLHelper.SetParametro("@pIdMensajeNoticia", SqlDbType.Decimal, -1, myVideoMensajeNoticiaDTO.TheMensajeNoticiaDTO.IdMensajeNoticia);
                wobjSQLHelper.SetParametro("@pTituloVideoMensajeNoticia", SqlDbType.VarChar, 200, myVideoMensajeNoticiaDTO.TituloVideoMensajeNoticia);
                wobjSQLHelper.SetParametro("@pUrlVideoMensajeNoticia", SqlDbType.VarChar, 200, myVideoMensajeNoticiaDTO.UrlVideoMensajeNoticia);
                //====================================================================================

                //Ejecuto SP.
                //====================================================================================
                switch (wobjSQLHelper.EjecutarNQ("UPD_VideoMensajeNoticia", "YouCom"))
                {
                case 0:
                    throw new Exception("No se pudo grabar.");

                case -1:
                    throw new Exception("Hubo un error.");

                case -2:
                    throw new Exception("Hubo un error.");
                }
                //====================================================================================

                retorno = true;
            }

            #region Catch

            catch (Exception eobjException)
            {
                throw eobjException;
            }
            #endregion

            return(retorno);
        }