0
데이터 액세스 계층은 WCF 서비스입니다. 나는 VWD 익스프레스는 2010 년 조감도의 전체 구조는이WCF 함수를 호출 할 수 없습니다.
[ServiceContract]
public interface IExcelReader
{
[OperationContract]
[FaultContract(typeof(StaffAllocationFault))]
void ReadExcel();
}
public void ReadExcel()
{
DataSet dataCollection = new DataSet();
table = new DataTable("Capacity");
//gets the connection string for the excelsheet with the employee details
//string strCon = ConfigurationManager.ConnectionStrings["capacityDB"].ConnectionString;
string strCon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\CapacityDB.xlsx;Extended Properties=Excel 12.0";
//gets the predefined filters in the application
string[] filter = GetDefinedFilters();
//creates the connection object
oledbCon = new OleDbConnection(strCon);
try
{
//opens the connection object
openConnection();
string strCmd = "Select * from [Capacity Report Data$]";
//creates the command object
oledbCmd = new OleDbCommand(strCmd, oledbCon);
//fills the datatable using the data adapter
oledbAdapter = new OleDbDataAdapter();
oledbAdapter.SelectCommand = oledbCmd;
oledbAdapter.Fill(table);
dataCollection.Tables.Add(table);
//to trim off the trailing/preceding whitespaces
foreach (DataRow row in table.Rows)
{
int count = 0;
while (count < filter.Count())
{
try
{
row[filter[count]] = row[filter[count]].ToString().Trim();
//if the field is blank
if (row[filter[count]].ToString() == "")
row[filter[count]] = "***";
count++;
}
catch (Exception ex)
{
throw new FaultException<StaffAllocationFault>(new StaffAllocationFault { FaultMessage = "Error while reading through the employee information" }, ex.Message);
}
}
}
}
catch (Exception ex)
{
throw new FaultException<StaffAllocationFault>(new StaffAllocationFault { FaultMessage = "Error while retreiving employee information" }, ex.Message);
}
finally
{
//closes the oledb connection
closeConnection();
}
}
public void ReadFromExcel()
{
try
{
new ExcelReaderClient().ReadExcel();
}
//service specific exceptions
catch (FaultException<StaffAllocationFault> ex)
{
throw new ExceptionLayer.StaffAllocationException("Error while reading from excel", ex);
}
//generic exceptions
catch (Exception genEx)
{
throw genEx;
}
}
같은 것입니다 사용 UI 나의 web.config
:
<client>
<endpoint address="http://localhost:49171/ExcelReader.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IExcelReader" contract="ExcelService.IExcelReader"
name="BasicHttpBinding_IExcelReader" />
</client>
응용 프로그램을 실행할 때 wcf의 함수가 호출되지 않습니다. Pls 도움.
오류가 있습니까? –
nopes ... 오류가 발생하지 않았습니다. ( – Niranjan
web.config에서 구성한 내용 WCF의 끝점을 지정해야합니다. –