public override int GetHashCode() { int hash = 1; if (Started != false) { hash ^= Started.GetHashCode(); } if (Completed != false) { hash ^= Completed.GetHashCode(); } if (Passed != false) { hash ^= Passed.GetHashCode(); } if (Scenario.Length != 0) { hash ^= Scenario.GetHashCode(); } if (Status.Length != 0) { hash ^= Status.GetHashCode(); } hash ^= durationMs_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { var hashCode = -745740247; hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Kursnamn); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Antal_poäng); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Poängtyp); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Kurskod); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Beskrivning); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Representant_email); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Läsperiod); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Specialisering); hashCode = hashCode * -1521134295 + _Passed.GetHashCode(); hashCode = hashCode * -1521134295 + Passed.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FullInfo); return(hashCode); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } hashCode = hashCode * 59 + Severity.GetHashCode(); hashCode = hashCode * 59 + Passed.GetHashCode(); hashCode = hashCode * 59 + Override.GetHashCode(); if (ActualValue != null) { hashCode = hashCode * 59 + ActualValue.GetHashCode(); } if (ExpectedValue != null) { hashCode = hashCode * 59 + ExpectedValue.GetHashCode(); } hashCode = hashCode * 59 + Comparator.GetHashCode(); if (Kpi != null) { hashCode = hashCode * 59 + Kpi.GetHashCode(); } return(hashCode); } }
//hash code trait public override int GetHashCode() { unchecked { var hash = 0; hash = hash * 31 + Passed.GetHashCode(); return(hash); } }
//pretty print public void Print(PrettyPrinter printer) { printer.Println("RunResult ("); using (printer.IndentCookie()) { printer.Print("passed = "); Passed.PrintEx(printer); printer.Println(); } printer.Print(")"); }
/// <inheritdoc/> public override int GetHashCode() { unchecked { var hashCode = (_specs != null ? _specs.GetHashCode() : 0); hashCode = (hashCode * 397) ^ StartTime.GetHashCode(); hashCode = (hashCode * 397) ^ EndTime.GetHashCode(); hashCode = (hashCode * 397) ^ Passed.GetHashCode(); return(hashCode); } }
/// <summary> /// Returns true if Metric instances are equal /// </summary> /// <param name="other">Instance of Metric to be compared</param> /// <returns>Boolean</returns> public bool Equals(Metric other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Severity == other.Severity || Severity.Equals(other.Severity) ) && ( Passed == other.Passed || Passed.Equals(other.Passed) ) && ( Override == other.Override || Override.Equals(other.Override) ) && ( ActualValue == other.ActualValue || ActualValue != null && ActualValue.Equals(other.ActualValue) ) && ( ExpectedValue == other.ExpectedValue || ExpectedValue != null && ExpectedValue.Equals(other.ExpectedValue) ) && ( Comparator == other.Comparator || Comparator.Equals(other.Comparator) ) && ( Kpi == other.Kpi || Kpi != null && Kpi.Equals(other.Kpi) )); }
public override int GetHashCode() { unchecked { var hashCode = Description != null?Description.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (EvaluatedObject != null ? EvaluatedObject.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Passed.GetHashCode(); hashCode = (hashCode * 397) ^ (ArchRule != null ? ArchRule.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Architecture != null ? Architecture.GetHashCode() : 0); return(hashCode); } }
public bool Equals(NodeData other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(_eventTimeLine.SetEquals(other._eventTimeLine) && NodeIndex == other.NodeIndex && StartTime == other.StartTime && EndTime == other.EndTime && Passed.Equals(other.Passed)); }
/// <inheritdoc/> public bool Equals(TestRunTree other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (_specs.SequenceEqual(other._specs) && StartTime == other.StartTime && EndTime == other.EndTime && Passed.Equals(other.Passed)); }
/// <inheritdoc/> public bool Equals(FactData other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(_nodes.SequenceEqual(other._nodes) && _testRunnerTimeLine.SetEquals(other._testRunnerTimeLine) && string.Equals(FactName, other.FactName) && StartTime == other.StartTime && EndTime == other.EndTime && Passed.Equals(other.Passed)); }
public override int GetHashCode() { int hash = 1; if (HasRequestToken) { hash ^= RequestToken.GetHashCode(); } if (HasPassed) { hash ^= Passed.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void SerializeAsNUnit(string xmlFile) { var doc = new XmlDocument(); var declaration = doc.CreateXmlDeclaration("1.0", "utf-8", "no"); var root = doc.DocumentElement; doc.InsertBefore(declaration, root); var run = doc.CreateElement(string.Empty, "test-run", string.Empty); run.SetAttribute("id", "2"); // Hardcoded for NUnit tests run.SetAttribute("name", RunName); run.SetAttribute("testcasecount", TestCaseCount.ToString()); run.SetAttribute("result", Result.ToString()); run.SetAttribute("time", ((double)((DateTime.Now - StartTime).TotalMilliseconds) / 1000.0).ToString("0.000")); run.SetAttribute("total", Total.ToString()); run.SetAttribute("passed", Passed.ToString()); run.SetAttribute("failed", Failed.ToString()); run.SetAttribute("inconclusive", Inconclusive.ToString()); run.SetAttribute("skipped", Skipped.ToString()); run.SetAttribute("asserts", "0"); run.SetAttribute("run-date", StartTime.ToString("yyyy-MM-dd")); run.SetAttribute("start-time", StartTime.ToString("hh:mm:ss")); doc.AppendChild(run); var env = doc.CreateElement(string.Empty, "environment", string.Empty); env.SetAttribute("nunit-version", "1.0.0.0"); run.AppendChild(env); foreach (var testSuite in TestSuites.Values) { var suite = doc.CreateElement(string.Empty, "test-suite", string.Empty); suite.SetAttribute("type", "TestSuite"); suite.SetAttribute("id", testSuite.Id.ToString()); suite.SetAttribute("name", testSuite.Name); suite.SetAttribute("testcasecount", testSuite.TestCaseCount.ToString()); suite.SetAttribute("total", testSuite.Total.ToString()); suite.SetAttribute("result", testSuite.Result.ToString()); suite.SetAttribute("time", ((double)((testSuite.EndTime - testSuite.StartTime).TotalMilliseconds) / 1000.0).ToString("0.000")); suite.SetAttribute("passed", testSuite.Passed.ToString()); suite.SetAttribute("failed", testSuite.Failed.ToString()); suite.SetAttribute("inconclusive", testSuite.Inconclusive.ToString()); suite.SetAttribute("skipped", testSuite.Skipped.ToString()); suite.SetAttribute("asserts", "0"); run.AppendChild(suite); foreach (var testCase in testSuite.TestCases) { var tc = doc.CreateElement(string.Empty, "test-case", string.Empty); tc.SetAttribute("id", testCase.Id.ToString()); tc.SetAttribute("name", testCase.Name); tc.SetAttribute("result", testCase.Result.ToString()); tc.SetAttribute("time", "0.000"); tc.SetAttribute("asserts", "0"); suite.AppendChild(tc); if (testCase.Properties != null && testCase.Properties.Count > 0) { var props = doc.CreateElement(string.Empty, "properties", string.Empty); tc.AppendChild(props); foreach (var property in testCase.Properties) { var prop = doc.CreateElement(string.Empty, "property", string.Empty); prop.SetAttribute("name", property.Key); prop.SetAttribute("value", property.Value); props.AppendChild(prop); } } if (testCase.Failure != null) { var failure = doc.CreateElement(string.Empty, "failure", string.Empty); tc.AppendChild(failure); if (testCase.Failure.Message != null) { var msg = doc.CreateElement(string.Empty, "message", string.Empty); var msgData = doc.CreateCDataSection(testCase.Failure.Message); msg.AppendChild(msgData); failure.AppendChild(msg); } if (testCase.Failure.StackTrace != null) { var stck = doc.CreateElement(string.Empty, "stack-trace", string.Empty); var stckData = doc.CreateCDataSection(testCase.Failure.StackTrace); stck.AppendChild(stckData); failure.AppendChild(stck); } } } } doc.Save(xmlFile); }
private void InitCallingConvention() { ArgumentsStackSize = 0; RedZoneSize = 0; SpillZoneSize = 0; CalleePopsStack = false; Passed.Reset(); Preserved.Reset(); if (Constants.X64) { switch (CallingConvention) { case CallingConvention.X64Win: SpillZoneSize = 32; Passed.Set(RegisterClass.Gp, Utils.Mask(RegisterIndex.Cx, RegisterIndex.Dx, 8, 9)); _passedOrderGp[0] = RegisterIndex.Cx; _passedOrderGp[1] = RegisterIndex.Dx; _passedOrderGp[2] = 8; _passedOrderGp[3] = 9; Passed.Set(RegisterClass.Xyz, Utils.Mask(0, 1, 2, 3)); _passedOrderXyz[0] = 0; _passedOrderXyz[1] = 1; _passedOrderXyz[2] = 2; _passedOrderXyz[3] = 3; Preserved.Set(RegisterClass.Gp, Utils.Mask(RegisterIndex.Bx, RegisterIndex.Sp, RegisterIndex.Bp, RegisterIndex.Si, RegisterIndex.Di, 12, 13, 14, 15)); Preserved.Set(RegisterClass.Xyz, Utils.Mask(6, 7, 8, 9, 10, 11, 12, 13, 14, 15)); break; case CallingConvention.X64Unix: RedZoneSize = 128; Passed.Set(RegisterClass.Gp, Utils.Mask(7, 6, 2, 1, 8, 9)); _passedOrderGp[0] = 7; _passedOrderGp[1] = 6; _passedOrderGp[2] = 2; _passedOrderGp[3] = 1; _passedOrderGp[4] = 8; _passedOrderGp[5] = 9; Passed.Set(RegisterClass.Xyz, Utils.Mask(0, 1, 2, 3, 4, 5, 6, 7)); _passedOrderXyz[0] = 0; _passedOrderXyz[1] = 1; _passedOrderXyz[2] = 2; _passedOrderXyz[3] = 3; _passedOrderXyz[4] = 4; _passedOrderXyz[5] = 5; _passedOrderXyz[6] = 6; _passedOrderXyz[7] = 7; Preserved.Set(RegisterClass.Gp, Utils.Mask(3, 4, 5, 12, 13, 14, 15)); break; } } else { _argumentPassingDirection = ArgumentPassingDirection.RightToLeft; Preserved.Set(RegisterClass.Gp, Utils.Mask(3, 4, 5, 6, 7)); switch (CallingConvention) { case CallingConvention.X86CDecl: break; case CallingConvention.X86StdCall: CalleePopsStack = true; break; case CallingConvention.X86MsThisCall: CalleePopsStack = true; Passed.Set(RegisterClass.Gp, Utils.Mask(1)); _passedOrderGp[0] = 1; break; case CallingConvention.X86MsFastCall: CalleePopsStack = true; Passed.Set(RegisterClass.Gp, Utils.Mask(1, 1)); _passedOrderGp[0] = 1; _passedOrderGp[1] = 2; break; case CallingConvention.X86BorlandFastCall: CalleePopsStack = true; _argumentPassingDirection = ArgumentPassingDirection.LeftToRight; Passed.Set(RegisterClass.Gp, Utils.Mask(0, 2, 1)); _passedOrderGp[0] = 0; _passedOrderGp[1] = 2; _passedOrderGp[2] = 1; break; case CallingConvention.X86GccFastCall: CalleePopsStack = true; Passed.Set(RegisterClass.Gp, Utils.Mask(1, 2)); _passedOrderGp[0] = 1; _passedOrderGp[1] = 2; break; case CallingConvention.X86GccRegParm1: Passed.Set(RegisterClass.Gp, Utils.Mask(0)); _passedOrderGp[0] = 0; break; case CallingConvention.X86GccRegParm2: Passed.Set(RegisterClass.Gp, Utils.Mask(0, 2)); _passedOrderGp[0] = 0; _passedOrderGp[1] = 2; break; case CallingConvention.X86GccRegParm3: Passed.Set(RegisterClass.Gp, Utils.Mask(0, 2, 1)); _passedOrderGp[0] = 0; _passedOrderGp[1] = 2; _passedOrderGp[2] = 1; break; } } }
public override string ToString() { return($"{SubjectName}, {Passed.ToString()}"); }
//Update public void UpdateChartValues(int GameID) { if (GameID == 0) { throw new Exception("GameID kan niet 0 zijn!"); } int ChartGroupID = _gameHandler.GetGame(GameID).ChartGroupID; //string DELETEQUERY = "DELETE FROM `chartvalues` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "'"; List <Models.DataModels.GameScore> gameScores = dbContext.GameScore.Where(g => g.ChartGroupID == ChartGroupID).ToList(); //NumOfBonusses //string NumOfBonusQry = "INSERT INTO `chartvalues` (`ID`, `ChartID`, `ChartGroupID`, `Label`, `Value`) VALUES "; List <Models.DataModels.ChartValues> values = new List <Models.DataModels.ChartValues>(); //SQL.Select("SELECT DISTINCT `NumOfBonus` FROM `gamescore` WHERE `ChartGroupID` = '"+ChartGroupID.ToString()+"'") foreach (int NumOfBonus in gameScores.Select(g => g.NumOfBonus).Distinct()) { //NumOfBonusQry += "(NULL, '1', '" +ChartGroupID.ToString()+"', '"+NumOfBonus+ "', (SELECT COUNT(`NumOfBonus`) FROM `gamescore` WHERE `ChartGroupID` = '"+ChartGroupID.ToString()+ "' AND `NumOfBonus` = '" + NumOfBonus + "')),"; values.Add(new Models.DataModels.ChartValues() { ChartID = 1, ChartGroupID = ChartGroupID, Label = NumOfBonus.ToString(), Value = Convert.ToString(dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.NumOfBonus == NumOfBonus).Count()) }); } //Passed /* * string PassedQry = "INSERT INTO `chartvalues` (`ID`, `ChartID`, `ChartGroupID`, `Label`, `Value`) VALUES "; * string _passed = ""; //SQL.Select("SELECT DISTINCT `Passed` FROM `gamescore` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "'") * foreach (string Passed in new List<string>() {"1","0" } ) * { * if (Passed == "True" || Passed == "0") { _passed = "0"; } * if (Passed == "False" || Passed == "1") { _passed = "1"; } * PassedQry += "(NULL, '2', '" + ChartGroupID.ToString() + "', '" + _passed + "', (SELECT COUNT(`Passed`) FROM `gamescore` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "' AND `Passed` = '" + _passed + "')),"; * } * PassedQry = PassedQry.Remove(PassedQry.Length - 1); */ foreach (int Passed in new List <int>() { 1, 0 }) { bool _passed = false; if (Passed == 0) { _passed = true; } values.Add(new Models.DataModels.ChartValues() { ChartID = 2, ChartGroupID = ChartGroupID, Label = Passed.ToString(), Value = Convert.ToString(dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.Passed == _passed).Count()) }); } //Lifes /* * string LifesQry = "INSERT INTO `chartvalues` (`ID`, `ChartID`, `ChartGroupID`, `Label`, `Value`) VALUES "; * foreach (string Lifes in SQL.Select("SELECT DISTINCT `Lifes` FROM `gamescore` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "'")) * { * LifesQry += "(NULL, '3', '" + ChartGroupID.ToString() + "', '" + Lifes + "', (SELECT COUNT(`Lifes`) FROM `gamescore` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "' AND `Lifes` = '" + Lifes + "' )),"; * } * LifesQry = LifesQry.Remove(LifesQry.Length - 1); */ foreach (int Lifes in gameScores.Select(g => g.Lifes).Distinct()) { values.Add(new Models.DataModels.ChartValues() { ChartID = 3, ChartGroupID = ChartGroupID, Label = Lifes.ToString(), Value = Convert.ToString(dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.Lifes == Lifes).Count()) }); } //Points /* * string PointsQry = "INSERT INTO `chartvalues` (`ID`, `ChartID`, `ChartGroupID`, `Label`, `Value`) VALUES "; * foreach (string Lifes in SQL.Select("SELECT DISTINCT `Points` FROM `gamescore` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "'")) * { * PointsQry += "(NULL, '4', '" + ChartGroupID.ToString() + "', '" + Lifes + "', (SELECT COUNT(`Points`) FROM `gamescore` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "' AND `Points` = '" + Lifes + "')),"; * } * PointsQry = PointsQry.Remove(PointsQry.Length - 1); */ foreach (int Points in gameScores.Select(g => g.Points).Distinct()) { values.Add(new Models.DataModels.ChartValues() { ChartID = 4, ChartGroupID = ChartGroupID, Label = Points.ToString(), Value = Convert.ToString(dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.Points == Points).Count()) }); } //Time /* * string TimeQry = "INSERT INTO `chartvalues` (`ID`, `ChartID`, `ChartGroupID`, `Label`, `Value`) VALUES "; * foreach (string Lifes in SQL.Select("SELECT DISTINCT `TimePlayed` FROM `gamescore` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "'")) * { * TimeQry += "(NULL, '5', '" + ChartGroupID.ToString() + "', '" + Lifes + "', (SELECT COUNT(`TimePlayed`) FROM `gamescore` WHERE `ChartGroupID` = '" + ChartGroupID.ToString() + "' AND `TimePlayed` = '" + Lifes + "')),"; * } * TimeQry = TimeQry.Remove(TimeQry.Length - 1); */ foreach (int Time in gameScores.Select(g => g.TimePlayed).Distinct()) { values.Add(new Models.DataModels.ChartValues() { ChartID = 5, ChartGroupID = ChartGroupID, Label = Time.ToString(), Value = Convert.ToString(dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.TimePlayed == Time).Count()) }); } dbContext.ChartValues.RemoveRange(dbContext.ChartValues.Where(cv => cv.ChartGroupID == ChartGroupID)); dbContext.SaveChanges(); dbContext.ChartValues.AddRange(values); dbContext.SaveChanges(); float l = (gameScores.Where(gs => gs.Passed == false).Count()); float r = (gameScores.Count()); float ProcentFailed = (l / r) * 100; if (dbContext.GameStatistics.Where(gs => gs.GameID == GameID).Count() == 0) { dbContext.GameStatistics.Add(new Models.DataModels.GameStatistics() { GameID = GameID, AVG_Lifes = 1, AVG_NumOfBonus = 1, AVG_Points = 1, NumOfUsers = 1, AVG_TimePlayed = 1, ProcentFailed = 0 }); dbContext.SaveChanges(); } string command = String.Format("UPDATE gamestatistics SET NumOfUsers = ( SELECT COUNT(DISTINCT userID) FROM gamescore WHERE ChartGroupID = {0}),AVG_TimePlayed =( SELECT FLOOR(AVG(TimePlayed)) FROM gamescore WHERE ChartGroupID = {0}),AVG_Points =( SELECT FLOOR(AVG(Points)) FROM gamescore WHERE ChartGroupID = {0}),AVG_Lifes =( SELECT FLOOR(AVG(Lifes)) FROM gamescore WHERE ChartGroupID = {0}),AVG_NumOfBonus =( SELECT FLOOR(AVG(NumOfBonus)) FROM gamescore WHERE ChartGroupID = {0}),ProcentFailed ={1} WHERE GameID = {2}", ChartGroupID, ProcentFailed, GameID); dbContext.Database.ExecuteSqlCommand(command); dbContext.SaveChanges(); /* * SQL.Delete(DELETEQUERY); * * SQL.Update(NumOfBonusQry); * SQL.Update(PassedQry); * SQL.Update(LifesQry); * SQL.Update(PointsQry); * SQL.Update(TimeQry); */ }
//Update public void UpdateChartValues(int GameID) { if (GameID == 0) { throw new Exception("GameID kan niet 0 zijn!"); } int ChartGroupID = _gameHandler.GetGame(GameID).ChartGroupID; List <Models.DataModels.GameScore> GameScores = _dbContext.GameScore.Where(g => g.ChartGroupID == ChartGroupID).ToList(); List <Models.DataModels.ChartValues> ChartValues = new List <Models.DataModels.ChartValues>(); foreach (int NumOfBonus in GameScores.Select(g => g.NumOfBonus).Distinct()) { ChartValues.Add(new Models.DataModels.ChartValues() { ChartID = 1, ChartGroupID = ChartGroupID, Label = NumOfBonus.ToString(), Value = Convert.ToString(_dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.NumOfBonus == NumOfBonus).Count()) }); } foreach (int Passed in new List <int>() { 1, 0 }) { bool _Passed = false; if (Passed == 0) { _Passed = true; } ChartValues.Add(new Models.DataModels.ChartValues() { ChartID = 2, ChartGroupID = ChartGroupID, Label = Passed.ToString(), Value = Convert.ToString(_dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.Passed == _Passed).Count()) }); } foreach (int Lifes in GameScores.Select(g => g.Lifes).Distinct()) { ChartValues.Add(new Models.DataModels.ChartValues() { ChartID = 3, ChartGroupID = ChartGroupID, Label = Lifes.ToString(), Value = Convert.ToString(_dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.Lifes == Lifes).Count()) }); } foreach (int Points in GameScores.Select(g => g.Points).Distinct()) { ChartValues.Add(new Models.DataModels.ChartValues() { ChartID = 4, ChartGroupID = ChartGroupID, Label = Points.ToString(), Value = Convert.ToString(_dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.Points == Points).Count()) }); } foreach (int Time in GameScores.Select(g => g.TimePlayed).Distinct()) { ChartValues.Add(new Models.DataModels.ChartValues() { ChartID = 5, ChartGroupID = ChartGroupID, Label = Time.ToString(), Value = Convert.ToString(_dbContext.GameScore.Where(gs => gs.ChartGroupID == ChartGroupID && gs.TimePlayed == Time).Count()) }); } _dbContext.ChartValues.RemoveRange(_dbContext.ChartValues.Where(cv => cv.ChartGroupID == ChartGroupID)); _dbContext.SaveChanges(); _dbContext.ChartValues.AddRange(ChartValues); _dbContext.SaveChanges(); float Numerator = (GameScores.Where(gs => gs.Passed == false).Count()); float Denumerator = (GameScores.Count()); float ProcentFailed = (Numerator / Denumerator) * 100; if (_dbContext.GameStatistics.Where(gs => gs.GameID == GameID).Count() == 0) { _dbContext.GameStatistics.Add(new Models.DataModels.GameStatistics() { GameID = GameID, AVGLifes = 1, AVGNumOfBonus = 1, AVGPoints = 1, NumOfUsers = 1, AVGTimePlayed = 1, ProcentFailed = 0 }); _dbContext.SaveChanges(); } string SQLCommand = String.Format("UPDATE gamestatistics SET NumOfUsers = ( SELECT COUNT(DISTINCT userID) FROM gamescore WHERE ChartGroupID = {0}),AVGTimePlayed =( SELECT FLOOR(AVG(TimePlayed)) FROM gamescore WHERE ChartGroupID = {0}),AVGPoints =( SELECT FLOOR(AVG(Points)) FROM gamescore WHERE ChartGroupID = {0}),AVGLifes =( SELECT FLOOR(AVG(Lifes)) FROM gamescore WHERE ChartGroupID = {0}),AVGNumOfBonus =( SELECT FLOOR(AVG(NumOfBonus)) FROM gamescore WHERE ChartGroupID = {0}),ProcentFailed ={1} WHERE GameID = {2}", ChartGroupID, ProcentFailed, GameID); _dbContext.Database.ExecuteSqlCommand(SQLCommand); _dbContext.SaveChanges(); }
protected void Page_Load(object sender, EventArgs e) { //Rebecca - If no session exists, or if not a Senior University Manager, redirect to default page. if (Session["user"] == null || (Convert.ToInt32(Session["typeID"]) != 3)) { Response.Redirect("../Default.aspx"); } else { //Otherwise, store session in username field. string user = Session["user"].ToString(); username.Text = user; username1.Text = user; // Rebecca: //////////////////////////////////////////////// CALCULATIONS ///////////////////////////////////////////////// //1 Student Count //Databinding the completed listview StudentList.DataBind(); //Counting number of students int sum = StudentList.Items.Count(); //Placing student count in label if (sum == 0) { studentCount.Text = "No students on record"; } else { studentCount.Text = Convert.ToString(sum); } //2 Dropped Out Count //Databinding the completed listview DroppedOutStudents.DataBind(); //Counting number of students dropped out int droppedOut = DroppedOutStudents.Items.Count(); //If no students are dropped out set the label to 0, otherwise put the number of students counted in the label. if (droppedOut == 0) { studentDropped.Text = "0"; } else { studentDropped.Text = Convert.ToString(droppedOut) + " students have left a course."; } //Calculating drop out rate: decimal DropOut = Decimal.Divide(droppedOut, sum) * 100; double dropOutRate = Convert.ToInt32(DropOut); PercentageDroppedOut.Text = Convert.ToString(dropOutRate) + "%"; //3 Caculating Retention: int retention = sum - droppedOut; Retention.Text = Convert.ToString(retention) + " students have remained on course."; //Retention Rate: decimal retent = Decimal.Divide(retention, sum) * 100; double RetentionRate = Convert.ToInt32(retent); retentionRate.Text = Convert.ToString(RetentionRate) + "%"; //4 Enrolled Count //Databinding the completed listview EnrolledStudents.DataBind(); //Counting number of students enrolled int enrolled = EnrolledStudents.Items.Count(); //If no students are counted set the label to 0, otherwise put the number of students counted in the label. if (enrolled == 0) { studentEnrolled.Text = "0"; } else { studentEnrolled.Text = Convert.ToString(enrolled); } //Calculating enrolled rate: decimal Enrolled = Decimal.Divide(enrolled, sum) * 100; double EnrolledRate = Convert.ToInt32(Enrolled); enrolledRate.Text = Convert.ToString(EnrolledRate) + "%"; //5 Counting all results on record results.DataBind(); int resultnum = results.Items.Count(); //6 Results Passed Count //Databinding the completed listview Passed.DataBind(); //Counting number of pass results int passnum = Passed.Items.Count(); //Placing pass count in label if (passnum == 0) { pass.Text = "No pass results on record."; } else { pass.Text = Convert.ToString(passnum) + " students have pass results."; } //Calculating pass rate: decimal PassedRate = Decimal.Divide(passnum, resultnum) * 100; double PassRate = Convert.ToInt32(PassedRate); passrate.Text = Convert.ToString(PassRate) + "%"; //7 Results Failed Count //Databinding the completed listview Failed.DataBind(); //Counting number of fail results int failnum = Failed.Items.Count(); //Placing pass count in label if (failnum == 0) { fail.Text = "No fail results on record."; } else { fail.Text = Convert.ToString(failnum) + " students have fail results."; } //Calculating pass rate: decimal FailedRate = Decimal.Divide(failnum, resultnum) * 100; double FailRate = Convert.ToInt32(FailedRate); failrate.Text = Convert.ToString(FailRate) + "%"; //8 Fees Unpaid Count //Databinding the completed listview unpaidlist.DataBind(); //Counting number of unpaid fees int unpaidnum = unpaidlist.Items.Count(); //Placing unpaid fee count in label if (unpaidnum == 0) { feesunpaid.Text = "No records"; } else { feesunpaid.Text = Convert.ToString(unpaidnum) + " students have no payments."; } //Calculating unpaid rate: decimal UnpaidRate = Decimal.Divide(unpaidnum, sum) * 100; double unpaidrate = Convert.ToInt32(UnpaidRate); feesunpaidrate.Text = Convert.ToString(unpaidrate) + "%"; //9 Fees Paid Count //Databinding the completed listview paidlist.DataBind(); //Counting number of fail results int paidnum = paidlist.Items.Count(); //Placing paid count in label if (unpaidnum == 0) { feespaid.Text = "No records"; } else { feespaid.Text = Convert.ToString(paidnum) + " students have paid off their fees."; } //Calculating paid rate: decimal PaidRate = Decimal.Divide(paidnum, sum) * 100; double paidrate = Convert.ToInt32(PaidRate); feespaidrate.Text = Convert.ToString(paidrate) + "%"; //10 Payments Made Count //Databinding the completed listview paymentlist.DataBind(); //Counting number of payments int paymentnum = paymentlist.Items.Count(); //Placing payments count in label if (paymentnum == 0) { paymade.Text = "No records"; } else { paymade.Text = Convert.ToString(paymentnum) + " students have made a payment."; } //Calculating payments rate: decimal paymentRate = Decimal.Divide(paymentnum, sum) * 100; double Payrate = Convert.ToInt32(paymentRate); paymentsrate.Text = Convert.ToString(Payrate) + "%"; //4 Progression Count //Databinding the completed listview firstyearlist.DataBind(); //Counting number of students dropped out int first = firstyearlist.Items.Count(); if (first == 0) { FirstPercent.Text = "0"; } else { FirstPercent.Text = Convert.ToString(first) + " first years."; } //Calculating first year rate: decimal firstP = Decimal.Divide(first, sum) * 100; double firstRate = Convert.ToInt32(firstP); FirstCount.Text = Convert.ToString(firstRate) + "%"; //Databinding the completed listview secondyearlist.DataBind(); //Counting number of students dropped out int second = secondyearlist.Items.Count(); if (second == 0) { SecondPercent.Text = "0"; } else { SecondPercent.Text = Convert.ToString(second) + " second years."; } //Calculating second year rate: decimal secondP = Decimal.Divide(second, sum) * 100; double secondRate = Convert.ToInt32(secondP); SecondCount.Text = Convert.ToString(secondRate) + "%"; //Databinding the completed listview thirdyearlist.DataBind(); //Counting number of students dropped out int third = thirdyearlist.Items.Count(); if (third == 0) { ThirdPercent.Text = "0"; } else { ThirdPercent.Text = Convert.ToString(third) + " third years."; } //Calculating third year rate: decimal thirdP = Decimal.Divide(third, sum) * 100; double thirdRate = Convert.ToInt32(thirdP); ThirdCount.Text = Convert.ToString(thirdRate) + "%"; ////////////////////////////////// CHARTS: /////////////////////////////////////////////// //Chart 1 - Enrolled & not enrolled student values for x & y axis: int notenrolled = sum - enrolled; int[] chart1yValues = { notenrolled, enrolled }; string[] chart1xValues = { "Unregistered", "Enrolled" }; //Adding values above to chart: Chart1.Series["Series1"].Points.DataBindXY(chart1xValues, chart1yValues); //Styling Chart: Chart1.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); Chart1.Series["Series1"]["PointWidth"] = "5"; Chart1.Series["Series1"].Points[0].Color = Color.CadetBlue; Chart1.Series["Series1"].Points[1].Color = Color.DarkCyan; //Chart 2 - Student Results values for x & y axis: int[] resultyValues = { passnum, failnum }; string[] resultxValues = { "Passed", "Failed" }; //Adding values above to chart: ResultsChart.Series["Series1"].Points.DataBindXY(resultxValues, resultyValues); //Styling Chart: ResultsChart.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); ResultsChart.Series["Series1"]["PointWidth"] = "0.1"; ResultsChart.Series["Series1"].Points[0].Color = Color.MediumSeaGreen; ResultsChart.Series["Series1"].Points[1].Color = Color.Firebrick; //Chart 3 - bar chart drop out/retention values for x & y axis: int[] dropyValues = { sum, retention, droppedOut }; string[] dropxValues = { "Total Students", "Retention", "Dropped out" }; //Adding values above to chart: DropChart.Series["Series1"].Points.DataBindXY(dropxValues, dropyValues); //Styling Chart: DropChart.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); DropChart.Series["Series1"].Points[0].Color = Color.Goldenrod; DropChart.Series["Series1"].Points[1].Color = Color.DarkGray; DropChart.Series["Series1"].Points[2].Color = Color.Peru; //Chart 4 - Finance values for x & y axis: int[] financeyValues = { paidnum, unpaidnum, paymentnum }; string[] financexValues = { "Fees Paid", "Fees Unpaid", "Payments Made" }; //Adding values above to chart: FinanceChart.Series["Series1"].Points.DataBindXY(financexValues, financeyValues); //Styling Chart: FinanceChart.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); FinanceChart.Series["Series1"]["PointWidth"] = "0.1"; FinanceChart.Series["Series1"].Points[0].Color = Color.Thistle; FinanceChart.Series["Series1"].Points[1].Color = Color.RosyBrown; FinanceChart.Series["Series1"].Points[2].Color = Color.LightGoldenrodYellow; //Chart 5 - Progression values for x & y axis: int[] progressyValues = { first, second, third }; string[] progressxValues = { "First", "Second", "Third" }; //Adding values above to chart: ProgressChart.Series["Series1"].Points.DataBindXY(progressxValues, progressyValues); //Styling Chart: ProgressChart.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); ProgressChart.Series["Series1"]["PointWidth"] = "0.1"; ProgressChart.Series["Series1"].Points[0].Color = Color.SlateGray; ProgressChart.Series["Series1"].Points[1].Color = Color.DarkSlateBlue; ProgressChart.Series["Series1"].Points[2].Color = Color.Lavender; } }
internal static Passed GuidHasValue(Guid?input, string name, ref List <string> messages) { Passed output = input.HasValue ? Passed.Yes : Passed.No; return(output); }