SharePoint Learning Notes
http://blog.csdn.net/qq873113580/article/details/20390149
1, install Microsoft Project software I'm faking 2010.
2, on net above test no problem
3, this error occurred while porting the code to SharePoint
Retrieving a component of the CLSID {36d27c48-a1e8-11d3-ba55-00c04f72f325} in a COM class factory failed because of the following error: 80010001 the callee refused to receive the call. (Exceptions are from hresult:0x80010001 (rpc_e_call_rejected)).
4, Baidu all kinds of search, online information may be account permissions issues
5, here is the information found online
-Enter: dcomcnfg on the command line, which displays the Component Services Manager
-Open "Component Services, computers--My Computer->dcom configuration", find "Microsoft Project", right-click, select "Properties"
-Click the Identity tab in the Properties dialog box and select Interactive User
-Then find "security", put all of the following permissions to choose Custom, and then add all kinds of user permissions, Erverone,admin,net ... I've got a lot of roles in my jurisdiction.
6, after the above layout everyone said OK, and then I tried or not, the mind is not a code problem, check n then and net version of the comparison code no problem
7, and finally found in SharePoint there is a code to mention the right
Spsecurity.runwithelevatedprivileges (delegate
{
Code to write this inside
Microsoft.Office.Interop.MSProject.ApplicationClass prj = new Microsoft.Office.Interop.MSProject.ApplicationClass ( );//This code directly error
});
8, it is estimated that permissions do not recognize the account permissions in SharePoint, so the new code to extract the changes to this
Microsoft.Office.Interop.MSProject.ApplicationClass prj = new Microsoft.Office.Interop.MSProject.ApplicationClass ( );//This is done.
Spsecurity.runwithelevatedprivileges (delegate
{
Code to write this inside
});
9, here is a small example of how to use project import to get data
Program Object
Microsoft.Office.Interop.MSProject.ApplicationClass prj = new Microsoft.Office.Interop.MSProject.ApplicationClass ( );
File path
String Prjfilename= "Xxx.mpp";
Read the file, only need to change prjfilename this, the parameters of the following default assignment is good
Prj. FileOpen (Prjfilename, True, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.MSProject.PjPoolOpen.pjPoolReadOnly, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
foreach (Microsoft.Office.Interop.MSProject.Project proj in PRJ. Projects)
{
foreach (Microsoft.Office.Interop.MSProject.Task Task in Proj. Tasks)
{
A task is a required object, a task. Property names There's no way to change the name of the property, it's all the system's own definition.
if (task! = null)
{
Task. OutlineLevel the level of the tree structure, default 1 start, the property name to find out for yourself a lot of system definitions represent what, I won't use project to do things, not much to say
Task. Text1........task. Text30 These fields are good for custom columns and are also the system's own
}
}
break;//here add break, actually I did not go deep into the prj. Projects inside in the end a few how to come, currently using the project file only one, so the cycle of time directly to find a good
}
SharePoint Project Import (MPP file import)