Esempio n. 1
0
        public static async Task <string> generateRSS(ApplicationDbContext context, VideoEntity Entity)
        {
            var str = new StringBuilder();

            str.AppendLine("<rss version=\"2.0\">");
            str.AppendLine("<channel>");
            str.AppendLine("<title>" + Jugnoon.Settings.Configs.GeneralSettings.website_title + "</title>");
            str.AppendLine("<description>" + Jugnoon.Settings.Configs.GeneralSettings.website_description + "</description>");
            str.AppendLine("<link>" + Config.GetUrl() + "</link>");
            str.AppendLine("<guid>" + Config.GetUrl() + "videos/" + "</guid>");
            var _lst = await VideoBLL.LoadItems(context, Entity);

            foreach (var Item in _lst)
            {
                string title_url = VideoUrlConfig.PrepareUrl(Item);
                string body      = WebUtility.HtmlEncode(UtilityBLL.StripHTML_v2(Item.description));
                str.AppendLine("<item>");
                str.AppendLine("<title>" + UtilityBLL.CleanBlogHTML(UtilityBLL.StripHTML(Item.title)) + "</title>");
                str.AppendLine("<link>" + title_url + "</link>");
                str.AppendLine("<guid>" + title_url + "</guid>");
                str.AppendLine("<pubDate>" + String.Format("{0:R}", Item.created_at) + "</pubDate>");
                str.AppendLine("<description>" + body + "</description>");
                str.AppendLine("</item>");
            }
            str.AppendLine("</channel>");
            str.AppendLine("</rss>");

            return(str.ToString());
        }
        private async Task <string> Favorites_Generate_Output(int FavType, int MediaType, string UserName, string ElementID, string Author_UserName, long ContentID, int _Favorites)
        {
            //**********************************************************
            // Generate Output Panel
            //**********************************************************
            var    str     = new StringBuilder();
            string media   = SiteConfig.generalLocalizer["_video"].Value;
            string _url    = Config.GetUrl();
            string fav_url = _url + "account/my-videos/favorites";

            if (FavType == 2)
            {
                media = "album";
                if (MediaType == 1)
                {
                    fav_url = _url + "account/my-audio/favorites";
                }
                else
                {
                    fav_url = _url + "account/my-alubms/favorites";
                }
            }
            else if (MediaType == 1)
            {
                media   = SiteConfig.generalLocalizer["_audio"].ToString();
                fav_url = _url + "account/my-audio/favorites";
            }

            // check authentication
            if (UserName == "")
            {
                string sign_in = "<a href=\"" + Config.GetUrl() + "signin\" class=\"bold\">" + SiteConfig.generalLocalizer["_sign_in"].Value + "</a>";
                string sign_up = "<a href=\"" + Config.GetUrl() + "signup\" class=\"bold\">" + SiteConfig.generalLocalizer["_sign_up"].Value + "</a>";
                str.AppendLine("" + sign_in + " or " + sign_up + " now!");
                return(Config.SetHiddenMessage_v2(str.ToString(), ElementID, true, 2));
            }

            // check your own video
            if (Author_UserName == UserName)
            {
                str.AppendLine("Can't add your own " + media + " to your <a href=\"" + fav_url + "\">" + SiteConfig.generalLocalizer["_favorites"] + "</a>.");
                return(Config.SetHiddenMessage_v2(str.ToString(), ElementID, true, 0));
            }

            if (await FavoriteBLL.Check(_context, UserName, ContentID, FavType))
            {
                str.AppendLine("You already add this " + media + " to your <a href=\"" + fav_url + "\">" + SiteConfig.generalLocalizer["_favorites"].Value + "</a>.");
                return(Config.SetHiddenMessage_v2(str.ToString(), ElementID, true, 0));
            }

            await FavoriteBLL.Add(_context, UserName, ContentID, MediaType, FavType);

            // increment favorite video state
            _Favorites++;
            VideoBLL.Update_Field_V3(_context, ContentID, _Favorites, "favorites");

            str.AppendLine(media.ToUpper() + " has been <strong>added</strong> to your <a href=\"" + fav_url + "\">" + SiteConfig.generalLocalizer["_favorites"].Value + "</a>.");
            // wrap output
            return(Config.SetHiddenMessage_v2(str.ToString(), ElementID, true, 4));
        }
 // like | dislike
 private void Post_Vote(int Action, int Liked, int Disliked, int Type, long ContentID)
 {
     if (Action == 0)
     {
         Liked = Liked + 1;
         switch (Type)
         {
         case 0:
             VideoBLL.Update_Field_V3(_context, ContentID, Liked, "liked");
             break;
         }
         Liked = Liked + 1;
     }
     else
     {
         Disliked = Disliked + 1;
         switch (Type)
         {
         case 0:
             VideoBLL.Update_Field_V3(_context, ContentID, Disliked, "disliked");
             break;
         }
         Disliked = Disliked + 1;
     }
 }
