Example #1
0
        protected override void Execute(CodeActivityContext context)
        {
            // Create a Lead class and populate it with the input arguments
            Lead l = new Lead();

            l.ContactName  = ContactName.Get(context);
            l.ContactPhone = ContactPhone.Get(context);
            l.Interests    = Interests.Get(context);
            l.Comments     = Notes.Get(context);
            l.WorkflowID   = context.WorkflowInstanceId;
            l.Status       = "Open";

            // Add this to the work queue to be persisted later
            PersistLead persist = context.GetExtension <PersistLead>();

            persist.AddLead(l, "Insert");

            // Store the request in the OutArgument
            Lead.Set(context, l);

            // Add a custom track record
            CustomTrackingRecord userRecord = new CustomTrackingRecord("New Lead")
            {
                Data =
                {
                    { "Name",  l.ContactName  },
                    { "Phone", l.ContactPhone }
                }
            };

            // Emit the custom tracking record
            context.Track(userRecord);
        }
Example #2
0
        protected override void Execute(CodeActivityContext context)
        {
            // Create a Lead class and populate it with the input arguments
            Lead l = new Lead();

            l.ContactName  = ContactName.Get(context);
            l.ContactPhone = ContactPhone.Get(context);
            l.Interests    = Interests.Get(context);
            l.Comments     = Notes.Get(context);
            l.WorkflowID   = context.WorkflowInstanceId;
            l.Status       = "Open";

            // Get the connection string
            DBExtension ext = context.GetExtension <DBExtension>();

            if (ext == null)
            {
                throw new InvalidProgramException("No connection string available");
            }

            // Insert a record into the Lead table
            LeadDataDataContext dc =
                new LeadDataDataContext(ext.ConnectionString);

            dc.Leads.InsertOnSubmit(l);
            dc.SubmitChanges();

            // Store the request in the OutArgument
            Lead.Set(context, l);
        }
Example #3
0
        public EnterLead()
        {
            // Define the variables used by this workflow
            Variable <Lead> lead = new Variable <Lead> {
                Name = "lead"
            };

            // Define the SendRequest workflow
            this.Implementation = () => new Sequence
            {
                DisplayName = "EnterLead",
                Variables   = { lead },
                Activities  =
                {
                    new CreateLead
                    {
                        ContactName = new InArgument <string>
                                          (env => ContactName.Get(env)),
                        ContactPhone = new InArgument <string>
                                           (env => ContactPhone.Get(env)),
                        Interests = new InArgument <string>
                                        (env => Interests.Get(env)),
                        Notes            = new InArgument <string>(env => Notes.Get(env)),
                        ConnectionString = new InArgument <string>
                                               (env => ConnectionString.Get(env)),
                        Lead = new OutArgument <Lead>(env => lead.Get(env)),
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Lead received [" + Rating.Get(env).ToString()
                                   + "]; waiting for assignment"),
                        TextWriter = new InArgument <TextWriter> (env => Writer.Get(env))
                    },
                    new InvokeMethod
                    {
                        TargetType = typeof(ApplicationInterface),
                        MethodName = "NewLead",
                        Parameters =
                        {
                            new InArgument <Lead>(env => lead.Get(env))
                        }
                    },
                    new WaitForInput <Lead>
                    {
                        BookmarkName = "GetAssignment",
                        Input        = new OutArgument <Lead>(env => lead.Get(env))
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Lead assigned [" + Rating.Get(env).ToString()
                                   + "] to " + lead.Get(env).AssignedTo),
                        TextWriter = new InArgument <TextWriter> (env => Writer.Get(env))
                    }
                }
            };
        }
Example #4
0
        protected override void Execute(CodeActivityContext context)
        {
            // Create a Lead class and populate it with the input arguments
            Lead l = new Lead();

            l.ContactName  = ContactName.Get(context);
            l.ContactPhone = ContactPhone.Get(context);
            l.Interests    = Interests.Get(context);
            l.Comments     = Notes.Get(context);
            l.WorkflowID   = context.WorkflowInstanceId;
            l.Status       = "Open";

            // Insert a record into the Lead table
            LeadDataDataContext dc =
                new LeadDataDataContext(ConnectionString.Get(context));

            dc.Leads.InsertOnSubmit(l);
            dc.SubmitChanges();

            // Store the request in the OutArgument
            Lead.Set(context, l);
        }
