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

            IList <YouCom.DTO.Mensajeria.Video.VideoMensajeDirectivaDTO> IVideoMensajeDirectiva = new List <YouCom.DTO.Mensajeria.Video.VideoMensajeDirectivaDTO>();

            DataTable pobjDataTable = new DataTable();

            if (YouCom.Mensajeria.DAL.Video.VideoMensajeDirectivaDAL.getListadoVideoMensajeDirectiva(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.VideoMensajeDirectivaDTO video_mensaje_directiva = new YouCom.DTO.Mensajeria.Video.VideoMensajeDirectivaDTO();

                        video_mensaje_directiva.IdVideoMensajeDirectiva = decimal.Parse(wobjDataRow["IdVideoMensajeDirectiva"].ToString());

                        YouCom.DTO.Mensajeria.MensajeDirectivaDTO myMensajeDirectivaDTO = new YouCom.DTO.Mensajeria.MensajeDirectivaDTO();
                        myMensajeDirectivaDTO.IdMensajeDirectiva       = decimal.Parse(wobjDataRow["idMensajeDirectiva"].ToString());
                        video_mensaje_directiva.TheMensajeDirectivaDTO = myMensajeDirectivaDTO;

                        video_mensaje_directiva.TituloVideoMensajeDirectiva = wobjDataRow["TituloVideoMensajeDirectiva"].ToString();
                        video_mensaje_directiva.UrlVideoMensajeDirectiva    = wobjDataRow["UrlVideoMensajeDirectiva"].ToString();

                        vCode = video_mensaje_directiva.UrlVideoMensajeDirectiva.Substring((video_mensaje_directiva.UrlVideoMensajeDirectiva.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_directiva.UrlWatchVideoMensajeDirectiva = video;

                        IVideoMensajeDirectiva.Add(video_mensaje_directiva);
                    }
                }
            }

            return(IVideoMensajeDirectiva);
        }
Exemple #2
0
        public static bool Update(YouCom.DTO.Mensajeria.Video.VideoMensajeDirectivaDTO myVideoMensajeDirectivaDTO)
        {
            bool retorno = false;

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

            try
            {
                //Seteo Parámetros.
                //====================================================================================
                wobjSQLHelper.SetParametro("@pIdVideoMensajeDirectiva", SqlDbType.Decimal, -1, myVideoMensajeDirectivaDTO.IdVideoMensajeDirectiva);
                wobjSQLHelper.SetParametro("@pIdMensajeDirectiva", SqlDbType.Decimal, -1, myVideoMensajeDirectivaDTO.TheMensajeDirectivaDTO.IdMensajeDirectiva);
                wobjSQLHelper.SetParametro("@pTituloVideoMensajeDirectiva", SqlDbType.VarChar, 200, myVideoMensajeDirectivaDTO.TituloVideoMensajeDirectiva);
                wobjSQLHelper.SetParametro("@pUrlVideoMensajeDirectiva", SqlDbType.VarChar, 200, myVideoMensajeDirectivaDTO.UrlVideoMensajeDirectiva);
                //====================================================================================

                //Ejecuto SP.
                //====================================================================================
                switch (wobjSQLHelper.EjecutarNQ("UPD_VideoMensajeDirectiva", "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);
        }