Ejemplo n.º 1
0
    private void InitChannels()
    {
      listViewChannels.Clear();
      listViewChannels.BeginUpdate();
      try
      {
        SqlBuilder sb = new SqlBuilder(Gentle.Framework.StatementType.Select, typeof (Channel));
        if (checkBoxGuideChannels.Checked)
        {
          sb.AddConstraint(Operator.Equals, "visibleInGuide", 1);
        }
        sb.AddConstraint(Operator.Equals, "isTv", 1);
        sb.AddOrderByField(true, "sortOrder");
        sb.AddOrderByField(true, "displayName");
        SqlStatement stmt = sb.GetStatement(true);
        IList<Channel> channels = ObjectFactory.GetCollection<Channel>(stmt.Execute());

        for (int i = 0; i < channels.Count; i++)
        {
          // TODO: add imagelist with channel logos from MP :)
          ListViewItem curItem = new ListViewItem(channels[i].DisplayName);
          curItem.Tag = channels[i];
          listViewChannels.Items.Add(curItem);
        }
      }
      finally
      {
        listViewChannels.EndUpdate();
      }
      mpButtonOk.Enabled = (listViewChannels.Items.Count > 0);
    }
    /// <summary>
    /// gets a value from the database table "Setting"
    /// </summary>
    /// <returns>A Setting object with the stored value, if it doesnt exist the given default string will be the value</returns>
    private Setting GetSetting(string tagName, string defaultValue)
    {
      if (defaultValue == null)
      {
        return null;
      }
      if (tagName == null)
      {
        return null;
      }
      if (tagName == "")
      {
        return null;
      }
      SqlBuilder sb;
      try
      {
        sb = new SqlBuilder(Gentle.Framework.StatementType.Select, typeof(Setting));
      }
      catch (TypeInitializationException)
      {
        return new Setting(tagName,defaultValue);
      }

      sb.AddConstraint(Operator.Equals, "tag", tagName);
      SqlStatement stmt = sb.GetStatement(true);
      IList<Setting> settingsFound = ObjectFactory.GetCollection<Setting>(stmt.Execute());
      if (settingsFound.Count == 0)
      {
        Setting set = new Setting(tagName, defaultValue);
        set.Persist();
        return set;
      }
      return settingsFound[0];
    }
        public void RemoveAllAttendancesOfPerson(Person aPerson)
        {
            SqlBuilder sb = new SqlBuilder(StatementType.Delete, typeof(Attendance));
            sb.AddConstraint(Operator.Equals, "id_person", aPerson.Id);

            SqlStatement stmt = sb.GetStatement(true);
            stmt.Execute();
        }
        public void RemoveAllAttendancesOfEvent(Event anEvent)
        {
            SqlBuilder sb = new SqlBuilder(StatementType.Delete, typeof(Attendance));
            sb.AddConstraint(Operator.Equals, "id_event", anEvent.Id);

            SqlStatement stmt = sb.GetStatement(true);
            stmt.Execute();
        }
    public void OnActivated()
    {
      try
      {
        Application.DoEvents();

        Cursor.Current = Cursors.WaitCursor;

        UpdateMenuAndTabs();

        listView1.Items.Clear();
        SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (GroupMap));

        sb.AddConstraint(Operator.Equals, "idGroup", _channelGroup.IdGroup);
        sb.AddOrderByField(true, "sortOrder");

        SqlStatement stmt = sb.GetStatement(true);

        IList<GroupMap> maps = ObjectFactory.GetCollection<GroupMap>(stmt.Execute());

        foreach (GroupMap map in maps)
        {
          Channel channel = map.ReferencedChannel();
          if (!channel.IsTv)
          {
            continue;
          }
          listView1.Items.Add(CreateItemForChannel(channel, map));
        }
        bool isAllChannelsGroup = (_channelGroup.GroupName == TvConstants.TvGroupNames.AllChannels);
        removeChannelFromGroup.Enabled = !isAllChannelsGroup;
        mpButtonDel.Enabled = !isAllChannelsGroup;

        if (_channelGroup.GroupName != TvConstants.TvGroupNames.AllChannels)
        {
          labelPinCode.Visible = true;
          textBoxPinCode.Visible = true;
          textBoxPinCode.Text = _channelGroup.PinCode;
        }

      }
      catch (Exception exp)
      {
        Log.Error("OnActivated error: {0}", exp.Message);
      }
      finally
      {
        Cursor.Current = Cursors.Default;
      }
    }