Esempio n. 4
0
 protected bool GetData()
 {
     if (!InfoType.ToText().IsIn("1;2"))
     {
         return(false);
     }
     if (InfoType == 1)
     {
         NewsBLL  bll   = new NewsBLL();
         NewsInfo model = bll.GetNewsInfo(NewsId.ToInt(0));
         if (model == null)
         {
             return(false);
         }
         strTitle = model.Title;
         Content  = model.Content;
         AddDate  = (model.AddDate ?? DateTime.Today).ToString("yyyy-MM-dd");
     }
     else if (InfoType == 2)
     {
         VideoBLL  bll   = new VideoBLL();
         VideoInfo model = bll.GetVideoInfo(SafeConvert.ToGuid(NewsId).Value);
         if (model == null)
         {
             return(false);
         }
         strTitle  = model.Title;
         AddDate   = (model.AddDate ?? DateTime.Today).ToString("yyyy-MM-dd");
         VideoPath = model.videopath;
     }
     return(true);
 }
Esempio n. 5
0
        public static async Task <List <JGN_Videos> > LoadItems(ApplicationDbContext context, VideoEntity entity)
        {
            if (!entity.iscache ||
                Jugnoon.Settings.Configs.GeneralSettings.cache_duration == 0 ||
                entity.pagenumber > Jugnoon.Settings.Configs.GeneralSettings.max_cache_pages)
            {
                return(await Load_Raw(context, entity));
            }
            else
            {
                string key  = VideoBLL.GenerateKey("lg_video_cat_", entity);
                var    data = new List <JGN_Videos>();
                if (!SiteConfig.Cache.TryGetValue(key, out data))
                {
                    data = await Load_Raw(context, entity);

                    var cacheEntryOptions = new MemoryCacheEntryOptions()
                                            // Keep in cache for this time, reset time if accessed.
                                            .SetSlidingExpiration(TimeSpan.FromSeconds(3600));

                    // Save data in cache.
                    SiteConfig.Cache.Set(key, data, cacheEntryOptions);
                }
                else
                {
                    data = (List <JGN_Videos>)SiteConfig.Cache.Get(key);
                }
                return(data);
            }
        }
Esempio n. 6
0
    public static Video ActualizarVideo(string url, string descripcion, string modulo, string id)
    {
        VideoBLL.Update(url, descripcion, modulo, Convert.ToInt32(id));
        Video objVideo = VideoBLL.SelectById(Convert.ToInt32(id));

        return(objVideo);
    }
Esempio n. 7
0
        /// <summary>
        /// 详细页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Detail(int id)
        {
            VideoBLL    videoBLL    = new VideoBLL();
            VideoEntity videoEntity = videoBLL.GetById(id);

            return(View(videoEntity));
        }
        public ActionResult GrigliaVideoRepartoPartial()
        {
            VideoBLL bll = new VideoBLL();
            List <VideoRepartoModel> model = bll.CreaListaVideoRepartoModel();

            return(PartialView("GrigliaVideoRepartoPartial", model));
        }
        public ActionResult CancellaVideoReparto(decimal IDVIDEOREPARTO)
        {
            VideoBLL bll = new VideoBLL();

            bll.CancellaVideoReparto(IDVIDEOREPARTO);

            return(null);
        }
 public ActionResult Edit([Bind(Include = "idvideo,titulo,fecha_publicacion,formato,duracion,categoria")] Video video)
 {
     if (ModelState.IsValid)
     {
         VideoBLL.Update(video);
         return(RedirectToAction("Index"));
     }
     return(View(video));
 }
 public ActionResult Edit([Bind(Include = "id,titulo,autor,isbn,fecha_publicacion,numero_ejemplares,id_categoria")] Videos video)
 {
     if (ModelState.IsValid)
     {
         VideoBLL.Update(video);
         return(RedirectToAction("Index"));
     }
     return(View(video));
 }
