Un dos patróns emerxentes que atopar na elaboración de solucións SharePoint emprega fluxo de traballo do SharePoint Design e un receptor de eventos.
Aquí está un escenario de negocios para colocar-lo no contexto:
- Eu enviar un documento a unha biblioteca doc.
- Eu ban fóra do fluxo de traballo multi-paso creado utilizando o SharePoint Design.
- Nalgún momento, durante ese proceso, fluxo de traballo asigna unha tarefa a alguén (vía recoller datos de usuario ou asignar unha tarefa).
- We want to use a KPI to track how long that task is awaiting completion. The KPI shows green for tasks that are completed or due more than 3 days from now. It shows yellow if the task is due tomorrow or today. It shows red if the task is past due.
- Aquí está o kicker: Quero que a data que impulsa que KPI ser festivo-aware.
I can’t calculate a holiday-aware due date in SharePoint Designer workflow very easily. I would have to create a custom action or use a 3rd party tool. Con todo, it’s easy enough to calculate such a date in an event receiver. Merge those two together and we get a pattern like this:
- Define a hidden yes/no site column on the document library labeled "DoCalcualteDueDate".
- Arrincar a falsa.
- No momento axeitado no fluxo de traballo (e.g. just before the "collect data" acción), asignar ese valor como True.
- Un ItemUpdate() event receiver looks to see if "DoCalculateDueDate" is true. Since the event receiver runs on every update, "DoCalculateDueDate" adoita teito.
- Cando o fluxo de traballo atribúe DoCalculateDueDate a verdade, o receptor de eventos calcula a data de caducidade de vacacións-aware.
- Cando o receptor de eventos fai este cálculo, el define a bandeira DoCalculateDueDate a falsa.
A finais, SPD workflow is communicated with an event receiver via the DoCalculateDueDate semaphore and we have holiday-aware due dates that are assigned at the exactly correct moment in the workflow’s life. SharePoint Designer controls when the due date is assigned but the event receiver performs the actual calculation and assignment.
</final>