Ejemplo n.º 6
0
        private void CreateShareForm_Load(object sender, EventArgs e)
        {
            _channelNameLabel.Text = this.Channel.DisplayName;
            LoadGroups();

            LinkedMediaPortalChannel linkedChannel = ChannelLinks.GetLinkedMediaPortalChannel(this.Channel);
            if (linkedChannel != null)
            {
                SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(TvDatabase.GroupMap));
                sb.AddConstraint(Operator.Equals, "idChannel", linkedChannel.Id);
                SqlResult result = Broker.Execute(sb.GetStatement());
                List<TvDatabase.GroupMap> groupMaps = (List<TvDatabase.GroupMap>)
                    ObjectFactory.GetCollection(typeof(TvDatabase.GroupMap), result, new List<TvDatabase.GroupMap>());
                if (groupMaps.Count > 0)
                {
                    foreach (ListViewItem item in _groupsListView.Items)
                    {
                        if (item.Tag is int
                            && (int)item.Tag == groupMaps[0].IdGroup)
                        {
                            item.Selected = true;
                            _groupsListView.EnsureVisible(item.Index);
                            break;
                        }
                        else
                        {
                            item.Selected = false;
                        }
                    }

                    foreach (ListViewItem item in _channelsListView.Items)
                    {
                        ChannelItem channelItem = item.Tag as ChannelItem;
                        if (channelItem.Channel.IdChannel == linkedChannel.Id)
                        {
                            item.Selected = true;
                            _channelsListView.EnsureVisible(item.Index);
                            break;
                        }
                        else
                        {
                            item.Selected = false;
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets a list of tv channels sorted by their group
 /// </summary>
 /// <returns>a list of TVDatabase Channels</returns>
 public List<Channel> GetTVGuideChannelsForGroup(int groupID)
 {
   SqlBuilder sb1 = new SqlBuilder(StatementType.Select, typeof (Channel));
   SqlStatement stmt1 = sb1.GetStatement(true);
   SqlStatement ManualJoinSQL = new SqlStatement(stmt1.StatementType, stmt1.Command,
                                                 String.Format(
                                                   "select c.* from Channel c inner join GroupMap g on (c.idChannel=g.idChannel and g.idGroup = '{0}') where visibleInGuide = 1 and isTv = 1 order by g.sortOrder",
                                                   groupID), typeof (Channel));
   return ObjectFactory.GetCollection<Channel>(ManualJoinSQL.Execute()) as List<Channel>;
 }
Ejemplo n.º 8
0
 public IList<Channel> GetChannelsInGroup(ChannelGroup group)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
   SqlStatement origStmt = sb.GetStatement(true);
   string sql = "select c.* from channel c inner join groupmap gm on (c.idChannel = gm.idChannel and gm.idGroup =" +
                group.IdGroup + ") order by gm.SortOrder asc";
   SqlStatement statement = new SqlStatement(StatementType.Select, origStmt.Command, sql,
                                             typeof (Channel));
   return ObjectFactory.GetCollection<Channel>(statement.Execute());
 }
Ejemplo n.º 9
0
    public IList<TuningDetail> GetTuningDetailsByName(string name, int channelType)
    {
      SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (TuningDetail));
      sb.AddConstraint(Operator.Equals, "name", name);
      sb.AddConstraint(Operator.Equals, "channelType", channelType);

      SqlStatement stmt = sb.GetStatement(true);
      IList<TuningDetail> details = ObjectFactory.GetCollection<TuningDetail>(stmt.Execute());
      return details;
    }
Ejemplo n.º 10
0
    public TuningDetail GetTuningDetail(String url, int channelType)
    {
      SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(TuningDetail));
      sb.AddConstraint(Operator.Equals, "url", url);
      sb.AddConstraint(Operator.Equals, "channelType", channelType);

      SqlStatement stmt = sb.GetStatement(true);
      IList<TuningDetail> details = ObjectFactory.GetCollection<TuningDetail>(stmt.Execute());

      if (details == null)
      {
        return null;
      }
      if (details.Count == 0)
      {
        return null;
      }
      return details[0];
    }
Ejemplo n.º 11
0
 public bool IsChannelMappedToCard(Channel dbChannel, Card card, bool forEpg)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelMap));
   SqlStatement origStmt = sb.GetStatement(true);
   string sql = "select cm.* from ChannelMap cm where cm.idChannel =" +
                dbChannel.IdChannel + " and cm.idCard=" + card.IdCard + (forEpg ? "" : " and cm.epgOnly=0");
   SqlStatement statement = new SqlStatement(StatementType.Select, origStmt.Command, sql,
                                             typeof (Channel));
   IList<ChannelMap> maps = ObjectFactory.GetCollection<ChannelMap>(statement.Execute());
   return maps != null && maps.Count > 0;
 }