Esempio n. 12
0
 public ActionResult Edit([Bind(Include = "id_vid,titulo_vid,fecha_publicacion_vid,formato_vid,duracion_vid,id_cat")] Video video)
 {
     if (ModelState.IsValid)
     {
         VideoBLL.Update(video);
     }
     ViewBag.id_cat = new SelectList(CategoriaBLL.List(), "id_cat", "nombre_cat", video.id_cat);
     return(View(video));
 }
 public ActionResult Edit([Bind(Include = "idVideo,titulo,fechapublicacion,formato,duracion,idCategoria")] Video video)
 {
     if (ModelState.IsValid)
     {
         VideoBLL.Update(video);
         return(RedirectToAction("Index"));
     }
     ViewBag.idCategoria = new SelectList(CategoriaBLL.List(), "idCategoria", "nombre", video.idCategoria);
     return(View(video));
 }
Esempio n. 14
0
 public ActionResult Edit([Bind(Include = "id_vdo,titulo_vdo,fch_public_vdo,duracion_vdo,id_categoria")] Video video)
 {
     if (ModelState.IsValid)
     {
         VideoBLL.Update(video);
         return(RedirectToAction("Index"));
     }
     ViewBag.id_categoria = new SelectList(CategoriaBLL.List(), "id_categoria", "descripcion", video.id_categoria);
     return(View(video));
 }
Esempio n. 15
0
        public ActionResult Create([Bind(Include = "id_video,titulo_video,fecha_publicacion_video,id_categoria,formato,duracion")] Video video)
        {
            if (ModelState.IsValid)
            {
                VideoBLL.Create(video);
                return(RedirectToAction("Index"));
            }

            ViewBag.id_categoria = new SelectList(CategoriaBLL.List(), "id_categoria", "categoria1", video.id_categoria);;
            return(View(video));
        }
Esempio n. 16
0
        /// <summary>
        /// 列表页面
        /// </summary>
        /// <param name="searchString"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public IActionResult List(string searchString, int?page)
        {
            ViewBag.searchString = string.IsNullOrWhiteSpace(searchString) ? "" : searchString;
            int pageNumber = (page ?? 1);
            int pageSize   = 15;

            VideoBLL videoBLL = new VideoBLL();
            IPagedList <VideoEntity> videoEntities = videoBLL.AdminPageList(pageNumber, pageSize, searchString);

            return(View(videoEntities));
        }
