Пример #1
0
        private static WorkflowApplication CreateWorkflowApplication(RegistrationData arguments = null)
        {
            if (RegistrationWorkflow == null)
            {
                RegistrationWorkflow = new TActivity();
            }

            var host = arguments != null
                           ? new WorkflowApplication(
                RegistrationWorkflow, new Dictionary <string, object> {
                { "RegData", arguments }
            })
                           : new WorkflowApplication(RegistrationWorkflow);

            var scope = new Dictionary <XName, object> {
                { WorkflowHostTypePropertyName, WorkflowHostTypeName }
            };

            // Add the WorkflowHostType value to workflow application so that it stores this data in the instance store when persisted
            host.AddInitialInstanceValues(scope);
            host.InstanceStore    = InstanceStore;
            host.PersistableIdle += args => PersistableIdleAction.Unload;

            // Setup the persistence participant
            host.Extensions.Add(new RegistrationPeristenceParticipant());
#if DEBUG
            // Output Workflow Tracking to VS Debug Window
            host.Extensions.Add(new TraceTrackingParticipant());
#endif
            return(host);
        }
 private static void ValidateData(RegistrationData data)
 {
     if (data.EmailTemplates == null)
     {
         throw new InvalidOperationException("No email templates supplied");
     }
 }
 private static void ValidateIndex(RegistrationData data, int index)
 {
     if (index < 0 || index > data.EmailTemplates.Count())
     {
         // ReSharper disable NotResolvedInText
         throw new ArgumentOutOfRangeException("EmailTemplateIndex");
         // ReSharper restore NotResolvedInText
     }
 }
Пример #4
0
        public Guid VerifyRegistration(RegistrationData data)
        {
            if (RegistrationWorkflow == null)
            {
                RegistrationWorkflow = new TActivity();
            }

            var host = CreateWorkflowApplication(data);

            data.VerificationUrl = this.AddVerificationCode(data.VerificationUrl, host.Id);
            data.CancelUrl       = this.AddVerificationCode(data.CancelUrl, host.Id);
            host.Run();

            return(host.Id);
        }
        private static void LoadTemplate(string path, RegistrationData data, Guid instanceId, int index)
        {
            var emailTemplate = TemplateCache.GetTemplate(path, data.BodyEncoding ?? Encoding.ASCII);

            var args = new object[5];

            args[InstanceIdIndex] = instanceId;
            args[VerificationUrlIndex] = data.VerificationUrl;
            args[CancelUrlIndex] = data.CancelUrl;
            args[StylesUrlIndex] = data.StylesUrl;
            args[TemplateIndex] = index;

            var body = string.Format(emailTemplate, data.BodyArguments.ToArray());
            body = ReplaceTokens(body, args);


            data.Body = string.Format(body, args.ToArray());
        }
Пример #6
0
        private static void LoadTemplate(string path, RegistrationData data, Guid instanceId, int index)
        {
            var emailTemplate = TemplateCache.GetTemplate(path, data.BodyEncoding ?? Encoding.ASCII);

            var args = new object[5];

            args[InstanceIdIndex]      = instanceId;
            args[VerificationUrlIndex] = data.VerificationUrl;
            args[CancelUrlIndex]       = data.CancelUrl;
            args[StylesUrlIndex]       = data.StylesUrl;
            args[TemplateIndex]        = index;

            var body = string.Format(emailTemplate, data.BodyArguments.ToArray());

            body = ReplaceTokens(body, args);


            data.Body = string.Format(body, args.ToArray());
        }
 private static void ValidateIndex(RegistrationData data, int index)
 {
     if (index < 0 || index > data.EmailTemplates.Count())
     {
         // ReSharper disable NotResolvedInText
         throw new ArgumentOutOfRangeException("EmailTemplateIndex");
         // ReSharper restore NotResolvedInText
     }
 }
 private static void ValidateData(RegistrationData data)
 {
     if (data.EmailTemplates == null)
     {
         throw new InvalidOperationException("No email templates supplied");
     }
 }