Ejemplo n.º 1
0
        // GET: VideoPage
        public ActionResult Index()
        {
            var VideoDao = new VideoDao();

            ViewBag.NewVideo = VideoDao.ListNewVideo(8);
            return(View());
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";

            HttpPostedFile file       = context.Request.Files["file"];
            string         uploadPath = HttpContext.Current.Server.MapPath("~/Video/");

            if (file != null)
            {
                if (!Directory.Exists(uploadPath))
                {
                    Directory.CreateDirectory(uploadPath);
                }

                string name = System.Guid.NewGuid().ToString() + ".mp4";

                string     video_title = context.Request["video_title"];
                string     video_des   = context.Request["video_des"];
                string     user_id     = context.Request["user_id"];
                VideoModel video       = new VideoModel(name, video_title, "\\\\Video\\\\" + name, user_id, video_des);
                VideoDao   dao         = Factory.Get(new VideoDao());
                dao.Insert(video);
                file.SaveAs(uploadPath + name);
                Tool.CatchImg(HttpContext.Current.Server.MapPath("../"), name, "240*180", "1");

                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }
        public void CreateItem_NoVideoExists_VideoAndItemCreated()
        {
            PlaylistItem playlistItem = Helpers.CreateItemInPlaylist(Playlist);

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();

            //  Ensure that the Video was created.
            Video videoFromDatabase = VideoDao.Get(playlistItem.Video.Id);

            Assert.NotNull(videoFromDatabase);

            //  Ensure that the PlaylistItem was created.
            PlaylistItem itemFromDatabase = PlaylistItemDao.Get(playlistItem.Id);

            Assert.NotNull(itemFromDatabase);

            //  Should have a sequence number after saving for sure.
            Assert.GreaterOrEqual(itemFromDatabase.Sequence, 0);

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            //  Pointers should be self-referential with only one item in the Playlist.
            //Assert.AreEqual(itemFromDatabase.NextItem, itemFromDatabase);
            //Assert.AreEqual(itemFromDatabase.PreviousItem, itemFromDatabase);
        }
        protected void Collect_Click(object sender, EventArgs e)
        {
            CollectDAO   yes_dao     = Factory.Get(new CollectDAO());
            VideoModel   video_model = (Session["video"] as VideoModel);
            CollectModel yes_model   = new CollectModel(video_model.video_id, (Session["user"] as UserModel).id);
            VideoDao     video_dao   = Factory.Get(new VideoDao());

            if (Button3.ForeColor == System.Drawing.ColorTranslator.FromHtml("#1763e9"))
            {
                Button3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#757575");
                yes_dao.Delete(yes_model);
                video_model.collect--;
            }
            else if (Button3.ForeColor == System.Drawing.ColorTranslator.FromHtml("#757575"))
            {
                Button3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9");
                yes_dao.Insert(yes_model);
                video_model.collect++;
            }


            Label4.Text = "收藏:" + video_model.collect;


            video_dao.Update(video_model);
        }
Ejemplo n.º 5
0
        public void CreateItem_VideoAlreadyExists_ItemCreatedVideoNotUpdated()
        {
            var videoNotInDatabase = Helpers.CreateUnsavedVideoWithId();

            VideoManager.Save(videoNotInDatabase);

            //  Change the title for videoInDatabase to check that cascade-update does not affect title. Videos are immutable.
            const string videoTitle      = "A video title";
            var          videoInDatabase = Helpers.CreateUnsavedVideoWithId(titleOverride: videoTitle);

            //  Create a new PlaylistItem and write it to the database.
            string title        = videoInDatabase.Title;
            var    playlistItem = new PlaylistItem(title, videoInDatabase);

            Playlist.AddItem(playlistItem);
            PlaylistItemManager.Save(playlistItem);

            //  Remove entity from NHibernate cache to force DB query to ensure actually created.
            NHibernateSessionManager.Instance.Clear();

            //  Ensure that the Video was NOT updated by comparing the new title to the old one.
            Video videoFromDatabase = VideoDao.Get(videoNotInDatabase.Id);

            Assert.AreNotEqual(videoFromDatabase.Title, videoTitle);

            //  Ensure that the PlaylistItem was created.
            PlaylistItem itemFromDatabase = PlaylistItemDao.Get(playlistItem.Id);

            Assert.NotNull(itemFromDatabase);

            //  Pointers should be self-referential with only one item in the Playlist.
            Assert.AreEqual(itemFromDatabase.NextItem, itemFromDatabase);
            Assert.AreEqual(itemFromDatabase.PreviousItem, itemFromDatabase);
        }
Ejemplo n.º 6
0
        // GET: Admin/Video
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new VideoDao();
            var model = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }
