Esempio n. 1
0
    //-------------------------------------------------------------------------------------------
    //  Load detailed db fields : export fields to skin as '#myfilms.<ant db column name> 
    //-------------------------------------------------------------------------------------------
    public static void Load_Detailed_DB(int itemId)
    {
      LogMyFilms.Debug("Load_Detailed_DB() - ItemId: '" + itemId + "'");
      var stopwatch = new Stopwatch(); stopwatch.Reset(); stopwatch.Start();
      string wstrformat = "";

      if (MyFilms.r == null || itemId > MyFilms.r.Length - 1)
      {
        LogMyFilms.Warn("Load_Detailed_DB() - Failed loading details - index '" + itemId + "' not within current dataset ... now clearing properties ...");
        Init_Detailed_DB(false);
        return;
      }
      #region always clear person properties in film details ...
      clearGUIProperty("person.name.value");
      clearGUIProperty("person.dateofbirth.value");
      clearGUIProperty("person.placeofbirth.value");
      clearGUIProperty("person.biography.value");
      //clearGUIProperty("person.dateofdeath.value");
      //clearGUIProperty("person.placeofdeath.value");
      //clearGUIProperty("person.movies.value");
      //clearGUIProperty("person.lastupdate.value");
      #endregion

      using (var ds = new AntMovieCatalog())
      {
        foreach (DataColumn dc in ds.Movie.Columns)
        {
          string wstring = "";
          string wstring2 = "";
          //LogMyFilms.Debug("PropertyManager: Set Properties for DB Column '" + dc.ColumnName + "' - '" + BaseMesFilms.Translate_Column(dc.ColumnName) + "'");

          if (MyFilms.r.Length > itemId && MyFilms.r[itemId][dc.ColumnName] != null) // make sure, it is a valid part of current loaded dataset "r"
          {
            #region set userdefined properties for main screen
            if (MyFilms.conf.Stritem1.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item1.label", MyFilms.conf.Strlabel1);
              if (MyFilms.conf.Stritem1.ToLower() == "date")
                setGUIProperty("user.item1.field", "w" + MyFilms.conf.Stritem1.ToLower());
              else
                setGUIProperty("user.item1.field", MyFilms.conf.Stritem1.ToLower());
              setGUIProperty("user.item1.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.Stritem2.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item2.label", MyFilms.conf.Strlabel2);
              if (MyFilms.conf.Stritem2.ToLower() == "date")
                setGUIProperty("user.item2.field", "w" + MyFilms.conf.Stritem2.ToLower());
              else
                setGUIProperty("user.item2.field", MyFilms.conf.Stritem2.ToLower());
              setGUIProperty("user.item2.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.Stritem3.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item3.label", MyFilms.conf.Strlabel3);
              if (MyFilms.conf.Stritem3.ToLower() == "date")
                setGUIProperty("user.item3.field", "w" + MyFilms.conf.Stritem3.ToLower());
              else
                setGUIProperty("user.item3.field", MyFilms.conf.Stritem3.ToLower());
              setGUIProperty("user.item3.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.Stritem4.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item4.label", MyFilms.conf.Strlabel4);
              if (MyFilms.conf.Stritem4.ToLower() == "date")
                setGUIProperty("user.item4.field", "w" + MyFilms.conf.Stritem4.ToLower());
              else
                setGUIProperty("user.item4.field", MyFilms.conf.Stritem4.ToLower());
              setGUIProperty("user.item4.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.Stritem5.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.item5.label", MyFilms.conf.Strlabel5);
              if (MyFilms.conf.Stritem5.ToLower() == "date")
                setGUIProperty("user.item5.field", "w" + MyFilms.conf.Stritem5.ToLower());
              else
                setGUIProperty("user.item5.field", MyFilms.conf.Stritem5.ToLower());
              setGUIProperty("user.item5.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            #endregion

            #region set userdefined properties for details screen
            if (MyFilms.conf.StritemDetails1.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem1.label", MyFilms.conf.StrlabelDetails1);
              if (MyFilms.conf.StritemDetails1.ToLower() == "date")
                setGUIProperty("user.detailsitem1.field", "w" + MyFilms.conf.StritemDetails1.ToLower());
              else
                setGUIProperty("user.detailsitem1.field", MyFilms.conf.StritemDetails1.ToLower());
              setGUIProperty("user.detailsitem1.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails2.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem2.label", MyFilms.conf.StrlabelDetails2);
              if (MyFilms.conf.Stritem2.ToLower() == "date")
                setGUIProperty("user.detailsitem2.field", "w" + MyFilms.conf.StritemDetails2.ToLower());
              else
                setGUIProperty("user.detailsitem2.field", MyFilms.conf.StritemDetails2.ToLower());
              setGUIProperty("user.detailsitem2.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails3.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem3.label", MyFilms.conf.StrlabelDetails3);
              if (MyFilms.conf.Stritem3.ToLower() == "date")
                setGUIProperty("user.detailsitem3.field", "w" + MyFilms.conf.StritemDetails3.ToLower());
              else
                setGUIProperty("user.detailsitem3.field", MyFilms.conf.StritemDetails3.ToLower());
              setGUIProperty("user.detailsitem3.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails4.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem4.label", MyFilms.conf.StrlabelDetails4);
              if (MyFilms.conf.Stritem4.ToLower() == "date")
                setGUIProperty("user.detailsitem4.field", "w" + MyFilms.conf.StritemDetails4.ToLower());
              else
                setGUIProperty("user.detailsitem4.field", MyFilms.conf.StritemDetails4.ToLower());
              setGUIProperty("user.detailsitem4.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails5.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem5.label", MyFilms.conf.StrlabelDetails5);
              if (MyFilms.conf.Stritem5.ToLower() == "date")
                setGUIProperty("user.detailsitem5.field", "w" + MyFilms.conf.StritemDetails5.ToLower());
              else
                setGUIProperty("user.detailsitem5.field", MyFilms.conf.StritemDetails5.ToLower());
              setGUIProperty("user.detailsitem5.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            if (MyFilms.conf.StritemDetails6.ToLower() == (dc.ColumnName.ToLower()))
            {
              setGUIProperty("user.detailsitem6.label", MyFilms.conf.StrlabelDetails6);
              if (MyFilms.conf.Stritem5.ToLower() == "date")
                setGUIProperty("user.detailsitem6.field", "w" + MyFilms.conf.StritemDetails6.ToLower());
              else
                setGUIProperty("user.detailsitem6.field", MyFilms.conf.StritemDetails6.ToLower());
              setGUIProperty("user.detailsitem6.value", MyFilms.r[itemId][dc.ColumnName].ToString());
            }
            #endregion

            #region set userdefined watched and rating field
            if (MyFilms.conf.StrWatchedField.ToLower() == dc.ColumnName.ToLower())
            {
              if (MyFilms.conf.EnhancedWatchedStatusHandling)
              {
                var userData = new MultiUserData(MyFilms.r[itemId][BaseMesFilms.MultiUserStateField].ToString());
                UserState user = userData.GetUserState(MyFilms.conf.StrUserProfileName);
                setGUIProperty("user.watched.value", user.WatchedCount > 0 ? "true" : "");
                setGUIProperty("user.watcheddate.value", (user.WatchedCount > 0 && user.WatchedDate > MultiUserData.NoWatchedDate) ? user.WatchedDate.ToShortDateString() : "");
                setGUIProperty("user.watchedcount.value", user.WatchedCount.ToString());
                setGUIProperty("user.name.value", (user.UserName != MyFilms.DefaultUsername) ? user.UserName : "");
                setGUIProperty("user.watchedcountglobal.value", userData.GetGlobalState().WatchedCount.ToString());
                setGUIProperty("user.rating.value", (user.UserRating > MultiUserData.NoRating) ? Math.Round(user.UserRating, 1).ToString() : "");
              }
              else
              {
                setGUIProperty("user.name.value", "");
                setGUIProperty("user.watched.value", MyFilms.r[itemId][dc.ColumnName].ToString().ToLower() != MyFilms.conf.GlobalUnwatchedOnlyValue.ToLower() ? "true" : "");
                decimal userRating = MultiUserData.NoRating;
                if (MyFilms.r[itemId]["RatingUser"].ToString().Length > 0)
                {
                  if (!(decimal.TryParse(MyFilms.r[itemId]["RatingUser"].ToString(), out userRating))) userRating = MultiUserData.NoRating;
                }
                setGUIProperty("user.rating.value", (userRating > MultiUserData.NoRating) ? Math.Round(userRating, 1).ToString() : "");
              }
            }
            #endregion

            #region set userdefined source and sourcetrailer
            if (MyFilms.conf.StrStorage.ToLower() == dc.ColumnName.ToLower())
            {
              string sourceFull = MyFilms.r[itemId][dc.ColumnName].ToString();
              string name = "";
              string path = "";
              string longname = "";
              string count = "";
              setGUIProperty("user.source.value", sourceFull);
              MyFilms.currentMovie.File = sourceFull;
              if (!string.IsNullOrEmpty(sourceFull.Trim()))
              {
                string[] split = sourceFull.Trim().Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                count = split.Count().ToString();
                foreach (string s in split.Select(x => x.Trim()).Where(x => x.LastIndexOf("\\", StringComparison.Ordinal) > 0))
                {
                  if (name.Length > 0) name += "; ";
                  name += s.Substring(s.LastIndexOf("\\", System.StringComparison.Ordinal) + 1);
                  if (path.Length > 0) path += "; ";
                  path += s.Substring(0, s.LastIndexOf("\\", System.StringComparison.Ordinal));
                  if (longname.Length > 0) longname += "; ";
                  string temppath = s.Substring(0, s.LastIndexOf("\\", System.StringComparison.Ordinal));
                  longname += (temppath.LastIndexOf("\\", System.StringComparison.Ordinal) > 0) ? temppath.Substring(temppath.LastIndexOf("\\", System.StringComparison.Ordinal) + 1) + "\\" + name : s;
                }
              }
              setGUIProperty("user.source.count", count);
              setGUIProperty("user.source.filepath", path);
              setGUIProperty("user.source.filename", name);
              setGUIProperty("user.source.shortname", longname);
            }

            if (MyFilms.conf.StrStorageTrailer.ToLower() == dc.ColumnName.ToLower())
            {
              string sourceFull = MyFilms.r[itemId][dc.ColumnName].ToString();
              string name = "";
              string path = "";
              string longname = "";
              string count = "";
              setGUIProperty("user.sourcetrailer.value", sourceFull);
              MyFilms.currentMovie.Trailer = sourceFull;
              if (!string.IsNullOrEmpty(sourceFull.Trim()))
              {
                string[] split = sourceFull.Trim().Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                count = split.Count().ToString();
                foreach (string s in split.Select(x => x.Trim()).Where(x => x.LastIndexOf("\\", StringComparison.Ordinal) > 0))
                {
                  if (name.Length > 0) name += "; ";
                  name += s.Substring(s.LastIndexOf("\\", System.StringComparison.Ordinal) + 1);
                  if (path.Length > 0) path += "; ";
                  path += s.Substring(0, s.LastIndexOf("\\", System.StringComparison.Ordinal));
                  if (longname.Length > 0) longname += "; ";
                  string temppath = s.Substring(0, s.LastIndexOf("\\", System.StringComparison.Ordinal));
                  longname += (temppath.LastIndexOf("\\", System.StringComparison.Ordinal) > 0) ? temppath.Substring(temppath.LastIndexOf("\\", System.StringComparison.Ordinal) + 1) + "\\" + name : s;
                }
              }
              setGUIProperty("user.sourcetrailer.count", count);
              setGUIProperty("user.sourcetrailer.filepath", path);
              setGUIProperty("user.sourcetrailer.filename", name);
              setGUIProperty("user.sourcetrailer.shortname", longname);
            }
            #endregion

            #region set all db fields ...
            switch (dc.ColumnName.ToLower())
            {
              case "translatedtitle":
              case "originaltitle":
              case "formattedtitle":
                #region titles
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  if (MyFilms.r[itemId][dc.ColumnName].ToString().Contains(MyFilms.conf.TitleDelim))
                  {
                    wstring = MyFilms.r[itemId][dc.ColumnName].ToString().Substring(MyFilms.r[itemId][dc.ColumnName].ToString().LastIndexOf(MyFilms.conf.TitleDelim) + 1);
                    wstring2 = MyFilms.r[itemId][dc.ColumnName].ToString().Substring(0, MyFilms.r[itemId][dc.ColumnName].ToString().LastIndexOf(MyFilms.conf.TitleDelim));
                  }
                  else
                  {
                    wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                    wstring2 = "";
                  }

                if (MyFilms.conf.StrTitle1.ToLower() == (dc.ColumnName.ToLower()))
                {
                  setGUIProperty("user.mastertitle.value", wstring);
                  setGUIProperty("user.mastertitle.groupname", wstring2);
                }
                if (MyFilms.conf.StrTitle2.ToLower() == (dc.ColumnName.ToLower()))
                {
                  setGUIProperty("user.secondarytitle.value", wstring);
                  setGUIProperty("user.secondarytitle.groupname", wstring2);
                }
                #endregion
                break;
              case "length":
                #region length
                int length = 0;
                if (MyFilms.r[itemId]["Length"].ToString().Length > 0) wstring = MyFilms.r[itemId]["Length"].ToString();
                setGUIProperty("db.length.value", wstring);
                bool success = int.TryParse(wstring, out length);
                MyFilms.currentMovie.Length = (success) ? length : 0;
                break;
                #endregion
              case "actors":
                #region actors
                if (MyFilms.r[itemId]["Actors"].ToString().Length > 0)
                {
                  wstring = MyFilms.r[itemId]["Actors"].ToString().Replace('|', '\n');
                  wstring = System.Web.HttpUtility.HtmlDecode(MediaPortal.Util.HTMLParser.removeHtml(wstring));

                  //IEnumerable<DbPersonInfo> persons = MyFilms.Search_String_Persons(wstring, false);
                  //foreach (DbPersonInfo t in persons)
                  //{
                  //  MyFilms.currentMovie.Actors.Add(t.Name);
                  //}
                }
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                Load_Detailed_DB_PushActorsToSkin(wstring);
                break;
                #endregion
              case "director":
              case "producer":
              case "writer":
                //wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                //if (wstring.Length > 0)
                //{
                //  wstring = System.Web.HttpUtility.HtmlDecode(MediaPortal.Util.HTMLParser.removeHtml(wstring));
                //  IEnumerable<DbPersonInfo> persons = MyFilms.Search_String_Persons(wstring, false);
                //  foreach (DbPersonInfo t in persons)
                //  {
                //    switch (dc.ColumnName.ToLower())
                //    {
                //      case "director":
                //        MyFilms.currentMovie.Directors.Add(t.Name);
                //        break;
                //      case "producer":
                //        MyFilms.currentMovie.Producers.Add(t.Name);
                //        break;
                //      case "writer":
                //        MyFilms.currentMovie.Writers.Add(t.Name);
                //        break;
                //    }
                //  }
                //}
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "");
                break;
              
              case "description":
              case "comments":
                #region description & comment
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                {
                  wstring = System.Web.HttpUtility.HtmlEncode(MyFilms.r[itemId][dc.ColumnName].ToString().Replace('’', '\''));
                  wstring = wstring.Replace('|', '\n').Replace('…', '.');
                  wstring = System.Web.HttpUtility.HtmlDecode(MediaPortal.Util.HTMLParser.removeHtml(wstring));
                }
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                break;
                #endregion
              case "date":
                #region date
                if (MyFilms.r[itemId]["Date"].ToString().Length > 0)
                  wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                break;
                #endregion
              case "videoformat":
                #region videoformat
                if (MyFilms.r[itemId]["VideoFormat"].ToString().Length > 0)
                  wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                wstrformat = "V:" + MyFilms.r[itemId]["VideoFormat"].ToString();
                break;
                #endregion
              case "audioformat":
                #region audioformat
                if (MyFilms.r[itemId]["AudioFormat"].ToString().Length > 0)
                {
                  wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                  if (wstrformat.Length > 1)
                    wstrformat = wstrformat + ", A:" + MyFilms.r[itemId]["AudioFormat"].ToString();
                  else
                    wstrformat = "A:" + MyFilms.r[itemId]["AudioFormat"].ToString();
                }
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                setGUIProperty("db.calc.format" + ".value", wstrformat);
                break;
                #endregion
              case "rating":
              case "ratinguser":
                #region rating
                wstring = "";
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                //try { MyFilms.conf.W_rating = (decimal)MyFilms.r[ItemId][dc.ColumnName]; }
                //catch { MyFilms.conf.W_rating = 0; }
                try
                {
                  wstring = ((decimal)MyFilms.r[itemId][dc.ColumnName]).ToString("0.0");
                }
                catch
                {
                  wstring = "";
                }
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                break;
                #endregion

              // fields to skip (do not publish)
              case "contents_id":
              case "dateadded":
              case "picture":
              case "watched":
                break;
              case "fanart":
                if (MyFilms.currentMovie.Fanart.Length == 0 && MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  MyFilms.currentMovie.Fanart = MyFilms.r[itemId][dc.ColumnName].ToString();
                break;
              case "imdb_id":
                #region imdb_id
                MyFilms.currentMovie.IMDBNumber = MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "";
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "");
                break;
                #endregion
              case "isonline":
                #region set online status
                if (MyFilms.InitialIsOnlineScan) // if availability scanner did run - either by autostart or manually
                {
                  if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  {
                    switch (MyFilms.r[itemId][dc.ColumnName].ToString())
                    {
                      case "True":
                        setGUIProperty("user.source.isonline", "available");
                        break;
                      case "False":
                        if (Helper.FieldIsSet(MyFilms.conf.StrStorage)) // if there is source field set
                        {
                          setGUIProperty("user.source.isonline", MyFilms.r[itemId][MyFilms.conf.StrStorage].ToString().Length > 0
                                                                   ? "offline"
                                                                   : "unavailable");
                        }
                        else
                          setGUIProperty("user.source.isonline", "unavailable");
                        break;
                    }
                  }
                  else
                    setGUIProperty("user.source.isonline", "unknown"); // should not happen, if scanner did run ...
                }
                else
                {
                  if (Helper.FieldIsSet(MyFilms.conf.StrStorage)) // if there is source field set
                  {
                    if (MyFilms.r[itemId][MyFilms.conf.StrStorage].ToString().Length > 0) // if there is source info available ...
                    {
                      setGUIProperty("user.source.isonline", MyFilms.conf.ScanMediaOnStart ? "unknown" : "available");
                    }
                    else
                      setGUIProperty("user.source.isonline", "unavailable");
                  }
                  else if (MyFilms.conf.SearchFile.ToLower() == "true" || MyFilms.conf.SearchFile.ToLower() == "yes") // if search is enabled in setup
                    setGUIProperty("user.source.isonline", "unknown");
                  else
                    setGUIProperty("user.source.isonline", "unavailable");
                }
                break;
                #endregion
              case "isonlinetrailer":
                #region set trailer online status
                if (MyFilms.InitialIsOnlineScan)
                {
                  if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  {
                    if (MyFilms.r[itemId][dc.ColumnName].ToString() == "True")
                      setGUIProperty("user.sourcetrailer.isonline", "available");
                    else
                    {
                      if (Helper.FieldIsSet(MyFilms.conf.StrStorageTrailer))
                      {
                        setGUIProperty("user.sourcetrailer.isonline", MyFilms.r[itemId][MyFilms.conf.StrStorageTrailer].ToString().Length > 0
                            ? "offline"
                            : "unavailable");
                      }
                      else
                        setGUIProperty("user.sourcetrailer.isonline", "unavailable");
                    }
                  }
                  else
                    setGUIProperty("user.sourcetrailer.isonline", "unknown"); // should not happen, if scanner did run ...
                }
                else
                {
                  if (Helper.FieldIsSet(MyFilms.conf.StrStorageTrailer))
                  {
                    if (MyFilms.r[itemId][MyFilms.conf.StrStorageTrailer].ToString().Length > 0)
                    {
                      setGUIProperty("user.sourcetrailer.isonline", MyFilms.conf.ScanMediaOnStart
                        ? "unknown"
                        : "available");
                    }
                    else
                      setGUIProperty("user.sourcetrailer.isonline", "unavailable");
                  }
                  //else if (MyFilms.conf.SearchFileTrailer.ToLower() == "true" || MyFilms.conf.SearchFileTrailer.ToLower() == "yes") // if search is enabled in setup
                  //  setGUIProperty("user.sourcetrailer.isonline", "unknown");
                  else
                    setGUIProperty("user.sourcetrailer.isonline", "unavailable");
                }
                break;
                #endregion
              case "resolution":
                #region set calculated aspectratio and image format
                string ar = "";
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                  try
                  {
                    decimal aspectratio;
                    wstring = MyFilms.r[itemId][dc.ColumnName].ToString();
                    setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                    if (!Decimal.TryParse(MyFilms.r[itemId]["Aspectratio"].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out aspectratio)) // if no media info data available, calculate data from video resolution - might not be exact DAR (display aspect ratio) // if (!Decimal.TryParse(MyFilms.r[itemId]["Aspectratio"].ToString().Replace(".", CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator).Replace(",", CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator), out aspectratio)) // if no media info data available, calculate data from video resolution - might not be exact DAR (display aspect ratio)
                    {
                      string[] arSplit = wstring.Split(new string[] { "x" }, StringSplitOptions.RemoveEmptyEntries);
                      aspectratio = Math.Round(decimal.Divide(Convert.ToInt32(arSplit[0]), Convert.ToInt32(arSplit[1])), 2);
                    }
                    //Formats:
                    //1,33 -> 4:3
                    //1,78 -> 16:9 / widescreen
                    //1,85 -> widescreen
                    //2,35+ -> cinemascope
                    if (aspectratio < (decimal)(1.4)) ar = "4:3";
                    else if (aspectratio < (decimal)(1.9)) ar = "16:9";
                    else if (aspectratio >= (decimal)(1.9)) ar = "cinemascope";
                    wstring = aspectratio.ToString(CultureInfo.InstalledUICulture);
                  }
                  catch { LogMyFilms.Info("Error calculating aspectratio !"); }
                setGUIProperty("db.calc.aspectratio.value", wstring);
                setGUIProperty("db.calc.imageformat.value", ar);
                break;
                #endregion
              case "certification":
                #region set cleaned certification for logos
                wstring = MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "";
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", wstring);
                wstring = Regex.Replace(wstring, @"\(|\)", ""); // strip ( and )
                wstring = Regex.Replace(wstring, @"^.*\s", ""); // strip start until forst white char
                setGUIProperty("db.certification.logo.value", wstring.Trim());
                break;
                #endregion
              case "year":
                #region year
                if (MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0)
                {
                  int year = 0;
                  setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", MyFilms.r[itemId][dc.ColumnName].ToString());
                  Int32.TryParse(MyFilms.r[itemId][dc.ColumnName].ToString(), out year);
                  MyFilms.currentMovie.Year = year;
                }

                else
                {
                  setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", "");
                  MyFilms.currentMovie.Year = 0;
                }
                break;
                #endregion

              default:
                setGUIProperty("db." + dc.ColumnName.ToLower() + ".value", MyFilms.r[itemId][dc.ColumnName].ToString().Length > 0 ? MyFilms.r[itemId][dc.ColumnName].ToString() : "");
                break;

            }
            #endregion
          }
        }
      }
      //// for catalog using "search" instead storage field
      //if (string.IsNullOrEmpty(MyFilms.currentMovie.File)) // use search method only if required...
      //{
      //  if ((MyFilms.conf.SearchFile == "True") || (MyFilms.conf.SearchFile == "yes"))
      //  {
      //    string movieName = MyFilms.r[ItemId][MyFilms.conf.ItemSearchFile].ToString();
      //    movieName = movieName.Substring(movieName.LastIndexOf(MyFilms.conf.TitleDelim) + 1).Trim();
      //    if (MyFilms.conf.ItemSearchFile.Length > 0)
      //    {
      //      MyFilms.currentMovie.File = Search_FileName(movieName, MyFilms.conf.StrDirStor).Trim();
      //    }
      //  }
      //}

      stopwatch.Stop();
      LogMyFilms.Debug("Load_Detailed_DB() - load details finished (" + stopwatch.ElapsedMilliseconds + " ms).");
    }
Esempio n. 2
0
 private static void SyncMusToExtendedFields(DataRow row, MultiUserData userData, string userprofilename)
 {
   row["DateWatched"] = (userData.GetUserState(userprofilename).WatchedDate == MultiUserData.NoWatchedDate || userData.GetUserState(MyFilms.conf.StrUserProfileName).Watched == false) ? Convert.DBNull : userData.GetUserState(userprofilename).WatchedDate;
   row["RatingUser"] = (userData.GetUserState(userprofilename).UserRating == -1) ? Convert.DBNull : userData.GetUserState(userprofilename).UserRating;
   row[MyFilms.conf.StrWatchedField] = userData.GetUserState(userprofilename).Watched ? "true" : MyFilms.conf.GlobalUnwatchedOnlyValue.ToLower();
   // row["LastPosition"] = (userData.GetUserState(userprofilename).ResumeData == -1) ? Convert.DBNull : userData.GetUserState(userprofilename).ResumeData;
   //if (MyFilms.conf.StrUserProfileName.Length > 0 && row["RatingUser"] != System.Convert.DBNull && row["RatingUser"] != MultiUserData.NoRating)
   //{
   //  string newValue = (row["RatingUser"] > MultiUserData.FavoriteRating) ? MultiUserData.Add(row["Favorite"].ToString(), MyFilms.conf.StrUserProfileName) : MultiUserData.Remove(row["Favorite"].ToString(), MyFilms.conf.StrUserProfileName);
   //  row["Favorite"] = (string.IsNullOrEmpty(newValue)) ? Convert.DBNull : newValue;
   //}
 }