/// /// Vérification du process en cours on passe l'Id de l'objet le nom du workflow /// /// /// /// /// /// /// private bool Wf_process(int Nid, string Swf, Guid Ng, string sNom_entree, string sId, int Id, WorkflowApplication app) { bool bRet = false; string sLigne; int NbFound = 0; try { using (WorkflowConnection connection = app.Open()) { int.TryParse(sId, out Id); SearchFilterOptions Options = new SearchFilterOptions() { Server = LF_server, Repository = LF_repository, WorkflowName = Swf, MinEntryId = Id, MaxEntryId = Id, InstanceId = Ng }; foreach (SearchResult result in connection.Database.Tracking.SearchWorkflowInstances(Options)) { WorkflowInstance instance = result.WorkflowInstance; if (instance.InstanceId == Ng) { instance.Refresh(); string workflowName = result.WorkflowInstance.WorkflowName; string username = result.WorkflowInstance.Initiator.Name; string startTime = result.WorkflowInstance.StartTime.ToString(); string statusTime = result.WorkflowInstance.StatusChanged.ToString(); Guid wfIntanceId = result.WorkflowInstance.InstanceId; WorkflowInstanceStatus status = result.WorkflowInstance.Status; bool isWaiting = status != WorkflowInstanceStatus.Completed && status != WorkflowInstanceStatus.Terminated; if (status == WorkflowInstanceStatus.Completed || status == WorkflowInstanceStatus.Terminated) { sLigne = string.Format("Nom du workflow: {0}\r\n", workflowName); sLigne += string.Format("username: {0}\r\n", username); sLigne += string.Format("startTime: {0}\r\n", startTime); sLigne += string.Format("statusTime: {0}\r\n", statusTime); sLigne += string.Format("isWaiting: {0}\r\n", isWaiting); sLigne += string.Format("wfInstanceId: {0}", wfIntanceId); Write_log(sLigne); NbFound++; sLigne = string.Format("---> {0} Intance ID {1} statut: {2}", instance.WorkflowName, instance.InstanceId, result.WorkflowInstance.Status); Write_log(sLigne); bRet = true; return bRet; } } } } if (NbFound == 0) { nBOUCLE++; bRet = Wf_process(Nid, Swf, Ng, sNom_entree, sId, Id, app); //if (nBOUCLE < nMax_wait) //{ // bRet = Wf_process(Nid, Swf, Ng, sNom_entree, sId, Id, app); //} } bRet = true; } catch (Exception ex) { sLigne = string.Format("{0}\r{1}", ex.Message, ex.StackTrace); Write_log(sLigne); bRet = false; } return bRet; }