Ejemplo n.º 7
0
        public ActionResult Tunes(long TunesId)
        {
            var tunes = new TunesDao().VideoByGiaiDieu(TunesId);

            ViewBag.Tunes = tunes;
            var model = new VideoDao().ListByTunes(TunesId);

            return(View(model));
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlHelper.Connect();



            VideoDao          dao  = Factory.Get(new VideoDao());
            List <VideoModel> list = (List <VideoModel>)dao.GetAll();
        }
Ejemplo n.º 9
0
        public ActionResult Update(Video video)
        {
            var result = VideoDao.Update(video);

            if (result == 1)
            {
                return(Ok());
            }
            return(BadRequest());
        }
Ejemplo n.º 10
0
        // GET: Home
        public ActionResult Index()
        {
            var VideoDao = new VideoDao();

            ViewBag.NewVideo = VideoDao.ListNewVideo(5);
            var model = new LessonDao();

            ViewBag.NewLesson = model.ListAllLesson();
            return(View());
        }
Ejemplo n.º 11
0
        public ActionResult Delete(string id)
        {
            var result = VideoDao.Delete(id);

            if (result == 1)
            {
                return(Ok());
            }
            return(BadRequest());
        }
Ejemplo n.º 12
0
        public List <VideoModel> GetVideoList(int page, int count)
        {
            VideoDao dao      = new VideoDao(connectionString);
            var      entities = dao.GetVideos(page, count);
            var      models   = new List <VideoModel>();

            entities?.ForEach(t =>
            {
                models.Add(t.TransformTo <VideoModel>());
            });
            return(models);
        }
Ejemplo n.º 13
0
        /// <summary>
        ///     This is the work for saving a PlaylistItem without the Transaction wrapper.
        /// </summary>
        private void DoSave(Playlist playlist)
        {
            foreach (PlaylistItem playlistItem in playlist.Items)
            {
                //  This is a bit of a hack, but NHibernate pays attention to the "dirtyness" of immutable entities.
                //  As such, if two PlaylistItems reference the same Video object -- NonUniqueObjectException is thrown even though no changes
                //  can be persisted to the database.
                playlistItem.Video = VideoDao.Merge(playlistItem.Video);

                playlistItem.ValidateAndThrow();
                playlistItem.Video.ValidateAndThrow();
            }

            playlist.ValidateAndThrow();
            PlaylistDao.Save(playlist);
        }
Ejemplo n.º 14
0
        public void CreateItem_NoVideoExists_VideoAndItemCreated()
        {
            PlaylistItem playlistItem = Helpers.CreateItemInPlaylist(Playlist);

            //  Ensure that the Video was created.
            Video videoFromDatabase = VideoDao.Get(playlistItem.Video.Id);

            Assert.NotNull(videoFromDatabase);

            //  Ensure that the PlaylistItem was created.
            PlaylistItem itemFromDatabase = PlaylistItemDao.Get(playlistItem.Id);

            Assert.NotNull(itemFromDatabase);

            //  Pointers should be self-referential with only one item in the Playlist.
            Assert.AreEqual(itemFromDatabase.NextItem, itemFromDatabase);
            Assert.AreEqual(itemFromDatabase.PreviousItem, itemFromDatabase);
        }