Esempio n. 17
0
        public static async Task <string> generateGoogleSitemap(ApplicationDbContext context, VideoEntity Entity)
        {
            var str = new StringBuilder();

            str.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            str.AppendLine("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"");
            str.AppendLine(" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"");
            str.AppendLine(" xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\">");
            var _lst = await VideoBLL.LoadItems(context, Entity);

            foreach (var Item in _lst)
            {
                string mediaUrl = "";
                if (Item.type == 1)
                {
                    mediaUrl = VideoUrlConfig.Return_MP3_Audio_Url(Item.pub_url, Item.userid) + "/" + Item.videofilename;
                }
                else
                {
                    mediaUrl = VideoUrlConfig.Return_FLV_Video_Url(Item.pub_url, Item.userid) + "/" + Item.videofilename;
                }


                string thumburl = VideoUrlConfig.Return_Video_Thumb_Url(Item.thumb_url, Item.userid) + "/" + Item.thumbfilename;

                str.AppendLine("<url>");
                str.AppendLine("<loc>" + VideoUrlConfig.PrepareUrl(Item) + "</loc>");
                str.AppendLine("<image:image>");
                str.AppendLine("<image:loc>" + thumburl + "</image:loc>");
                str.AppendLine("<image:caption>" + Item.title + "</image:caption>");
                str.AppendLine("</image:image>");
                str.AppendLine("<video:video>");
                str.AppendLine("<video:content_loc>");
                str.AppendLine(mediaUrl);
                str.AppendLine("</video:content_loc>");

                str.AppendLine("<video:thumbnail_loc>");
                str.AppendLine(thumburl);
                str.AppendLine("</video:thumbnail_loc>");
                str.AppendLine("<video:title>" + Item.title + "</video:title>");

                if (Item.description != "")
                {
                    str.AppendLine("<video:description>");
                    str.AppendLine(Item.description);
                    str.AppendLine("</video:description>");
                }
                str.AppendLine("</video:video>");
                str.AppendLine("</url>");
            }
            str.AppendLine("</urlset>");

            return(str.ToString());
        }
        public ActionResult CaricaAssociaVideoPartial()
        {
            VideoBLL          bll          = new VideoBLL();
            List <RWListItem> Video_List   = bll.CreaListaVideo();
            List <RWListItem> Reparti_List = Reparti.CreaListaReparti();

            ViewData.Add("video", Video_List);
            ViewData.Add("reparti", Reparti_List);

            return(PartialView("AssociaVideoRepartiPartial"));
        }
 public ActionResult Create([Bind(Include = "idvideo,titulo,fecha_publi,formato,duracion,categoria")] Video video)
 {
     if (ModelState.IsValid)
     {
         VideoBLL.Create(video);
         return(RedirectToAction("Index"));
     }
     ViewBag.title     = "Añadir nuevo video";
     ViewBag.categoria = new SelectList(CategoriaBLL.List(), "idcategoria", "nombre", video.categoria);
     return(View(video));
 }
Esempio n. 20
0
 public static int EliminarVideo(int idVideo)
 {
     try
     {
         VideoBLL.Delete(idVideo);
         return(idVideo);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Esempio n. 21
0
 private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity)
 {
     return(context.JGN_Videos
            .Join(context.AspNetusers,
                  video => video.userid,
                  user => user.Id, (video, user) => new { video, user })
            .Join(context.JGN_User_Ratings,
                  video => video.video.id,
                  rating => rating.itemid, (video, rating) => new VideoQueryEntity {
         video = video.video, user = video.user, rating = rating
     })
            .Where(VideoBLL.returnWhereClause(entity)));
 }
Esempio n. 22
0
 private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity)
 {
     return(context.JGN_Videos
            .Join(context.AspNetusers,
                  video => video.userid,
                  user => user.Id, (video, user) => new { video, user })
            .Join(context.JGN_Favorites,
                  video => video.video.id,
                  favorite => favorite.contentid, (video, favorite) => new VideoQueryEntity {
         video = video.video, user = video.user, favorite = favorite
     })
            .Where(VideoBLL.returnWhereClause(entity)));
 }
Esempio n. 23
0
 private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity)
 {
     return(context.JGN_Videos
            .Join(context.AspNetusers,
                  video => video.userid,
                  user => user.Id, (video, user) => new { video, user })
            .Join(context.JGN_AbuseReports,
                  video => video.video.id,
                  abusereports => abusereports.contentid, (video, abusereports) => new VideoQueryEntity {
         video = video.video, user = video.user, abusereports = abusereports
     })
            .Where(VideoBLL.returnWhereClause(entity)));
 }
Esempio n. 24
0
 private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity)
 {
     return(context.JGN_Videos
            .Join(context.AspNetusers,
                  video => video.userid,
                  user => user.Id, (video, user) => new { video, user })
            .Join(context.JGN_Playlist_Videos,
                  video => video.video.id,
                  playlist => playlist.contentid, (video, playlist) => new VideoQueryEntity {
         video = video.video, user = video.user, playlist = playlist
     })
            .Where(VideoBLL.returnWhereClause(entity)));
 }
