public IHttpActionResult Get() { string message = ""; bool flag = false; List <GamePostModel> data = new List <GamePostModel>(); try { object infoObject; Request.Properties.TryGetValue(Constants.IdentificationInfo, out infoObject); DBServerIdentification identificationInfo = (DBServerIdentification)infoObject; DataSQL objSQL = new DataSQL(identificationInfo); GamesLogic gl = new GamesLogic(objSQL); data = gl.getPendingApprovals(); message = gl.errorMessage; } catch (Exception ex) { message = ex.Message; FileLogger.AppendLog("ModeratorController >> ", LogType.Error, "GET", ex.Message); } if (message.Length == 0) { return(Ok(data)); } else { return(BadRequest(message)); } }
/// <summary> /// Describe your member here. /// </summary> public static bool verifyTwoStepAuthentication(string access_token, string verfication_code) { bool flag = false; try { var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(DbName); var collection = database.GetCollection <CustomerAccess>("customeraccess"); List <CustomerAccess> data = collection.Find <CustomerAccess>(Builders <CustomerAccess> .Filter.Eq(x => x.access_token, access_token)).ToList(); if (data.Count == 1) { if (data[0].twoFactorCode.Equals(verfication_code)) { flag = true; data[0].twoFactorVerified = "True"; collection.ReplaceOne(Builders <CustomerAccess> .Filter.Eq(x => x.access_token, access_token), data[0]); } } } catch (Exception ex) { FileLogger.AppendLog("POWebAPI", LogType.Error, "POWebAPI >> AuditLogs >> verifyTwoStepAuthentication >> " + access_token + " >>", ex.Message); } return(flag); }
public bool approveGame(GamesMaster game) { bool flag = false; try { var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(dbServerID); var collection = database.GetCollection <GamesMaster>("GamesMaster"); game.is_validated = true; game.validated_by_name = objIdentification.Name; game.validated_user_id = objIdentification.ObjectID.ToString(); game.validated_date = DateTime.Now; var update = Builders <GamesMaster> .Update .Set(x => x.is_validated, true) .Set(x => x.validated_by_name, objIdentification.Name) .Set(x => x.validated_user_id, objIdentification.ObjectID.ToString()) .Set(x => x.validated_date, DateTime.Now); collection.UpdateOne(Builders <GamesMaster> .Filter.Eq(x => x.id, ObjectId.Parse(game.id.ToString())), update); flag = true; } catch (Exception ex) { errorMessage = ex.Message; FileLogger.AppendLog("Rx ", LogType.Error, "getRx >> ", ex.Message); } return(flag); }
public IHttpActionResult Post([FromBody] GamesMaster approveGame) { string message = "approved"; bool flag = false; try { object infoObject; Request.Properties.TryGetValue(Constants.IdentificationInfo, out infoObject); DBServerIdentification identificationInfo = (DBServerIdentification)infoObject; DataSQL objSQL = new DataSQL(identificationInfo); GamesLogic gl = new GamesLogic(objSQL); flag = gl.approveGame(approveGame); message = gl.errorMessage; } catch (Exception ex) { message = ex.Message; FileLogger.AppendLog("GamesController >> ", LogType.Error, "POST", ex.Message); } if (flag) { return(Ok(message)); } else { return(BadRequest(message)); } }
/// <summary> /// Describe your member here. /// </summary> public static async Task InsertRequestCall(string access_token, string URL, string RequestHeaders, string RequestParameters, string Response, string ResponseStatus, string ContentSize, string resHeaders, string ReqSentTime, string reqCompletedTime, int resHttpCode) { try { var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(DbName); var collection = database.GetCollection <CustomerAccess>("customeraccess"); APICalls call = new APICalls(); call.APIUrl = URL; call.RequestParameters = RequestParameters; call.ResponseContent = Response; call.ResponseStatus = ResponseStatus; call.ResponseContentSize = ContentSize; call.ResponseHeaders = resHeaders; call.RequestSentTime = ReqSentTime; call.RequestCompletedTime = reqCompletedTime; call.ResHttpCode = resHttpCode; call.RequestHeaders = RequestHeaders; collection.UpdateOne(Builders <CustomerAccess> .Filter.Eq(x => x.access_token, access_token), Builders <CustomerAccess> .Update.AddToSet(x => x.apiCalls, call)); } catch (Exception ex) { FileLogger.AppendLog("POWebAPI", LogType.Error, "POWebAPI >> AuditLogs >> insertRequestCall >> " + access_token + " >> ", ex.Message); } }
/// <summary> /// Describe your member here. /// </summary> public static bool insertCustomerAuthCall(string dbServerID, string name, string URL, string EmailID, string zip, string PhoneNumber, string access_token, string RemoteIP, string twoFactorEnabled, string twoFactorCode) { bool flag = true; try { var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(DbName); var collection = database.GetCollection <CustomerAccess>("customeraccess"); CustomerAccess access = new CustomerAccess(); access.Name = name; access.access_token = access_token; access.URL = URL; access.EmailID = EmailID; access.Zip = zip; access.PhoneNumber = PhoneNumber; access.RemoteIP = RemoteIP; access.TokenGenTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); access.TokenExpTime = DateTime.Now.AddHours(24).ToString("yyyy-MM-dd HH:mm:ss"); access.DBServerID = dbServerID; access.twoFactorVerified = twoFactorEnabled; access.twoFactorCode = twoFactorCode; access.isValidToken = true; access.apiCalls = new List <APICalls>(); collection.InsertOne(access); } catch (Exception ex) { flag = false; FileLogger.AppendLog("POWebAPI", LogType.Error, "POWebAPI >> AuditLogs >> insertCustomerAuthCall >> " + access_token + " >>", ex.Message); } return(flag); }
/// <summary> /// Describe your member here. /// </summary> public static DBServerIdentification getIdentificationInfo1(string access_token, string remoteIP, bool skipTwoStep = false) { DBServerIdentification obj = new DBServerIdentification() { Name = string.Empty, phone = string.Empty, Status = "Error" }; //LicenseClass sls = new LicenseClass(); try { var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(DbName); var collection = database.GetCollection <CustomerAccess>("customeraccess"); var list = collection.Find(Builders <CustomerAccess> .Filter.Eq(x => x.access_token, access_token)).ToList(); foreach (var tmpData in list) { obj.ObjectID = tmpData.id; obj.Name = tmpData.Name; obj.phone = tmpData.PhoneNumber; obj.access_token = tmpData.access_token; obj.EmailID = tmpData.EmailID; DateTime fromDate = Convert.ToDateTime(tmpData.TokenGenTime); DateTime toDate = Convert.ToDateTime(tmpData.TokenExpTime); if ((toDate - fromDate).TotalMinutes > 0) { if (tmpData.isValidToken && /*tmpData.RemoteIP.ToString().Equals(remoteIP) &&*/ AuditLogs.verifyAllowedIpAccess(tmpData.id.ToString(), remoteIP)) { if (tmpData.twoFactorVerified.ToString().ToLower().Equals("true") || skipTwoStep) { obj.Status = "Success"; } else { obj.Status = "Please verify two step authentication"; } } else { obj.Status = "Unauthorized access"; } } else { obj.Status = "TokenExpired"; tmpData.isValidToken = false; collection.UpdateOne(Builders <CustomerAccess> .Filter.Eq(x => x.access_token, access_token), Builders <CustomerAccess> .Update.Set(x => x.isValidToken, false)); } } } catch (Exception ex) { FileLogger.AppendLog("POWebAPI", LogType.Error, "POWebAPI >> AuditLogs >> getIdentificationInfo " + access_token + " >> ", ex.Message); } return(obj); }
public List <GamePostModel> getGames(string frm = "", string itn = "", string aud = "", string mnp = "", string mxp = "") { List <GamePostModel> data = new List <GamePostModel>(); errorMessage = string.Empty; try { List <string> filtersFrm = new List <string>(); if (frm.Length > 0) { filtersFrm = frm.Split(',').ToList(); } List <string> filtersitn = new List <string>(); if (itn.Length > 0) { filtersitn = itn.Split(',').ToList(); } List <string> filtersaud = new List <string>(); if (aud.Length > 0) { filtersaud = aud.Split(',').ToList(); } List <string> filtersmnp = new List <string>(); if (mnp.Length > 0) { filtersmnp = mnp.Split(',').ToList(); } List <string> filtersmxp = new List <string>(); if (mxp.Length > 0) { filtersmxp = mxp.Split(',').ToList(); } var filter = Builders <GamePostModel> .Filter.Eq(x => x.is_validated, true) & (filtersFrm.Count > 0 ? Builders <GamePostModel> .Filter.In(x => x.formation, filtersFrm) : Builders <GamePostModel> .Filter.Eq(x => x.is_validated, true)) & (filtersitn.Count > 0 ? Builders <GamePostModel> .Filter.In(x => x.intensity, filtersitn) : Builders <GamePostModel> .Filter.Eq(x => x.is_validated, true)) & (filtersaud.Count > 0 ? Builders <GamePostModel> .Filter.In(x => x.audiance, filtersaud) : Builders <GamePostModel> .Filter.Eq(x => x.is_validated, true)) & (filtersmnp.Count > 0 ? Builders <GamePostModel> .Filter.In(x => x.min_participants, filtersmnp) : Builders <GamePostModel> .Filter.Eq(x => x.is_validated, true)) & (filtersmxp.Count > 0 ? Builders <GamePostModel> .Filter.In(x => x.max_participants, filtersmxp) : Builders <GamePostModel> .Filter.Eq(x => x.is_validated, true)); var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(dbServerID); var collection = database.GetCollection <GamePostModel>("GamesMaster"); data = collection.Find(filter).ToList(); } catch (Exception ex) { errorMessage = ex.Message; FileLogger.AppendLog("DataSQL", LogType.Error, "getAllReports >> ", ex.Message); } return(data); }
public GamePostModel getGames(string gameid) { GamePostModel data = new GamePostModel(); errorMessage = string.Empty; try { data = objSQL.getGames(gameid); } catch (Exception ex) { errorMessage = ex.Message; FileLogger.AppendLog("GamesLogic ", LogType.Error, "getPendingApprovals >> ", ex.Message); } return(data); }
public List <GamePostModel> getGames(string frm = "", string itn = "", string aud = "", string mnp = "", string mxp = "") { List <GamePostModel> data = new List <GamePostModel>(); errorMessage = string.Empty; try { data = objSQL.getGames(frm, itn, aud, mnp, mxp); } catch (Exception ex) { errorMessage = ex.Message; FileLogger.AppendLog("GamesLogic ", LogType.Error, "getPendingApprovals >> ", ex.Message); } return(data); }
public List <GamePostModel> getPendingApprovals() { List <GamePostModel> data = new List <GamePostModel>(); errorMessage = string.Empty; try { data = objSQL.getPendingApprovals(); } catch (Exception ex) { errorMessage = ex.Message; FileLogger.AppendLog("GamesLogic ", LogType.Error, "getPendingApprovals >> ", ex.Message); } return(data); }
public bool approveGame(GamesMaster game) { bool flag = false; errorMessage = string.Empty; try { flag = objSQL.approveGame(game); errorMessage = objSQL.errorMessage; } catch (Exception ex) { flag = false; errorMessage = ex.Message; FileLogger.AppendLog("GamesLogic ", LogType.Error, "addNewGame >> ", ex.Message); } return(flag); }
public List <GamePostModel> getPendingApprovals() { List <GamePostModel> data = new List <GamePostModel>(); errorMessage = string.Empty; try { var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(dbServerID); var collection = database.GetCollection <GamePostModel>("GamesMaster"); data = collection.Find(Builders <GamePostModel> .Filter.Eq(x => x.is_validated, false)).ToList(); } catch (Exception ex) { errorMessage = ex.Message; FileLogger.AppendLog("DataSQL", LogType.Error, "getAllReports >> ", ex.Message); } return(data); }
public GamePostModel getGames(string gameid) { GamePostModel data = new GamePostModel(); errorMessage = string.Empty; try { var filter = Builders <GamePostModel> .Filter.Eq(x => x.id, ObjectId.Parse(gameid)); var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(dbServerID); var collection = database.GetCollection <GamePostModel>("GamesMaster"); data = collection.Find(filter).First(); } catch (Exception ex) { errorMessage = ex.Message; FileLogger.AppendLog("DataSQL", LogType.Error, "getAllReports >> ", ex.Message); } return(data); }
public bool addNewGame(GamePostModel game) { bool flag = false; try { var client = new MongoClient(MongoConnectionString); var database = client.GetDatabase(dbServerID); var collection = database.GetCollection <GamePostModel>("GamesMaster"); game.is_validated = false; game.submited_by_name = objIdentification.Name; game.submited_by_user_id = objIdentification.ObjectID.ToString(); game.submited_date = DateTime.Now; collection.InsertOne(game); flag = true; } catch (Exception ex) { errorMessage = ex.Message; FileLogger.AppendLog("Rx ", LogType.Error, "getRx >> ", ex.Message); } return(flag); }
public IHttpActionResult Post([FromBody] RegistrationModel value) { string message = string.Empty; try { LicenseClass lc = new LicenseClass(); message = lc.Register(value, HttpContext.Current.Request.UserHostAddress); } catch (Exception ex) { message = ex.Message; FileLogger.AppendLog("ACCOUNT", LogType.Error, "POST", ex.Message); } if (message.ToLower().Equals("success")) { return(Ok(message)); } else { return(BadRequest(message)); } }
/// <summary> /// Describe your member here. /// </summary> public override Task TokenEndpointResponse(OAuthTokenEndpointResponseContext context) { bool flag = false; try { DateTime expiry = DateTime.Now.AddMinutes(context.Options.AccessTokenExpireTimeSpan.TotalMinutes); context.AdditionalResponseParameters.Add("expiry", expiry.ToString("ddd, dd MMM yyyy HH:mm:ss 'GMT'")); flag = AuditLogs.insertCustomerAuthCall(ld.id.ToString(), ld.first_name + " " + ld.last_name, context.Request.Host.Value, ld.email_address, ld.zip, ld.phone_number, context.AccessToken, HttpContext.Current.Request.UserHostAddress, (!ld.is_two_step_enabled).ToString(), ld.verificationCode); //flag = AuditLogs.insertCustomerAuthCall(ld.last_name + " " + ld.first_name, ld.UserID, context.Request.Host.Value, ld.DBServerID, ld.EmailID, ld.MasterCustomerID, ld.Speciality, ld.zip, ld.PhoneNumber, context.AccessToken, ld.UserIPAddress, (!ld.IS2wayEnabled).ToString(), ld.verificationCode, ld.User_Type); } catch (Exception ex) { FileLogger.AppendLog("POWebAPI", LogType.Error, "POWebAPI >> ApplicationOAuthProvider >> GrantResourceOwnerCredentials >> ", ex.Message); } if (flag) { return(base.TokenEndpointResponse(context)); } else { return(null); } }
/// <summary> /// Describe your member here. /// </summary> public static bool verifyAllowedIpAccess(string MasterCustomerID, string IPAddress) { bool flag = true; try { //var client = new MongoClient(MongoConnectionString); //var database = client.GetDatabase(DbName); //var collection = database.GetCollection<IPAddressMapping>("customeripmapping"); //var ipList = collection.Find<IPAddressMapping>(Builders<IPAddressMapping>.Filter.Eq(x => x.MasterCustomerID, MasterCustomerID)).ToList(); //if (ipList.Count > 0) //{ // if ((from x in ipList where x.IpAddress.Equals(IPAddress) select x).Count() == 0) // flag = false; //} } catch (Exception ex) { flag = false; FileLogger.AppendLog(MasterCustomerID, LogType.Error, "POWebAPI >> AuditLogs >> verifyAllowedIpAccess >> ", ex.Message); } return(flag); }