1
我必須在SharePoint中做一個計時器來諮詢各種列表和工作流程實例,應該改進代碼嗎?提高SharePoint代碼
我有很多如果,foreach,我不知道我是否應該改變。
這是代碼:
if (DateTime.Now.DayOfWeek == DayOfWeek.Friday || DateTime.Now.DayOfWeek == DayOfWeek.Tuesday)
{
using (SPSite site = new SPSite(ConfigManagerHelper.GetSetting("siteUrl")))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[ConfigManagerHelper.GetSetting("listName")];
SPListItemCollection items = list.Items;
foreach (SPListItem item in items)
{
string tipo = item.ContentType.Name;
if (tipo != CMIHelper.IndicadorEstrategico && tipo != CMIHelper.ObjetivoEstrategico && tipo != CMIHelper.ObjetivoOperativo)
{
continue;
}
if (tipo.Equals(CMIHelper.ObjetivoEstrategico))
{
foreach (SPWorkflow wf in item.Workflows)
{
if (wf.InternalState == SPWorkflowState.Running)
{
//Indicadores
if (wf.ParentAssociation.BaseTemplate.Name == "WFCuadroMandos")
{
foreach (SPListItem indAux in web.Lists["IndicadoresAux"].Items)
{
if (wf.InstanceId.ToString().Equals(indAux["APV_PE_WorkflowIdAux"].ToString()))
{
}
}
}
//Objetivos Estratégicos
if (wf.ParentAssociation.BaseTemplate.Name == "WFCuadroMandosObjEstr")
{
}
}
}
}
}
}
}
}
感謝,
謝謝,我要改變代碼。 – 2013-04-01 10:44:15