Example #1
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb web = properties.Feature.Parent as SPWeb;

            if (web != null)
            {
                SPList taskList         = web.Lists[Lists.RegistrationApprovalTasks];
                SPList historyList      = web.Lists[Lists.WorkflowHistory];
                SPList registrationList = web.Lists[Lists.Registrations];

                SPWorkflowAssociation existingAssociation = null;
                existingAssociation = registrationList.WorkflowAssociations.GetAssociationByName(WorkflowTemplates.RegistrationApprovalNameV2, CultureInfo.CurrentCulture);
                if (existingAssociation == null)
                {
                    //Create a worklow manager and associate the Course Registration Approval Workflow template
                    //to our Registrations list.
                    SPWorkflowManager            workflowManager = web.Site.WorkflowManager;
                    SPWorkflowTemplateCollection templates       = workflowManager.GetWorkflowTemplatesByCategory(web, null);
                    SPWorkflowTemplate           template        = templates.GetTemplateByBaseID(new Guid(WorkflowTemplates.RegistrationApprovalBaseIdV2));
                    SPWorkflowAssociation        association     = SPWorkflowAssociation.CreateListAssociation(template, template.Name, taskList, historyList);
                    association.AllowManual     = true;
                    association.AutoStartCreate = true;
                    registrationList.AddWorkflowAssociation(association);
                    registrationList.Update();
                    association.Enabled = true;
                }
            }
        }
Example #2
0
        //Methode: SharePoint-Designer-Workflow wird gestartet.
        public void StartSPWorkflow(String workflowName)
        {
            SPWorkflowAssociationCollection associationCollection = listItemOrder.ParentList.WorkflowAssociations;

            //Mit foreach wird durch alle vorhandenen Workflows in der Websitesammlung gegangen
            foreach (SPWorkflowAssociation association in associationCollection)
            {
                //Wenn einer der Workflownamen dem Angegebenen (dh. <string workflow>) entspricht wird der enthaltene Code ausgeführt
                if (association.Name == workflowName)
                {
                    //Überprüfen ob eine weitere Instanz des gleichen Workflows schon ausgeführt wird.
                    //Das ist nötig, wenn eine Drittlandsbestellung gemacht wird. Dabei wird der Workflow solange angehalten/pausiert bis die Zollbeauftragten den Auftrag genehmigt haben.
                    //Wenn vor der Genehmigung etwas am Auftrag geändert wird, muss der SP-Designer-WF erneut gestartet werden. Da die vorige Instanz des Workfows aber noch läuft und nur pausiert ist,
                    //schlägt das Starten des Workflows fehl.
                    foreach (SPWorkflow spworkflow in site.WorkflowManager.GetItemActiveWorkflows(listItemOrder))
                    {
                        //Überprüft wird, ob die AssocationId übereinstimmt --> wenn ja, wird diese Instanz mit "CancelWorkflow" abgebrochen
                        if (spworkflow.AssociationId == association.Id)
                        {
                            SPWorkflowManager.CancelWorkflow(spworkflow);
                        }
                    }
                    association.AutoStartChange = true;
                    association.AutoStartCreate = false;
                    association.AssociationData = string.Empty;
                    //Befehl zum Starten des Workflows
                    site.WorkflowManager.StartWorkflow(listItemOrder, association, association.AssociationData);
                }
            }
        }
Example #3
0
        private static void StartWorkflow(SPListItem listItem, string workflowName)
        {
            try
            {
                SPWorkflowManager manager = listItem.Web.Site.WorkflowManager;
                SPWorkflowAssociationCollection objWorkflowAssociationCollection = listItem.ParentList.WorkflowAssociations;
                foreach (SPWorkflowAssociation objWorkflowAssociation in objWorkflowAssociationCollection)
                {
                    if (String.Compare(objWorkflowAssociation.Name, workflowName, true) == 0)
                    {
                        //We found our workflow association that we want to trigger.

                        //Replace the workflow_GUID with the GUID of the workflow feature that you
                        //have deployed.

                        try
                        {
                            manager.StartWorkflow(listItem, objWorkflowAssociation, objWorkflowAssociation.AssociationData, true);
                            //The above line will start the workflow...
                        }
                        catch (Exception)
                        { }


                        break;
                    }
                }
            }
            catch (Exception)
            {}
        }
