diff --git a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj index 90933ca..033b085 100644 --- a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj +++ b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj @@ -120,6 +120,7 @@ + @@ -131,6 +132,7 @@ Global.asax + @@ -146,7 +148,9 @@ - + + Designer + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs index 04a295c..c950bd1 100644 --- a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs +++ b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs @@ -44,5 +44,42 @@ namespace AIAHTML5.API.Constants public const string LAB_EXERCISE_SAVE_SUCCESS = "Your lab exercise attempt is saved."; public const string LAB_EXERCISE_SAVE_FAILURE = "We are unable to save your lab exercise attempt, please try again."; public const string SAVED_LAB_EXERCISE_NOT_FOUND = "Saved Lab Exercise not found."; + public const string VALIDATED_CLIENT = "Valid Client."; + public const string INVALID_CLIENT = "InValid Client."; + + public const string STATUS_OK = "ok"; + public const string STATUS_NOT_OK = "notok"; + public const int NO_ERROR = 0; + public const int RUN_TIME_EXCEPTION = 10000; + + public const String SITE_IP = "siteIP"; + public const String SITE_ID = "siteId"; + public const String TERM_CONDITION = "termCondition"; + public const String MODESTY_SETTING = "modestySetting"; + + public const Byte SUPER_ADMIN = 1; + public const Byte GENERAL_ADMIN = 2; + public const String USER_NAME = "username"; + public const String PASSWORD = "password"; + public const String ERROR_ID = "errorId"; + public const String LICENSE_ACTIVE = "licenceActive"; + public const String ACCOUNT_NUMBER = "accountNumber"; + public const String LICENSE_TYPE_ID = "licenceTypeId"; + public const String TOTAL_LOGIN = "totalLogin"; + public const String EDITION_ID = "editionId"; + public const String URL_REFERER = "urlReferer"; + public const String USER_CONTEXT = "usercontext"; + + public const Byte CONCURRENT_USER = 6; + public const Byte SINGLE_USER = 5; + public const Byte SITE_USER = 9; + + public const String LICENSE_ID = "licenseId"; + public const Byte LICENSE_TYPE_CONCURRENT = 1; + public const Byte LICENSE_TYPE_SINGLE = 2; + public const Byte LICENSE_TYPE_SITE = 3; + public const Byte LICENSE_TYPE_RESELLER = 4; + public const Byte LICENSE_TYPE_TEST = 5; + } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs index a2d5ffb..f256911 100644 --- a/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs +++ b/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs @@ -29,6 +29,10 @@ namespace AIAHTML5.API.Constants public const string GET_BLOCKED_USERS_BY_USER_TYPE = "GetBlockedUserByUserType"; public const string SAVE_LAB_EXERCISE_ATTEMPT = "usp_SaveLabExerciseAttempts"; public const string GET_LAB_EXERCISE = "GetLabExcerciseByUserId"; + public const string GET_LICENSEINFO_BY_SITE_URL = "GetLicenseIdBySiteUrl"; + public const string GET_LICENSE_BY_SITE_ID = "GetLicenseBySiteId"; + public const string GET_LICENSE_EDITIONS_FOR_MODESTY = "GetLicenseEditionsForModesty"; + public const string GET_PRODUCT_FEATURES = "GetProductFeatures"; } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs new file mode 100644 index 0000000..4c5f9f3 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs @@ -0,0 +1,49 @@ +using AIAHTML5.API.Constants; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using AIAHTML5.API.Models; +using Newtonsoft.Json.Linq; + +namespace AIAHTML5.API.Controllers +{ + public class ClientController : ApiController + { + // GET api/client + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api/client/5 + public string Get(int id) + { + return "value"; + } + + // POST api/client + public HttpResponseMessage Post([FromBody]JObject siteUrl) + { + HttpResponseMessage response = null; + + int siteId = AIAHTML5.API.Models.Users.ValidateLicenseSiteIP(siteUrl["siteIP"].ToString(), siteUrl["remoteIPAddress"].ToString(), siteUrl["accountNumber"].ToString(), Convert.ToByte(siteUrl["edition"].ToString())); + int x = AIAHTML5.API.Models.Users.ValidateSiteLogin(siteUrl["siteIP"].ToString(),siteUrl["accountNumber"].ToString(),siteUrl["urlReferer"].ToString(),siteUrl["edition"].ToString(),siteId) + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.VALIDATED_CLIENT) }; + + return response; + } + + // PUT api/client/5 + public void Put(int id, [FromBody]string value) + { + } + + // DELETE api/client/5 + public void Delete(int id) + { + } + } +} diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index 7c48a86..a7387b9 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -980,5 +980,151 @@ namespace AIAHTML5.API.Models // return 1; //} + + internal DataTable GetLicenseInfoBySiteUrl(string licenceAccount, int editionId) + { + logger.Debug(" inside GetLicenseIdBySiteUrl for UserId= " + editionId + ",licenceAccount = " + licenceAccount); + + // SiteUrl siteUrl = null; + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_LICENSEINFO_BY_SITE_URL; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@sLicenseAccount", licenceAccount); + cmd.Parameters.AddWithValue("@iEditionId", editionId); + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + //if (dt != null && dt.Rows.Count > 0) + //{ + // siteUrl = new SiteUrl(); + // foreach (DataRow dr in dt.Rows) + // { + // siteUrl.Id = Convert.ToInt32(dr["Id"]); + // siteUrl.SiteIp = dr["SiteIp"].ToString(); + // siteUrl.SiteIpTo = dr["SiteIpTo"].ToString(); + // siteUrl.SiteMasterIpTo = dr["SiteMasterIpTo"].ToString(); + // siteUrl.IsMaster = Convert.ToInt32(dr["IsMaster"]); + + // } + //} + + //return siteUrl; + return dt; + } + + internal DataTable GetLicenseBySiteId(int siteId) + { + logger.Debug(" inside GetLicenseBySiteId for siteId= " + siteId); + + // SiteUrl siteUrl = null; + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_LICENSE_BY_SITE_ID; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@sSiteId", siteId); + + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + //if (dt != null && dt.Rows.Count > 0) + //{ + // siteUrl = new SiteUrl(); + // foreach (DataRow dr in dt.Rows) + // { + // siteUrl.Id = Convert.ToInt32(dr["Id"]); + // siteUrl.SiteIp = dr["SiteIp"].ToString(); + // siteUrl.SiteIpTo = dr["SiteIpTo"].ToString(); + // siteUrl.SiteMasterIpTo = dr["SiteMasterIpTo"].ToString(); + // siteUrl.IsMaster = Convert.ToInt32(dr["IsMaster"]); + + // } + //} + + //return siteUrl; + return dt; + + } + internal DataTable GetEditionsForModesty(int licenceId, int buildingLevelAcc) + { + logger.Debug(" inside GetEditionsForModesty for licenceId= " + licenceId); + + // SiteUrl siteUrl = null; + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_LICENSE_EDITIONS_FOR_MODESTY; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@iLicenseId", licenceId); + cmd.Parameters.AddWithValue("@iBuildingLevelId", buildingLevelAcc); + + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + //if (dt != null && dt.Rows.Count > 0) + //{ + // siteUrl = new SiteUrl(); + // foreach (DataRow dr in dt.Rows) + // { + // siteUrl.Id = Convert.ToInt32(dr["Id"]); + // siteUrl.SiteIp = dr["SiteIp"].ToString(); + // siteUrl.SiteIpTo = dr["SiteIpTo"].ToString(); + // siteUrl.SiteMasterIpTo = dr["SiteMasterIpTo"].ToString(); + // siteUrl.IsMaster = Convert.ToInt32(dr["IsMaster"]); + + // } + //} + + //return siteUrl; + return dt; + } + + internal Hashtable GetEditionFeatures(byte editionId) + { + Hashtable objFeatures = new Hashtable(); + + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_PRODUCT_FEATURES; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@EditionId", editionId); + + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + if (dt != null && dt.Rows.Count > 0) + { + foreach (DataRow dr in dt.Rows) + { + if ((bool)dr["IsActive"]) + { + objFeatures.Add(dr["Id"], dr["Title"]); + } + + + } + } + + return objFeatures; + } } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/IPValidator.cs b/400-SOURCECODE/AIAHTML5.API/Models/IPValidator.cs new file mode 100644 index 0000000..ff1f8b9 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Models/IPValidator.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace AIAHTML5.API.Models +{ + public class IPValidator + { + public static Double ChangeIpToDouble(String ipVal) + { + String[] resultArray = new String[20]; + //Array resultArray ; + String n = ipVal; + String[] array = n.Split('.'); + for (int i = 0; i < array.Length; i++) + { + if (array[i].Length == 1) + { + array[i] = "00" + array[i]; + resultArray[i] = (array[i]); + } + else if (array[i].Length == 2) + { + array[i] = "0" + array[i]; + resultArray[i] = (array[i]); + } + else + { + array[i] = array[i]; + resultArray[i] = (array[i]); + } + } + + //String theContent = resultArray.ToString(); + String theContent = ""; + + for (int i = 0; i <= resultArray.Length - 1; i++) + { + if (!String.IsNullOrEmpty(resultArray[i])) + theContent += resultArray[i]; + } + theContent = (theContent == "" ? "0" : theContent); + + return Convert.ToDouble(theContent); + //return theContent; + } + + + public static bool ValidateIP(String strSiteIp, String strSiteIPTo, String strSiteMasterIPTo, String strIPToValidate, int intIsMaster) + { + Double dblSiteIP = 0; + Double dblSiteIPTo = 0; + Double dblSiteMIPTo = 0; + Double dblIPToValidate = 0; + bool boolReturn = false; + + try + { + // Convert all IP to double values + dblSiteIP = ChangeIpToDouble(((strSiteIp == "" || IsNumericIP(strSiteIp) == false) ? "0" : strSiteIp)); + dblSiteIPTo = ChangeIpToDouble(((strSiteIPTo == "" || IsNumericIP(strSiteIPTo) == false) ? "0" : strSiteIPTo)); + dblSiteMIPTo = ChangeIpToDouble(((strSiteMasterIPTo == "" || IsNumericIP(strSiteMasterIPTo) == false) ? "0" : strSiteMasterIPTo)); + dblIPToValidate = ChangeIpToDouble(((strIPToValidate == "" || IsNumericIP(strIPToValidate) == false) ? "0" : strIPToValidate)); + + if (intIsMaster > 0) + { + if (dblSiteIP == dblIPToValidate) + boolReturn = true; + + if (dblSiteIPTo > 0 && dblSiteMIPTo > 0) + { + if (isBetween(dblIPToValidate, dblSiteIPTo, dblSiteMIPTo) == true) + { + boolReturn = true; + } + } + else if (dblSiteIPTo > 0) + { + if (dblSiteIPTo == dblIPToValidate) + boolReturn = true; + } + else if (dblSiteMIPTo > 0) + { + if (dblSiteMIPTo == dblIPToValidate) + boolReturn = true; + } + } + else + { + if (dblSiteIP > 0 && dblSiteIPTo > 0) + { + if (isBetween(dblIPToValidate, dblSiteIP, dblSiteIPTo) == true) + { + boolReturn = true; + } + } + else if (dblSiteIP > 0) + { + if (dblSiteIP == dblIPToValidate) + boolReturn = true; + } + else if (dblSiteIPTo > 0) + { + if (dblSiteIPTo == dblIPToValidate) + boolReturn = true; + } + } + + return boolReturn; + } + catch (Exception objExp) + { + return false; + } + } + + public static String FormatURLToIP(String strURL) + { + strURL = strURL.Replace("www.", ""); + strURL = strURL.Replace("http://", ""); + strURL = strURL.Replace("https://", ""); + strURL = strURL.Replace("/", ""); + + if (strURL.IndexOf(":") != -1) + { + char[] delimiters = new char[] { ':' }; + string[] parts = strURL.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); + strURL = parts[0]; + } + + return strURL; + } + + /// + /// + /// + /// + /// + /// + /// + private static bool isBetween(Double iNum, Double iFrom, Double iTo) + { + if (iNum == 0) + return false; + + if (iNum >= iFrom && iNum <= iTo) + { + return true; + } + return false; + } + + /// + /// + /// + /// + /// + public static bool IsNumericIP(string text) + { + //Regex objRegex = new Regex(@"^[-+]?[0-9]*\.?[0-9]+$"); + Regex objRegex = new Regex(@"^[-+]?[0-9]*\.?[0-9]+$*\.?[0-9]+$*\.?[0-9]+$*\.?[0-9]+$"); + + return objRegex.IsMatch(text); + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/User.cs b/400-SOURCECODE/AIAHTML5.API/Models/User.cs index ba34df4..4ad2492 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/User.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/User.cs @@ -14,6 +14,11 @@ namespace AIAHTML5.API.Models public string EmailId { get; set; } public string LoginId { get; set; } public string Password { get; set; } + public string AccountNumber { get; set; } + public byte LicenseTypeId { get; set; } + public bool Modesty { get; set; } + public bool ModestyMode { get; set; } + public Hashtable objEditionFeatures { get;set} public int? SecurityQuestionId { get; set; } public string SecurityAnswer { get; set; } public int? CreatorId { get; set; } @@ -49,6 +54,8 @@ namespace AIAHTML5.API.Models public const string RESELLER = "Reseller"; public const string TEST_ACCOUNT = "Test Account"; public const string SITE_USER = "Site User"; + + } public enum UserType @@ -113,4 +120,18 @@ namespace AIAHTML5.API.Models public string AccountNumber { get; set; } public DateTime LoginTime { get; set; } } + + public class SiteUrl + { + public int Id { get; set; } + public string SiteIp { get; set; } + public string SiteIpTo { get; set; } + public string SiteMasterIpTo { get; set; } + public int IsMaster { get; set; } + + + + + } + } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs index f070dcc..9f1c730 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs @@ -11,7 +11,9 @@ using AIAHTML5.API.Models; using Newtonsoft.Json; using System.Collections; using System.Data.SqlClient; - +using System.Net; +using System.Data; +using AIAHTML5.API.Constants; namespace AIAHTML5.API.Models { public class Users @@ -354,5 +356,226 @@ namespace AIAHTML5.API.Models return isUserBlocked; } + + + + public static int ValidateLicenseSiteIP(string strLicenseSiteIP, string remoteIpAddress, string strAccountNumber, byte editionId) + { + if (strLicenseSiteIP == null) + strLicenseSiteIP = remoteIpAddress; + + int intReturn = 0; + DBModel objDBModel = new DBModel(); + DataTable dtLicense = objDBModel.GetLicenseInfoBySiteUrl(strAccountNumber, (byte)editionId); + + if (dtLicense.Rows.Count > 0) + { + //strLicenseSiteIP + String strSiteIP = ""; + String strSiteIPTo = ""; + String strSiteMIPTo = ""; + + IPAddress[] arrHostIP = new IPAddress[2]; + try + { + arrHostIP.SetValue(IPAddress.Parse(remoteIpAddress), 0); + arrHostIP.SetValue(IPAddress.Parse(strLicenseSiteIP), 1); + } + catch (Exception e) + { + //NOTE: if no domain name found we try to resolve by IP. + //arrHostIP.SetValue(Dns.GetHostAddresses(strLicenseSiteIP),1); //I SHould remove this feature it is useless + }; + + // foreach (IPAddress address in arrHostIP) + foreach (IPAddress address in arrHostIP) + { + if (address == null) + continue; + String ipStr = address.ToString(); + if (ipStr == "::1" || ipStr == "") continue; + foreach (DataRow objLicenseRow in dtLicense.Rows) + { + strSiteIP = (String.IsNullOrEmpty(objLicenseRow["SiteIp"].ToString()) ? "" : objLicenseRow["SiteIp"].ToString()); + strSiteIPTo = (String.IsNullOrEmpty(objLicenseRow["SiteIPTo"].ToString()) ? "" : objLicenseRow["SiteIPTo"].ToString()); + //if (String.IsNullOrEmpty(objLicenseRow.SiteIPTo) == false) + //strSiteIPTo = objLicenseRow.SiteIPTo; + strSiteMIPTo = (String.IsNullOrEmpty(objLicenseRow["SiteMasterIPTo"].ToString()) ? "" : objLicenseRow["SiteMasterIPTo"].ToString()); + if (IPValidator.ValidateIP(strSiteIP.ToLower(), strSiteIPTo.ToLower(), strSiteMIPTo.ToLower(), ipStr.ToLower(), Convert.ToInt16(objLicenseRow["IsMaster"])) == true) + { + intReturn = Convert.ToInt32(objLicenseRow["Id"]); + return intReturn; + } + } + } + + if (IPValidator.IsNumericIP(strLicenseSiteIP) == false) + { + foreach (DataRow objLicenseRow in dtLicense.Rows) + { + strSiteIP = (String.IsNullOrEmpty(objLicenseRow["SiteIp"].ToString()) ? "" : objLicenseRow["SiteIp"].ToString()); + // strSiteIPTo = (String.IsNullOrEmpty(objLicenseRow.SiteIPTo) ? "" : objLicenseRow.SiteIPTo); + if (String.IsNullOrEmpty(objLicenseRow["SiteIPTo"].ToString()) == false) + strSiteIPTo = objLicenseRow["SiteIPTo"].ToString(); + strSiteMIPTo = (String.IsNullOrEmpty(objLicenseRow["SiteMasterIPTo"].ToString()) ? "" : objLicenseRow["SiteMasterIPTo"].ToString()); + // if provided ip is not numeric, then compare directly with all the fields + if ((strLicenseSiteIP.ToLower() == strSiteIP.ToLower()) || + (strLicenseSiteIP.ToLower() == IPValidator.FormatURLToIP(strSiteIP).ToLower()) || + (strLicenseSiteIP.ToLower() == strSiteIPTo.ToLower()) || + (strLicenseSiteIP.ToLower() == IPValidator.FormatURLToIP(strSiteIPTo).ToLower()) || + (strLicenseSiteIP.ToLower() == strSiteMIPTo.ToLower()) || + (strLicenseSiteIP.ToLower() == IPValidator.FormatURLToIP(strSiteMIPTo).ToLower())) + { + intReturn = Convert.ToInt32(objLicenseRow["Id"]); + return intReturn; + } + } + } + } + return intReturn; + } + + public static int ValidateSiteLogin( String strSiteIP, String strAcccountNumber,String strUrlReferer,string strEdition,int intSiteId ) { + Int32 intUserId = 0; + bool isExpired ; + try { + Int16 intErrorID = ErrorHelper.E_NO_ERROR; + String strStatus = AIAConstants.STATUS_OK; + + int intLicenseId = 0; + int intEditionId = Convert.ToInt16(strEdition); + + DateTime dtLogDate = DateTime.Now; + //strSiteIP = (String)objRequest.GetData(AIAConstants.SITE_IP); + //strAcccountNumber = (String)objRequest.GetData(AIAConstants.ACCOUNT_NUMBER); + //intEditionId = Convert.ToInt16(objRequest.GetData(AIAConstants.EDITION_ID)); + //strUrlReferer = (String)objRequest.GetData(AIAConstants.URL_REFERER); + //strEdition = (String)objRequest.GetData(AIAConstants.EDITION_ID); + //intSiteId = (Int32)objRequest.GetData(AIAConstants.SITE_ID); + //AdminDAL.AdminDal.GetLicenseBySiteIdDataTable dtLicense = new ADAM.AIA50.AdminDAL.AdminDal.GetLicenseBySiteIdDataTable(); + if (string.IsNullOrEmpty(strAcccountNumber)) { + //----logAuthenticationTryForAccountNumber(strAcccountNumber, dtLogDate, ErrorHelper.ACCOUNT_NUMBER_NOT_NULL, strSiteIP, strEdition, strUrlReferer); + intErrorID = ErrorHelper.E_ACCOUNT_NUMBER_NOT_NULL; + strStatus = AIAConstants.STATUS_NOT_OK; + } else if (string.IsNullOrEmpty(strEdition)) { + strEdition = "0"; + //----logAuthenticationTryForAccountNumber(strAcccountNumber, dtLogDate, ErrorHelper.EDITION_ID_NOT_NULL, strSiteIP, strEdition, strUrlReferer); + intErrorID = ErrorHelper.E_EDITION_ID_NOT_NULL; + strStatus = AIAConstants.STATUS_NOT_OK; + } + else { + DBModel objDBModel = new DBModel(); + DataTable dtLicense = objDBModel.GetLicenseBySiteId(intSiteId); + if (dtLicense.Rows.Count > 0) { + foreach (DataRow licRow in dtLicense.Rows) + { + + //isExpired = LicenseHelper.IsLicenseExpired(licRow["Id"]); + User userInfo = new User(); + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(Convert.ToInt32(licRow["Id"])); + + if (userInfo.LicenseInfo != null) + { + //05.3 get licenseSubscription details + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); + + //05.4 check the License expiration irespective of either user is active or not because on AIA + //we shows the License expiration message for inactive users too + + + if (userInfo.LicenseSubscriptions != null) + { + DateTime? subscriptionValidThrough = userInfo.LicenseSubscriptions.SubscriptionValidThrough; + if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date) + { + isExpired = false; + } + else + { + isExpired = true; + } + } + + + + if (!isExpired && Convert.ToBoolean(licRow["IsActive"]) == true) { + User objUserContext = new User(); + objUserContext.Id = 0; + objUserContext.FirstName = licRow["LicenseeFirstName"].ToString(); + objUserContext.LastName = licRow["LicenseeLastName"].ToString(); + objUserContext.UserTypeId = AIAConstants.SITE_USER; + if (licRow["EmailId"].ToString()!= null) + { + objUserContext.EmailId = licRow["EmailId"].ToString(); + } else { + objUserContext.EmailId = null; + } + objUserContext.AccountNumber = strAcccountNumber; + objUserContext.EditionId = (Byte)intEditionId; + objUserContext.LicenseTypeId = (byte)licRow["LicenseTypeId"]; + objUserContext.LicenseId = Convert.ToInt32(licRow["Id"]); + objUserContext.LoginId = ""; + objUserContext.Modesty =(bool)licRow["IsModesty"]; + //Retreive ModestyMode + objUserContext.ModestyMode = false; + + intLicenseId = Convert.ToInt32(licRow["Id"]); + + + DataTable dtblEditionForModesty = new DBModel().GetEditionsForModesty(objUserContext.LicenseId, 0); + //This table result set should return always have 0 or 1 record if modesty mode is present. + foreach (DataRow drEditionForModesty in dtblEditionForModesty.Rows) { + if ((bool)drEditionForModesty["IsModesty"]) { + objUserContext.Modesty = true; + objUserContext.ModestyMode = true; + } + } + + // get edition features details + objUserContext.objEditionFeatures = objDBModel.GetEditionFeatures((Byte)intEditionId); + + + + if (intLicenseId > 0) + objUserContext.Modules = getModuleListByLicenseId(intLicenseId); + else + objUserContext.Modules = getAllModulesList(); + + objResponse.AddData(LoginConst.USER_CONTEXT, objUserContext); + SessionManager.GetInstance().AddSession((int)0, (int)objLicenseRow.Id, (byte)intEditionId); + + + //SessionManager.GetInstance().AddSession(userRow.Id, int.Parse(accountTransactInfo.licenseId), byte.Parse(accountTransactInfo.licenseEditionId)); + //accountTransactInfo.licenseId = Convert.ToInt32(objLicEdition[LoginConst.LICENSE_ID]).ToString(); + Hashtable arrModuleList = LicenseHelper.GetInstance().GetAllModuleByLicenseId(objLicenseRow.Id); + if (arrModuleList[9].Equals(true)) { + SessionManager.GetInstance().AddModSession("ModuleNameIP10", "IP10"); + } + + logAuthenticationTryForAccountNumber(strAcccountNumber, dtLogDate, 0, strSiteIP, strEdition, strUrlReferer); + } else { + logAuthenticationTryForAccountNumber(strAcccountNumber, dtLogDate, ErrorHelper.LICENSE_INACTIVE, strSiteIP, Convert.ToString(intEditionId), strUrlReferer); + intErrorID = ErrorHelper.E_LICENCE_IS_INACTIVE; + strStatus = GlobalConstant.STATUS_NOT_OK; + } + } else { + //intErrorID = ErrorDescription(strAcccountNumber, (byte)intEditionId, strSiteIP, strUrlReferer); + //strStatus = GlobalConstant.STATUS_NOT_OK; + + intErrorID = ErrorHelper.E_EDITION_NOT_LINKED_WITH_SITE; + strStatus = GlobalConstant.STATUS_NOT_OK; + } + } + objResponse.ErrorCode = intErrorID; + objResponse.Status = strStatus; + objResponse.ErrorDesc = ErrorHelper.GetInstance().GetErrorDescriptionHelper(intErrorID).ToString(); + } catch (Exception objExp) { + objResponse.Status = GlobalConstant.STATUS_NOT_OK; + objResponse.ErrorCode = GlobalConstant.RUN_TIME_EXCEPTION; + objResponse.strErrorDesc = objExp.Message; + } + if (isExpired != null && (bool)isExpired["result"]) + objResponse.strErrorDesc = objResponse.strErrorDesc.Replace("{0}", (string)isExpired["date"]); + return intUserId; } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj b/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj index 0fb61dc..9bb9c3a 100644 --- a/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj +++ b/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj @@ -45202,7 +45202,8 @@ - + + @@ -45445,6 +45446,20 @@ ..\packages\log4net.2.0.7\lib\net45-full\log4net.dll True + + + + + + + + + index.aspx + ASPXCodeBehind + + + index.aspx + 10.0 diff --git a/400-SOURCECODE/AIAHTML5.Web/Web.config b/400-SOURCECODE/AIAHTML5.Web/Web.config index 9a16866..d92fcca 100644 --- a/400-SOURCECODE/AIAHTML5.Web/Web.config +++ b/400-SOURCECODE/AIAHTML5.Web/Web.config @@ -49,6 +49,7 @@ + diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 1f8bbe2..aa08cf6 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -92,6 +92,15 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A userLicenseId: 0, licenseeAccountNumber: null }; + + $rootScope.siteUrlInfo = { + siteIP: null, + remoteIPAddress:null, + status: null, + accountNumber: null, + edition: null, + urlReferer:null + } $rootScope.userData; $rootScope.userModules; $rootScope.passwordMismatchMessage; @@ -123,7 +132,12 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $rootScope.initializeAIA = function () { - + if (urlParams != null && urlParams != undefined) { + + $scope.ValidateClientSiteUrl(); + } + + if (navigator.cookieEnabled) { $rootScope.isLoading = false; @@ -381,6 +395,28 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A } + + $scope.ValidateClientSiteUrl = function () { + urlParams = strIPAddress + "&" + strAccountNumber + "&" + strEdition + "&" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); + + var siteInfo = urlParams.split('&'); + $rootScope.siteUrlInfo.siteIP = siteInfo[0]; + $rootScope.siteUrlInfo.remoteIPAddress = siteInfo[1]; + $rootScope.siteUrlInfo.accountNumber = siteInfo[2]; + $rootScope.siteUrlInfo.edition = siteInfo[3]; + $rootScope.siteUrlInfo.urlReferer = siteInfo[4]; + + AuthenticationService.validateClientSite($rootScope.siteUrlInfo) + .then( + + function (result) { + + }, + function (error) { } + ) + } + + $scope.saveRemeberMeDetails = function (result, userInfo) { localStorage.setItem('RememberMeLoginId', result.LoginId); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js index 427b498..f827bb4 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js @@ -22,6 +22,29 @@ return deferred.promise; }, + validateClientSite: function (clientInfo) { + var deferred = $q.defer(); + + $http.post('/API/api/Client', JSON.stringify(clientInfo), { + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + + }); + return deferred.promise; + }, + + SendMailToUser: function (userInfo, havePassword) { var deferred = $q.defer(); diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx b/400-SOURCECODE/AIAHTML5.Web/index.aspx new file mode 100644 index 0000000..a4231f0 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx @@ -0,0 +1,2019 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="ADAM.AIA.index" %> + + + + + + + + + + + + A.D.A.M. Interactive Anatomy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+
+

A.D.A.M. Interactive Anatomy

+

The most comprehensive online interactive anatomy learning resource

+
+
+
+ +
+
+
+ +
+
+ + + + +
+ + +
+ Forgot User ID? + + +
+
+ + +
+ + +
+ Forgot Password? +
+ +
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
+ + + + +
+
Copyright © {{current_year}} Ebix Inc. All rights reserved.
+
+
+ + + + +
+
+ + + +
+ + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + +
+
+ +
+ + + + + + + + + + +
AIA
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Reset Password
 
New Password
+ + The password is required. +

Password length must be between 8 - 20 characters.

+

Password length must be between 8 - 20 characters.

+
 
Confirm Password
+ + Confirm password is required. + {{passwordMismatchMessage}} +
 
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs b/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs new file mode 100644 index 0000000..049cb7e --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace ADAM.AIA +{ + public partial class index : System.Web.UI.Page + { + public string strIPAddress = ""; + public bool bValidIP = false; + public string strAccountNumber = ""; + public string strEdition = ""; + public string strUrlReferer = ""; + public string strSiteReferer = ""; + public string urlParams = "?"; + public string test = ""; + + protected void Page_Load(object sender, EventArgs e) + { + urlParams = "XYZ"; + + if (Request.HttpMethod == "POST") + { + if (Request.Form["calsCredantial"] != null && Request.Form["calsCredantial"].ToString() == "yes") + { + urlParams = "?calsCredantial=" + Request.Form["calsCredantial"].ToString() + "&username=" + Request.Form["calsUsername"].ToString() + "&password=" + Request.Form["calsPassword"].ToString(); + } + } + + string c = "nm"; + if (Request.QueryString["account"] != null) + { + // http://stackoverflow.com/questions/9032005/request-servervariableshttp-referer-is-not-working-in-ie + // http://stackoverflow.com/questions/5643773/http-referrer-not-always-being-passed?rq=1 + // + strSiteReferer = Request.ServerVariables["HTTP_REFERER"]; + strAccountNumber = Request.QueryString["account"]; + strEdition = Request.QueryString["edition"]; + string remoteIPAddress = Request.ServerVariables["REMOTE_ADDR"]; + string strHttpReferer = null; + int intSiteId = 0; + + + + + if (Request.Form["referer"] != null) + { + strUrlReferer = Request.Form["referer"]; + } + else if (Request.QueryString["referer"] == null) + { + strUrlReferer = Request.ServerVariables["HTTP_REFERER"]; + } + else if (Request.Params["referer"] != null) + { + strUrlReferer = Request.Params["referer"]; + } + else + { + + strUrlReferer = Request.QueryString["referer"]; + } + + + if (strUrlReferer != "" && strUrlReferer != null) + { + strHttpReferer = strUrlReferer.ToLower().Replace("http://", "").Replace("https://", "").Replace("www.", "").ToString().Split('/')[0].ToString(); + + if (strHttpReferer.IndexOf(":") != -1) + { + char[] delimiters = new char[] { ':' }; + string[] parts = strHttpReferer.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); + strHttpReferer = parts[0]; + } + } + + try + { + + if (strHttpReferer != "" && strHttpReferer != null) + strIPAddress = strHttpReferer; + if (strIPAddress == "" || strIPAddress == null) + strIPAddress = remoteIPAddress; + + + // intSiteId = LicenseHelper.GetInstance().ValidateLicenseSiteIP(strIPAddress, remoteIPAddress, strAccountNumber, Convert.ToByte(strEdition)); + + } + catch (Exception objEx) + { + + } + //urlParams = "?siteIP=" + strIPAddress + "&status=" + intSiteId + "&accountNumber=" + strAccountNumber + "&edition=" + strEdition + "&urlReferer=" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); + //urlParams = "siteIP=" + strIPAddress + "&accountNumber=" + strAccountNumber + "&edition=" + strEdition + "&urlReferer=" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); + + //For the ease of splitting desgined urlParms in the pattern of + //urlParams = siteIP&accountNumber&remoteIPAddress&edition&urlReferer; without mentioning the variableName + urlParams = strIPAddress + "&" + remoteIPAddress+"&"+ strAccountNumber + "&" + strEdition + "&" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); + + + } + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx.designer.cs b/400-SOURCECODE/AIAHTML5.Web/index.aspx.designer.cs new file mode 100644 index 0000000..2a5236b --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx.designer.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ADAM.AIA { + + + public partial class index { + } +} diff --git a/400-SOURCECODE/AIAHTML5.Web/index.html b/400-SOURCECODE/AIAHTML5.Web/index1.html index 058b6db..058b6db 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.html +++ b/400-SOURCECODE/AIAHTML5.Web/index1.html