Ejemplo n.º 15
0
        public async Task <WebResult> Post([FromBody] BaseDanmuDataIn data)
        {
            if (string.IsNullOrWhiteSpace(data.Id) || string.IsNullOrWhiteSpace(data.Text))
            {
                return(new WebResult(1));
            }
            data.Ip = IPAddress.TryParse(Request.Headers["X-Real-IP"], out var ip)
                ? ip
                : Request.HttpContext.Connection.RemoteIpAddress;
            data.Referer ??= Request.Headers["Referer"].FirstOrDefault();
            var video = VideoDao.Insert(data.Id, new Uri(data.Referer ?? string.Empty));
            var danmu = new DanmuTable
            {
                Vid   = data.Id,
                Data  = data,
                Ip    = data.Ip,
                Video = video
            };
            var result = await DanmuDao.InsertDanmuAsync(danmu);

            return(new WebResult(result ? 0 : 1));
        }
        public void CreateItem_VideoAlreadyExists_ItemCreatedVideoNotUpdated()
        {
            var videoNotInDatabase = Helpers.CreateUnsavedVideoWithId();

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            VideoManager.Save(videoNotInDatabase);
            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            //  Change the title for videoInDatabase to check that cascade-update does not affect title. Videos are immutable.
            const string videoTitle      = "A video title";
            var          videoInDatabase = Helpers.CreateUnsavedVideoWithId(titleOverride: videoTitle);

            //  Create a new PlaylistItem and write it to the database.
            string title        = videoInDatabase.Title;
            var    playlistItem = new PlaylistItem(title, videoInDatabase);

            Playlist.AddItem(playlistItem);
            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            PlaylistItemManager.Save(playlistItem);
            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();

            //  Ensure that the Video was NOT updated by comparing the new title to the old one.
            Video videoFromDatabase = VideoDao.Get(videoNotInDatabase.Id);

            Assert.AreNotEqual(videoFromDatabase.Title, videoTitle);

            //  Ensure that the PlaylistItem was created.
            PlaylistItem itemFromDatabase = PlaylistItemDao.Get(playlistItem.Id);

            Assert.NotNull(itemFromDatabase);

            //  Should have a sequence number after saving for sure.
            Assert.GreaterOrEqual(itemFromDatabase.Sequence, 0);

            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();
        }
        protected void No_Click(object sender, EventArgs e)
        {
            NoDAO      no_dao      = Factory.Get(new NoDAO());
            VideoModel video_model = (Session["video"] as VideoModel);
            NoModel    no_model    = new NoModel(video_model.video_id, (Session["user"] as UserModel).id);
            VideoDao   video_dao   = Factory.Get(new VideoDao());

            if (Button2.ForeColor == System.Drawing.ColorTranslator.FromHtml("#1763e9"))
            {
                YesDAO   yes_dao   = Factory.Get(new YesDAO());
                YesModel yes_model = new YesModel(video_model.video_id, (Session["user"] as UserModel).id);

                Button2.ForeColor = System.Drawing.ColorTranslator.FromHtml("#757575");
                yes_dao.Delete(yes_model);
                video_model.yes--;
                Label3.Text = "赞:" + video_model.yes;
            }

            if (Button4.ForeColor == System.Drawing.ColorTranslator.FromHtml("#1763e9"))
            {
                Button4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#757575");
                no_dao.Delete(no_model);
                video_model.no--;
            }
            else if (Button4.ForeColor == System.Drawing.ColorTranslator.FromHtml("#757575"))
            {
                Button4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9");
                no_dao.Insert(no_model);
                video_model.no++;
            }



            Label5.Text = "踩:" + video_model.no;


            video_dao.Update(video_model);
        }
        public async Task <WebResult <string[]> > GetVidList()
        {
            var vids = await VideoDao.GetVidsAsync();

            return(new WebResult <string[]>(vids));
        }
 public DanmuListController(DanmuDao danmuDao, VideoDao videoDao) : base(danmuDao, videoDao)
 {
 }
