Exemplo n.º 1
0
 private void LoadVideoToGridView()
 {
     try
     {
         gridControl1.DataSource = null;
         gridControl1.DataSource = BLLVideoLibrary.Gets();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        private void FrmVideoShedule_Load(object sender, EventArgs e)
        {
            gridDetail.Enabled    = true;
            cbVideo.DataSource    = null;
            cbVideo.DataSource    = BLLVideoLibrary.Gets();
            cbVideo.DisplayMember = "Name";
            cbVideo.ValueMember   = "Id";

            cbLine.DataSource    = null;
            cbLine.DataSource    = BLLLine.GetLines_s(AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList());
            cbLine.ValueMember   = "Machuyen";
            cbLine.DisplayMember = "TenChuyen";
        }
Exemplo n.º 3
0
 private void btnDelete_v_Click(object sender, EventArgs e)
 {
     try
     {
         if (videoId > 0)
         {
             if (MessageBox.Show("Bạn có muốn xoá?", "Xoá file", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 BLLVideoLibrary.Delete(videoId);
                 ResetVideoForm();
                 LoadVideoToGridView();
             }
         }
         else
         {
             MessageBox.Show("Lỗi: Bạn chưa chọn đối tượng để xoá.");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: " + ex.Message);
     }
 }
Exemplo n.º 4
0
        private void SaveVideo()
        {
            try
            {
                if (dlg != null && !string.IsNullOrEmpty(dlg.FileName))
                {
                    var      dtime = DateTime.Now;
                    var      f = dlg.FileName;
                    var      video = new P_VideoLibrary();
                    var      fi = new FileInfo(f);
                    string[] xxx = f.Split('\\');
                    string   tenFile = xxx[xxx.Length - 1], fullPath = "";

                    string[] yyy  = tenFile.Split('.');
                    string   type = yyy[yyy.Length - 1];
                    tenFile = tenFile.Replace("." + type, "");

                    var shortPath = (tenFile.Length > 17 ? tenFile.Substring(0, 17) : tenFile) + "_" + dtime.ToString("yyMMddhhmmss") + "." + type;
                    shortPath = convertToUnSign(shortPath);

                    if (!Directory.Exists(UrlSaveMediaFile))
                    {
                        Directory.CreateDirectory(UrlSaveMediaFile);
                    }
                    fullPath = UrlSaveMediaFile + shortPath;

                    File.Copy(f, fullPath);

                    video.Name      = txtName_v.Text;
                    video.Type      = fi.Extension;
                    video.Length    = 0;
                    video.Size      = fi.Length;
                    video.Path      = shortPath;
                    video.IsDeleted = false;
                    var result = BLLVideoLibrary.CreateOrUpdate(video);


                    //var video = new P_VideoLibrary();
                    //var fi = new FileInfo(f);
                    //string[] xxx = f.Split('\\');
                    //string tenFile = xxx[xxx.Length - 1];
                    //video.Name = tenFile;
                    //string[] yyy = tenFile.Split('.');
                    //string type = yyy[yyy.Length - 1];
                    //tenFile = tenFile.Replace("." + type, "");
                    //video.Type = fi.Extension;
                    //video.Length = 0;
                    //video.Size = fi.Length;

                    //var shortPath = (tenFile.Length > 17 ? tenFile.Substring(0, 17) : tenFile) + "_" + dtime.ToString("yyMMddhhmmss") + "." + type;
                    //shortPath = convertToUnSign(shortPath);

                    //if (!Directory.Exists(UrlSaveMediaFile))
                    //    Directory.CreateDirectory(UrlSaveMediaFile);
                    //fullPath = UrlSaveMediaFile + shortPath;

                    //File.Copy(f, fullPath);

                    //video.Path = shortPath;
                    //video.IsDeleted = false;
                    //BLLVideoLibrary.CreateOrUpdate(video);


                    if (result.IsSuccess)
                    {
                        ResetVideoForm();
                        LoadVideoToGridView();
                    }
                    else
                    {
                        MessageBox.Show(result.Messages[0].msg, result.Messages[0].Title);
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng chọn tệp!.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
        private void btnAddMulti_v_Click(object sender, EventArgs e)
        {
            try
            {
                openVideoFileDialog.Filter      = "Video (*.mp4;*.MP4)" + "All files (*.*)|*.*";
                openVideoFileDialog.Multiselect = true;
                var folderResult = openVideoFileDialog.ShowDialog();
                if (folderResult == DialogResult.OK)
                {
                    var filterStr = "*.mp4,*.mp3";
                    var files     = openVideoFileDialog.FileNames;
                    if (files.Count() > 0)
                    {
                        var dtime = DateTime.Now;
                        int count = 0;
                        foreach (string f in files)
                        {
                            string fullPath = string.Empty;
                            try
                            {
                                var      video   = new P_VideoLibrary();
                                var      fi      = new FileInfo(f);
                                string[] xxx     = f.Split('\\');
                                string   tenFile = xxx[xxx.Length - 1];
                                video.Name = tenFile;
                                string[] yyy  = tenFile.Split('.');
                                string   type = yyy[yyy.Length - 1];
                                tenFile      = tenFile.Replace("." + type, "");
                                video.Type   = fi.Extension;
                                video.Length = 0;
                                video.Size   = fi.Length;

                                var shortPath = (tenFile.Length > 17 ? tenFile.Substring(0, 17) : tenFile) + "_" + dtime.ToString("yyMMddhhmmss") + "." + type;
                                shortPath = convertToUnSign(shortPath);

                                //if (!Directory.Exists(Application.StartupPath + @"\Media"))
                                //    Directory.CreateDirectory(Application.StartupPath + @"\Media");
                                //string fullPath = Application.StartupPath + @"\Media\" + shortPath;

                                if (!Directory.Exists(UrlSaveMediaFile))
                                {
                                    Directory.CreateDirectory(UrlSaveMediaFile);
                                }
                                fullPath = UrlSaveMediaFile + shortPath;

                                File.Copy(f, fullPath);

                                video.Path      = shortPath;
                                video.IsDeleted = false;
                                BLLVideoLibrary.CreateOrUpdate(video);
                                count++;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message + "/n path: " + fullPath + " : " + UrlSaveMediaFile);
                            }
                        }
                        LoadVideoToGridView();
                        MessageBox.Show("Đã thêm " + count + " Tệp video thành công.", "Thông Báo");
                    }
                    else
                    {
                        MessageBox.Show("Không tìm thấy tệp video trong thư mục bạn vừa chọn.", "Thông Báo");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }