Beispiel #1
0
        //// This method called on notification workflow completion.
        //internal static void NotificationWFCompleted(WorkflowApplicationCompletedEventArgs e) {
        //  switch (e.CompletionState) {
        //    // If workflow complated without any error.
        //    case ActivityInstanceState.Closed:
        //      #if DEBUG
        //      Console.WriteLine("Workflow Completed.");
        //      #endif
        //    break;
        //    // If any error occurred during workflow execution, will be handled here.
        //    case ActivityInstanceState.Faulted:
        //      Exception ex = e.TerminationException;
        //      ExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error, "Error occured in Notification Workflow", "PresentPolicy");
        //      break;
        //  }
        //}

        // Start notification workflow with provided input parameters.
        internal static void StartWorkflow(IDictionary <string, object> inputParam, NotificationWFCompleted handler)
        {
            // Initialize the notification workflow instance.
            NotificationWF notificationWF = new NotificationWF();

            // Initialize workflow application instance with notification workflow and
            // with required input argument dictionary.
            WorkflowApplication wfApp = new WorkflowApplication(notificationWF, inputParam);

            wfApp.SynchronizationContext = SynchronizationContext.Current;
            // Attaching a method with workflow completed event.
            wfApp.Completed = new Action <WorkflowApplicationCompletedEventArgs>(handler);

            //// Start the workflow execution asynchronously.
            wfApp.Run();
        }
Beispiel #2
0
        // Start the notification workflow to send notification for provided list of events.
        public static void StartNotificationWF(string id, string partyName, string compName, string userName, NotificationDefinition notificationDef, string xslPath, NotificationWFCompleted handler, string bookingID = "", string soID = "")
        {
            IDictionary <string, object> input = new Dictionary <string, object>
            {
                { "CustomerName", partyName },
                { "CompanyName", compName },
                { "UserName", userName },
                { "EntityID", id.ToString() },
                { "NotificationDef", notificationDef },
                { "XSLPath", xslPath },
                { "NotificationType", (int)EnumNotificationEntity.Scale },
                { "BookingID", bookingID },
                { "SOID", soID }
            };

            // Start workflow.
            StartWorkflow(input, handler);
        }