Ejemplo n.º 20
0
        protected void ShowVideoImage()
        {
            VideoDao          dao  = Factory.Get(new VideoDao());
            List <VideoModel> list = (List <VideoModel>)dao.GetBy("where user_id='" + (Session["user"] as UserModel).id + "'");

            foreach (VideoModel model in list)
            {
                System.Windows.Forms.ListViewItem item1 = new System.Windows.Forms.ListViewItem();
                //之前是直接用Images.FromFile(string Path)从文件夹中读取,删除时没法删除
                //改从文件流中读取图片,关闭窗口时可以删除文件
                string      image_path = "VideoIcon/" + model.video_id.Split('.')[0] + ".jpg";
                ImageButton button     = new ImageButton();
                button.Height   = 100;
                button.Width    = 160;
                button.ImageUrl = image_path;
                Label label = new Label();
                button.Click += (object sender, ImageClickEventArgs e) => {
                    if (model.iscansee)
                    {
                        Session["video"] = model; Response.Redirect("VideoPage.aspx");
                    }
                    else
                    {
                        Server.Transfer("ErrorPage.aspx");
                    }
                };
                Label  title         = new Label();
                Button delete_button = new Button();
                delete_button.Text     = "删除";
                delete_button.CssClass = "del_btn";
                delete_button.Click   += (object sender, EventArgs e) => {
                    VideoDao video_dao = Factory.Get(new VideoDao());
                    video_dao.Delete(model);
                    File.Delete(Server.MapPath("~/Video/") + model.video_id);
                    File.Delete(Server.MapPath("~/VideoIcon/") + model.video_id.Split('.')[0] + ".jpg");
                    Server.Transfer("VideoUpLoadPage.aspx");
                };

                if (model.iscansee)
                {
                    label.Text = "审核已通过";
                }
                else
                {
                    label.Text = "正在审核...";
                }
                title.Text      = model.title;
                label.Font.Bold = true;
                title.Font.Size = 15;
                label.Font.Size = 20;
                if (Table1.Rows.Count == 0)
                {
                    _last_row = new TableRow();
                    Table1.Rows.Add(_last_row);
                }

                if (_last_row.Cells.Count < 2)
                {
                    TableCell cell = new TableCell();
                    cell.Controls.Add(button);

                    TableCell cell3 = new TableCell();
                    cell3.Controls.Add(title);
                    TableCell cell1 = new TableCell();
                    cell1.Controls.Add(label);
                    TableCell cell2 = new TableCell();
                    cell2.Controls.Add(delete_button);

                    _last_row.Cells.Add(cell);
                    _last_row.Cells.Add(cell3);
                    _last_row.Cells.Add(cell1);
                    _last_row.Cells.Add(cell2);

                    cell.HorizontalAlign  = HorizontalAlign.Center;
                    cell2.HorizontalAlign = HorizontalAlign.Center;
                }
                else
                {
                    _last_row = new TableRow();
                    TableCell cell  = new TableCell();
                    TableCell cell1 = new TableCell();
                    TableCell cell2 = new TableCell();
                    cell1.Controls.Add(label);
                    cell2.Controls.Add(delete_button);
                    TableCell cell3 = new TableCell();
                    cell3.Controls.Add(title);
                    cell.Controls.Add(button);

                    _last_row.Cells.Add(cell);
                    _last_row.Cells.Add(cell3);
                    _last_row.Cells.Add(cell1);
                    _last_row.Cells.Add(cell2);

                    Table1.Rows.Add(_last_row);

                    cell.HorizontalAlign  = HorizontalAlign.Center;
                    cell2.HorizontalAlign = HorizontalAlign.Center;
                }
            }
        }
Ejemplo n.º 21
0
        public async Task DownloadVideoList()
        {
            try
            {
                TokenDao tokenDao = new TokenDao(connectionString);
                var      token    = tokenDao.GetAvaliableToken();
                if (token == null)
                {
                    logger.LogWarning("没有可用的Token");
                    return;
                }

                using (var client = HttpClientFactory.Create())
                {
                    string url      = $"{domain}/video/list?open_id={token.OpenId}&access_token={token.AccessToken}&cursor={0}&count={pageCount}";
                    var    response = await client.SendAsync(new HttpRequestMessage(HttpMethod.Get, url));

                    var content = await response.Content.ReadAsStringAsync();

                    var videoListResponse = JsonConvert.DeserializeObject <VideoListResponseModel>(content);
                    if (videoListResponse?.data.error_code != 0)
                    {
                        logger.LogError($"请求Token失败:{videoListResponse?.data?.error_code} {videoListResponse?.data?.description}");
                        return;
                    }

                    List <VideoEntity> entities = new List <VideoEntity>();
                    var dao = new VideoDao(connectionString);
                    videoListResponse?.data?.list?.ForEach(t =>
                    {
                        entities.Add(new VideoEntity()
                        {
                            ItemId        = t.item_id,
                            VideoStatus   = t.video_status,
                            Title         = t.title,
                            CreateTime    = StampToDateTime(t.create_time),
                            Cover         = t.cover,
                            ShareUrl      = t.share_url,
                            CommentCount  = t.statistics.comment_count,
                            DiggCount     = t.statistics.digg_count,
                            DownloadCount = t.statistics.download_count,
                            ForwardCount  = t.statistics.forward_count,
                            PlayCount     = t.statistics.play_count,
                            ShareCount    = t.statistics.share_count,
                            ReceiveTime   = DateTime.Now
                        });
                    });

                    if (entities.Count == 0)
                    {
                        return;
                    }

                    var existIds = dao.GetVideosByItemIds(entities.Select(t => t.ItemId).ToArray())
                                   .Select(t => t.ItemId)
                                   .ToArray();

                    var newEntities = entities
                                      .Where(t => !existIds.Contains(t.ItemId))
                                      .ToList();

                    dao.CreateVideo(newEntities);
                }
            }
            catch (Exception err)
            {
                logger.LogError("获取视频列表失败", err);
            }
        }