Ejemplo n.º 12
0
 public ChannelGroup GetGroupByName(string aGroupName, int aSortOrder)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelGroup));
   sb.AddConstraint(Operator.Like, "groupName", "%" + aGroupName + "%");
   // use like here since the user might have changed the casing
   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];
 }
Ejemplo n.º 13
0
 public void RemoveAllPrograms(int idChannel)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Delete, typeof (Program));
   sb.AddConstraint(Operator.Equals, "idChannel", idChannel);
   SqlStatement stmt = sb.GetStatement(true);
   ObjectFactory.GetCollection<Program>(stmt.Execute());
 }
Ejemplo n.º 14
0
 public void RemoveOldPrograms(int idChannel)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Delete, typeof (Program));
   DateTime dtToKeep = DateTime.Now.AddHours(-EpgKeepDuration);
   IFormatProvider mmddFormat = new CultureInfo(String.Empty, false);
   sb.AddConstraint(Operator.Equals, "idChannel", idChannel);
   sb.AddConstraint(String.Format("endTime < '{0}'", dtToKeep.ToString(GetDateTimeString(), mmddFormat)));
   SqlStatement stmt = sb.GetStatement(true);
   ObjectFactory.GetCollection<Program>(stmt.Execute());
 }
Ejemplo n.º 15
0
 public IList<ChannelLinkageMap> GetLinkagesForChannel(Channel channel)
 {
   IList<ChannelLinkageMap> pmap = channel.ReferringLinkedChannels();
   if (pmap != null)
   {
     if (pmap.Count > 0)
       return pmap;
   }
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelLinkageMap));
   sb.AddConstraint(Operator.Equals, "idLinkedChannel", channel.IdChannel);
   SqlStatement stmt = sb.GetStatement(true);
   return ObjectFactory.GetCollection<ChannelLinkageMap>(stmt.Execute());
 }
Ejemplo n.º 16
0
 public Recording GetRecordingByFileName(string fileName)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Recording));
   sb.AddConstraint(Operator.Equals, "fileName", fileName);
   sb.SetRowLimit(1);
   SqlStatement stmt = sb.GetStatement(true);
   IList<Recording> recordings = ObjectFactory.GetCollection<Recording>(stmt.Execute());
   if (recordings.Count == 0)
   {
     return null;
   }
   return recordings[0];
 }
Ejemplo n.º 17
0
 public RadioChannelGroup GetRadioChannelGroupByName(string name)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (RadioChannelGroup));
   sb.AddConstraint(Operator.Equals, "groupName", name);
   SqlStatement stmt = sb.GetStatement(true);
   IList<RadioChannelGroup> groups = ObjectFactory.GetCollection<RadioChannelGroup>(stmt.Execute());
   if (groups == null)
   {
     return null;
   }
   if (groups.Count == 0)
   {
     return null;
   }
   return groups[0];
 }
Ejemplo n.º 18
0
 public IList<Program> GetOnairNow()
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Program));
   IFormatProvider mmddFormat = new CultureInfo(String.Empty, false);
   sb.AddConstraint(String.Format("startTime <= '{0}' and endTime >= '{1}'",
                                  DateTime.Now.ToString(GetDateTimeString(), mmddFormat),
                                  DateTime.Now.ToString(GetDateTimeString(), mmddFormat)));
   SqlStatement stmt = sb.GetStatement(true);
   return ObjectFactory.GetCollection<Program>(stmt.Execute());
 }
