Beispiel #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";

            // 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);
        }
Beispiel #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Open the config file and get the connection string
            Configuration config =
                ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ConnectionStringsSection css =
                (ConnectionStringsSection)config.GetSection("connectionStrings");

            _connectionString = css.ConnectionStrings["LeadGenerator"].ConnectionString;

            _instanceStore = new SqlWorkflowInstanceStore(_connectionString);
            InstanceView view = _instanceStore.Execute
                                    (_instanceStore.CreateInstanceHandle(),
                                    new CreateWorkflowOwnerCommand(),
                                    TimeSpan.FromSeconds(30));

            _instanceStore.DefaultInstanceOwner = view.InstanceOwner;

            // Create the DBExtension
            _dbExtension = new DBExtension(_connectionString);

            // Set up the tracking participants
            CreateTrackingParticipant();
            CreateETWTrackingParticipant();
            CreateSqlTrackingParticipant();

            LoadExistingLeads();
        }
Beispiel #3
0
        public virtual void ApplyDispatchBehavior
            (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            WorkflowServiceHost workflowServiceHost
                = serviceHostBase as WorkflowServiceHost;

            if (null != workflowServiceHost)
            {
                DBExtension db = new DBExtension(_connectionString);
                workflowServiceHost.WorkflowExtensions.Add(db);
            }
        }
Beispiel #4
0
        protected override void Execute(NativeActivityContext context)
        {
            // Get the connection string
            DBExtension ext = context.GetExtension <DBExtension>();

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

            // Create a data context
            LeadDataDataContext dc = new LeadDataDataContext(ext.ConnectionString);

            // Enlist on the current transaction
            RuntimeTransactionHandle rth = new RuntimeTransactionHandle();

            rth = context.Properties.Find(rth.ExecutionPropertyName)
                  as RuntimeTransactionHandle;
            if (rth != null)
            {
                Transaction t = rth.GetCurrentTransaction(context);

                // Open the connection, if necessary
                if (dc.Connection.State == System.Data.ConnectionState.Closed)
                {
                    dc.Connection.Open();
                }

                dc.Connection.EnlistTransaction(t);
            }

            // Create an Assignment class and populate its properties
            Assignment a = new Assignment();

            dc.Assignments.InsertOnSubmit(a);

            a.WorkflowID   = context.WorkflowInstanceId;
            a.LeadID       = LeadID.Get(context);
            a.DateAssigned = DateTime.Now;
            a.AssignedTo   = AssignedTo.Get(context);
            a.Status       = "Assigned";
            a.DateDue      = DateTime.Now + TimeSpan.FromDays(5);

            dc.SubmitChanges();
        }
Beispiel #5
0
        protected override void Execute(NativeActivityContext context)
        {
            // Get the connection string
            DBExtension ext = context.GetExtension <DBExtension>();

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

            // Query the Lead table
            LeadDataDataContext dc = new LeadDataDataContext(ext.ConnectionString);

            dc.Refresh(RefreshMode.OverwriteCurrentValues, dc.Leads);
            Lead l = dc.Leads.SingleOrDefault <Lead>
                         (x => x.WorkflowID == context.WorkflowInstanceId);

            if (l == null)
            {
                throw new InvalidProgramException
                          ("The Lead was not found in the database");
            }

            l.AssignedTo = AssignedTo.Get(context);
            l.Status     = "Assigned";

            // Enlist on the current transaction
            RuntimeTransactionHandle rth = new RuntimeTransactionHandle();

            rth = context.Properties.Find(rth.ExecutionPropertyName)
                  as RuntimeTransactionHandle;
            if (rth != null)
            {
                Transaction t = rth.GetCurrentTransaction(context);
                dc.Connection.EnlistTransaction(t);
            }

            dc.SubmitChanges();

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