我必须在 SharePoint 中做一个计时器,咨询各种列表和工作流实例,应该改进代码吗?
我有很多if,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")
{
}
}
}
}
}
}
}
}
谢谢,