Example #4
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb web = properties.Feature.Parent as SPWeb;

            IConfigManager hierarchicalConfig = SharePointServiceLocator.Current.GetInstance <IConfigManager>();

            hierarchicalConfig.SetInPropertyBag(Constants.SubSiteCreationConfigSiteKey, web.Url, SPFarm.Local);

            SPList taskList    = web.Lists[taskListName];
            SPList historyList = web.Lists[workflowHistoryName];
            SPList subSiteCreationRequestList = web.Lists[subSiteRequestsListName];

            var existingAssociation = subSiteCreationRequestList.WorkflowAssociations.GetAssociationByName(workflowTemplateName, CultureInfo.CurrentCulture);

            if (existingAssociation == null)
            {
                SPWorkflowManager            workflowManager = web.Site.WorkflowManager;
                SPWorkflowTemplateCollection templates       = workflowManager.GetWorkflowTemplatesByCategory(web, null);
                SPWorkflowTemplate           template        = templates.GetTemplateByBaseID(workflowTemplateId);
                SPWorkflowAssociation        association     = SPWorkflowAssociation.CreateListAssociation(template, template.Name, taskList, historyList);
                association.AllowManual     = true;
                association.AutoStartCreate = true;
                subSiteCreationRequestList.AddWorkflowAssociation(association);
                subSiteCreationRequestList.Update();
                association.Enabled = true;
            }

            ServiceLocatorConfig typeMappings = new ServiceLocatorConfig();

            typeMappings.RegisterTypeMapping <IBusinessEventTypeConfigurationRepository, BusinessEventTypeConfigurationRepository>();
            typeMappings.RegisterTypeMapping <ISubSiteCreationRequestRepository, SubSiteCreationRequestsRepository>();
        }
Example #5
0
        public static void StartWorkflow(SPListItem listItem, string workflowName, SPWorkflowRunOptions runOption)
        {
            try
            {
                SPWorkflowManager manager = listItem.Web.Site.WorkflowManager;
                SPWorkflowAssociationCollection objWorkflowAssociationCollection = listItem.ParentList.WorkflowAssociations;
                Debug.WriteLine("WF.Count=" + objWorkflowAssociationCollection.Count.ToString());

                foreach (SPWorkflowAssociation objWorkflowAssociation in objWorkflowAssociationCollection)
                {
                    Debug.WriteLine("WF.InternalName=" + objWorkflowAssociation.InternalName);
                    Debug.WriteLine("WF.Id=" + objWorkflowAssociation.Id.ToString());

                    if (String.Compare(objWorkflowAssociation.Name, workflowName, true) == 0)
                    {
                        Debug.WriteLine("WF.Selected");

                        try
                        {
                            SPWorkflowCollection wfc = manager.GetItemActiveWorkflows(listItem);
                            bool isActive            = false;
                            foreach (SPWorkflow wf in wfc)
                            {
                                Debug.WriteLine("WF.InternalName=" + wf.ItemName);

                                // wf.IsCompleted nie używać - blokuje kolejne uruchomienie procesu jeżęli status jest "Ukończono"
                                if (wf.IsLocked && objWorkflowAssociation.Id.Equals(wf.AssociationId))
                                {
                                    isActive = true;
                                    Debug.WriteLine("WF.IsLocked=" + wf.IsLocked.ToString());
                                    Debug.WriteLine("WF.AssociationId=" + wf.AssociationId.ToString());
                                    break;
                                }
                            }

                            if (!isActive)
                            {
                                SPWorkflow spw = manager.StartWorkflow(listItem, objWorkflowAssociation, objWorkflowAssociation.AssociationData, runOption);
                                Debug.WriteLine("Workflow: " + workflowName + " Internal State: " + spw.InternalState);
                                //The above line will start the workflow...
                            }
                            else
                            {
                                Debug.WriteLine("WF aktualnie uruchomiony - kolejna aktywacja procesu przerwana");
                                //ElasticEmail.EmailGenerator.SendMail("wf aktualnie uruchomiony" + listItem.ID.ToString(), string.Empty);
                            }
                        }
                        catch (Exception)
                        { }


                        break;
                    }
                }
            }
            catch (Exception)
            { }
        }
