Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi code guru's,

I'm new to WCF and WF while walk through some of interesting new technologies in Asp.net. I found WCF and WF, so began to implement in my live project.
After successive practice of WCF and WF individually, I tried to combine it together but I got some error. Please someone help me to get out of it, I've given my error code below.
Further, Is my way correct or is there any other way to communicate between these two?

MY ERROR is I couldn't pass values from WF to business layer to perform operations which I called

my UI PAGE CODES;
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TimeOBJ25_10;
using WF_30;
using System.Workflow;
using System.Workflow.Activities;
using System.Workflow.Runtime;
using System.Workflow.ComponentModel;
using System.Workflow.Runtime.Hosting;
using System.Threading;
using System.Workflow.Runtime.Configuration;
using System.Workflow.Activities.Design;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;


public partial class EmpStatus_1 : System.Web.UI.Page
{
    DateTime ctime;
    protected void Page_Load(object sender, EventArgs e)
    {
        ctime = System.DateTime.Now;
        lblDate.Text = ctime.ToString("dd-MM-yyyy");
        lblInTime.Text = ctime.ToLongTimeString();
        lblOutTime.Text = ctime.ToLongTimeString();
    }
    protected void btnSubmit_Click1(object sender, EventArgs e)
    {
        
        
        using (WorkflowRuntime wr = new WorkflowRuntime())
        {
            List<ServiceEndpoint> eps = new List<ServiceEndpoint>();
            Binding b = new WSHttpBinding();
            EndpointAddress ea = new EndpointAddress("http://localhost:2819/Service1.svc");
            ChannelFactory<WF_30.ServiceReference1.TimeSevice> ch = new ChannelFactory<WF_30.ServiceReference1.TimeSevice>(b, ea);
      
            eps.Add(ch.Endpoint);
            ChannelManagerService chs = new ChannelManagerService(eps);
            wr.AddService(chs);
            

            EmployeeStatus obj = new EmployeeStatus();
            obj.EmpId = Convert.ToInt16(txtEmpId.Text);
            obj.EmpName = txtName.Text;
            obj.Designation = txtDesc.Text;
            obj.CDate = ctime;
            obj.InTime = DateTime.Parse(lblInTime.Text);
            obj.OutTime = DateTime.Parse(lblOutTime.Text);
            obj.ProjectName = ddlProject.SelectedItem.Text;
            obj.DurationFrom = DateTime.Parse(txtDurationFrom.Text);
            obj.DurationTo = DateTime.Parse(txtDurationTo.Text);
            obj.Createddate = ctime;
            obj.Modifieddate = ctime;
            obj.Createdby = txtName.Text;
            obj.Modifiedby = "";     
            
           
        }
    }
}

my BUSINESS ACCESS LAYER CODES
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Transactions;
using TimeDAL25_10;
using TimeOBJ25_10;
namespace TimeBL25_10
{
    public class EmpStatusBL
    {
        int res1=0;
        int res=0;
        public int StatusInsert(EmployeeStatus es)
        {
            using (TransactionScope scop = new TransactionScope(TransactionScopeOption.Required))
            {
                EmpstatusDal da = new EmpstatusDal();
                da.insertstatus(es, res1);
                scop.Complete();
            }
            return res;
        }
    }
}

MY DATA ACCESS LAYER CODES
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using TimeOBJ25_10;

namespace TimeDAL25_10
{
    public class EmpstatusDal:SqlConfiguration
    {
        public int insertstatus(EmployeeStatus es, int result)
        {
            using (SqlConnection conn=createconnection())
            {
                using (SqlCommand cmd=new SqlCommand("EmployeeStatus",conn))
                {
                    cmd.CommandType=CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@EmpId", es.EmpId);
                    cmd.Parameters.AddWithValue("@EmpName", es.EmpName);
                    cmd.Parameters.AddWithValue("@Designation", es.Designation);
                    cmd.Parameters.AddWithValue("@CDate", es.CDate);
                    cmd.Parameters.AddWithValue("@InTime", es.InTime);
                    cmd.Parameters.AddWithValue("@outTime", es.OutTime);
                    cmd.Parameters.AddWithValue("@ProjectName", es.ProjectName);
                    cmd.Parameters.AddWithValue("@DurationFrom", es.DurationFrom);
                    cmd.Parameters.AddWithValue("@DurationTo", es.DurationTo);
                    cmd.Parameters.AddWithValue("@Createddate", es.Createddate);
                    cmd.Parameters.AddWithValue("@Modifieddate", es.Modifieddate);
                    cmd.Parameters.AddWithValue("@Createdby", es.Createdby);
                    cmd.Parameters.AddWithValue("@Modifiedby", es.Modifiedby);
                    TimeSQLCommand.OpenConnection(cmd);
                    result = cmd.ExecuteNonQuery();
                }
            }
            return result;
        }
    }
}


MY WF CODES
C#
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace WF_30
{
    public sealed partial class Workflow1 : SequentialWorkflowActivity
    {
        public Workflow1()
        {
            InitializeComponent();
        }
        public static DependencyProperty sendActivity1__ReturnValue_1Property = DependencyProperty.Register("sendActivity1__ReturnValue_1", typeof(System.Int32), typeof(WF_30.Workflow1));
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        [BrowsableAttribute(true)]
        [CategoryAttribute("Parameters")]
        public Int32 sendActivity1__ReturnValue_1
        {
            get
            {
                return ((int)(base.GetValue(WF_30.Workflow1.sendActivity1__ReturnValue_1Property)));
            }
            set
            {
                base.SetValue(WF_30.Workflow1.sendActivity1__ReturnValue_1Property, value);
            }
        }
        private void codeActivity1_ExecuteCode(object sender, EventArgs e)
        {
            sendActivity1__ReturnValue_1 = 1;
        }
    }
}

Advance thanks.
Posted
Updated 21-Jan-11 19:11pm
v2
Comments
Indivara 22-Jan-11 1:22am    
A suggestion - rather than just dump your code, step through it using the debugger and give specifics of what error and where exactly it occurred.
(Those who answer questions volunteer their services, and seldom have time to go through large quantities of code)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900