项目管理工具----普加项目管理中间件(PlusProject )入门教程(11):msProject项目的导入和导出(中)

普加项目管理中间件是用于跨浏览器和跨平台应用程序的功能齐全的 Gantt 图表,可满足项目管理应用程序的所有需求,是最完善的甘特图图表库。

 

.net下可以导入xml.mpp,微软提供了Microsoft.Office.Interop.MSProject.dll,可以将mpp文件转换成xml格式,我们提供了Plusoft.dllxml文件进行了解析处理,转换成可读的格式存入到数据库中。

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
private static HashMap getObjectFromXML(Element root) throws Exception {
        NodeList lst = root.getChildNodes();
        HashMap hs = new HashMap();    
        if (lst == null){
            return null;
        }
        for (int it = 0; it <  lst.getLength(); it++){
            Node nd = lst.item(it);
            NodeList tmp = nd.getChildNodes();
            String name = nd.getNodeName();
            String value =  null;
            if(tmp != null && tmp.item(0) != null){
                value = tmp.item(0).getNodeValue();
            }
            //String
            if( name.equals("UID")
                || name.equals("Name")
                || name.equals("CalendarUID")
                || name.equals("DefaultStartTime")
                || name.equals("DefaultFinishTime")
            ){
                hs.put(name, value);
            }
            //Int
            if( name.equals("MinutesPerDay")
                || name.equals("MinutesPerWeek")
                || name.equals("DaysPerMonth")
                || name.equals("WeekStartDay")
            ){
                hs.put(name, toInt(value));
            }
            //Date
            if( name.equals("CreationDate")
                || name.equals("LastSaved")
                || name.equals("StartDate")
                || name.equals("FinishDate")
            ){
                hs.put(name, parseDate(value));
            }
             
            if( name.equals("Calendars")){
                hs.put(name, getCalendars(nd));
            }
            if( name.equals("Assignments")){
                hs.put(name, getAssignments(nd));
            }
            if( name.equals("Resources")){
                hs.put(name, getResources(nd));
            }
            if( name.equals("Tasks")){
                hs.put(name, getTasks(nd));
            }          
            //ExtendedAttributes
            if(name.equals("ExtendedAttributes")){             
                hs.put("ExtendedAttributes", getNodesList(nd));            
            }
            //OutlineCodes
            if(name.equals("OutlineCodes")){
                ArrayList list = new ArrayList();
                NodeList node_list = nd.getChildNodes();
                for (int i = 0; i < node_list.getLength(); i++){
                    NodeList child = node_list.item(i).getChildNodes();            
                    if (child.getLength() > 0){
                        //OutlineCode                      
                        HashMap o = new HashMap();
                        for (int j = 0; j < child.getLength(); j++){
                            Node _node = child.item(j);
                            String nodeName = _node.getNodeName();             
                            putNodeValue(o, _node);
                            if(nodeName.equals("Masks")){
                                o.put("Masks", getNodesList(_node));               
                            }
                            if(nodeName.equals("Values")){
                                o.put("Values", getNodesList(_node));              
                            }
                        }
                        list.add(o);
                    }                  
                }
                hs.put("OutlineCodes", list);              
            }
        }      
        //Calendars
        ArrayList calendars = (ArrayList)hs.get("Calendars");
        for(int i=0,l=calendars.size(); i<l; i++)
        {
            HashMap calendar = (HashMap)calendars.get(i);                            
            ArrayList WeekDays = (ArrayList)calendar.get("WeekDays");           
            if(WeekDays == null) continue;
            ArrayList Exceptions = (ArrayList)calendar.get("Exceptions");         
            if(Exceptions == null){
                Exceptions = new ArrayList();
                calendar.put("Exceptions", Exceptions);
            }
            for (int j = WeekDays.size() - 1; j >= 0; j--)
            {
                HashMap weekday = (HashMap)WeekDays.get(j);
                if (weekday.get("DayType") == null || weekday.get("DayType").toString().equals("0"))
                {
                    //Exceptions.add(weekday);
                    WeekDays.remove(weekday);
                }
            }
        }       
        if (calendars != null && calendars.size() > 0 && (hs.get("CalendarUID") == null || hs.get("CalendarUID").toString().equals("null")))
        {
            hs.put("CalendarUID", ((Map)calendars.get(0)).get("UID"));
        }
         
        return hs;
    }

 

  

 

posted @   在上班的又一天  阅读(8)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示