diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs
index b36b232..968376b 100644
--- a/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs
+++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs
@@ -7,6 +7,9 @@ using System.Net.Http;
using System.Web.Http;
using AIAHTML5.API.Models;
using Newtonsoft.Json.Linq;
+using System.Data.SqlClient;
+using System.Collections;
+using log4net;
namespace AIAHTML5.API.Controllers
{
@@ -27,31 +30,60 @@ namespace AIAHTML5.API.Controllers
// POST api/client
public HttpResponseMessage Post([FromBody]JObject siteUrl)
{
- HttpResponseMessage response = null;
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug("inside POST in ClientController");
- int siteId = AIAHTML5.API.Models.Users.ValidateLicenseSiteIP(siteUrl["siteIP"].ToString(), siteUrl["remoteIPAddress"].ToString(), siteUrl["accountNumber"].ToString(), Convert.ToByte(siteUrl["edition"].ToString()));
- if (siteId > 0)
+ HttpResponseMessage response = null;
+ try
{
- dynamic uerinfo = AIAHTML5.API.Models.Users.ValidateSiteLogin(siteUrl["siteIP"].ToString(), siteUrl["accountNumber"].ToString(), siteUrl["urlReferer"].ToString(), siteUrl["edition"].ToString(), siteId);
- if (uerinfo != null)
- response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(uerinfo) };
+ int siteId = AIAHTML5.API.Models.Users.ValidateLicenseSiteIP(siteUrl["siteIP"].ToString(), siteUrl["remoteIPAddress"].ToString(), siteUrl["accountNumber"].ToString(), Convert.ToByte(siteUrl["edition"].ToString()));
+ if (siteId > 0)
+ {
+ dynamic uerinfo = AIAHTML5.API.Models.Users.ValidateSiteLogin(siteUrl["siteIP"].ToString(), siteUrl["accountNumber"].ToString(), siteUrl["urlReferer"].ToString(), siteUrl["edition"].ToString(), siteId);
+ if (uerinfo != null)
+ response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(uerinfo) };
+ else
+ {
+ //ser user = new User();
+ //user.LoginFailureCauseId = AIAConstants.INVALID_CLIENT;
+ //dynamic userinfo = user;
+ //response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userInfo) };
+
+ response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.INVALID_CLIENT) };
+ }
+ }
else
{
- //ser user = new User();
- //user.LoginFailureCauseId = AIAConstants.INVALID_CLIENT;
- //dynamic userinfo = user;
- //response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userInfo) };
-
- response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.INVALID_CLIENT) };
+ response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MSG_NOT_AUTHORIZE_SITE_USER) };
+
+
}
+ return response;
}
- else
+ catch (SqlException e)
{
- response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MSG_NOT_AUTHORIZE_SITE_USER) };
+ logger.Fatal("SqlException occured for siteUrl =" + siteUrl["siteIP"].ToString() + " and siteUrl= " + siteUrl["siteIP"].ToString() + " & accountNumber = " + siteUrl["accountNumber"].ToString() + " &edition = " + siteUrl["edition"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
+
+ ArrayList supportMailList = UserUtility.GetSupportMailList();
+ string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT;
+ string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
+ UserUtility.SendEmailForException(0, supportMailList, "", mailSubject, mailBody,true,siteUrl);
+
+ return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) };
+ }
+ catch (Exception e)
+ {
+
+ logger.Fatal("Exception occured for loginId =" + siteUrl["siteIP"].ToString() + " and siteUrl= " + siteUrl["siteIP"].ToString() + " & accountNumber = " + siteUrl["accountNumber"].ToString() + " &edition = " + siteUrl["edition"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
+ ArrayList supportMailList = UserUtility.GetSupportMailList();
+ string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT;
+ string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
+ UserUtility.SendEmailForException(0, supportMailList, "", mailSubject, mailBody, true, siteUrl);
+
+ return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) };
}
- return response;
}
// PUT api/client/5
diff --git a/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs
index 52f2547..0154fb2 100644
--- a/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs
+++ b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs
@@ -16,6 +16,7 @@ using System.Configuration;
using System.Collections;
using System.Data;
using System.Reflection;
+using Newtonsoft.Json.Linq;
namespace AIAHTML5.API.Models
{
@@ -216,10 +217,10 @@ namespace AIAHTML5.API.Models
}
}
- public static bool SendEmailForException(int userid, ArrayList mailToList, string sender, string mailSubject = "", string mailBody = "")
+ public static bool SendEmailForException(int userid, ArrayList mailToList, string sender, string mailSubject = "", string mailBody = "", bool isMailForClentSite=false, JObject info=null)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
- logger.Debug("Inside SendEmail with userid =" + userid);
+ // logger.Debug("Inside SendEmail with userid =" + userid);
try
{
@@ -235,8 +236,14 @@ namespace AIAHTML5.API.Models
lstToAddress.Add(email);
}
- emailMessage = "Unable to process request for userid: " + userid;
-
+ if (isMailForClentSite && info!=null)
+ {
+ emailMessage = "Unable to process request for siteUrl =" + info["siteIP"].ToString() + " and siteIP= " + info["siteIP"].ToString() + " & accountNumber = " + info["accountNumber"].ToString() + " &edition = " + info["edition"].ToString() ;
+ }
+ else
+ {
+ emailMessage = "Unable to process request for userid: " + userid;
+ }
if (string.IsNullOrEmpty(sender))
@@ -264,7 +271,13 @@ namespace AIAHTML5.API.Models
return true;
}
catch (Exception ex)
- {
+ {
+ if (isMailForClentSite){
+ logger.Fatal("exception in SendEmail for siteUrl =" + info["siteIP"].ToString()+ ". msg= " + ex.Message + ", stacktrace= " + ex.StackTrace);
+
+ }
+
+ else
logger.Fatal("exception in SendEmail for userid"+userid+ ". msg= " + ex.Message + ", stacktrace= " + ex.StackTrace);
return false;
}