Ejemplo n.º 22
0
        public async Task <string> GetVideoUrl(string itemId)
        {
            try
            {
                TokenDao tokenDao = new TokenDao(connectionString);
                var      token    = tokenDao.GetAvaliableToken();
                if (token == null)
                {
                    logger.LogWarning("没有可用的Token");
                    return(null);
                }

                using (var client = HttpClientFactory.Create())
                {
                    string url = $"{domain}/video/data?open_id={token.OpenId}&access_token={token.AccessToken}";
                    //var response = await client.SendAsync(new HttpRequestMessage(HttpMethod.Post, url));
                    var str = JsonConvert.SerializeObject(new
                    {
                        item_ids = new[] { itemId }
                    });
                    HttpContent requestContent = new StringContent(str);
                    requestContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                    var response = await client.PostAsync(url, requestContent);

                    var content = await response.Content.ReadAsStringAsync();

                    var videoListResponse = JsonConvert.DeserializeObject <VideoListResponseModel>(content);
                    if (videoListResponse?.data.error_code != 0)
                    {
                        logger.LogError($"请求Token失败:{videoListResponse?.data?.error_code} {videoListResponse?.data?.description}");
                        return(null);
                    }

                    List <VideoEntity> entities = new List <VideoEntity>();
                    var dao = new VideoDao(connectionString);
                    videoListResponse?.data?.list?.ForEach(t =>
                    {
                        entities.Add(new VideoEntity()
                        {
                            ItemId        = t.item_id,
                            VideoStatus   = t.video_status,
                            Title         = t.title,
                            CreateTime    = StampToDateTime(t.create_time),
                            Cover         = t.cover,
                            ShareUrl      = t.share_url,
                            CommentCount  = t.statistics.comment_count,
                            DiggCount     = t.statistics.digg_count,
                            DownloadCount = t.statistics.download_count,
                            ForwardCount  = t.statistics.forward_count,
                            PlayCount     = t.statistics.play_count,
                            ShareCount    = t.statistics.share_count,
                            ReceiveTime   = DateTime.Now
                        });
                    });

                    if (entities.Count == 0)
                    {
                        return(null);
                    }

                    return(entities.FirstOrDefault()?.ShareUrl);
                }
            }
            catch (Exception err)
            {
                logger.LogError("获取视频列表失败", err);
                return(null);
            }
        }
        protected void ShowVideoImage()
        {
            VideoDao          dao  = Factory.Get(new VideoDao());
            List <VideoModel> list = (List <VideoModel>)dao.GetAll();

            foreach (VideoModel model in list)
            {
                System.Windows.Forms.ListViewItem item1 = new System.Windows.Forms.ListViewItem();
                //之前是直接用Images.FromFile(string Path)从文件夹中读取,删除时没法删除
                //改从文件流中读取图片,关闭窗口时可以删除文件

                string image_path = "VideoIcon/" + model.video_id.Split('.')[0] + ".jpg";

                ImageButton button = new ImageButton();
                button.Height   = 100;
                button.Width    = 160;
                button.ImageUrl = image_path;
                Label title_user = new Label();
                button.Click += (object sender, ImageClickEventArgs e) => { Session["video"] = model; Response.Redirect("VideoPage.aspx"); };
                Label  label      = new Label();
                Button see_button = new Button();
                title_user.Text = model.title + "<br>上传者:" + model.user_id;
                Button delete_button = new Button();
                delete_button.Text   = "删除";
                delete_button.Click += (object sender, EventArgs e) => {
                    VideoDao video_dao = Factory.Get(new VideoDao());
                    video_dao.Delete(model);
                    File.Delete(Server.MapPath("~/Video/") + model.video_id);
                    File.Delete(Server.MapPath("~/VideoIcon/") + model.video_id.Split('.')[0] + ".jpg");
                    Server.Transfer("ManagerPage.aspx");
                };
                if (model.iscansee)
                {
                    label.Text         = "审核已通过";
                    see_button.Text    = "已审核";
                    see_button.Enabled = false;
                }
                else
                {
                    label.Text      = "未审核";
                    see_button.Text = "审核";
                }
                see_button.Click += (object sender, EventArgs e) => { model.iscansee     = true; VideoDao video_dao = Factory.Get(new VideoDao()); video_dao.Update(model); label.Text = "审核已通过";
                                                                      see_button.Text    = "已审核";
                                                                      see_button.Enabled = false; };
                see_button.Height    = 50;
                see_button.Width     = 80;
                delete_button.Height = 50;
                delete_button.Width  = 80;
                label.Font.Bold      = true;
                label.Font.Size      = 20;
                if (Table1.Rows.Count == 0)
                {
                    _last_row = new TableRow();
                    Table1.Rows.Add(_last_row);
                }

                if (_last_row.Cells.Count < 2)
                {
                    TableCell cell = new TableCell();
                    cell.Controls.Add(button);
                    TableCell cell4 = new TableCell();
                    cell4.Controls.Add(title_user);
                    TableCell cell1 = new TableCell();
                    cell1.Controls.Add(label);
                    TableCell cell2 = new TableCell();
                    cell1.Controls.Add(label);
                    cell2.Controls.Add(see_button);
                    cell2.Controls.Add(delete_button);
                    _last_row.Cells.Add(cell);
                    _last_row.Cells.Add(cell4);
                    _last_row.Cells.Add(cell1);
                    _last_row.Cells.Add(cell2);

                    cell1.HorizontalAlign = HorizontalAlign.Center;
                    cell.HorizontalAlign  = HorizontalAlign.Center;
                    cell2.HorizontalAlign = HorizontalAlign.Center;
                }
                else
                {
                    _last_row = new TableRow();
                    TableCell cell  = new TableCell();
                    TableCell cell1 = new TableCell();
                    TableCell cell2 = new TableCell();
                    cell1.Controls.Add(label);
                    TableCell cell4 = new TableCell();
                    cell4.Controls.Add(title_user);
                    cell2.Controls.Add(see_button);
                    cell2.Controls.Add(delete_button);
                    cell.Controls.Add(button);
                    _last_row.Cells.Add(cell);
                    _last_row.Cells.Add(cell4);
                    _last_row.Cells.Add(cell1);
                    _last_row.Cells.Add(cell2);
                    Table1.Rows.Add(_last_row);
                    cell1.HorizontalAlign = HorizontalAlign.Center;
                    cell.HorizontalAlign  = HorizontalAlign.Center;
                    cell2.HorizontalAlign = HorizontalAlign.Center;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            UserModel user = (UserModel)Session["user"];

            if (user == null)
            {
                Server.Transfer("LoginPage.aspx");
            }
            Label6.Text = user.name;

            VideoDao          video_dao = Factory.Get(new VideoDao());
            List <VideoModel> list      = (List <VideoModel>)video_dao.GetBy("where video_id='" + (Session["video"] as VideoModel).video_id + "'");
            var title   = (Session["video"] as VideoModel).title;
            var des     = (Session["video"] as VideoModel).des;
            var yes     = list[0].yes;
            var no      = list[0].no;
            var collect = list[0].collect;

            Label1.Text = title;
            UserDAO user_dao = Factory.Get(new UserDAO());

            Label2.Text = "上传者:" + ((List <UserModel>)user_dao.GetBy("where id='" + (Session["video"] as VideoModel).user_id + "'"))[0].name + "<br>" + des;
            Label3.Text = "赞:" + yes;
            Label4.Text = "收藏:" + collect;
            Label5.Text = "踩:" + no;

            NoDAO          nodao   = Factory.Get(new NoDAO());
            List <NoModel> no_list = (List <NoModel>)nodao.GetBy("where video_id='" + (Session["video"] as VideoModel).video_id + "' and user_id='" + (Session["user"] as UserModel).id + "'");

            CollectDAO          collect_dao  = Factory.Get(new CollectDAO());
            List <CollectModel> collect_list = (List <CollectModel>)collect_dao.GetBy("where video_id='" + (Session["video"] as VideoModel).video_id + "' and user_id='" + (Session["user"] as UserModel).id + "'");

            YesDAO          dao      = Factory.Get(new YesDAO());
            List <YesModel> yes_list = (List <YesModel>)dao.GetBy("where video_id='" + (Session["video"] as VideoModel).video_id + "' and user_id='" + (Session["user"] as UserModel).id + "'");

            if (yes_list.Count > 0)
            {
                Button2.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9");
            }
            if (no_list.Count > 0)
            {
                Button4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9");
            }
            if (collect_list.Count > 0)
            {
                Button3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9");
            }
            UpdateComment();

            if ((Session["user"] as UserModel).type == "manager")
            {
                tougao.Visible   = false;
                shoucang.Visible = false;
                return1.Visible  = true;
            }

            else
            {
                tougao.Visible   = true;
                shoucang.Visible = true;
                return1.Visible  = false;
            }
        }
Ejemplo n.º 25
0
        protected void ShowVideoImage()
        {
            VideoDao          dao  = Factory.Get(new VideoDao());
            List <VideoModel> list = (List <VideoModel>)dao.GetAll();

            List <VideoModel> CanSeeVideoList = new List <VideoModel>();

            foreach (var item in list)
            {
                if (item.iscansee)
                {
                    CanSeeVideoList.Add(item);
                }
            }
            foreach (VideoModel model in CanSeeVideoList)
            {
                System.Windows.Forms.ListViewItem item1 = new System.Windows.Forms.ListViewItem();
                //之前是直接用Images.FromFile(string Path)从文件夹中读取,删除时没法删除
                //改从文件流中读取图片,关闭窗口时可以删除文件

                string image_path = "VideoIcon/" + model.video_id.Split('.')[0] + ".jpg";


                ImageButton button = new ImageButton();
                button.Height   = 140;
                button.Width    = 200;
                button.ImageUrl = image_path;
                Label title = new Label();
                button.Click += (object sender, ImageClickEventArgs e) => { Session["video"] = model;   Response.Redirect("VideoPage.aspx"); };
                title.Text    = "<br>" + model.title;
                if (Table1.Rows.Count == 0)
                {
                    _last_row = new TableRow();
                    Table1.Rows.Add(_last_row);
                }

                if (_last_row.Cells.Count < 5)
                {
                    TableCell cell = new TableCell();
                    cell.Controls.Add(button);

                    cell.Controls.Add(title);
                    _last_row.Cells.Add(cell);
                }
                else
                {
                    _last_row = new TableRow();
                    TableCell cell = new TableCell();
                    cell.Controls.Add(button);

                    cell.Controls.Add(title);
                    _last_row.Cells.Add(cell);
                    Table1.Rows.Add(_last_row);
                }
            }
            if (_last_row != null)
            {
                int index = 5 - _last_row.Cells.Count;
                for (int i = 0; i < index; i++)
                {
                    TableCell cell = new TableCell();
                    Label     l    = new Label();

                    l.Height = 140;
                    l.Width  = 200;
                    cell.Controls.Add(l);
                    _last_row.Cells.Add(cell);
                }
            }
        }
Ejemplo n.º 26
0
 public DplayerController(DanmuDao danmuDao, VideoDao videoDao) : base(danmuDao, videoDao)
 {
 }
 public AccountBaseController(AppConfiguration configuration, UserDao userDao, DanmuDao danmuDao,
                              VideoDao videoDao) : base(danmuDao, videoDao)
 {
     _admin   = configuration.GetAppSetting().Admin;
     _userDao = userDao;
 }
Ejemplo n.º 28
0
 public void LogVideoAccess(VideoAudit videoAudit)
 {
     VideoDao.LogVideoAccess(videoAudit);
 }
Ejemplo n.º 29
0
 protected DanmuBaseController(DanmuDao danmu, VideoDao video)
 {
     DanmuDao = danmu;
     VideoDao = video;
 }
Ejemplo n.º 30
0
 protected AdminBaseController(DanmuDao danmuDao, VideoDao videoDao)
 {
     DanmuDao = danmuDao;
     VideoDao = videoDao;
 }