码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-05-25 23:49:21      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:



///
<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 > 0) { int temp = 0; int total_update_count = 0; 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 >= 400 || temp >= totalcount) { Guid jobuid = Guid.NewGuid(); StatusingClient.QueueLockDownTasks(jobuid, projectuid, statusing_pro_dst_update); queuesystemutils.WaitForQueue(jobuid); total_update_count = 0; statusing_pro_dst_update = new StatusingWebSvc.ProjectDataSet(); } } } return true; } catch (Exception ex) { new LogHelper().WriteLine(ex.ToString()); return false; } }

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

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

标签:

原文地址:http://www.cnblogs.com/systemnet123/p/5528997.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!