public static List<MovieMaker> GetMatchData(string myText, List<MovieMaker> myListMakers, MovieFileContents myFileContents) { List<MovieMaker> listMatchMaker = null; // 品番っぽい文字列が存在する場合 //if (myFileContents.Kind == MovieFileContents.KIND_AVRIP) if (myFileContents.ProductNumber != null && myFileContents.ProductNumber.Length > 0) { string[] label = myFileContents.ProductNumber.Split('-'); var matchdata = from makerdata in myListMakers where makerdata.MatchStr.ToUpper() == label[0].ToUpper() // + '-' && makerdata.MatchProductNumber.Length <= 0 select makerdata; if (matchdata.Count() > 0) { listMatchMaker = new List<MovieMaker>(); foreach (MovieMaker m in matchdata) listMatchMaker.Add(m); } } // 品番っぽいのが無い場合は、品番一致文字列があるタイトルと一致 if (listMatchMaker == null || listMatchMaker.Count() <= 0) { foreach(MovieMaker makerdata in myListMakers) { if (makerdata.MatchProductNumber.Length <= 0) continue; Regex regex = new Regex(makerdata.MatchStr, RegexOptions.IgnoreCase); if (regex.IsMatch(myText)) { try { Regex regexPN = new Regex(makerdata.MatchProductNumber); if (regexPN.IsMatch(myText)) { makerdata.MatchProductNumberValue = regexPN.Match(myText).Value; if (listMatchMaker == null) listMatchMaker = new List<MovieMaker>(); listMatchMaker.Add(makerdata); } } catch (ArgumentException) { throw new Exception("正規表現が不正です\n" + makerdata.Name + "\n" + makerdata.MatchProductNumber); } } } } return listMatchMaker; }
public void ParseFromFileName(MovieFileContents myFile) { if (myFile.Name.IndexOf("[AVRIP]") == 0) Kind = MovieFileContents.KIND_AVRIP; else if (myFile.Name.IndexOf("[IVRIP]") == 0) Kind = MovieFileContents.KIND_IVRIP; else if (myFile.Name.IndexOf("[裏AVRIP]") == 0) Kind = MovieFileContents.KIND_URAAVRIP; Regex regex = new Regex("【(.*)】"); if (regex.IsMatch(myFile.Name)) { string work = regex.Match(myFile.Name).Groups[1].Value.ToString(); string[] arrSplitStr = {":"}; string[] arrMakerNames = work.Split(arrSplitStr, StringSplitOptions.None); if (arrMakerNames.Length >= 2) { Name = arrMakerNames[0]; Label = arrMakerNames[1]; } else Name = work; } }
public static MovieMaker GetSearchByProductNumber(string myProductNumber) { DbConnection dbcon = new DbConnection(); if (myProductNumber == null) myProductNumber = ""; string[] product = myProductNumber.Split('-'); List<MovieFileContents> listMContents = new List<MovieFileContents>(); string queryString = "SELECT ID, NAME, SIZE, FILE_DATE, LABEL, SELL_DATE, PRODUCT_NUMBER FROM MOVIE_FILES WHERE PRODUCT_NUMBER LIKE @pProduct ORDER BY FILE_DATE DESC "; dbcon.openConnection(); SqlCommand command = new SqlCommand(queryString, dbcon.getSqlConnection()); SqlParameter param = new SqlParameter("@pProduct", SqlDbType.VarChar); param.Value = product[0] + "-%"; command.Parameters.Add(param); SqlDataReader reader = command.ExecuteReader(); do { while (reader.Read()) { MovieFileContents data = new MovieFileContents(); data.Id = DbExportCommon.GetDbInt(reader, 0); data.Name = DbExportCommon.GetDbString(reader, 1); data.Size = DbExportCommon.GetLong(reader, 2); data.FileDate = DbExportCommon.GetDbDateTime(reader, 3); data.Label = DbExportCommon.GetDbString(reader, 4); data.SellDate = DbExportCommon.GetDbDateTime(reader, 5); data.ProductNumber = DbExportCommon.GetDbString(reader, 6); listMContents.Add(data); } } while (reader.NextResult()); reader.Close(); dbcon.closeConnection(); MovieMaker maker = null; foreach(MovieFileContents data in listMContents) { maker = new MovieMaker(); maker.ParseFromFileName(data); break; } return maker; }
public void SetDbMovieFilesInfo() { DatabaseMovieFile = new MovieFileContents(); DatabaseMovieFile.Name = DestFilename; DatabaseMovieFile.Label = LabelPath; foreach (string ext in listExtension) { if (ext.ToUpper().Equals(".JPG") || ext.ToUpper().Equals(".JPEG") || ext.ToUpper().Equals(".PNG") || ext.ToUpper().Equals(".ISO")) continue; // 動画ファイルが複数合った場合に後ろに付加する「_1」などのために名前順に並べ替える var dataMatch = from seldata in listSelectedFiles where seldata.FileInfo.Extension == ext orderby seldata.Name ascending select seldata; DatabaseMovieFile.Extension = ext.Replace(".", "").ToUpper(); DatabaseMovieFile.FileCount = dataMatch.Count(); if (dataMatch.Count() == 1) { foreach (TargetFiles sel in dataMatch) { DatabaseMovieFile.Size = sel.FileInfo.Length; DatabaseMovieFile.FileDate = sel.FileInfo.LastWriteTime; } } else { long size = 0; foreach (TargetFiles sel in dataMatch) { size += sel.FileInfo.Length; DatabaseMovieFile.FileDate = sel.FileInfo.LastWriteTime; } DatabaseMovieFile.Size = size; } } // 品番、販売日を設定 DatabaseMovieFile.Parse(); }