博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VARCHART XGantt .NET的最佳实践:通过表交互式交换任务
阅读量:7022 次
发布时间:2019-06-28

本文共 2515 字,大约阅读时间需要 8 分钟。

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

本文主要通过利用VARCHART XGantt来处理文章提及的可能发生的情况,向大家展示VARCHART XGantt.NET的最佳实践,即通过表交互式交换任务。

项目情况

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

项目需求

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

移动前

移动后

解决方案

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);}复制代码

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

查看转载原文请点击。

你可能感兴趣的文章
看书不挑出版社的都是山炮——评60家国内出版社
查看>>
关于消除超长的case列表的一个思路
查看>>
shell下root用户切换其他用户运行程序
查看>>
恢复Ext3下被删除的文件(转)
查看>>
Instagram 架构分析笔记(转)
查看>>
java http线程池
查看>>
java较全的面试题
查看>>
day3
查看>>
软件程序编码
查看>>
感觉好累
查看>>
使用ant制作hadoop1.1.2的eclipse插件(转载)
查看>>
Css的transform和transition
查看>>
POJ1386Play on Words(欧拉回路)
查看>>
configparser 文件的生成和读写
查看>>
20个PHP程序性能优化的方法
查看>>
关于游戏平衡性工作内容——王者荣耀英雄伤害附录
查看>>
47种常见的浏览器兼容性问题大汇总
查看>>
数据结构与算法预热--线性表是什么?
查看>>
Winform自定义控件实例
查看>>
Golang使用MongoDB通用操作
查看>>