예제 #1
0
        /// <summary>
        /// 增加Genre类别到NFO文件中。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAddGenre_Click(object sender, EventArgs e)
        {
            if (this.cbGenre.Text.Length > 0)
            {
                string[] dirs = Directory.GetFiles(currentFilePath, "*.nfo");
                FuncNFO  nfo  = new FuncNFO();
                //bool boolGenreQuality=false;

                if (dirs.Length > 0)
                {
                    List <string> lsTags = nfo.GetTags(dirs[0]);
                    //string zh=  lsTags.Where(s => s.Substring(2, 4) == "中文字幕").FirstOrDefault();
                    //string gq = lsTags.Where(s => s.Substring(2, 2) == "高清").FirstOrDefault();

                    //判断某字符串在集合中是否存在,存在就跳出。
                    foreach (string item in lsTags)
                    {
                        if ("Ge" + this.cbGenre.Text == item)
                        {
                            return;
                        }

                        //if (this.cbGenre.Text.Contains("清") && item.Contains("清"))
                        //{
                        //    boolGenreQuality = true;
                        //}
                    }


                    //更新到数据库中。
                    TblNumDal numDal = new TblNumDal();
                    numDal.UpdateGenre(this.cbGenre.Text, _numID);
                    //重新加载。
                    ViMovieNumDal vi = new ViMovieNumDal();
                    LoadData(vi.Select("select * from viMovieNum"));


                    //添加到NFO文件中。
                    foreach (string item in dirs)
                    {
                        nfo.AddGenre(item, this.cbGenre.Text);
                    }



                    MessageBox.Show("添加成功。");
                }
                else
                {
                    MessageBox.Show("未找到有效的NFO文件。");
                }
            }
            else
            {
                MessageBox.Show("Genre不能为空值。");
            }
        }
예제 #2
0
        /// <summary>
        /// 显示NFO文件中的Genre与Actor。动态生成label与动态清除label。
        /// </summary>
        private void ShowNfoTag()
        {
            try
            {
                FuncNFO  nfo  = new FuncNFO();
                string[] dirs = Directory.GetFiles(currentFilePath, "*.nfo");
                //this.lblTag.Text = null;

                //下面这种遍历的方式,由于控件的位置发生了变化,无法清除干净。
                //foreach (Control cc in this.gbNfo.Controls)
                //{
                //    gbNfo.Controls.Remove(cc);
                //    cc.Dispose();
                //}

                this.gbNfo.Controls.Clear();

                if (dirs != null)
                {
                    if (dirs.Length > 0)
                    {
                        List <string> list = nfo.GetTags(dirs[0]);
                        List <Label>  lbs  = new List <Label>();
                        for (int i = 0; i < list.Count; i++)
                        {
                            //this.lblTag.Text += list[i] + ";";
                            lbs.Add(new Label());
                            lbs[i].Name = "lbTag" + i;
                            lbs[i].Text = list[i];
                            if (lbs[i].Text == "Ge中文字幕")
                            {
                                lbs[i].ForeColor = Color.ForestGreen;
                            }
                            else
                            {
                                lbs[i].ForeColor = Color.Red;
                            }

                            lbs[i].Size = new Size(70, 15);
                            if (i <= 5)
                            {
                                lbs[i].Location = new Point(i * 70 + 10, 15);
                            }
                            else if (i <= 10)
                            {
                                lbs[i].Location = new Point((i - 6) * 70 + 10, 30);
                            }
                            else if (i <= 15)
                            {
                                lbs[i].Location = new Point((i - 11) * 70 + 10, 45);
                            }
                            else
                            {
                                lbs[i].Location = new Point((i - 16) * 70 + 10, 60);
                            }


                            this.gbNfo.Controls.Add(lbs[i]);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
예제 #3
0
        /// <summary>
        /// 通过读取文件夹内NFO文件,将相关节点写入tblNum表中。
        /// </summary>
        /// <param name="sqlNumXmlScan">获得tblNum表中待扫描(1)的数据。</param>
        private static void UpdateTblNumNode(string sqlNumXmlScan)
        {
            //获得数据
            List <TblNum> listRead = new List <TblNum>();

            using (SQLiteDataReader reader = SqliteHelper.ExecuteReader(sqlNumXmlScan))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        TblNum model = new TblNum
                        {
                            Num_ID   = reader.GetInt32(0),
                            NumIndex = reader["numIndex"].ToString(),
                            SubTitle = reader["subTitle"].ToString(),
                            Quality  = reader["quality"].ToString(),
                            Actors   = reader["actors"].ToString(),
                            FilePath = reader["filePath"].ToString(),
                            XmlScan  = reader.GetInt32(6)
                        };
                        listRead.Add(model);
                    }
                }
            }


            for (int i = 0; i < listRead.Count; i++)
            {
                //其次,扫描FilePath下面的NFO文件,提取相关的节点值。
                FuncNFO nfo = new FuncNFO();

                string[]      nfoFiles = Directory.GetFiles(listRead[i].FilePath, "*.nfo");
                List <string> liTags   = nfo.GetTags(nfoFiles[0]);
                TblNum        model    = listRead[i];

                foreach (string tag in liTags)
                {
                    if (tag.Substring(0, 2) == "Ge")
                    {
                        if (tag == "Ge中文字幕")
                        {
                            model.SubTitle = tag.Replace("Ge", "");
                        }
                    }
                    else
                    {
                        model.Actors += tag + ",";
                    }
                }
                //数据库更新操作。
                string sqlUpdate = "update tblNum set subTitle=@subTitle,actors=@actors,xmlScan=0 where num_ID=@id";
                SqliteHelper.ExecuteNonQuery(sqlUpdate, new SQLiteParameter[] {
                    new SQLiteParameter("@subTitle", System.Data.DbType.String, 10)
                    {
                        Value = model.SubTitle
                    },
                    new SQLiteParameter("@actors", System.Data.DbType.String, 600)
                    {
                        Value = model.Actors.Substring(0, model.Actors.Length - 1)
                    },
                    new SQLiteParameter("@id", System.Data.DbType.Int32)
                    {
                        Value = model.Num_ID
                    }
                });
            }
        }