Example #6
0
        public void CancelWorkflow(SPWorkflowInstance workflow)
        {
            if (workflow == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "An instance of a SPWorkflow object must be supplied as the first argument.");
            }

            SPWorkflowManager.CancelWorkflow(workflow.SPWorkflow);
        }
Example #7
0
        public SPWorkflowManagerInstance(ObjectInstance prototype, SPWorkflowManager workflowManager)
            : this(prototype)
        {
            if (workflowManager == null)
            {
                throw new ArgumentNullException("workflowManager");
            }

            m_workflowManager = workflowManager;
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SPSite curSite = SPContext.Current.Site;
            SPWeb  curWeb  = SPContext.Current.Web;
            string listId  = Request.QueryString["listId"].ToString();
            string itemIds = Request.QueryString["ID"].ToString();

            if (!string.IsNullOrEmpty(listId))
            {
                list = curWeb.Lists[new Guid(listId)];
            }
            if (list != null && !string.IsNullOrEmpty(itemIds))
            {
                SPSecurity.RunWithElevatedPrivileges(delegate() {
                    curWeb.AllowUnsafeUpdates = true;
                    var idArr = itemIds.Split(',');
                    foreach (var id in idArr)
                    {
                        if (!string.IsNullOrEmpty(id))
                        {
                            int itemid = System.Convert.ToInt32(id);
                            try
                            {
                                item = list.GetItemById(itemid);
                                foreach (SPWorkflow spWF in item.Workflows)
                                {
                                    if (spWF.IsCompleted == false)
                                    {
                                        foreach (SPWorkflowTask task in spWF.Tasks)
                                        {
                                            if (task["PercentComplete"].ToString() != "1")
                                            {
                                                task["Status"]          = "Canceled";
                                                task["PercentComplete"] = "1";
                                                task.Update();
                                            }
                                        }
                                        SPWorkflowManager.CancelWorkflow(spWF);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                throw new SPException("Cancel Failed: " + ex.Message);
                            }
                        }
                    }
                    curWeb.AllowUnsafeUpdates = false;
                });

                Redirect();
            }
        }
Example #9
0
        private void TerminateButton_Click(object sender, EventArgs e)
        {
            if (grid.SelectedRows.Count > 0)
            {
                if (SquadronContext.Confirm("Are you sure you wanted to Terminate this workflow?"))
                {
                    SPWorkflow workflow = grid.SelectedRows[0].DataBoundItem as SPWorkflow;

                    SPWorkflowManager.CancelWorkflow(workflow);

                    RefreshWorkflows();
                }
            }
        }
Example #10
0
        public static SPWorkflow StartWorkflow(SPListItem listItem, string workflowName)
        {
            SPWorkflow wf = null;

            try
            {
                SPWorkflowManager manager = listItem.Web.Site.WorkflowManager;
                SPWorkflowAssociationCollection objWorkflowAssociationCollection = listItem.ParentList.WorkflowAssociations;
                foreach (SPWorkflowAssociation objWorkflowAssociation in objWorkflowAssociationCollection)
                {
                    if (String.Compare(objWorkflowAssociation.Name, workflowName, true) == 0)
                    {
                        //We found our workflow association that we want to trigger.

                        //Replace the workflow_GUID with the GUID of the workflow feature that you
                        //have deployed.

                        try
                        {
                            //result = manager.StartWorkflow(listItem, objWorkflowAssociation, objWorkflowAssociation.AssociationData, SPWorkflowRunOptions.SynchronousAllowPostpone);
                            wf = manager.StartWorkflow(listItem, objWorkflowAssociation, objWorkflowAssociation.AssociationData, true);

                            //ElasticEmail.EmailGenerator.SendMail("StartWorkflow: " + workflowName + " " + wf.InternalState.ToString(), "");

                            //manager.StartWorkflow(listItem, objWorkflowAssociation, objWorkflowAssociation.AssociationData, true);
                            //The above line will start the workflow...
                        }
                        catch (Exception)
                        { }


                        break;
                    }
                }
            }
            catch (Exception)
            { }

            return(wf);
        }
Example #11
0
        public static void CancelWorkflowAppropriately(SPWorkflow workflow, SPSite site)
        {
            bool flag = false;

            try
            {
                //E43856D2-1BB4-40ef-B08B-016D89A0
                Guid objB = new Guid("a938eabe-8db1-45b9-87cb-b930728afe10");
                foreach (SPWorkflowModification modification in workflow.Modifications)
                {
                    if (object.Equals(modification.TypeId, objB))
                    {
                        site.WorkflowManager.ModifyWorkflow(workflow, modification, null);
                        flag = true;
                        break;
                    }
                }
                //ULS.SendTraceTag(0x38747333, ULSCat.msoulscat_CMS_Publishing, ULSTraceLevel.Verbose, "Simple cancellation on workflow: {0} for item: {1} ", new object[] { workflow.AssociationId.ToString(), workflow.ParentItem.Url });
            }
            catch (ArgumentNullException)
            {
                flag = false;
            }
            catch (ArgumentException)
            {
                flag = false;
            }
            catch (SPException)
            {
                flag = false;
            }
            if (!flag)
            {
                SPWorkflowManager.CancelWorkflow(workflow);
                //ULS.SendTraceTag(0x38747334, ULSCat.msoulscat_CMS_Publishing, ULSTraceLevel.Verbose, "SPWorkflowManager.CancelWorkflow(), full cancellation on workflow: {0} for item: {1} ", new object[] { workflow.AssociationId.ToString(), workflow.ParentItem.Url });
            }
        }
Example #12
0
 /// <summary>
 /// Cancels the workflows.  This code is a re-engineering of the code that Microsoft uses
 /// when approving an item via the browser.  That code is in Microsoft.SharePoint.ApplicationPages.ApprovePage.
 /// </summary>
 /// <param name="test">If true test the change only (don't make any changes).</param>
 /// <param name="list">The list.</param>
 /// <param name="item">The item.</param>
 private void CancelWorkflows(bool test, SPList list, SPListItem item)
 {
     if (list.DefaultContentApprovalWorkflowId != Guid.Empty &&
         item.DoesUserHavePermissions((SPBasePermissions.ApproveItems |
                                       SPBasePermissions.EditListItems)))
     {
         // If the user has rights to do so then we need to cancel any workflows that
         // are associated with the item.
         SPSecurity.RunWithElevatedPrivileges(
             delegate
         {
             foreach (SPWorkflow workflow in item.Workflows)
             {
                 if (workflow.ParentAssociation.Id !=
                     list.DefaultContentApprovalWorkflowId)
                 {
                     continue;
                 }
                 SPWorkflowManager.CancelWorkflow(workflow);
                 Logger.Write("Cancelling workflow {0} for item: {1} ({2})", workflow.WebId.ToString(), item.ID.ToString(), item.Url);
             }
         });
     }
 }
Example #13
0
        /// <summary>
        /// An item was updated.
        /// </summary>
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);
            if (properties.ListItem.Name.Contains(".pdf"))
            {
                //Durch folgende Zeile wird der enthaltene Code als SHAREPOINT\System ausgeführt und nicht unter dem Kontext des Benutzers, der den Auftrag unterschrieben hat
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    //Laden des aktuellen Webs; das ist nötig, um alle möglichen Operationen mit Bibliotheken und Elementen auszuführen
                    //dieses wird wieder geschlossen bzw. freigegeben, wenn die geschweifte Klammer von "using" geschlossen wird
                    using (SPSite site = new SPSite(properties.WebUrl))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            //Festlegen von Variablen
                            //Initialisieren der "Helper"-Klasse. Diese enthält selbst geschriebene Methoden, die hier aufgerufen werden.
                            Helper helper = new Helper();
                            //Laden des aktuell geänderten bzw. unterschrieben Elements
                            SPListItem _currentItem = web.Lists[properties.ListId].GetItemById(properties.ListItemId);
                            //Abspeichern von Spaltenwerten des Elements in Variablen; der String in den eckigen Klammern ist der Spaltenname
                            string requirementId = _currentItem["Title"].ToString();
                            string docId         = _currentItem.Properties["_dlc_DocId"].ToString();
                            //Laden der Bibliothek "Temp" und des Unterordners, welcher als Namen die Auftragsnummer hat

                            //Angabe des Namens der Bibliothek der Auftragsformulare und deren Dateinamen
                            //string formLibrary = "BedarfsmeldungFormulare";
                            string formLibrary  = "Bedarfsmeldung-Formulare";
                            string formFileName = requirementId + ".xml";
                            string xAttachment  = "my:file";
                            string xReason      = "/my:myFields/my:reason";

                            //Definieren einer vorerst leeren String-Variable
                            string prevSigned = "";
                            //Wenn die Spalte "SignaturePreviousSigned" nicht leer ist, wird der enthaltene Wert der Variable "davorsigniert" zugwiesen
                            if (_currentItem["SignaturePreviousSigned"] != null)
                            {
                                prevSigned = _currentItem["SignaturePreviousSigned"].ToString();
                            }

                            //Auslesen der Empfängeradressen
                            string rcptRequirementFiles        = "";
                            string spGroupRcptRequirementFiles = "Empfänger der Bedarfsmeldungen";
                            foreach (SPUser user in web.SiteGroups[spGroupRcptRequirementFiles].Users)
                            {
                                rcptRequirementFiles += user.Email.ToString() + ";";
                            }

                            string rcptBbc        = "";
                            string spGroupRcptBbc = "E-Mails der Ereignisempfänger (BBC) ";
                            foreach (SPUser user in web.SiteGroups[spGroupRcptBbc].Users)
                            {
                                rcptBbc += user.Email.ToString() + ";";
                            }

                            //Laden des gerade signierten PDFs; zuerst wird es als SharePoint-Datei (SPFile) geladen, dann als Byte-Array.
                            SPFile requirementPdf     = _currentItem.File;
                            byte[] requirementPdfByte = requirementPdf.OpenBinary();
                            //Initialisieren eines PDFReaders (von itextsharp) mit Verweis auf das eben geöffnete Byte-Array; der PDF-Reader kann PDF-Dateien nur lesen
                            using (PdfReader pdfreader = new PdfReader(requirementPdfByte))
                            {
                                //Laden der vorhandenen PDF-Formularfelder
                                AcroFields fields = pdfreader.AcroFields;
                                //Speichern der Namen aller signierten Felder in disem PDF in Liste "signatures". Die zu signierenden Felder heißen "Projektleiter" und "Verwaltung"; demnach kann dieser Wert leer, "Projektleiter" oder "ProjektleiterVerwaltung" sein
                                List <string> signatures = pdfreader.AcroFields.GetSignatureNames();
                                //Die gerade gespeicherten Feldnamen werden mit Komma getrennt (wenn mehrere vorhanden sind) und in eine neue String-Variable gespeichert. Somit wird aus "ProjektleiterVerwaltung" > "Projektleiter,Verwaltung"
                                string signed = string.Join(",", signatures.ToArray());
                                //Anhand dieser IF-Abfrage wird geprüft ob der Auftag überhaupt signiert wurde. Es wird der Spaltenwert ("SignaturePreviousSigned") mit den im PDF tatsächlich signierten Feldern verglichen
                                if (signed != prevSigned)
                                {
                                    //Starten des SharePoint-Designer-Workflows "Unterschriftenlauf" mit Parameter "signedfields". Mit diesem Parameter werden die Namen der Signierten Felder direkt als String mitgegeben.
                                    SPWorkflowAssociationCollection associationCollection = _currentItem.ParentList.WorkflowAssociations;
                                    foreach (SPWorkflowAssociation association in associationCollection)
                                    {
                                        if (association.Name == "Bedarfsmeldung - Genehmigungsvorgang")
                                        {
                                            //Überprüfen ob eine weitere Instanz des gleichen Workflows schon ausgeführt wird.
                                            //Das ist nötig, wenn eine Drittlandsbestellung gemacht wird. Dabei wird der Workflow solange angehalten/pausiert bis die Zollbeauftragten den Auftrag genehmigt haben.
                                            //Wenn vor der Genehmigung etwas am Auftrag geändert wird, muss der SP-Designer-WF erneut gestartet werden. Da die vorige Instanz des Workfows aber noch läuft und nur pausiert ist,
                                            //schlägt das Starten des Workflows fehl.
                                            foreach (SPWorkflow spworkflow in site.WorkflowManager.GetItemActiveWorkflows(_currentItem))
                                            {
                                                //Überprüft wird, ob die AssocationId übereinstimmt --> wenn ja, wird diese Instanz mit "CancelWorkflow" abgebrochen
                                                if (spworkflow.AssociationId == association.Id)
                                                {
                                                    SPWorkflowManager.CancelWorkflow(spworkflow);
                                                }
                                            }
                                            association.AutoStartChange = true;
                                            association.AutoStartCreate = false;
                                            association.AssociationData = "<Data><Signiert>" + signed + "</Signiert></Data>";
                                            //web.Site.WorkflowManager.StartWorkflow(_currentItem, association, association.AssociationData);
                                            site.WorkflowManager.StartWorkflow(_currentItem, association, association.AssociationData);
                                        }
                                    }
                                    //Der SharePoint-Designer-Workflow geht nun alle vorhandenen Fälle durch und versendet die nötigen Benachrichtigungen und ändert das Status-Feld des Auftrags
                                    //Im Code muss nun nur noch der Fall beachtet werden, wenn Projektleiter und Verwaltung unterschrieben haben
                                    //In diesem Fall muss ein PDF für die Verwaltung und eins (nur wenn nötig) für den Empfang erstellt werden. Letzteres wird benötigt, um dem Empfang dieses per Mail zu versenden, damit es gefaxt oder per Post versendet werden kann.
                                    //Das ist nur nötig, wenn die Bestellmethode NICHT "online" oder "Abholung" ist
                                    //Zu aller erst wird überprüft ob der beschriebene Fall eintritt: Die Variable "signiert" enthält alle Namen der Signaturfelder aus dem PDf, die unterschrieben sind.
                                    if (signed == "Projektleiter")
                                    {
                                        SPList tempLibrary = web.Lists["Temp"];
                                        var tempFolder     = web.GetFolder(String.Format("{0}/Temp/" + requirementId, web.Url));
                                        //Angabe des Namens der Bibliothek, in der die Begründungen gespeichert werden, und des Dateinamens der Begründungen
                                        string urlRequirementInTempFolder = tempLibrary.RootFolder.SubFolders[requirementId].Url + "/" + requirementId + ".pdf";

                                        string tempuploadurl = helper.TempOrdner(tempLibrary, tempFolder, requirementId);
                                        //Laden des Auftragsformulars
                                        byte[] xmlfile     = helper.GetFileFromWeb(formLibrary, formFileName, web);
                                        Stream xmlmemstr   = new MemoryStream(xmlfile);
                                        XmlDocument xmldoc = new XmlDocument();
                                        xmldoc.Load(xmlmemstr);
                                        XPathNavigator root       = xmldoc.CreateNavigator();
                                        XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
                                        //Angeben des NameSpaces: Die Werte werden direkt aus einem beispiel Formular entnommen (stehen am Anfang der XML-Datei)
                                        nsmgr.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2019-02-06T08:35:46");
                                        helper.UploadAttachments(root.Select("/my:myFields/my:attachments/my:attachment", nsmgr), xAttachment, nsmgr, docId, tempFolder, tempuploadurl, web);

                                        string reasonFolder          = "Begruendungen";
                                        string reasonLibrary         = "Begründungen";
                                        string reasonFileName        = requirementId + "_Begruendung.pdf";
                                        string urlReasonInTempFolder = tempLibrary.RootFolder.SubFolders[requirementId].Url + "/" + reasonFileName;
                                        if (root.SelectSingleNode(xReason, nsmgr).ToString() != "")
                                        {
                                            byte[] reasonPdf    = helper.GetFileFromWeb(reasonLibrary, reasonFileName, web);
                                            SPFile spFileReason = tempFolder.Files.Add(urlReasonInTempFolder, reasonPdf, true);
                                        }

                                        //Bedarfsmeldungs-Pdf
                                        byte[] flattenedRequirementPdf = helper.flattenPdfForm(requirementPdfByte);
                                        SPFile spFileRequirementPdf    = tempFolder.Files.Add(urlRequirementInTempFolder, flattenedRequirementPdf, true);
                                        //Setzen des Spaltenwerts "Weitergabe" auf true, da der Lieferant den Auftragszettel immer erhalten muss. Wäre dieser WErt auf "false" würde Auftragszettel beim PDf für Fax oder Post fehlen. Der Wert ist in der SharePoint-Bibliothek "Temp" standardmäßig auf "false" gesetzt.
                                        //SPListItem spItemRequirementPdf = spFileRequirementPdf.Item;
                                        //spItemRequirementPdf.SystemUpdate();

                                        //diese IF-Abfrage ist nur reine Sicherheitsmaßnahme: Es wird geprüft ob im Temp-Ordner auch Dateien vorhanden sind. Da der Auftrag direkt davor in diesen Ordner kopiert wird sollte diese Bedingung immer zutreffen.
                                        if (tempFolder.ItemCount > 0)
                                        {
                                            SPListItemCollection itemCollection = helper.CollectFiles(tempFolder, tempLibrary, false);
                                            string mailText = "<div style='font-family: Frutiger LT COM 45 Light; font-size: 11pt;'>Guten Tag,<br><br>"
                                                              + "die Bedarfsmeldung #" + requirementId + " wurde vom Projektleiter signiert. "
                                                              + "Die Bedarfsmeldung und die zugehörigen Anlagen sind im Anhang enthalten.<br><br>"
                                                              + "Name Besteller: " + helper.GetUserDisplayName(_currentItem, "Name Besteller") + "<br>"
                                                              + "Projektleiter: " + helper.GetUserDisplayName(_currentItem, "Projektleiter") + "<br><br>"
                                                              + "Dies ist eine automatische Benachrichtigung. Bitte antworten Sie nicht auf diese E-Mail.";
                                            helper.Mail("Bestellung", rcptRequirementFiles, rcptBbc, "Neue Bedarfsmeldung (#" + requirementId + ")", mailText, itemCollection, requirementId, site);
                                        }
                                        tempFolder.Delete();
                                    }
                                }
                            }
                        }
                    }
                });
            }
        }