VARCHART XGantt .NET的最佳实践:通过表交互式交换任务

文章主要介绍关于VARCHART XGantt .NET的最佳实践之通过表交互式完成交换任务

VARCHART XGantt是一款功能强大的甘特图控件,其模块化的设计让您可以创建满足需要的应用程序。XGantt可用于.NET,ActiveX和ASP.NET应用程序,可以快速、简单地集成到您的应用程序中,帮助您识别性能瓶颈、避免延迟以及高效利用资源,使复杂数据变得更加容易理解。

XGantt展示图VARCHART XGantt最新版免费下载试用

项目情况

客户已经开发出一个图形规划板,用于使用VARCHART XGantt管理他的机器。任务在机器上按顺序运行,没有缓冲时间。在计划表的表格区域中,任务按开始日期排序,相应地按顺序列出。这在甘特区显示为“下降楼梯”。

VARCHART XGantt .NET的最佳实践:通过表交互式交换任务

项目需求

客户希望能够仅在表区域中通过拖放更改机器内的任务顺序。从技术上讲,这个问题必须通过制作一个已经在表格中移动的任务来实现。需要相应地改变任务的进程顺序,如下所示:

移动前

VARCHART XGantt .NET的最佳实践:通过表交互式交换任务

移动后

VARCHART XGantt .NET的最佳实践:通过表交互式交换任务

解决方案

VARCHART XGantt中以交互方式移动节点会触发事件VcNodeModifyingVcNodeModifiedEx

VcNodemodifying首先检查任务是否已被移动到另一个组,因为根据规范这是违规的。需要检查在移动任务之后其机器数据字段的内容是否已经改变。如果内容已更改,则ReturnStatus将设置为vcRetStatFalse,从而撤消移动。在这种情况下,事件VcNodeModifiedEx将不会出现。

private void vcGantt1_VcNodeModifying(object sender, VcNodeModifyingEventArgs e){   //Make sure that a task cannot be moved to another machine   string oldGroupName = e.OldNode.get_DataField(eMainData.Machine).ToString();   string newGroupName = e.Node.get_DataField(eMainData.Machine).ToString();   e.ReturnStatus = oldGroupName == newGroupName      VcReturnStatus.vcRetStatDefault : VcReturnStatus.vcRetStatFalse;}

如果允许移动,则必须重新安排任务,通过在VcNodeModifiedEx事件中完成的。然后再次运行该组的所有任务,并重新计算其开始和结束日期。从最早的开始日期开始,考虑相应的机器日历。在VcNodeCollection nodesInGroup中,节点按表中显示的顺序列出。

private void vcGantt1_VcNodeModifiedEx(object sender, VcNodeModifiedExEventArgs e){   DateTime minStartDate = DateTime.MaxValue;   DateTime startDate;   DateTime endDate;   VcCalendar cal =       vcGantt1.CalendarCollection.CalendarByName(e.Node.get_DataField(eMainData.Machine).ToString());   VcNodeCollection nodesInGroup = e.Node.SuperGroup.NodeCollection;   //Mark the moved node as "moved"   e.Node.set_DataField(eMainData._Moved, "1");   e.Node.Update();   //Search for the earliest start date of the nodes in the group   foreach (VcNode node in nodesInGroup)   {      startDate = Convert.ToDateTime(node.get_DataField(eMainData.Start));      minStartDate = (startDate < minStartDate startDate : minStartDate);   }   startDate = minStartDate;   //Reposition the tasks on the machine so that they follow each other    //without gaps or overlaps.   vcGantt1.SuspendUpdate(true);   foreach (VcNode node in nodesInGroup)   {      endDate = cal.AddDuration(startDate, Convert.ToInt32(node.get_DataField(eMainData.Duration)));      node.set_DataField(eMainData.Start, startDate);      node.set_DataField(eMainData.End, endDate);      node.Update();      startDate = (cal.IsWorktime(endDate) endDate : cal.GetStartOfNextWorktime(endDate));   }   vcGantt1.SuspendUpdate(false);}

重新计算日期后,任务将再次显示为降序楼梯:

VARCHART XGantt .NET的最佳实践:通过表交互式交换任务
想要购买VARCHART XGantt正版授权,或者获取更多该产品相关信息的朋友可以点击” 咨询在线客服 “~
海量产品正在参加年终大促,价格优惠!详情请点击” 年终巅峰钜惠 “~

标签:项目管理甘特图XGantt任务管理甘特图开发

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2018年11月23日
下一篇 2018年11月24日

相关推荐

发表回复

登录后才能评论