Ejemplo n.º 19
0
 public IList<SoftwareEncoder> GetSofwareEncodersAudio()
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (SoftwareEncoder));
   sb.AddConstraint(Operator.Equals, "type", 1);
   sb.AddOrderByField(true, "priority");
   SqlStatement stmt = sb.GetStatement(true);
   return ObjectFactory.GetCollection<SoftwareEncoder>(stmt.Execute());
 }
Ejemplo n.º 20
0
    public IList<Program> GetPrograms(Channel channel, DateTime startTime)
    {
      //The DateTime.MinValue is lower than the min datetime value of the database
      if (startTime == DateTime.MinValue)
      {
        startTime = startTime.AddYears(1900);
      }
      IFormatProvider mmddFormat = new CultureInfo(String.Empty, false);
      SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Program));

      sb.AddConstraint(Operator.Equals, "idChannel", channel.IdChannel);
      sb.AddConstraint(String.Format("startTime>='{0}'", startTime.ToString(GetDateTimeString(), mmddFormat)));
      sb.AddOrderByField(true, "startTime");

      SqlStatement stmt = sb.GetStatement(true);
      return ObjectFactory.GetCollection<Program>(stmt.Execute());
    }
Ejemplo n.º 21
0
    public Channel GetChannel(int idChannel)
    {
      SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
      sb.AddConstraint(Operator.Equals, "idChannel", idChannel);

      SqlStatement stmt = sb.GetStatement(true);
      IList<Channel> channels = ObjectFactory.GetCollection<Channel>(stmt.Execute());
      if (channels == null)
      {
        return null;
      }
      if (channels.Count == 0)
      {
        return null;
      }
      return channels[0];
    }
Ejemplo n.º 22
0
 public DateTime GetNewestProgramForChannel(int idChannel)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Program));
   sb.AddConstraint(Operator.Equals, "idChannel", idChannel);
   sb.AddOrderByField(false, "startTime");
   sb.SetRowLimit(1);
   SqlStatement stmt = sb.GetStatement(true);
   IList<Program> progs = ObjectFactory.GetCollection<Program>(stmt.Execute());
   return progs.Count > 0 ? progs[0].StartTime : DateTime.MinValue;
 }
Ejemplo n.º 23
0
    public TuningDetail GetTuningDetail(int networkId, int transportId, int serviceId, int channelType)
    {
      SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (TuningDetail));
      sb.AddConstraint(Operator.Equals, "networkId", networkId);
      sb.AddConstraint(Operator.Equals, "serviceId", serviceId);
      sb.AddConstraint(Operator.Equals, "transportId", transportId);
      sb.AddConstraint(Operator.Equals, "channelType", channelType);

      SqlStatement stmt = sb.GetStatement(true);
      IList<TuningDetail> details = ObjectFactory.GetCollection<TuningDetail>(stmt.Execute());

      if (details == null)
      {
        return null;
      }
      if (details.Count == 0)
      {
        return null;
      }
      return details[0];
    }
Ejemplo n.º 24
0
    public IList<Program> GetProgramsByTitle(Channel channel, DateTime startTime, DateTime endTime, string title)
    {
      IFormatProvider mmddFormat = new CultureInfo(String.Empty, false);
      SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Program));

      string sub1 = String.Format("(EndTime > '{0}' and EndTime < '{1}')",
                                  startTime.ToString(GetDateTimeString(), mmddFormat),
                                  endTime.ToString(GetDateTimeString(), mmddFormat));
      string sub2 = String.Format("(StartTime >= '{0}' and StartTime <= '{1}')",
                                  startTime.ToString(GetDateTimeString(), mmddFormat),
                                  endTime.ToString(GetDateTimeString(), mmddFormat));
      string sub3 = String.Format("(StartTime <= '{0}' and EndTime >= '{1}')",
                                  startTime.ToString(GetDateTimeString(), mmddFormat),
                                  endTime.ToString(GetDateTimeString(), mmddFormat));

      sb.AddConstraint(Operator.Equals, "idChannel", channel.IdChannel);
      sb.AddConstraint(string.Format("({0} or {1} or {2}) ", sub1, sub2, sub3));
      sb.AddConstraint(Operator.Equals, "title", title);
      sb.AddOrderByField(true, "starttime");

      SqlStatement stmt = sb.GetStatement(true);
      return ObjectFactory.GetCollection<Program>(stmt.Execute());
    }
