本文整理汇总了C#中Gentle.Framework.SqlBuilder.AddConstraint方法的典型用法代码示例。如果您正苦于以下问题:C# SqlBuilder.AddConstraint方法的具体用法?C# SqlBuilder.AddConstraint怎么用?C# SqlBuilder.AddConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gentle.Framework.SqlBuilder
的用法示例。
在下文中一共展示了SqlBuilder.AddConstraint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitChannels
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);
}
示例2: GetSetting
/// <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];
}
示例3: RemoveAllAttendancesOfPerson
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();
}
示例4: RemoveAllAttendancesOfEvent
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();
}
示例5: OnActivated
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;
}
}
示例6: CreateShareForm_Load
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;
}
}
}
}
}
示例7: GetSetting
/// <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];
}
示例8: GetTuningDetailsByName
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;
}
示例9: GetTuningDetail
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];
}
示例10: GetSofwareEncodersAudio
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());
}
示例11: GetRadioChannelGroupByName
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];
}
示例12: GetSchedule
// 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];
}
示例13: AddSelectedItemsToGroup
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 RadioGroupMap)
{
channel = layer.GetChannel(((RadioGroupMap)sourceItem.Tag).IdChannel);
}
else
{
continue;
}
RadioGroupMap groupMap = null;
layer.AddChannelToRadioGroup(channel, _channelGroup);
//get the new group map and set the listitem tag
SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (RadioGroupMap));
sb.AddConstraint(Operator.Equals, "idChannel", channel.IdChannel);
sb.AddConstraint(Operator.Equals, "idGroup", _channelGroup.IdGroup);
SqlStatement stmt = sb.GetStatement(true);
groupMap = ObjectFactory.GetInstance<RadioGroupMap>(stmt.Execute());
foreach (ListViewItem item in listView1.Items)
{
if ((item.Tag as Channel) == channel)
{
item.Tag = groupMap;
break;
}
}
}
}
示例14: ReLoad
public void ReLoad()
{
//System.Diagnostics.Debugger.Launch();
try
{
SetupDatabaseConnection();
Log.Info("get channels from database");
SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
sb.AddConstraint(Operator.Equals, "isTv", 1);
sb.AddOrderByField(true, "sortOrder");
SqlStatement stmt = sb.GetStatement(true);
channels = ObjectFactory.GetCollection(typeof (Channel), stmt.Execute());
Log.Info("found:{0} tv channels", channels.Count);
TvNotifyManager.OnNotifiesChanged();
m_groups.Clear();
TvBusinessLayer layer = new TvBusinessLayer();
RadioChannelGroup allRadioChannelsGroup =
layer.GetRadioChannelGroupByName(TvConstants.RadioGroupNames.AllChannels);
IList<Channel> radioChannels = layer.GetAllRadioChannels();
if (radioChannels != null)
{
if (radioChannels.Count > allRadioChannelsGroup.ReferringRadioGroupMap().Count)
{
foreach (Channel radioChannel in radioChannels)
{
layer.AddChannelToRadioGroup(radioChannel, allRadioChannelsGroup);
}
}
}
Log.Info("Done.");
Log.Info("get all groups from database");
sb = new SqlBuilder(StatementType.Select, typeof (ChannelGroup));
sb.AddOrderByField(true, "groupName");
stmt = sb.GetStatement(true);
IList<ChannelGroup> groups = ObjectFactory.GetCollection<ChannelGroup>(stmt.Execute());
IList<GroupMap> allgroupMaps = GroupMap.ListAll();
bool hideAllChannelsGroup = false;
using (
Settings xmlreader =
new MPSettings())
{
hideAllChannelsGroup = xmlreader.GetValueAsBool("mytv", "hideAllChannelsGroup", false);
}
foreach (ChannelGroup group in groups)
{
if (group.GroupName == TvConstants.TvGroupNames.AllChannels)
{
foreach (Channel channel in channels)
{
if (channel.IsTv == false)
{
continue;
}
bool groupContainsChannel = false;
foreach (GroupMap map in allgroupMaps)
{
if (map.IdGroup != group.IdGroup)
{
continue;
}
if (map.IdChannel == channel.IdChannel)
{
groupContainsChannel = true;
break;
}
}
if (!groupContainsChannel)
{
layer.AddChannelToGroup(channel, TvConstants.TvGroupNames.AllChannels);
}
}
break;
}
}
groups = ChannelGroup.ListAll();
foreach (ChannelGroup group in groups)
{
//group.GroupMaps.ApplySort(new GroupMap.Comparer(), false);
if (hideAllChannelsGroup && group.GroupName.Equals(TvConstants.TvGroupNames.AllChannels) && groups.Count > 1)
{
continue;
}
m_groups.Add(group);
}
Log.Info("loaded {0} tv groups", m_groups.Count);
//TVHome.Connected = true;
}
catch (Exception ex)
{
Log.Error("TVHome: Error in Reload");
Log.Error(ex);
//TVHome.Connected = false;
}
//.........这里部分代码省略.........
示例15: OnMessage
public override bool OnMessage(GUIMessage message)
{
switch (message.Message)
{
case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: // fired when OSD is hidden
{
//if (g_application.m_pPlayer) g_application.m_pPlayer.ShowOSD(true);
// following line should stay. Problems with OSD not
// appearing are already fixed elsewhere
//for (int i = (int)Controls.Panel1; i < (int)Controls.Panel2; i++)
//{
// HideControl(GetID, i);
//}
Dispose();
GUIPropertyManager.SetProperty("#currentmodule", GUIWindowManager.GetWindow(message.Param1).GetModuleName());
return true;
}
case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: // fired when OSD is shown
{
// following line should stay. Problems with OSD not
// appearing are already fixed elsewhere
SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
sb.AddConstraint(Operator.Equals, "istv", 1);
sb.AddOrderByField(true, "sortOrder");
SqlStatement stmt = sb.GetStatement(true);
listTvChannels = ObjectFactory.GetCollection(typeof (Channel), stmt.Execute());
GUIPropertyManager.SetProperty("#currentmodule", GetModuleName());
previousProgram = null;
AllocResources();
// if (g_application.m_pPlayer) g_application.m_pPlayer.ShowOSD(false);
ResetAllControls(); // make sure the controls are positioned relevant to the OSD Y offset
isSubMenuVisible = false;
m_iActiveMenuButtonID = 0;
m_iActiveMenu = 0;
m_bNeedRefresh = false;
m_dateTime = DateTime.Now;
Reset();
FocusControl(GetID, (int)Controls.OSD_PLAY, 0); // set focus to play button by default when window is shown
ShowPrograms();
QueueAnimation(AnimationType.WindowOpen);
for (int i = (int)Controls.Panel1; i < (int)Controls.Panel2; i++)
{
ShowControl(GetID, i);
}
if (g_Player.Paused)
{
ToggleButton((int)Controls.OSD_PLAY, true);
// make sure play button is down (so it shows the pause symbol)
}
else
{
ToggleButton((int)Controls.OSD_PLAY, false); // make sure play button is up (so it shows the play symbol)
}
m_delayInterval = MediaPortal.Player.Subtitles.SubEngine.GetInstance().DelayInterval;
if (m_delayInterval > 0)
m_subtitleDelay = MediaPortal.Player.Subtitles.SubEngine.GetInstance().Delay / m_delayInterval;
m_delayIntervalAudio = PostProcessingEngine.GetInstance().AudioDelayInterval;
if (m_delayIntervalAudio > 0)
m_audioDelay = PostProcessingEngine.GetInstance().AudioDelay / m_delayIntervalAudio;
g_Player.UpdateMediaInfoProperties();
GUIPropertyManager.SetProperty("#TV.View.HasTeletext", TVHome.Card.HasTeletext.ToString());
MediaPortal.Player.VideoStreamFormat videoFormat = g_Player.GetVideoFormat();
GUIPropertyManager.SetProperty("#Play.Current.TSBitRate",
((float)MediaPortal.Player.g_Player.GetVideoFormat().bitrate / 1024 / 1024).ToString("0.00", CultureInfo.InvariantCulture));
GUIPropertyManager.SetProperty("#Play.Current.VideoFormat.RawResolution",
videoFormat.width.ToString() + "x" + videoFormat.height.ToString());
GUIPropertyManager.SetProperty("#TV.TuningDetails.FreeToAir", string.Empty);
Channel chan = TVHome.Navigator.Channel;
if (chan != null)
{
IList<TuningDetail> details = chan.ReferringTuningDetail();
if (details.Count > 0)
{
TuningDetail detail = null;
switch (TVHome.Card.Type)
{
case TvLibrary.Interfaces.CardType.Analog:
foreach (TuningDetail t in details)
{
if (t.ChannelType == 0)
detail = t;
}
break;
case TvLibrary.Interfaces.CardType.Atsc:
foreach (TuningDetail t in details)
{
if (t.ChannelType == 1)
detail = t;
}
break;
case TvLibrary.Interfaces.CardType.DvbC:
foreach (TuningDetail t in details)
//.........这里部分代码省略.........