通过PSI读取项目信息时性能不佳 [英] Poor Performance when Reading Project Info via PSI

查看:65
本文介绍了通过PSI读取项目信息时性能不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个SharePoint Web部件,它通过PSI从PS2010访问信息。我的代码基于以下演练:

I am developing a SharePoint Web Part that accessing information from PS2010, via the PSI. My code is based off of the walkthrough at:

http://msdn.microsoft.com/en-us/library/ee767691.aspx

 

I我只阅读项目信息(我正在从草案数据库中检索所有项目),但是当我将Web部署部署到客户端环境时,我的性能非常差(他们在系统中有大约55个项目,而我的本地
dev环境只有大约5个项目。)

I am only reading Project information (I am retrieving all the projects from the Draft database), but I'm experiencing very poor performance when I deploy my Web Part to a client's environment (they have around 55 projects in their system, whereas my local dev environment only has about 5 projects).

这是我检索所有项目的代码:

Here is my code to retrieve all the projects:


                // Get list of all projects
                backendProject.ProjectDataSet projectDs = projectClient.ReadProjectStatus(Guid.Empty,
                                                                    backendProject.DataStoreEnum.WorkingStore,
                                                                    string.Empty,
                                                                    (int)PSLibrary.Project.ProjectType.Project);

                backendProject.ProjectDataSet tempProjDs = null;

                DataRow row;

                for (int i = 0; i < projectDs.Project.Count; i++)
                {
                    tempProjDs = projectClient.ReadProject(projectDs.Project[i].PROJ_UID, backendProject.DataStoreEnum.WorkingStore);

                    backendProject.ProjectDataSet.TaskDataTable tdt;
                    tdt = tempProjDs.Task;
                    int pct = 0;

                    // Populate percentage complete for project (value is in first row of tasks data table)
                    if (tdt.Rows.Count > 0)
                        pct = tdt[0].TASK_PCT_COMP;

                    row = dtResults.NewRow();
                    AddProjectRow(ref row, tempProjDs, pct, "");

                    // Only add to datatable if project is published (exception is eaten, in case the project is not published)
                    try
                    {
                        string strTemp = tempProjDs.Project[0].WPROJ_LAST_PUB.ToString();
                        dtResults.Rows.Add(row);
                    }
                    catch (Exception ex)
                    {
                    }
                }

推荐答案

嗨John,

如果您不需要所有项目实体,请尝试ReadProjectEntities方法而不是ReadProject。您可以选择所需的实体,例如只是任务或只是项目自定义字段或任何组合。通常任务自定义字段是最大的
表,如果你不需要这些数据,你可以节省一些时间。

if you don't need all project entities try the ReadProjectEntities-method instead of ReadProject. You can choose the entities you need e.g. just the tasks or just the project custom fields or any combination. Usually the task custom fields is the largest table and if you do not need this data, you can save some time here.

根据我的经验,性能很大程度上取决于如何整个系统实施。如果您安装了数据库和项目服务器的单个开发机器,则速度不是很快。将数据库和项目服务器放在不同的机器上
要快得多。

In my experience the performance depends a lot on how the whole system is implemented. If you have a single development machine the database and project server installed, it is not very fast. Having the database and the project server on separate machines is much faster.

我们通常必须处理大型项目,每项任务最多6000个任务和20个自定义字段。所以我总是要解释为什么表现如此糟糕。这是因为开发机器不是最快的。幸运的是,客户端环境更好
: - )

We usually have to deal with large projects up to 6000 tasks and 20 custom fields per task. So I always have to explain why the performance is so poor. It's because the development machine is not the fastest one. Fortunately, the clients environments are much better :-)

我的代码中也有一件事:在循环中使用try / catch可以减慢整个过程如果它经常进入捕获区块。最好使用IF来检查某些东西,而不是让它抛出异常。对于循环中只有一些
的项目,它应该不是一个大问题。但是如果你有几千件商品,其中一半会抛出一个例外,你必须抓住它,这确实会降低性能。

Also there is one thing I experienced in my code: using try/catch in a loop can slow down the whole thing too, if it runs into the catch-block regularly. It's better to use IF for checking something than letting it throw an exception. For only some items in the loop, it should not be a big problem. But if you have several thousand items and half of them throwing an exception you have to catch, it really slows down performance.

 

问候,

Dirk


这篇关于通过PSI读取项目信息时性能不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