Merge
This commit is contained in:
commit
5ee5167da9
7 changed files with 689 additions and 478 deletions
|
@ -1492,7 +1492,6 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
private static bool AccountExists(string accountName, int ServiceId)
|
private static bool AccountExists(string accountName, int ServiceId)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!DataProvider.ExchangeAccountExists(accountName))
|
if (!DataProvider.ExchangeAccountExists(accountName))
|
||||||
{
|
{
|
||||||
Organizations orgProxy = GetOrganizationProxy(ServiceId);
|
Organizations orgProxy = GetOrganizationProxy(ServiceId);
|
||||||
|
@ -1503,6 +1502,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int DeleteUser(int itemId, int accountId)
|
public static int DeleteUser(int itemId, int accountId)
|
||||||
|
|
|
@ -40,9 +40,9 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
public sealed class Scheduler
|
public sealed class Scheduler
|
||||||
{
|
{
|
||||||
static SchedulerJob nextSchedule = null;
|
public static SchedulerJob nextSchedule = null;
|
||||||
|
|
||||||
// main timer
|
// main timer and put it to sleep
|
||||||
static Timer scheduleTimer = new Timer(new TimerCallback(RunNextSchedule),
|
static Timer scheduleTimer = new Timer(new TimerCallback(RunNextSchedule),
|
||||||
null,
|
null,
|
||||||
Timeout.Infinite,
|
Timeout.Infinite,
|
||||||
|
@ -92,6 +92,8 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
// this will put the timer to sleep
|
// this will put the timer to sleep
|
||||||
scheduleTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
scheduleTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
|
|
||||||
|
System.Threading.Thread.Sleep(1000);
|
||||||
|
|
||||||
// run immediately
|
// run immediately
|
||||||
RunNextSchedule(null);
|
RunNextSchedule(null);
|
||||||
}
|
}
|
||||||
|
@ -122,31 +124,47 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
static void RunSchedule(SchedulerJob schedule, bool changeNextRun)
|
static void RunSchedule(SchedulerJob schedule, bool changeNextRun)
|
||||||
{
|
{
|
||||||
// update next run (if required)
|
|
||||||
if (changeNextRun)
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
SchedulerController.CalculateNextStartTime(schedule.ScheduleInfo);
|
// update next run (if required)
|
||||||
|
if (changeNextRun)
|
||||||
|
{
|
||||||
|
SchedulerController.CalculateNextStartTime(schedule.ScheduleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable run once task
|
||||||
|
if (schedule.ScheduleInfo.ScheduleType == ScheduleType.OneTime)
|
||||||
|
schedule.ScheduleInfo.Enabled = false;
|
||||||
|
|
||||||
|
Dictionary<int, BackgroundTask> scheduledTasks = TaskManager.GetScheduledTasks();
|
||||||
|
if (!scheduledTasks.ContainsKey(schedule.ScheduleInfo.ScheduleId))
|
||||||
|
// this task should be run, so
|
||||||
|
// update its last run
|
||||||
|
schedule.ScheduleInfo.LastRun = DateTime.Now;
|
||||||
|
|
||||||
|
// update schedule
|
||||||
|
SchedulerController.UpdateSchedule(schedule.ScheduleInfo);
|
||||||
|
|
||||||
|
// skip execution if the current task is still running
|
||||||
|
scheduledTasks = TaskManager.GetScheduledTasks();
|
||||||
|
if (!scheduledTasks.ContainsKey(schedule.ScheduleInfo.ScheduleId))
|
||||||
|
{
|
||||||
|
// run the schedule in the separate thread
|
||||||
|
schedule.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception Ex)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TaskManager.WriteError(string.Format("RunSchedule Error : {0}", Ex.Message));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable run once task
|
|
||||||
if (schedule.ScheduleInfo.ScheduleType == ScheduleType.OneTime)
|
|
||||||
schedule.ScheduleInfo.Enabled = false;
|
|
||||||
|
|
||||||
Dictionary<int, BackgroundTask> scheduledTasks = TaskManager.GetScheduledTasks();
|
|
||||||
if (!scheduledTasks.ContainsKey(schedule.ScheduleInfo.ScheduleId))
|
|
||||||
// this task should be run, so
|
|
||||||
// update its last run
|
|
||||||
schedule.ScheduleInfo.LastRun = DateTime.Now;
|
|
||||||
|
|
||||||
// update schedule
|
|
||||||
SchedulerController.UpdateSchedule(schedule.ScheduleInfo);
|
|
||||||
|
|
||||||
// skip execution if the current task is still running
|
|
||||||
if (scheduledTasks.ContainsKey(schedule.ScheduleInfo.ScheduleId))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// run the schedule in the separate thread
|
|
||||||
schedule.Run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,21 +86,21 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
{
|
{
|
||||||
DataSet ds = DataProvider.GetSchedule(SecurityContext.User.UserId, scheduleId);
|
DataSet ds = DataProvider.GetSchedule(SecurityContext.User.UserId, scheduleId);
|
||||||
ScheduleInfo si = ObjectUtils.FillObjectFromDataView<ScheduleInfo>(ds.Tables[0].DefaultView);
|
ScheduleInfo si = ObjectUtils.FillObjectFromDataView<ScheduleInfo>(ds.Tables[0].DefaultView);
|
||||||
return si;
|
return si;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets view configuration for a certain task.
|
/// Gets view configuration for a certain task.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="taskId">Task id for which view configuration is intended to be loeaded.</param>
|
/// <param name="taskId">Task id for which view configuration is intended to be loeaded.</param>
|
||||||
/// <returns>View configuration for the task with supplied id.</returns>
|
/// <returns>View configuration for the task with supplied id.</returns>
|
||||||
public static List<ScheduleTaskViewConfiguration> GetScheduleTaskViewConfigurations(string taskId)
|
public static List<ScheduleTaskViewConfiguration> GetScheduleTaskViewConfigurations(string taskId)
|
||||||
{
|
{
|
||||||
List<ScheduleTaskViewConfiguration> c = ObjectUtils.CreateListFromDataReader<ScheduleTaskViewConfiguration>(DataProvider.GetScheduleTaskViewConfigurations(taskId));
|
List<ScheduleTaskViewConfiguration> c = ObjectUtils.CreateListFromDataReader<ScheduleTaskViewConfiguration>(DataProvider.GetScheduleTaskViewConfigurations(taskId));
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static SchedulerJob GetScheduleComplete(int scheduleId)
|
internal static SchedulerJob GetScheduleComplete(int scheduleId)
|
||||||
{
|
{
|
||||||
DataSet ds = DataProvider.GetSchedule(SecurityContext.User.UserId, scheduleId);
|
DataSet ds = DataProvider.GetSchedule(SecurityContext.User.UserId, scheduleId);
|
||||||
return CreateCompleteScheduleFromDataSet(ds);
|
return CreateCompleteScheduleFromDataSet(ds);
|
||||||
|
@ -199,7 +199,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
nextStart = lastRun.AddSeconds(schedule.Interval);
|
nextStart = lastRun.AddSeconds(schedule.Interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nextStart < now)
|
if (nextStart < now)
|
||||||
nextStart = now; // run immediately
|
nextStart = now; // run immediately
|
||||||
|
|
||||||
// check if start time is in allowed interval
|
// check if start time is in allowed interval
|
||||||
|
@ -261,7 +261,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
if (accountCheck < 0) return accountCheck;
|
if (accountCheck < 0) return accountCheck;
|
||||||
|
|
||||||
// check quota
|
// check quota
|
||||||
if(PackageController.GetPackageQuota(schedule.PackageId, Quotas.OS_SCHEDULEDTASKS).QuotaExhausted)
|
if (PackageController.GetPackageQuota(schedule.PackageId, Quotas.OS_SCHEDULEDTASKS).QuotaExhausted)
|
||||||
return BusinessErrorCodes.ERROR_OS_SCHEDULED_TASK_QUOTA_LIMIT;
|
return BusinessErrorCodes.ERROR_OS_SCHEDULED_TASK_QUOTA_LIMIT;
|
||||||
|
|
||||||
CalculateNextStartTime(schedule);
|
CalculateNextStartTime(schedule);
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
TaskManager.ItemId = scheduleInfo.ScheduleId;
|
TaskManager.ItemId = scheduleInfo.ScheduleId;
|
||||||
TaskManager.ScheduleId = scheduleInfo.ScheduleId;
|
TaskManager.ScheduleId = scheduleInfo.ScheduleId;
|
||||||
TaskManager.MaximumExecutionTime = scheduleInfo.MaxExecutionTime;
|
TaskManager.MaximumExecutionTime = scheduleInfo.MaxExecutionTime;
|
||||||
|
|
||||||
// set task parameters
|
// set task parameters
|
||||||
foreach (ScheduleTaskParameterInfo prm in scheduleInfo.Parameters)
|
foreach (ScheduleTaskParameterInfo prm in scheduleInfo.Parameters)
|
||||||
TaskManager.TaskParameters[prm.ParameterId] = prm.ParameterValue;
|
TaskManager.TaskParameters[prm.ParameterId] = prm.ParameterValue;
|
||||||
|
@ -119,7 +119,13 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// complete task
|
// complete task
|
||||||
TaskManager.CompleteTask();
|
try
|
||||||
|
{
|
||||||
|
TaskManager.CompleteTask();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -754,6 +754,49 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public bool DoesSamAccountNameExist(string accountName)
|
||||||
|
{
|
||||||
|
return DoesSamAccountNameExistInternal(accountName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool DoesSamAccountNameExistInternal(string accountName)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("DoesSamAccountNameExistInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("sAMAccountName : {0}", accountName);
|
||||||
|
bool bFound = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
string path = GetRootOU();
|
||||||
|
HostedSolutionLog.DebugInfo("Search path : {0}", path);
|
||||||
|
DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path);
|
||||||
|
|
||||||
|
DirectorySearcher searcher = new DirectorySearcher(entry);
|
||||||
|
searcher.PropertiesToLoad.Add("sAMAccountName");
|
||||||
|
searcher.Filter = "(sAMAccountName=" + accountName + ")";
|
||||||
|
searcher.SearchScope = SearchScope.Subtree;
|
||||||
|
|
||||||
|
SearchResult resCollection = searcher.FindOne();
|
||||||
|
if (resCollection != null)
|
||||||
|
{
|
||||||
|
if (resCollection.Properties["samaccountname"] != null)
|
||||||
|
bFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.DebugInfo("Failed : {0}", e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostedSolutionLog.DebugInfo("DoesSamAccountNameExistInternal Result: {0}", bFound);
|
||||||
|
HostedSolutionLog.LogEnd("DoesSamAccountNameExistInternal");
|
||||||
|
|
||||||
|
return bFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Domains
|
#region Domains
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
<Version>2.1.0</Version>
|
<Version>2.1.0</Version>
|
||||||
<FileVersion>$(BUILD_NUMBER)</FileVersion>
|
<FileVersion>$(BUILD_NUMBER)</FileVersion>
|
||||||
<VersionLabel>$(BUILD_NUMBER)</VersionLabel>
|
<VersionLabel>$(BUILD_NUMBER)</VersionLabel>
|
||||||
<ReleaseDate>2012-01-22</ReleaseDate>
|
<ReleaseDate>2012-01-25</ReleaseDate>
|
||||||
<BuildConfiguration></BuildConfiguration>
|
<BuildConfiguration></BuildConfiguration>
|
||||||
<RootFolder>..</RootFolder>
|
<RootFolder>..</RootFolder>
|
||||||
<TrunkFolder>$(RootFolder)\WebsitePanel</TrunkFolder>
|
<TrunkFolder>$(RootFolder)\WebsitePanel</TrunkFolder>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue