[fixed] Grouping of Channels won't work (1 Viewer)

ramu

Portal Pro
July 15, 2008
190
7
Hello,

there is a error in grouping channels in TV Setup. I have a DVB-S and DVB-S AT group created in MP. When trying to add channels to the group named DVB-S the selected channel goes to the group DVB-S AT the group I created earlier and NOT to the group DVB-S which I chose???

So I belive the methode MP edit channels to the groups is not excact enough, perhaps MP looks for the first channelgroup with an name nearby the name to add or MP can not work with blank lines...

Please have a look to the adding methode, it causes problems by group names which are nearly identcal or the first part is the same like this example.

Thx ramu
 
Last edited by a moderator:

HomeY

Test Group
  • Team MediaPortal
  • February 23, 2008
    6,475
    4,645
    47
    ::1
    Home Country
    Netherlands Netherlands
    Hi Ramu,

    TNX for reporting this. I've tested this and i can confirm the problem. I'm sure i've seen this issue before but somehow it slipped through the net :)
    @gibman or @mm1352000 any thoughts on this?

    Before this gets lost again, i'll create a mantis issue about it.

    0004046: TV-Server Adding TV Channels to similar named groups results in TV channel added to wrong group
     

    ramu

    Portal Pro
    July 15, 2008
    190
    7
    Hi HomeY,

    thx, perhaps it was me talking abiut that error in a differnt thread..

    I'm not quite sure, could the error be in this code ? I guess it's the TvBusinessLayer.addChanneTogroup methode...

    ramu

    private void AddSelectedItemsToGroup(MPListView sourceListView)
    {
    if (_channelGroup == null)
    {
    return;
    }

    TvBusinessLayer layer = new TvBusinessLayer();
    foreach (ListViewItem sourceItem in sourceListView.SelectedItems)
    {
    Channel channel = null;
    if (sourceItem.Tag is Channel)
    {
    channel = (Channel)sourceItem.Tag;
    }
    else if (sourceItem.Tag is GroupMap)
    {
    channel = layer.GetChannel(((GroupMap)sourceItem.Tag).IdChannel);
    }
    else
    {
    continue;
    }

    GroupMap groupMap = null;

    layer.AddChannelToGroup(channel, _channelGroup);

    //get the new group map and set the listitem tag
    SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (GroupMap));

    sb.AddConstraint(Operator.Equals, "idChannel", channel.IdChannel);
    sb.AddConstraint(Operator.Equals, "idGroup", _channelGroup.IdGroup);

    SqlStatement stmt = sb.GetStatement(true);

    groupMap = ObjectFactory.GetInstance<GroupMap>(stmt.Execute());

    foreach (ListViewItem item in listView1.Items)
    {
    if ((item.Tag as Channel) == channel)
    {
    item.Tag = groupMap;
    break;
    }
    }
    }
    }
     

    HomeY

    Test Group
  • Team MediaPortal
  • February 23, 2008
    6,475
    4,645
    47
    ::1
    Home Country
    Netherlands Netherlands
    Nah, i've talked about this with another team member, and we both confirmed the issue a few weeks ago, but somehow it wasn't added to mantis yet.
    Not sure about the code, 1 of our developers will need to look into this ;)
     

    HomeY

    Test Group
  • Team MediaPortal
  • February 23, 2008
    6,475
    4,645
    47
    ::1
    Home Country
    Netherlands Netherlands
    Wow, so you found this issue already in February.... The strange thing is that i only have this bug on 1.3Alpha release, and not on the v1.2.3 Final version. So maybe things got fixed after the v1.2.2 version and got broken again?

    Let's wait and see what our developers have to say about it. I'm sure @mm1352000 or @gibman will get the notice :)
     
    Last edited:

    mm1352000

    Development Group
  • Team MediaPortal
  • September 1, 2008
    21,577
    8,223
    Home Country
    New Zealand New Zealand
    Hello everyone

    I think there is a better solution - just remove the '%' from the like match:
    Code:
        public ChannelGroup CreateGroup(string groupName)
        {
          SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelGroup));
          [B]sb.AddConstraint(Operator.Like, "groupName", groupName);[/B]
          SqlStatement stmt = sb.GetStatement(true);
          IList<ChannelGroup> groups = ObjectFactory.GetCollection<ChannelGroup>(stmt.Execute());
          ChannelGroup group;
          if (groups.Count == 0)
          {
            group = new ChannelGroup(groupName, 9999);
            group.Persist();
          }
          else
          {
            group = groups[0];
          }
          return group;
        }

    But having said that, I'm not sure why we would use Operator.Like instead of Operator.Equals in the first place.

    This code says that it is for import/export:
    Code:
        public ChannelGroup GetGroupByName(string aGroupName, int aSortOrder)
        {
          SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelGroup));
          sb.AddConstraint(Operator.Like, "groupName", "%" + aGroupName + "%");
          [B]// use like here since the user might have changed the casing[/B]
          if (aSortOrder > -1)
          {
            sb.AddConstraint(Operator.Equals, "sortOrder", aSortOrder);
          }
          SqlStatement stmt = sb.GetStatement(true);
          Log.Debug(stmt.Sql);
          IList<ChannelGroup> groups = ObjectFactory.GetCollection<ChannelGroup>(stmt.Execute());
          if (groups == null)
          {
            return null;
          }
          if (groups.Count == 0)
          {
            return null;
          }
          return groups[0];
        }

    In that case, the code is still wrong - the '%' should be removed if we want to check with case-insensitive matching.

    mm
     

    Sebastiii

    Development Group
  • Team MediaPortal
  • November 12, 2007
    16,579
    10,397
    France
    Home Country
    France France
    I just try the change on "public ChannelGroup CreateGroup(string groupName)"and i get this :
    Code:
    Gentle.Common.GentleException was unhandled
      Message=Unexpected argument count (passed 1, expected 2).
      Source=Gentle.Common
      StackTrace:
          at Gentle.Common.Messages.FormatMessage(Error error, Object[] args)
          at Gentle.Common.Messages.GetMsg(Error error, Object[] args)
          at Gentle.Common.Check.Fail(Exception e, Error error, Object[] args)
          at Gentle.Common.Check.Fail(Error error, Object[] args)
          at Gentle.Common.Check.IsTrue(Boolean condition, Error error, Object[] args)
          at Gentle.Common.Check.Verify(Boolean condition, Error error, Object[] args)
          at Gentle.Framework.SqlBuilder.AddConstraint(Operator op, String field, Object value, Boolean isCaseSensitive)
          at Gentle.Framework.SqlBuilder.AddConstraint(Operator op, String field, Object value)
          at TvDatabase.TvBusinessLayer.CreateGroup(String groupName) in D:\MediaPortal-1\TvEngine3\TVLibrary\TVDatabase\TvBusinessLayer\BusinessLayer.cs:line 203
          at SetupTv.Startup.Main(String[] arguments) in D:\MediaPortal-1\TvEngine3\TVLibrary\SetupTv\Startup.cs:line 297
      InnerException:

    But we have always : "group = groups[0];"
    That mean that it take always the first "groupName" that start with the string.
    For ex in my test case, I have HDCSAT / HD, when i want to put a channel in HD with "group = groups[0];" it goes always in HDCSAT lol
    That why i add a a match :
    Code:
    "if (groups[i].GroupName == groupName)"
    :)
     
    Last edited:

    Users who are viewing this thread

    Top Bottom