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);

            // 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 #3
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);
        }
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
        private void btnAssign_Click(object sender, RoutedEventArgs e)
        {
            if (lstLeads.SelectedIndex >= 0)
            {
                Lead l  = (Lead)lstLeads.Items[lstLeads.SelectedIndex];
                Guid id = l.WorkflowID;

                LeadDataDataContext dc = new LeadDataDataContext(_connectionString);
                dc.Refresh(RefreshMode.OverwriteCurrentValues, dc.Leads);
                l = dc.Leads.SingleOrDefault <Lead>(x => x.WorkflowID == id);
                if (l != null)
                {
                    l.AssignedTo = txtAgent.Text;
                    l.Status     = "Assigned";
                    dc.SubmitChanges();

                    // Clear the input
                    txtAgent.Text = "";
                }

                // Update the grid
                lstLeads.Items[lstLeads.SelectedIndex] = l;
                lstLeads.Items.Refresh();

                WorkflowApplication i = new WorkflowApplication(new EnterLead());

                SetupInstance(i);
                i.Load(id);

                try
                {
                    i.ResumeBookmark("GetAssignment", l);
                }
                catch (Exception e2)
                {
                    AddEvent(e2.Message);
                }
            }
        }
Example #6
0
        private void btnAssign_Click(object sender, RoutedEventArgs e)
        {
            if (lstLeads.SelectedIndex >= 0)
            {
                Lead l  = (Lead)lstLeads.Items[lstLeads.SelectedIndex];
                Guid id = l.WorkflowID;

                WorkflowApplication i = new WorkflowApplication(new EnterLead());

                SetupInstance(i);
                i.Load(id);

                try
                {
                    i.ResumeBookmark("GetAssignment", txtAgent.Text);
                }
                catch (Exception e2)
                {
                    AddEvent(e2.Message);
                }
            }
        }
Example #7
0
        public void UpdateLead(Lead lead)
        {
            // Find the row that matches this record
            int nSelected = -1;

            for (int i = 0; i < lstLeads.Items.Count; i++)
            {
                Lead l = lstLeads.Items[i] as Lead;
                if (l.LeadID == lead.LeadID)
                {
                    nSelected = i;
                    break;
                }
            }
            // Update the grid
            if (nSelected >= 0)
            {
                lstLeads.Items[nSelected] = lead;
                lstLeads.Items.Refresh();

                UpdateControls(lead);
            }
        }
Example #8
0
 partial void InsertLead(Lead instance);
Example #9
0
 public void AddNewLead(Lead l)
 {
     this.lstLeads.Dispatcher.BeginInvoke
         (new Action(() => this.lstLeads.Items.Add(l)));
 }
 partial void DeleteLead(Lead instance);
 partial void UpdateLead(Lead instance);
 partial void InsertLead(Lead instance);
Example #13
0
        protected override void CollectValues
            (out IDictionary <XName, object> readWriteValues,
            out IDictionary <XName, object> writeOnlyValues)
        {
            // We're not actually providing data to the caller
            readWriteValues = null;
            writeOnlyValues = null;

            // See if there is any work to do...
            if (_object.Count > 0)
            {
                // Get the current transaction
                Transaction t = System.Transactions.Transaction.Current;

                // Setup the DataContext
                LeadDataDataContext dc = new LeadDataDataContext(_connectionString);

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

                if (t != null)
                {
                    dc.Connection.EnlistTransaction(t);
                }

                // Process each object in our work queue
                foreach (KeyValuePair <Guid, Lead> kvp in _object)
                {
                    Lead   l      = kvp.Value as Lead;
                    string action = _action[l.WorkflowID];

                    // Perform the insert
                    if (action == "Insert")
                    {
                        dc.Leads.InsertOnSubmit(l);
                    }

                    // Perform the update
                    if (action == "Update")
                    {
                        dc.Refresh(RefreshMode.OverwriteCurrentValues, dc.Leads);
                        Lead lTmp = dc.Leads.SingleOrDefault <Lead>
                                        (x => x.WorkflowID == l.WorkflowID);

                        if (lTmp != null)
                        {
                            lTmp.AssignedTo = l.AssignedTo;
                            lTmp.Status     = l.Status;
                        }
                    }
                }

                // Submit all the changes to the database
                dc.SubmitChanges();

                // Remove all objects since the changes have been submitted
                _object.Clear();
                _action.Clear();
            }
        }
 private void UpdateControls(Lead l)
 {
     lblSelectedNotes.Content = l.Comments;
     lblSelectedNotes.Visibility = Visibility.Visible;
     if (l.Status == "Open")
     {
         lblAgent.Visibility = Visibility.Visible;
         txtAgent.Visibility = Visibility.Visible;
         btnAssign.Visibility = Visibility.Visible;
     }
     else
     {
         lblAgent.Visibility = Visibility.Hidden;
         txtAgent.Visibility = Visibility.Hidden;
         btnAssign.Visibility = Visibility.Hidden;
     }
 }
Example #15
0
 partial void UpdateLead(Lead instance);
 public static void UpdateLead(Lead l)
 {
     if (_app != null)
         _app.lstLeads.Dispatcher.BeginInvoke(new Action(() => _app.UpdateLead(l)));
 }
 public static void NewLead(Lead l)
 {
     if (_app != null)
         _app.AddNewLead(l);
 }
 public void UpdateLead(Lead lead)
 {
     // Find the row that matches this record
     int nSelected = -1;
     for (int i = 0; i < lstLeads.Items.Count; i++)
     {
         Lead l = lstLeads.Items[i] as Lead;
         if (l.LeadID == lead.LeadID)
         {
             nSelected = i;
             break;
         }
     }
     // Update the grid
     if (nSelected >= 0)
     {
         lstLeads.Items[nSelected] = lead;
         lstLeads.Items.Refresh();
         UpdateControls(lead);
     }
 }
Example #19
0
 partial void DeleteLead(Lead instance);
 public void AddNewLead(Lead l)
 {
     this.lstLeads.Dispatcher.BeginInvoke
         (new Action(() => this.lstLeads.Items.Add(l)));
 }