Esempio n. 25
0
        // GET: Videos/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Video video = VideoBLL.Get(id);

            if (video == null)
            {
                return(HttpNotFound());
            }
            return(View(video));
        }
        private async Task <string> Process_V3(string content_username, long contentid, string reason, int type, int mediatype)
        {
            if (HttpContext.User.Identity.IsAuthenticated)
            {
                string sign_in = "<a href=\"" + Config.GetUrl() + "Login.aspx\" class=\"bold\">Sign In</a>";
                string sign_up = "<a href=\"" + Config.GetUrl() + "Register.aspx\" class=\"bold\">Sign Up</a>";
                return(sign_in + " or " + sign_up + " to post report!");
            }
            var info     = SiteConfig.userManager.GetUserAsync(User).Result;
            var userName = info.UserName;

            if (content_username == userName)
            {
                return(SiteConfig.generalLocalizer["_abuse_msg_01"].Value); // You can't post abuse / spam report on your own content.
            }

            if (await AbuseReport.Check_UserName(_context, userName, contentid, type))
            {
                return(SiteConfig.generalLocalizer["_abuse_msg_02"].Value); // "You already post abuse / spam report on this content.";
            }

            //***********************************
            // ENABLE comment if you want to validate report based on ip address
            //***********************************
            string ipaddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            if (await AbuseReport.Check_IPAddress(_context, ipaddress, contentid, type))
            {
                return(SiteConfig.generalLocalizer["_abuse_msg_03"].Value); //	Report already posted from this IP address.
            }

            await AbuseReport.Add(_context, contentid, userName, ipaddress, reason, type);

            int count_reports = await AbuseReport.Count(_context, contentid, type);

            if (count_reports > Jugnoon.Settings.Configs.GeneralSettings.spam_count)
            {
                int OldValue = 0;
                switch (type)
                {
                case 0:
                    // disable video
                    VideoBLL.Update_Field_V3(_context, contentid, (byte)0, "isenabled");
                    OldValue = Convert.ToInt32(VideoBLL.Get_Field_Value(_context, contentid, "isenabled"));
                    break;
                }
            }
            return(SiteConfig.generalLocalizer["_abuse_msg_04"].Value);
        }
        // GET: Videos/Details/5
        public ActionResult Details(int?id)
        {
            ViewBag.title = "Detalle";
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Video video = VideoBLL.Get(id);

            if (video == null)
            {
                return(HttpNotFound());
            }
            return(View(video));
        }
Esempio n. 28
0
        // GET: Videos/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Video video = VideoBLL.Get(id);

            if (video == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_cat = new SelectList(CategoriaBLL.List(), "id_cat", "nombre_cat", video.id_cat);
            return(View(video));
        }
Esempio n. 29
0
        public static async Task <string> GenerateBingSitemap(ApplicationDbContext context, VideoEntity Entity)
        {
            var str = new StringBuilder();

            str.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            str.AppendLine("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
            var _lst = await VideoBLL.LoadItems(context, Entity);

            foreach (var Item in _lst)
            {
                str.AppendLine("<url>");
                str.AppendLine("<loc>" + VideoUrlConfig.PrepareUrl(Item) + "</loc>");
                str.Append("</url>");
            }
            str.AppendLine("</urlset>");

            return(str.ToString());
        }
Esempio n. 30
0
        public ActionResult <DataResult> Create([Bind("remark, url")] VideoEntity videoEntity)
        {
            DataResult dataResult = new DataResult();

            try
            {
                if (string.IsNullOrWhiteSpace(videoEntity.url))
                {
                    dataResult.code = "201";
                    dataResult.msg  = "视频不能为空";
                    return(dataResult);
                }

                VideoBLL    videoBLL = new VideoBLL();
                VideoEntity video    = new VideoEntity()
                {
                    createDate = DateTime.Now,
                    modifyDate = DateTime.Now,
                    remark     = videoEntity.remark ?? "",
                    url        = videoEntity.url
                };

                int rows = videoBLL.ActionDal.ActionDBAccess.Insertable(video).ExecuteCommand();

                if (rows > 0)
                {
                    dataResult.code = "200";
                    dataResult.msg  = "成功";
                }
                else
                {
                    dataResult.code = "201";
                    dataResult.msg  = "失败";
                }
            }
            catch (Exception e)
            {
                dataResult.code = "999";
                dataResult.msg  = e.Message;
                return(dataResult);
            }

            return(dataResult);
        }