Testing and fixing scheduler
This commit is contained in:
parent
20f4b371d1
commit
b2d9fb43b2
7 changed files with 44 additions and 51 deletions
|
@ -1976,13 +1976,14 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@taskId", taskId));
|
||||
}
|
||||
|
||||
public static void AddBackgroundTaskParam(int taskId, string name, string value)
|
||||
public static void AddBackgroundTaskParam(int taskId, string name, string value, string typeName)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "AddBackgroundTaskParam",
|
||||
new SqlParameter("@taskId", taskId),
|
||||
new SqlParameter("@name", name),
|
||||
new SqlParameter("@value", value));
|
||||
new SqlParameter("@value", value),
|
||||
new SqlParameter("@typeName", typeName));
|
||||
}
|
||||
|
||||
public static void DeleteBackgroundTaskParams(int taskId)
|
||||
|
|
|
@ -152,10 +152,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo);
|
||||
|
||||
|
||||
if (accountCheck < 0)
|
||||
return accountCheck;
|
||||
|
||||
|
||||
SchedulerJob schedule = GetScheduleComplete(scheduleId);
|
||||
if (schedule == null)
|
||||
return 0;
|
||||
|
@ -177,9 +177,9 @@ namespace WebsitePanel.EnterpriseServer
|
|||
schedule.ScheduleInfo.MaxExecutionTime, parameters) { Status = BackgroundTaskStatus.Starting };
|
||||
|
||||
TaskController.AddTask(backgroundTask);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int StopSchedule(int scheduleId)
|
||||
{
|
||||
|
|
|
@ -109,7 +109,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
objTask.DoWork();
|
||||
else
|
||||
throw new Exception(String.Format("Could not create scheduled task of '{0}' type",
|
||||
task.TaskType));
|
||||
task.TaskType));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -88,15 +88,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
public static void AddTaskParams(int taskId, List<BackgroundTaskParameter> parameters)
|
||||
{
|
||||
if (parameters == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
foreach (BackgroundTaskParameter param in SerializeParams(parameters))
|
||||
{
|
||||
DataProvider.AddBackgroundTaskParam(taskId, param.Name, param.SerializerValue);
|
||||
DataProvider.AddBackgroundTaskParam(taskId, param.Name, param.SerializerValue, param.TypeName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,9 +126,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
foreach (BackgroundTaskParameter param in parameters)
|
||||
{
|
||||
param.TypeName = param.Value.GetType().Name;
|
||||
var type = param.Value.GetType();
|
||||
param.TypeName = type.FullName;
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(Type.GetType(param.TypeName));
|
||||
XmlSerializer serializer = new XmlSerializer(type);
|
||||
MemoryStream ms = new MemoryStream();
|
||||
serializer.Serialize(ms, param.Value);
|
||||
|
||||
|
@ -178,22 +174,17 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
private static string[] ReBuildParametersXml(string parameters)
|
||||
{
|
||||
string[] textParameters = new string[] {};
|
||||
var textParameters = new List<string>();
|
||||
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
var xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(parameters);
|
||||
|
||||
if (xmlDoc != null)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (XmlNode xmlParameter in xmlDoc.SelectNodes("parameters/parameter"))
|
||||
{
|
||||
textParameters[index] = xmlParameter.Attributes.GetNamedItem("value").Value;
|
||||
index++;
|
||||
}
|
||||
textParameters.AddRange(from XmlNode xmlParameter in xmlDoc.SelectNodes("parameters/parameter") select xmlParameter.Attributes.GetNamedItem("value").Value);
|
||||
}
|
||||
|
||||
return textParameters;
|
||||
return textParameters.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public static void StartTask(string source, string taskName, object itemName, int itemId,
|
||||
int scheduleId, int packageId, int maximumExecutionTime, List<BackgroundTaskParameter> parameters)
|
||||
{
|
||||
StartTask(null, source, taskName, itemName, itemId, scheduleId, packageId, maximumExecutionTime, new List<BackgroundTaskParameter>());
|
||||
StartTask(null, source, taskName, itemName, itemId, scheduleId, packageId, maximumExecutionTime, parameters);
|
||||
}
|
||||
|
||||
public static void StartTask(string taskId, string source, string taskName, object itemName, int itemId,
|
||||
|
@ -152,8 +152,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
taskId = Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
int userId = SecurityContext.User.UserId;
|
||||
int effectiveUserId = SecurityContext.User.IsPeer ? SecurityContext.User.OwnerId : userId;
|
||||
int userId = SecurityContext.User.OwnerId;
|
||||
int effectiveUserId = SecurityContext.User.IsPeer ? SecurityContext.User.OwnerId : SecurityContext.User.UserId;
|
||||
String itemNameStr = itemName != null ? itemName.ToString() : String.Empty;
|
||||
|
||||
BackgroundTask task = new BackgroundTask(Guid, taskId, userId, effectiveUserId, source, taskName, itemNameStr,
|
||||
|
@ -595,7 +595,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// get user tasks
|
||||
foreach (BackgroundTask task in TaskController.GetTasks())
|
||||
{
|
||||
if (task.EffectiveUserId == userId && !task.Completed)
|
||||
if (task.UserId == userId && !task.Completed)
|
||||
list.Add(task);
|
||||
}
|
||||
return list;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue