Question

J'ai ce code dans la méthode externe d'appel.

callExternalMethodActivity1_MethodInvoking private void (object sender, EventArgs e)

{

callExternalMethodActivitysitename = twInfo.Code;

callExternalMethodActivityurl = workflowProperties.WebUrl;

}

et la méthode dans le service de workflow connectable a:

CreateTrainingSite public void (string nomdusite, string url)         {            // CODE ICI         }

Lorsque je entre dans la première méthode, les propriétés sont remplis, mais quand je fais un pas dans la seconde méthode les variables sont nulles.

S'il vous plaît aider


Modifié:

namespace TrainingApprovalSiteWorkflow {

[ExternalDataExchange]
public interface ITrainingSiteCreationService
{
    event EventHandler<CommunicationObjArgs> MessageIn;
    void CreateTrainingSite(string sitename, string url);
}

[Serializable]
public class CommunicationObjArgs : ExternalDataEventArgs
{
    public CommunicationObjArgs(Guid id) : base(id) { }
    public string webID;
}

class StateObject
{
    public SPWeb web;
    public Guid instanceId;
    public StateObject(Guid instanceId, SPWeb web)
    {
        this.instanceId = instanceId;
        this.web = web;
    }
}

class TrainingSiteCreationService : SPWorkflowExternalDataExchangeService, ITrainingSiteCreationService
{
    public event EventHandler<CommunicationObjArgs> MessageIn;

    public void CreateTrainingSite(string sitename, string url)
    {
        ThreadPool.QueueUserWorkItem(delegate(object state)
        {
            StateObject sObject = state as StateObject;
            string webID = string.Empty;
            using (SPSite siteCollection = new SPSite(url))
            {
                using (SPWeb web = siteCollection.OpenWeb())
                {
                    using (SPWeb trainingWeb = web.Webs.Add(sitename))
                    {
                        trainingWeb.Description = "This site is created by a pluggable workflow service.";
                        trainingWeb.Title = sitename;
                        trainingWeb.Update();
                        webID = trainingWeb.ID.ToString();
                    }

                }
            }
            RaiseEvent(sObject.web, sObject.instanceId,
                typeof(ITrainingSiteCreationService),
                "MessageIn", new object[] { webID });
        }, new StateObject(WorkflowEnvironment.WorkflowInstanceId,
            this.CurrentWorkflow.ParentWeb));
    }

    public override void  CallEventHandler(Type eventType, string eventName, object[] eventData, SPWorkflow workflow, string identity, IPendingWork workHandler, object workItem)
    {
        var msg = new CommunicationObjArgs(workflow.InstanceId);
        msg.webID = eventData[0].ToString();
        msg.WorkHandler = workHandler;
        msg.WorkItem = workItem;
        msg.Identity = identity;
        this.MessageIn(null, msg);
    }

    public override void CreateSubscription(MessageEventSubscription subscription)
    {
        throw new NotImplementedException();
    }

    public override void DeleteSubscription(Guid subscriptionId)
    {
        throw new NotImplementedException();
    }
}

}

Était-ce utile?

La solution 2

j'ai pu trouver le problème.

Sur la méthode Invoquer onworkflow activée je mettais un autre champs,

et pas ces

callExternalMethodActivitysitename = twInfo.Code;

callExternalMethodActivityurl = workflowProperties.WebUrl;

, quand il arrive à la méthode externe d'appel, ils étaient vides, trop Obvius après avoir regardé très détaillé.

Autres conseils

Je vous suggère de créer un objet métier personnalisé qui a ces deux propriétés. En outre, vous devez faire cet objet sérialisable et utiliser cet objet pour communiquer avec la méthode dans votre service de workflow.

je l'ai fait quelque chose comme ça yestarday et cela fonctionne comme un charme quand vous devez fournir plusieurs paramètres à votre service WF.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top