I posted this in the webservices newsgroup but not responses as of yet and
it looks to be a bit slower newsgroup so I thought that i would go ahead and
post here also to see if someone might be able to help, I guess I am really
confussed on this.
Thanks,
Jeff
Hi All,
I am hoping that maybe someone can help me out.
I am trying to learn how to create and use A WCF service.
Right now I have a windows application that does some room calculations, I
send a list of 5 arguments right now to a separate class and it does all the
calculation and sends back a room rate, so what i have to do now is instead
of use the roomrate class is send those 5 arguments to a services class and
have it do all the calculations and return the roomrate.
i am very very very confussed on this, as every example I have read and even
the book I am using creates a Function in the Iservices.vb and references to
a Function in the Services.vb which does a simple multiplication of 2
predefined variables and retuns to the form. But in the class that I have
right now it sends thoses 5 arguments to a New() Constructor and there is
not a single function in the whole class so I do not even see how use the
Service? It does several things within the class to set different variables
to be able to determine the room rate. then I call a Public Read Only
property to get the final roomRate Amount
I just can not figure out for the life of me based on the examples I have
found how to send 5 arguments to the service and have it do all the behind
the scences calculating without a sigle function to do this?
This is how I would call the class module.
'Dim RoomRateObject As New _
' RoomRate(NumberNightsInteger, BedSizeInteger,
WeekendRateInteger, SeasonInteger, MemberRateInteger)
this is how I was trying to call the Service but does not work,
Dim ARoomRateService As New
RoomRateService.RoomRateServiceClient '(NumberNightsInteger, BedSizeInteger,
WeekendRateInteger, SeasonInteger, MemberRateInteger)
This is how I pass it to the Class,
Sub New(ByVal NumberNightsInteger As Integer, ByVal BedSizeInteger As
Integer, _
ByVal WeekendRateInteger As Integer, ByVal SeasonRateInteger As
Integer, ByVal MemberRateInteger As Integer)
' Assign property values.
LengthOfStay = NumberNightsInteger
BedSize = BedSizeInteger
WeekendRate = WeekendRateInteger
SeasonRate = SeasonRateInteger
MemberRate = MemberRateInteger
FindRoomRate()
End Sub
Have no Idea how to pass this to the Services?
This is most of the calculation that takes place in the class module
Sub FindRoomRate()
' Determine the room rate.
Dim NightlyRateDecimal, AmountRoomTaxDecimal, _
HighSeasonRateDecimal As Decimal
' Determine bed size and weekend/weekday rate.
Select Case BedSizeInteger
Case BedType.KingBed
Select Case WeekendRateInteger
Case Rate.Weekend ' Weekend Rate.
NightlyRateDecimal = KING_WEEKEND_Decimal
Case Rate.Weekday
NightlyRateDecimal = KING_WEEKDAY_Decimal
End Select
Case BedType.QueenBed
Select Case WeekendRateInteger
Case Rate.Weekend ' Weekend Rate.
NightlyRateDecimal = QUEEN_WEEKEND_Decimal
Case Rate.Weekday
NightlyRateDecimal = QUEEN_WEEKDAY_Decimal
End Select
Case BedType.DoubleBed
Select Case WeekendRateInteger
Case Rate.Weekend ' Weekend Rate.
NightlyRateDecimal = DOUBLE_WEEKEND_Decimal
Case Rate.Weekday
NightlyRateDecimal = DOUBLE_WEEKDAY_Decimal
End Select
End Select
' Calculate amount due.
' Determine nightly rate by deducting member discount and adding
high season rate
' to the nightly rate. Then add tax. Then multiply by the number
of nights.
Select Case SeasonRateInteger
Case Season.HighSeason
' If high season charge premium price.
HighSeasonRateDecimal = NightlyRateDecimal +
(NightlyRateDecimal * HIGH_SEASON_Decimal)
' Determine if member discount to be given
Select Case MemberRateInteger
Case RateForMembers.Member
HighSeasonRateDecimal = HighSeasonRateDecimal -
(HighSeasonRateDecimal * MEMBER_DISCOUNT_Decimal)
End Select
AmountRoomTaxDecimal = HighSeasonRateDecimal *
ROOM_TAX_Decimal
AmountDueDecimal = (HighSeasonRateDecimal +
AmountRoomTaxDecimal) * LengthOfStayInteger
Case Season.OffSeason
' Determine if member discount to be given
Select Case MemberRateInteger
Case RateForMembers.Member
NightlyRateDecimal = NightlyRateDecimal -
(NightlyRateDecimal * MEMBER_DISCOUNT_Decimal)
End Select
AmountRoomTaxDecimal = NightlyRateDecimal * ROOM_TAX_Decimal
AmountDueDecimal = (NightlyRateDecimal +
AmountRoomTaxDecimal) * LengthOfStayInteger
End Select
End Sub
Not sure if this needs to be turned into a function of some sorts in
Services?
And this is how it gets returned from the class
Public ReadOnly Property AmountDue() As Decimal
Get
Return AmountDueDecimal
End Get
End Property
Have no Idea how to even get this far from the Services Side
Can someone maybe please clarify what I must obviously be letting go over my
head?
Thanks,
Jeff