Project Server调用PSI关闭任务以进行更新锁定任务


/// <summary>
/// 锁定和解锁项目任务
/// </summary>
/// <param name="projectuid">项目UID</param>
/// <param name="islock">是否锁定</param>
/// <returns></returns>
public bool CloseProjectTask(Guid projectuid, bool islock)
{
try
{
QueueSystemUtils queuesystemutils = new QueueSystemUtils(); ProjectDataSet dst = GetProjectByUid(projectuid);
StatusingWebSvc.ProjectDataSet statusing_pro_dst = new StatusingWebSvc.ProjectDataSet();
foreach (ProjectWebSvc.ProjectDataSet.TaskRow taskrow in dst.Task)
{
if (taskrow.TASK_LOCKDOWN_BY_MANAGER != islock)
{
taskrow.TASK_LOCKDOWN_BY_MANAGER = islock;
statusing_pro_dst.Task.ImportRow(taskrow);
}
}
if (statusing_pro_dst.Task.Count > )
{
int temp = ;
int total_update_count = ;
int totalcount = statusing_pro_dst.Task.Count;
StatusingWebSvc.ProjectDataSet statusing_pro_dst_update = new StatusingWebSvc.ProjectDataSet();
foreach (StatusingWebSvc.ProjectDataSet.TaskRow item in statusing_pro_dst.Task)
{
temp++;
total_update_count++;
statusing_pro_dst_update.Task.ImportRow(item);
if (total_update_count >= || temp >= totalcount)
{
Guid jobuid = Guid.NewGuid();
StatusingClient.QueueLockDownTasks(jobuid, projectuid, statusing_pro_dst_update);
queuesystemutils.WaitForQueue(jobuid);
total_update_count = ;
statusing_pro_dst_update = new StatusingWebSvc.ProjectDataSet();
} }
}
return true;
}
catch (Exception ex)
{
new LogHelper().WriteLine(ex.ToString());
return false;
}
}

注意:如果计划任务数量超过500条,会出现错误,必须分批去处理任务,调用QueueLockDownTasks来关闭项目任务已更新,锁定和解锁项目计划任务

上一篇:设计模式之单例模式--instance


下一篇:MySQL初始化设置