private ApplicationHistory GetAppHistory(int deviceID, string app) { Database db = new Database(); ApplicationHistory history = db.GetApplicationHistory(deviceID, app); return(history); }
public ApplicationHistory RetrieveTestHistory(Guid applicationId) { ApplicationHistory result = new ApplicationHistory(); var application = dbContext.Applications.FirstOrDefault(a => a.ApplicationGuid == applicationId); if (application != null) { result = new ApplicationHistory() { Applicationid = applicationId, ApplicatioName = application.ApplicationName }; var tests = dbContext.Tests.Where(t => t.ApplicationId == application.ApplicationId).ToList(); var testRuns = (from tr in dbContext.TestRuns join t in dbContext.Tests on tr.TestId equals t.TestId where t.ApplicationId == application.ApplicationId select tr ).OrderByDescending(t => t.RunDate).ToList(); foreach (var test in tests) { TestHistory th = new TestHistory() { Comments = test.RollingComments, IsUnderDevelopment = test.CurrentStatus == ORMModel.Test.TestDefinitionStatusEnumeration.UnderDevelopment, TestDescription = test.Description, TestName = test.TestName, TestNumber = test.TestNumber, TestId = test.TestGuid, TestFamily = test.TestFamily, ETA = test.CurrentETA.HasValue ? test.CurrentETA.Value.ToString("MM/dd/yyyy") : test.OriginalETA.HasValue ? test.OriginalETA.Value.ToString("MM/dd/yyyy") : "" }; var runs = testRuns.Where(t => t.TestId == test.TestId); foreach (var run in runs) { TestRunHistory runHistory = new TestRunHistory() { BugReportLink = run.BugReportLink, RecordedBugDate = run.RecordedBugDate, TestReportLink = run.TestReportLink, Comments = run.Comments, DateRan = run.RunDate, RunStatus = run.RunStatus, TestRunId = run.TestRunGuid }; th.RunHistory.Add(runHistory); } result.Add(th); } } return(result); }
public static IDictionary <string, object> MapApplicationHistoryDictionary(this ApplicationHistory applicationHistory) { return(new Dictionary <string, object> { { "ApplicationHistoryId", applicationHistory.ApplicationHistoryId }, { "ApplicationId", applicationHistory.ApplicationId }, { "UserName", applicationHistory.UserName }, { "ApplicationHistoryEventDate", applicationHistory.ApplicationHistoryEventDate }, { "ApplicationHistoryEventTypeId", applicationHistory.ApplicationHistoryEventTypeId }, { "ApplicationHistoryEventSubTypeId", applicationHistory.ApplicationHistoryEventSubTypeId }, { "Comment", applicationHistory.Comment }, }); }
public string ChangeApplicationStatus([FromBody] ApplicationHistory applicationHistory) { string result = ""; using (MySqlConnection conn = new MySqlConnection(connection.MySQLConnectionString)) { conn.Open(); string spName = "change_Application_Status"; using (MySqlCommand cmd = new MySqlCommand(spName, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@_ApplicationId", applicationHistory.ApplicationId); cmd.Parameters.AddWithValue("@_ApplicationStatusId", applicationHistory.ApplicationStatusId); cmd.Parameters.AddWithValue("@_Comments", applicationHistory.Comments); cmd.Parameters.AddWithValue("@_CreatedBy", applicationHistory.CreatedBy); cmd.ExecuteNonQuery(); } conn.Close(); result = "Success"; } return(result); }
public void SaveApplicationHistory(ApplicationHistory history) { var text = JsonConvert.SerializeObject(history); File.WriteAllText(_FileName, text); }
/// <summary>Controller to run when invoked to track history</summary> /// <param name="filterContext">An ActionExecutingContext passed by the invoked controllers</param> public override void OnActionExecuting(ActionExecutingContext filterContext) { try { // We retrieve the user info cookie if it exists HttpCookie userCookie = filterContext.HttpContext.Request.Cookies[Convert.ToString(WebConfigurationManager.AppSettings["ApplicationName"]) + ".User"]; // We build our database context var accountContext = new UtilityEntities(); // We create a new history object and start hoovering in data ApplicationHistory record = new ApplicationHistory(); record.Application = "Picol"; // We use Convert.ToString() on anything in a object so in the event that the object is null we get an empty string instead of an exception record.Path = Convert.ToString(HttpContext.Current.Request.Url.AbsoluteUri); // Set the IP address to the x forwarded IP, then test if it is empty record.IpAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; // If X forwarded is empty, check remote address and host address if (string.IsNullOrEmpty(record.IpAddress)) { record.IpAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; if (string.IsNullOrEmpty(record.IpAddress)) { record.IpAddress = Convert.ToString(HttpContext.Current.Request.UserHostAddress); } } else { // Using X-Forwarded-For last address record.IpAddress = record.IpAddress.Split(',').Last().Trim(); } // For each key in a form we convert it into a comma delimmited string foreach (var f in HttpContext.Current.Request.Form.AllKeys) { // Add the name of the key to the string record.Form += f + ":"; // If contains sensitive data redact, otherwise record if (f.ToLower().Contains("password") || f.ToLower().Contains("ssn") || f.ToLower().Contains("birthdate") || f.ToLower().Contains("sms") || f.ToLower().Contains("externalemail") || f.ToLower().Contains("response") || f.ToLower().Contains("answer")) { record.Form += "********" + ","; } else { // Add non-password data record.Form += HttpContext.Current.Request.Form[f] + ","; } } // Foreach querystring variable we convert it into a comma delimmited string foreach (var q in HttpContext.Current.Request.QueryString.AllKeys) { if (q == null) { continue; } // If contains sensitive data redact, otherwise record if (q.ToLower().Contains("password") || q.ToLower().Contains("ssn") || q.ToLower().Contains("birthdate") || q.ToLower().Contains("sms") || q.ToLower().Contains("externalemail") || q.ToLower().Contains("response") || q.ToLower().Contains("answer")) { record.QueryString += "********" + ","; } else { record.QueryString += HttpContext.Current.Request.QueryString[q] + ","; } } // If the user info cookie exists we assign the username if (userCookie != null) { record.UserName = Encryption.UnprotectString(userCookie["Email"], new string[] { "Cookie" }, true); } // Create out history entry record.Created = DateTime.Now; accountContext.ApplicationHistories.Add(record); accountContext.SaveChanges(); return; } catch (Exception e) { // Signal the error to be logged by elmah ErrorSignal.FromCurrentContext().Raise(e); // Don't redirect on failure because we don't want to disrupt use of the site return; } }