mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-05-07 15:07:50 +08:00
Minor cleanup and formatting.
This commit is contained in:
parent
c6a87f5228
commit
3896a8f921
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.WindowsAzure.ServiceRuntime;
|
||||
using Microsoft.WindowsAzure.ServiceRuntime;
|
||||
using Orchard.Environment;
|
||||
|
||||
namespace Orchard.Azure.Services.TaskLease {
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Data.Conventions;
|
||||
|
||||
namespace Orchard.TaskLease.Models
|
||||
|
@ -27,7 +27,7 @@ namespace Orchard.TaskLease.Services {
|
||||
}
|
||||
|
||||
public string Acquire(string taskName, DateTime expiredUtc) {
|
||||
var machineName = _applicationEnvironment.GetEnvironmentIdentifier();
|
||||
var environmentIdentifier = _applicationEnvironment.GetEnvironmentIdentifier();
|
||||
|
||||
// retrieve current lease for the specified task
|
||||
var taskLease = _repository.Get(x => x.TaskName == taskName);
|
||||
@ -36,7 +36,7 @@ namespace Orchard.TaskLease.Services {
|
||||
if (taskLease == null) {
|
||||
taskLease = new TaskLeaseRecord {
|
||||
TaskName = taskName,
|
||||
MachineName = machineName,
|
||||
MachineName = environmentIdentifier,
|
||||
State = String.Empty,
|
||||
UpdatedUtc = _clock.UtcNow,
|
||||
ExpiredUtc = expiredUtc
|
||||
@ -49,12 +49,12 @@ namespace Orchard.TaskLease.Services {
|
||||
}
|
||||
|
||||
// lease can't be aquired only if for a different machine and it has not expired
|
||||
if (taskLease.MachineName != machineName && taskLease.ExpiredUtc >= _clock.UtcNow) {
|
||||
if (taskLease.MachineName != environmentIdentifier && taskLease.ExpiredUtc >= _clock.UtcNow) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// otherwise update information
|
||||
taskLease.MachineName = machineName;
|
||||
taskLease.MachineName = environmentIdentifier;
|
||||
taskLease.UpdatedUtc = _clock.UtcNow;
|
||||
taskLease.ExpiredUtc = expiredUtc;
|
||||
|
||||
@ -64,10 +64,10 @@ namespace Orchard.TaskLease.Services {
|
||||
}
|
||||
|
||||
public void Update(string taskName, string state) {
|
||||
var machineName = _applicationEnvironment.GetEnvironmentIdentifier();
|
||||
var environmentIdentifier = _applicationEnvironment.GetEnvironmentIdentifier();
|
||||
|
||||
// retrieve current lease for the specified task
|
||||
var taskLease = _repository.Get(x => x.TaskName == taskName && x.MachineName == machineName);
|
||||
var taskLease = _repository.Get(x => x.TaskName == taskName && x.MachineName == environmentIdentifier);
|
||||
|
||||
if (taskLease == null) {
|
||||
return;
|
||||
@ -78,10 +78,10 @@ namespace Orchard.TaskLease.Services {
|
||||
}
|
||||
|
||||
public void Update(string taskName, string state, DateTime expiredUtc) {
|
||||
var machineName = _applicationEnvironment.GetEnvironmentIdentifier();
|
||||
var environmentIdentifier = _applicationEnvironment.GetEnvironmentIdentifier();
|
||||
|
||||
// retrieve current lease for the specified task
|
||||
var taskLease = _repository.Get(x => x.TaskName == taskName && x.MachineName == machineName);
|
||||
var taskLease = _repository.Get(x => x.TaskName == taskName && x.MachineName == environmentIdentifier);
|
||||
|
||||
if (taskLease == null) {
|
||||
return;
|
||||
|
@ -136,7 +136,7 @@ namespace Orchard.Tasks.Locking.Services {
|
||||
}
|
||||
|
||||
private bool EnsureDistributedLockRecord(string internalName, TimeSpan? maxValidFor) {
|
||||
var localMachineName = _applicationEnvironment.GetEnvironmentIdentifier();
|
||||
var environmentIdentifier = _applicationEnvironment.GetEnvironmentIdentifier();
|
||||
var hasLockRecord = false;
|
||||
|
||||
ExecuteOnSeparateTransaction(repository => {
|
||||
@ -148,16 +148,16 @@ namespace Orchard.Tasks.Locking.Services {
|
||||
|
||||
repository.Create(new DistributedLockRecord {
|
||||
Name = internalName,
|
||||
MachineName = localMachineName,
|
||||
MachineName = environmentIdentifier,
|
||||
CreatedUtc = _clock.UtcNow,
|
||||
ValidUntilUtc = maxValidFor.HasValue ? _clock.UtcNow + maxValidFor.Value : default(DateTime?)
|
||||
});
|
||||
|
||||
hasLockRecord = true;
|
||||
}
|
||||
else if (record.MachineName == localMachineName) {
|
||||
else if (record.MachineName == environmentIdentifier) {
|
||||
// Existing lock was for correct machine name => lock record exists.
|
||||
Logger.Debug("Found a valid record for lock '{0}' and current local machine name '{1}'.", internalName, localMachineName);
|
||||
Logger.Debug("Found a valid record for lock '{0}' and current local machine name '{1}'.", internalName, environmentIdentifier);
|
||||
hasLockRecord = true;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user