Ejemplo n.º 25
0
 public IList<Channel> GetChannelsByName(string name)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
   sb.AddConstraint(Operator.Equals, "displayName", name);
   SqlStatement stmt = sb.GetStatement(true);
   IList<Channel> channels = ObjectFactory.GetCollection<Channel>(stmt.Execute());
   return channels;
 }
Ejemplo n.º 26
0
 public IList<Card> ListAllEnabledCardsOrderedByPriority()
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Card));
   sb.AddConstraint("enabled=1");
   sb.AddOrderByField(false, "priority");
   SqlStatement stmt = sb.GetStatement(true);
   return ObjectFactory.GetCollection<Card>(stmt.Execute());
 }
Ejemplo n.º 27
0
    /// <summary>
    /// gets a value from the database table "Setting"
    /// </summary>
    /// <returns>A Setting object with the stored value, if it doesnt exist a empty string will be the value</returns>
    public Setting GetSetting(string tagName)
    {
      SqlBuilder sb;
      try
      {
        sb = new SqlBuilder(StatementType.Select, typeof (Setting));
      }
      catch (TypeInitializationException)
      {
        checkGentleFiles(); // Try to throw a more meaningfull exception
        throw; // else re-throw the original error
      }

      sb.AddConstraint(Operator.Equals, "tag", tagName);
      SqlStatement stmt = sb.GetStatement(true);
      IList<Setting> settingsFound = ObjectFactory.GetCollection<Setting>(stmt.Execute());
      if (settingsFound.Count == 0)
      {
        Setting set = new Setting(tagName, "");
        set.Persist();
        return set;
      }
      return settingsFound[0];
    }
Ejemplo n.º 28
0
 public ChannelGroup CreateGroup(string groupName)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (ChannelGroup));
   sb.AddConstraint(Operator.Like, "groupName", "%" + groupName + "%");
   SqlStatement stmt = sb.GetStatement(true);
   IList<ChannelGroup> groups = ObjectFactory.GetCollection<ChannelGroup>(stmt.Execute());
   ChannelGroup group;
   int GroupSelected = 0;
   if (groups.Count == 0)
   {
     group = new ChannelGroup(groupName, 9999);
     group.Persist();
   }
   else
   {
     for (int i = 0; i < groups.Count; ++i)
     {
       if (groups[i].GroupName == groupName)
       {
         GroupSelected = i;
       }
     }
     group = groups[GroupSelected];
   }
   return group;
 }
Ejemplo n.º 29
0
 public IList<Channel> GetAllRadioChannels()
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
   sb.AddConstraint(Operator.Equals, "isRadio", 1);
   SqlStatement stmt = sb.GetStatement(true);
   IList<Channel> radioChannels = ObjectFactory.GetCollection<Channel>(stmt.Execute());
   if (radioChannels == null)
   {
     return null;
   }
   if (radioChannels.Count == 0)
   {
     return null;
   }
   return radioChannels;
 }
Ejemplo n.º 30
0
 // Get schedules to import from xml
 public Schedule GetSchedule(int idChannel, string programName, DateTime startTime, DateTime endTime,
                             int scheduleType)
 {
   SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Schedule));
   sb.AddConstraint(Operator.Equals, "idChannel", idChannel);
   sb.AddConstraint(Operator.Equals, "programName", programName);
   sb.AddConstraint(Operator.Equals, "startTime", startTime);
   sb.AddConstraint(Operator.Equals, "endTime", endTime);
   sb.AddConstraint(Operator.Equals, "scheduleType", scheduleType);
   SqlStatement stmt = sb.GetStatement(true);
   Log.Info(stmt.Sql);
   IList<Schedule> schedules = ObjectFactory.GetCollection<Schedule>(stmt.Execute());
   if (schedules == null)
   {
     return null;
   }
   if (schedules.Count == 0)
   {
     return null;
   }
   return schedules[0];
 }