本文整理汇总了C#中QueueName.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# QueueName.ToString方法的具体用法?C# QueueName.ToString怎么用?C# QueueName.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueName
的用法示例。
在下文中一共展示了QueueName.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Name
public string Name(QueueName name)
{
var val = _ht[name];
if (val == null)
{
val = name.ToString("G");
_ht[name] = val;
}
return val.ToString();
}
示例2: ToEvent
public static Event ToEvent(this BrokeredMessage message,
QueueName queueName)
{
return
new Event()
{
Body = message.GetBody<string>(),
ContentType = message.ContentType,
EventType = queueName.TopicName,
QueueName = queueName.ToString(),
UnderlyingMessage = message
};
}
示例3: Prepare
/// <summary>
/// Stages indexes. Should run only using one process.
/// </summary>
/// <param name="scope"></param>
/// <param name="documentType"></param>
/// <param name="rebuild"></param>
/// <exception cref="System.ArgumentNullException">scope</exception>
public void Prepare(string scope, string documentType = "", bool rebuild = false)
{
if (String.IsNullOrEmpty(scope))
throw new ArgumentNullException("scope");
foreach (var builder in _indexBuilders)
{
// skip not requested indexers or index using all if index is not specified
if (!String.IsNullOrEmpty(documentType) && !documentType.Equals(builder.DocumentType))
continue;
// Execute builder, which will create partitions and put them in the queue
var queueName = new QueueName("index-{0}-{1}-in", scope, builder.DocumentType);
var config = GetBuildConfig(_repository, queueName.Scope, queueName.DocumentType);
var lastBuild = DateTime.UtcNow;
var newBuildDate = lastBuild;
if (config.Status == BuildStatus.NeverStarted.GetHashCode() || rebuild) // build was never started, so set min date
{
rebuild = true;
lastBuild = DateTime.MinValue;
config.LastBuildDate = DateTime.UtcNow.AddYears(-30); // have to set the date to something repository won't complain
}
else
{
lastBuild = config.LastBuildDate.AddSeconds(-30); // make sure we get all the changes
}
// Delete all the records
if (rebuild)
{
_searchProvider.RemoveAll(queueName.Scope, queueName.DocumentType);
}
var partitions = builder.CreatePartitions(queueName.Scope, lastBuild);
var newPartitionsExist = false; // tells if there are any partitions that has been processed
foreach (var partition in partitions)
{
newPartitionsExist = true;
//_observer.Notify(new ConsumeBegin(msg, consumer, envelope.QueueName));
_messageSender.Send(queueName.ToString(), partition);
}
var newBuildStatus = BuildStatus.Started;
if (newPartitionsExist)
{
_messageSender.Send(queueName.ToString(), new SearchIndexStatusMessage(queueName.Scope, queueName.DocumentType, BuildStatus.Completed));
}
else
{
newBuildStatus = BuildStatus.Completed;
}
config.LastBuildDate = newBuildDate;
config.Status = newBuildStatus.GetHashCode();
_repository.UnitOfWork.Commit();
}
}
示例4: GetQueueClient
public QueueClient GetQueueClient(QueueName queueName)
{
Func<object> factory = () =>
QueueClient.CreateFromConnectionString(_connectionString,
queueName.TopicName);
if (_cache)
{
var lazy =
_cachedClients.GetOrAdd(
queueName.ToString(),
(name) =>
new Lazy<object>(factory));
return (QueueClient)lazy.Value;
}
return (QueueClient)factory();
}
示例5: SucceededTasks
/// <summary>
/// Returns all succeeded tasks.
/// </summary>
/// <param name="queue"></param>
/// <returns></returns>
public IList<TaskMessage> SucceededTasks(QueueName queue)
{
if (string.IsNullOrEmpty(queue.ToString()))
throw new NoQueueSpecifiedException(
"Parameter <queue> is empty or null. Cannot retrieve task for no queue.");
return TypedClient.Lists[queue.NameWhenSucceeded];
}
示例6: Reserve
/// <summary>
/// Obtains the first available task from the specified queue, and changes the client's
/// state into TaskReserved. In that state, no new tasks can be reserved until the
/// task's outcome is evident.
/// </summary>
/// <param name="queue"></param>
/// <returns></returns>
public TaskMessage Reserve(QueueName queue)
{
if (State == RedisQueueState.TaskReserved)
throw new TaskAlreadyReservedException("Cannot reserve multiple tasks at once.");
if (string.IsNullOrEmpty(queue.ToString()))
throw new NoQueueSpecifiedException(
"Parameter <queue> is empty or null. Cannot retrieve task for no queue.");
if (TypedClient.Lists[queue.NameWhenPending].Count == 0)
throw new QueueIsEmptyException("No tasks available in specified queue.");
CurrentTask = TypedClient.Lists[queue.NameWhenPending].RemoveStart();
State = RedisQueueState.TaskReserved;
Log.Info("Reserved task from [" + queue.NameWhenPending + "]");
Log.DebugFormat("Task Parameters: {0}", CurrentTask.Parameters);
CacheCurrentTask();
return CurrentTask;
}