本文整理汇总了C#中SqlFilter类的典型用法代码示例。如果您正苦于以下问题:C# SqlFilter类的具体用法?C# SqlFilter怎么用?C# SqlFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlFilter类属于命名空间,在下文中一共展示了SqlFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSubscription
public void CreateSubscription(ServiceBusEnpointData value) {
//TODO determine how we can change the filters for an existing registered item
logger.Log(LogLevel.Info, "CreateSubscription {0} Declared {1} MessageTytpe {2}, IsReusable {3}", value.SubscriptionName, value.DeclaredType.ToString(), value.MessageType.ToString(), value.IsReusable);
SubscriptionDescription desc = null;
var data = value.MessageType.FullName;
if (!namespaceManager.SubscriptionExists(topic.Path, value.SubscriptionName)) {
logger.Log(LogLevel.Info, "CreateSubscription Creating {0}", value.SubscriptionName);
var filter = new SqlFilter(string.Format(TYPE_HEADER_NAME + " = '{0}'", value.MessageType.FullName.Replace('.', '_')));
Helpers.Execute(() => {
desc = namespaceManager.CreateSubscription(topic.Path, value.SubscriptionName, filter);
});
}
else {
logger.Log(LogLevel.Info, "CreateSubscription Exists {0}", value.SubscriptionName);
desc = namespaceManager.GetSubscription(topic.Path, value.SubscriptionName);
}
SubscriptionClient subscriptionClient = factory.CreateSubscriptionClient(topic.Path, value.SubscriptionName, ReceiveMode.PeekLock);
var state = new AzureBusReceiverState() {
Client = subscriptionClient,
EndPointData = value,
Subscription = desc
};
mappings.Add(state);
Task t = new Task(ProcessMessagesForSubscription, state);
t.Start();
}
示例2: CreateAndGetSubscriptionInternal
private SubscriptionClient CreateAndGetSubscriptionInternal(string subscriptionName, ISpecification filterSpecification)
{
var filter = new SqlFilter(filterSpecification.Result());
EnsureSubscriptionNameIsValid(subscriptionName);
log.Info($"Checking subscription for path {subscriptionName} exists");
if (!this.namespaceManager.SubscriptionExists(this.topic, subscriptionName))
{
log.Info("Creating subscription as it does not currently exist");
var subscriptionDescription = new SubscriptionDescription(this.topic, subscriptionName)
{
LockDuration = TimeSpan.FromMinutes(5)
};
this.namespaceManager.CreateSubscription(subscriptionDescription, filter);
log.Info("Subscription created");
}
log.Info("Creating subscription client");
var client = SubscriptionClient.CreateFromConnectionString(
connectionString, this.topic, subscriptionName);
log.Info("Subscription client created");
return client;
}
示例3: Main
static void Main(string[] args)
{
string topicName = "sb-salesorder-topic";
string sbconnection = "Endpoint=sb://sb-twocents-ns.servicebus.windows.net/;SharedAccessKeyName=Admin;SharedAccessKey=mueFV8NQkt5MmSIMzbbXvBw4EAtXLntue/gLP7OfSEE=";
var ns = NamespaceManager.CreateFromConnectionString(sbconnection);
SqlFilter filter = new SqlFilter("Priority=1");
ns.CreateSubscription(topicName, "salesorder-sub-priority", filter);
}
示例4: PreExecute
public void PreExecute(SqlFilter filter)
{
if (filter == null)
throw new ArgumentNullException("filter");
// get...
UserItem user = ServiceAuthenticator.Current.GetUser();
if (user == null)
throw new InvalidOperationException("'user' is null.");
// mangle the query...
filter.Constraints.Add("userid", user.UserId);
}
示例5: CancelSubscription
/// <summary>
/// Cancel a subscription
/// </summary>
/// <param name="value">The data used to cancel the subscription</param>
public void CancelSubscription(ServiceBusEnpointData value)
{
Guard.ArgumentNotNull(value, "value");
var subscription = mappings.FirstOrDefault(item => item.Data.EndPointData.SubscriptionName.Equals(value.SubscriptionName, StringComparison.OrdinalIgnoreCase));
if (subscription == null)
{
return;
}
subscription.Data.Cancel();
Task t = Task.Factory.StartNew(() =>
{
//HACK find better way to wait for a cancel request so we are not blocking.
for (int i = 0; i < 100; i++)
{
if (!subscription.Data.Cancelled)
{
Thread.Sleep(1000);
}
else
{
break;
}
}
if (configurationFactory.NamespaceManager.SubscriptionExists(topic.Path, value.SubscriptionName))
{
var filter = new SqlFilter(string.Format(TYPE_HEADER_NAME + " = '{0}'", value.MessageType.FullName.Replace('.', '_')));
retryPolicy.ExecuteAction(() => configurationFactory.NamespaceManager.DeleteSubscription(topic.Path, value.SubscriptionName));
}
});
try
{
Task.WaitAny(t);
}
catch (Exception ex)
{
if (ex is AggregateException)
{
//do nothing
}
else
{
throw;
}
}
}
示例6: Main
static void Main(string[] args)
{
string connectionStr = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
NamespaceManager nsm = NamespaceManager.CreateFromConnectionString(connectionStr);
string topicName = "yolitopic";
TopicDescription topic = null;
if (!nsm.TopicExists(topicName))
{
nsm.CreateTopic(new TopicDescription(topicName) {
EnablePartitioning = false
});
}
topic = nsm.GetTopic(topicName);
if (topic.SubscriptionCount == 0)
{
SqlFilter filter1 = new SqlFilter("(index % 2) = 0");
nsm.CreateSubscription(topic.Path, "YoliSubscription1", filter1);
SqlFilter filter2 = new SqlFilter("(index % 2) > 0");
nsm.CreateSubscription(topic.Path, "YoliSubscription2", filter2);
}
//
//sadfsdf
foreach(var s in nsm.GetSubscriptions(topicName))
{
Console.WriteLine(s.Name);
foreach(var r in nsm.GetRules(topic.Path,s.Name))
{
Console.WriteLine("{0}-{1}", r.Name, r.Filter.ToString());
}
}
Console.WriteLine("Sending message to topic");
TopicClient topicClient = TopicClient.CreateFromConnectionString(connectionStr, topicName);
for (int i = 0; i < 5000; i++)
{
BrokeredMessage message = new BrokeredMessage();
message.Properties["index"] = i;
message.Properties["value"] = (i * 10 + 5) % 11;
topicClient.Send(message);
}
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
示例7: GetOrCreateSubscription
public static SubscriptionDescription GetOrCreateSubscription(this NamespaceManager namespaceManager, TopicDescription topicDescription,
string name)
{
if (!namespaceManager.SubscriptionExists(topicDescription.Path, name))
{
try
{
var filter = new SqlFilter(string.Format("LogicalDestinationQueue = '{0}'", name));
var subscription = namespaceManager.CreateSubscription(topicDescription.Path, name, filter);
return subscription;
}
catch (MessagingEntityAlreadyExistsException)
{
}
}
return namespaceManager.GetSubscription(topicDescription.Path, name);
}
示例8: EnsureTopic
private async Task EnsureTopic()
{
var namespaceManager = NamespaceManager.CreateFromConnectionString(_globalSettings.ServiceBusConnectionString);
if (await namespaceManager.TopicExistsAsync(_globalSettings.DiscoTopicName) == false)
{
await namespaceManager.CreateTopicAsync(_globalSettings.DiscoTopicName);
}
if (await namespaceManager.SubscriptionExistsAsync(_globalSettings.DiscoTopicName, "Gadgets") == false)
{
var discoFilter = new SqlFilter("Disco = true");
await namespaceManager.CreateSubscriptionAsync(_globalSettings.DiscoTopicName, "Gadgets", discoFilter);
}
if (await namespaceManager.SubscriptionExistsAsync(_globalSettings.DiscoTopicName, "Notifications") == false)
{
await namespaceManager.CreateSubscriptionAsync(_globalSettings.DiscoTopicName, "Notifications");
}
}
示例9: MakeSubscription
public void MakeSubscription()
{
//https://msdn.microsoft.com/en-us/library/azure/hh367516.aspx
//http://azure.microsoft.com/EN-US/documentation/articles/service-bus-dotnet-how-to-use-topics-subscriptions/
string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.SubscriptionExists("WebsiteMessages", "Problem"))
{
SqlFilter filter = new SqlFilter("FormType = 'Problem'");
namespaceManager.CreateSubscription("WebsiteMessages", "Problem", filter);
}
if (!namespaceManager.SubscriptionExists("WebsiteMessages", "Question"))
{
SqlFilter filter = new SqlFilter("FormType = 'Question'");
namespaceManager.CreateSubscription("WebsiteMessages", "Question", filter);
}
}
示例10: Main
private static void Main(string[] args)
{
string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
// Create topic
if (!namespaceManager.TopicExists(_topicName))
{
namespaceManager.CreateTopic(_topicName);
}
// Create subscriptions
if (!namespaceManager.SubscriptionExists(_topicName, "Bookings"))
{
SqlFilter filter = new SqlFilter("EventType = 'Booking'");
namespaceManager.CreateSubscription(_topicName, "Bookings", filter);
}
if (!namespaceManager.SubscriptionExists(_topicName, "Notifications"))
{
SqlFilter filter = new SqlFilter("EventType = 'Notification'");
namespaceManager.CreateSubscription(_topicName, "Notifications", filter);
}
// Push messages to topics
TopicClient client = TopicClient.CreateFromConnectionString(connectionString, _topicName);
int count = 1;
while (true)
{
Task.Run(() => SendMessage(client, "Booking", count));
Task.Run(() => SendMessage(client, "Notification", count));
Thread.Sleep(2000);
count++;
if (count > 20) break;
}
}
示例11: Create
public SubscriptionClient Create(Type eventType, string topicPath, string subscriptionname)
{
if (NamespaceClient.TopicExists(topicPath))
{
try
{
if (!NamespaceClient.SubscriptionExists(topicPath, subscriptionname))
{
var description = new SubscriptionDescription(topicPath, subscriptionname)
{
LockDuration = LockDuration,
RequiresSession = RequiresSession,
DefaultMessageTimeToLive = DefaultMessageTimeToLive,
EnableDeadLetteringOnMessageExpiration = EnableDeadLetteringOnMessageExpiration,
MaxDeliveryCount = MaxDeliveryCount,
EnableBatchedOperations = EnableBatchedOperations,
EnableDeadLetteringOnFilterEvaluationExceptions =
EnableDeadLetteringOnFilterEvaluationExceptions
};
var filter = string.Format( "[{0}] LIKE '{1}%' OR [{0}] LIKE '%{1}%' OR [{0}] LIKE '%{1}' OR [{0}] = '{1}'", Headers.EnclosedMessageTypes, eventType.AssemblyQualifiedName);
var typefilter = new SqlFilter(filter);
NamespaceClient.CreateSubscription(description, typefilter);
}
}
catch (MessagingEntityAlreadyExistsException)
{
// the queue already exists or another node beat us to it, which is ok
}
return Factory.CreateSubscriptionClient(topicPath, subscriptionname, ReceiveMode.PeekLock);
}
return null;
}
开发者ID:modulexcite,项目名称:NServiceBus.WindowsServiceBus,代码行数:37,代码来源:WindowsServicebusSubscriptionClientCreator.cs
示例12: GetRecords
/// <summary>
/// This is a shared function that can be used to get an array of UsersRecord records using a where and order by clause clause with pagination.
/// </summary>
public static UsersRecord[] GetRecords(BaseFilter join, string where, OrderBy orderBy, int pageIndex, int pageSize)
{
SqlFilter whereFilter = null;
if (where != null && where.Trim() != "")
{
whereFilter = new SqlFilter(where);
}
ArrayList recList = UsersTable.Instance.GetRecordList(join, whereFilter, null, orderBy, pageIndex, pageSize);
return (UsersRecord[])recList.ToArray(Type.GetType("FPCEstimate.Business.UsersRecord"));
}
示例13: GetRecords
/// <summary>
/// This is a shared function that can be used to get an array of EstimateRecord records using a where and order by clause clause with pagination.
/// </summary>
public static EstimateRecord[] GetRecords(string where, OrderBy orderBy, int pageIndex, int pageSize)
{
SqlFilter whereFilter = null;
if (where != null && where.Trim() != "")
{
whereFilter = new SqlFilter(where);
}
BaseClasses.Data.BaseFilter join = null;
ArrayList recList = EstimateTable.Instance.GetRecordList(join, whereFilter, null, orderBy, pageIndex, pageSize);
return (EstimateRecord[])recList.ToArray(Type.GetType("FPCEstimate.Business.EstimateRecord"));
}
示例14: GetRecord
/// <summary>
/// This is a shared function that can be used to get a UsersRecord record using a where and order by clause.
/// </summary>
public static UsersRecord GetRecord(BaseFilter join, string where, OrderBy orderBy)
{
SqlFilter whereFilter = null;
if (where != null && where.Trim() != "")
{
whereFilter = new SqlFilter(where);
}
ArrayList recList = UsersTable.Instance.GetRecordList(join, whereFilter, null, orderBy, BaseTable.MIN_PAGE_NUMBER, BaseTable.MIN_BATCH_SIZE);
UsersRecord rec = null;
if (recList.Count > 0)
{
rec = (UsersRecord)recList[0];
}
return rec;
}
示例15: GetRecordCount
/// <summary>
/// This is a shared function that can be used to get total number of records that will be returned using the where clause.
/// </summary>
public static int GetRecordCount(BaseFilter join, string where)
{
SqlFilter whereFilter = null;
if (where != null && where.Trim() != "")
{
whereFilter = new SqlFilter(where);
}
return (int)UsersTable.Instance.GetRecordListCount(join, whereFilter, null, null);
}