Example #5
0
        public EnterLead()
        {
            // Define the variables used by this workflow
            Variable <Lead> lead = new Variable <Lead> {
                Name = "lead"
            };
            Variable <string> assignedTo = new Variable <string> {
                Name = "assignedTo"
            };

            // Define the SendRequest workflow
            this.Implementation = () => new Sequence
            {
                DisplayName = "EnterLead",
                Variables   = { lead, assignedTo },
                Activities  =
                {
                    new CreateLead
                    {
                        ContactName = new InArgument <string>
                                          (env => ContactName.Get(env)),
                        ContactPhone = new InArgument <string>
                                           (env => ContactPhone.Get(env)),
                        Interests = new InArgument <string>
                                        (env => Interests.Get(env)),
                        Notes = new InArgument <string>(env => Notes.Get(env)),
                        Lead  = new OutArgument <Lead>(env => lead.Get(env)),
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Lead received [" + Rating.Get(env).ToString()
                                   + "]; waiting for assignment"),
                        TextWriter = new InArgument <TextWriter> (env => Writer.Get(env))
                    },
                    new InvokeMethod
                    {
                        TargetType = typeof(ApplicationInterface),
                        MethodName = "NewLead",
                        Parameters =
                        {
                            new InArgument <Lead>(env => lead.Get(env))
                        }
                    },
                    new AddComment
                    {
                        Comment = new InArgument <string>(env => "Lead has been created")
                    },
                    new WaitForInput <string>
                    {
                        BookmarkName = "GetAssignment",
                        Input        = new OutArgument <string>(env => assignedTo.Get(env))
                    },
                    new TransactionScope
                    {
                        Body = new Sequence
                        {
                            Activities =
                            {
                                new AssignLead
                                {
                                    AssignedTo = new InArgument <string>(env => assignedTo.Get(env)),
                                    Lead       = new OutArgument <Lead>(env => lead.Get(env)),
                                },
                                new Delay
                                {
                                    Duration = TimeSpan.FromSeconds(20)
                                },
                                new CreateAssignment
                                {
                                    AssignedTo = new InArgument <string>(env => assignedTo.Get(env)),
                                    LeadID     = new InArgument <int>(env => lead.Get(env).LeadID),
                                }
                            }
                        },
                    },
                    new InvokeMethod
                    {
                        TargetType = typeof(ApplicationInterface),
                        MethodName = "UpdateLead",
                        Parameters =
                        {
                            new InArgument <Lead>(env => lead.Get(env))
                        }
                    },
                    new AddComment
                    {
                        Comment = new InArgument <string>(env => "Lead is being assigned")
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Lead assigned [" + Rating.Get(env).ToString()
                                   + "] to " + lead.Get(env).AssignedTo),
                        TextWriter = new InArgument <TextWriter> (env => Writer.Get(env))
                    }
                }
            };
        }
        public EnterLead()
        {
            // Define the variables used by this workflow
            Variable <Lead> lead = new Variable <Lead> {
                Name = "lead"
            };
            Variable <string> assignedTo = new Variable <string> {
                Name = "assignedTo"
            };
            Send send = new Send
            {
                OperationName       = "Assign",
                ServiceContractName = "CreateAssignment",
                Content             = new SendParametersContent
                {
                    Parameters =
                    {
                        {
                            "leadID",
                            new InArgument <int> (env => lead.Get(env).LeadID)
                        },
                        {
                            "assignedTo",
                            new InArgument <string>(env => assignedTo.Get(env))
                        }
                    }
                },
                EndpointAddress = new InArgument <Uri>
                                      (env => new Uri("http://localhost/CreateAssignment")),
                Endpoint = new Endpoint
                {
                    Binding = new BasicHttpBinding()
                }
            };

            // Define the SendRequest workflow
            this.Implementation = () => new Sequence
            {
                DisplayName = "EnterLead",
                Variables   = { lead, assignedTo },
                Activities  =
                {
                    new CreateLead
                    {
                        ContactName = new InArgument <string>
                                          (env => ContactName.Get(env)),
                        ContactPhone = new InArgument <string>
                                           (env => ContactPhone.Get(env)),
                        Interests = new InArgument <string>
                                        (env => Interests.Get(env)),
                        Notes = new InArgument <string>(env => Notes.Get(env)),
                        //ConnectionString = new InArgument<string>(env => ConnectionString.Get(env)),
                        Lead = new OutArgument <Lead>(env => lead.Get(env)),
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Lead received [" + Rating.Get(env).ToString()
                                   + "]; waiting for assignment"),
                        TextWriter = new InArgument <TextWriter>
                                         (env => Writer.Get(env))
                    },
                    new InvokeMethod
                    {
                        TargetType = typeof(ApplicationInterface),
                        MethodName = "NewLead",
                        Parameters =
                        {
                            new InArgument <Lead>(env => lead.Get(env))
                        }
                    },
                    new AddComment
                    {
                        Comment = new InArgument <string>(env => "Lead has been created")
                    },



                    new WaitForInput <string>
                    {
                        BookmarkName = "GetAssignment",
                        Input        = new OutArgument <string>(env => assignedTo.Get(env))
                    },
                    //funziona capitolo 15
                    //new TransactionScope
                    //{
                    //    Body = new Sequence
                    //    {
                    //        Activities =
                    //        {

                    //            new AssignLead
                    //            {
                    //            AssignedTo = new InArgument<string>(env => assignedTo.Get(env)),
                    //            Lead = new InOutArgument<Lead>(env => lead.Get(env)),
                    //            },
                    //            new Delay
                    //            {
                    //            Duration = TimeSpan.FromSeconds(20)
                    //            },
                    //            new CreateAssignment
                    //            {
                    //            AssignedTo = new InArgument<string>(env => assignedTo.Get(env)),
                    //            LeadID = new InArgument<int>(env => lead.Get(env).LeadID),
                    //            }
                    //        }
                    //    },
                    // },
                    new AssignLead
                    {
                        AssignedTo = new InArgument <string>
                                         (env => assignedTo.Get(env)),
                        Lead = new InOutArgument <Lead>(env => lead.Get(env)),
                    },
                    new CorrelationScope
                    {
                        Body = new Sequence
                        {
                            Activities =
                            {
                                send,
                                new ReceiveReply
                                {
                                    Request = send
                                }
                            }
                        }
                    },

                    new InvokeMethod
                    {
                        TargetType = typeof(ApplicationInterface),
                        MethodName = "UpdateLead",
                        Parameters =
                        {
                            new InArgument <Lead>(env => lead.Get(env))
                        }
                    },

                    new AddComment
                    {
                        Comment = new InArgument <string>(env => "Lead is being assigned")
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Lead assigned [" + Rating.Get(env).ToString()
                                   + "] to " + lead.Get(env).AssignedTo),
                        TextWriter = new InArgument <TextWriter>
                                         (env => Writer.Get(env))
                    }
                }
            };
        }