asked on
[WebMethod(), SoapHeader("sHeader")]
public void SendMessages(Int64 userID, Int32 serviceID, String[] messageInfo)
{
if (sHeader.AuthenticateUser())
{
Subscriptions theSubscription = new Subscriptions();
theSubscription.UserID = userID;
theSubscription.ServiceID = serviceID;
theSubscription.GetSubscriptionDetails();
if (theSubscription.IsSubscribed())
{
Messages theMessage = new Messages();
theMessage.MessageRecipient = theSubscription.MobileNumber;
theMessage.ServiceID = theSubscription.ServiceID;
theMessage.SubscriptionID = theSubscription.SubscriptionID;
theMessage.MessageParameters = messageInfo;
theMessage.SendMessage("serviceMsg", true, true);
}
else
{
//this user is not subscribed you can't message them...
theSubscription.NotifyAxionUnsubscribe();
}
}
else
{
//unauthorized consumption of webservice!
ErrorHandler.HandleError(76, HttpContext.Current.Request.UserHostAddress, this, "");
}
}
[WebMethod(), SoapHeader("sHeader")]
public void SendThankyouMessages(Int64 userID, Int32 serviceID)
{
if (sHeader.AuthenticateUser())
{
Subscriptions theSubscription = new Subscriptions();
theSubscription.UserID = userID;
theSubscription.ServiceID = serviceID;
theSubscription.GetSubscriptionDetails();
if (theSubscription.IsSubscribed())
{
Messages theMessage = new Messages();
theMessage.MessageRecipient = theSubscription.MobileNumber;
theMessage.ServiceID = theSubscription.ServiceID;
theMessage.SubscriptionID = theSubscription.SubscriptionID;
theMessage.SendMessage("thankyou", true, false);
}
else
{
//this user is not subscribed you can't message them...
theSubscription.NotifyAxionUnsubscribe();
}
}
else
{
//unauthorized consumption of webservice!
ErrorHandler.HandleError(76, HttpContext.Current.Request.UserHostAddress, this, "");
}
}
[WebMethod(), SoapHeader("sHeader")]
public void SendStandardMessages(Int64 userID, Int32 serviceID, String message)
{
if (sHeader.AuthenticateUser())
{
Subscriptions theSubscription = new Subscriptions();
theSubscription.UserID = userID;
theSubscription.ServiceID = serviceID;
theSubscription.GetSubscriptionDetails();
if (theSubscription.IsSubscribed())
{
Messages theMessage = new Messages();
theMessage.MessageRecipient = theSubscription.MobileNumber;
theMessage.ServiceID = theSubscription.ServiceID;
theMessage.SubscriptionID = theSubscription.SubscriptionID;
theMessage.MessageBody = message;
theMessage.SendMessage("standard", false, false);
}
else
{
//this user is not subscribed you can't message them...
theSubscription.NotifyAxionUnsubscribe();
}
}
else
{
//unauthorized consumption of webservice!
ErrorHandler.HandleError(76, HttpContext.Current.Request.UserHostAddress, this, "");
}
}
ASKER
ASKER
ASKER
ASKER
ASKER
[WebMethod(), SoapHeader("sHeader")]
public void SendMessage(Int64 userID, Int32 serviceID, String[] messageInfo)
{
DoSend(userID, serviceID, messageInfo, true, true);
}
private void DoSend(Int64 userID, Int32 serviceID, Object objMsg, Boolean premium, Boolean includeInTotal)
{
if (sHeader.AuthenticateUser())
{
Subscriptions theSubscription = new Subscriptions();
theSubscription.UserID = userID;
theSubscription.ServiceID = serviceID;
theSubscription.GetSubscriptionDetails();
if (theSubscription.IsSubscribed())
{
Messages theMessage = new Messages();
theMessage.MessageRecipient = theSubscription.MobileNumber;
theMessage.ServiceID = theSubscription.ServiceID;
theMessage.SubscriptionID = theSubscription.SubscriptionID;
switch (objMsg.GetType().Name)
{
//using message paramaters so its a serviceMsg
case "String[]":
theMessage.MessageParameters = (String[])objMsg;
theMessage.SendMessage("serviceMsg", true, true);
break;
//string to its a standard message
case "String":
theMessage.MessageBody = (String)objMsg;
theMessage.SendMessage("standard", false, false);
break;
// new object so its a thankyou message
case "Object":
theMessage.SendMessage("thankyou", true, false);
break;
}
}
else
{
//this user is not subscribed you can't message them...
theSubscription.NotifyAxionUnsubscribe();
}
}
else
{
//unauthorized consumption of webservice!
ErrorHandler.HandleError(76, HttpContext.Current.Request.UserHostAddress, this, "");
}
}
[WebMethod(), SoapHeader("sHeader")]
public void SendMessage(Int64 userID, Int32 serviceID)
{
DoSend(userID, serviceID, new Object(), true, false);
}
[WebMethod(), SoapHeader("sHeader")]
public void SendMessage(Int64 userID, Int32 serviceID, String message)
{
DoSend(userID, serviceID, message, false, false);
}
ASKER
ASKER
C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).
TRUSTED BY
All three methods send a message. Overloading would definitely make it better. However, it may not be best to have different send function based on type of message. An alternative is to have a single send function that takes serviceId, usedID and a message object. The message object itself can be constructed from a string or any other source you like.
Regards,
sunnycoder