public void AddGame_ShouldAddCorrectOutcomeToData(outcome outcome) { IDataSaver TEST_SAVER = new RpsTestDataSaver(); RpsHandler rpsHandler = new RpsHandler(TEST_SAVER, TEST_PROFILE_HANDLER); //Assert. }
/// <summary> /// Method to generate a guess and return it /// </summary> /// <param name="_feedback"> Previous guess feedback </param> /// <param name="_initialGuess"> Boolean to define whether it is the first guess </param> /// <returns></returns> public char[] guess(outcome _feedback, bool _initialGuess) { if (_initialGuess == false) { char[] initialguess = new char[4]; initialguess[0] = '1'; initialguess[1] = '1'; initialguess[2] = '2'; initialguess[3] = '2'; prevGuess = initialguess; return(initialguess); } else { //Generate the population geneticEvolution(prevGuess); //Compare our population to the previous guess and it's feedback comparison(_feedback, prevGuess); var sortedDictionary = guessFitness.OrderByDescending(i => i.Value); //Take the highest scoring guess and play it char[] guess = sortedDictionary.First().Key; //Set it as previousGuess prevGuess = guess; return(guess); } }
public void onRightWrite() { started = true; initTime = Time.time; outcomeSign = outcome.Right; resetAlphaAndScale(); }
public void onFailWrite() { started = true; initTime = Time.time; outcomeSign = outcome.Wrong; resetAlphaAndScale(); }
/// <summary> /// Comparing guess population to previous guess and feedback /// </summary> /// <param name="_feedback">Previous guess feedback</param> /// <param name="_prevGuess">the previous guess array</param> private void comparison(outcome _feedback, char[] _prevGuess) { //Foreach Guess in guesses, get a score from fitness_score guessFitness.Clear(); foreach (char[] _guess in m_guesses) { guessFitness.Add(_guess, fitnessScore(_guess, _feedback, prevGuess)); } }
/// <summary> /// give all the guesses a fitness score, based on the comparison to previous feedback /// </summary> /// <param name="_guess"> The guess we want to compare and score</param> /// <param name="_feedback"> The previous feedback </param> /// <param name="_prevGuess"> The previous guess </param> /// <returns></returns> private int fitnessScore(char[] _guess, outcome _feedback, char[] _prevGuess) { //Takes a guess and compares it to a feedback code //Returns a score based on the probability of "_guess" being a correct guess outcome o = check(_guess, prevGuess); int score = 0; score += o.m_black - _feedback.m_black * bWeight; score += o.m_white - _feedback.m_white * wWeight; return(score); }
/// <summary> /// Eliminate guesses from the list of possible guesses. /// </summary> /// <param name="_outcomes">An array of all possible outcomes</param> /// <param name="_guesses">List of possible guesses</param> /// <param name="_feedback">Feedback from the previous guess</param> /// <param name="_previousGuess">The previously made guess</param> /// <returns></returns> private List <char[]> elimination(outcome[] _outcomes, List <char[]> _guesses, outcome _feedback, char[] _previousGuess) { List <char[]> guesses_to_keep = new List <char[]>(); //Eliminate all guesses that wouldn't get the same outcome as our feedback foreach (var guess in _guesses) { outcome o = check(_previousGuess, guess); if ((o == _feedback) && (guess != _previousGuess)) { guesses_to_keep.Add(guess); } } return(guesses_to_keep); }
/* Generates random numbers between 0 and the number of events in the event list * Then generates random numbers between 0 and the number of outcomes for each event * Finally sets the text of each option button to the eventName for each gameEvent * and adds an onClick listener delegate for the method "buttonEvent" using the values from * the outcome * * Fixes: Considering making an object method for outcome that just does the button event * using its member variables which would make sense honestly. Might need some finaggling. * * Also need to find the best way to make sure the random numbers don't repeat, hoping to find * some kind of "sample" method that can find 3 random unique numbers from a range instead of just * generating 3 numbers and rerolling until they're all unique. */ public void randomizeButtons() { if (phase == 1) { int randomVal1 = Random.Range(0, eventDataPhase1.Count); int randomVal2 = Random.Range(0, eventDataPhase1.Count); int randomVal3 = Random.Range(0, eventDataPhase1.Count); //this method of random non-repeat is slow, clunky, and only works if there are at least 3 events (which there will be) /*while (randomVal2 == randomVal1) *{ * randomVal2 = Random.Range(0, eventDataPhase1.Count); *} * while (randomVal3 == randomVal1 || randomVal3 == randomVal2) *{ * randomVal3 = Random.Range(0, eventDataPhase1.Count); *} */ int randomOutcome1 = Random.Range(0, eventDataPhase1[randomVal1].getNumOutcomes()); int randomOutcome2 = Random.Range(0, eventDataPhase1[randomVal2].getNumOutcomes()); int randomOutcome3 = Random.Range(0, eventDataPhase1[randomVal3].getNumOutcomes()); outcome outcome1 = eventDataPhase1[randomVal1].getRandomOutcome(); outcome outcome2 = eventDataPhase1[randomVal2].getRandomOutcome(); outcome outcome3 = eventDataPhase1[randomVal3].getRandomOutcome(); // Removes all the previous listeners to add fresh ones optionButton1.onClick.RemoveAllListeners(); optionButton2.onClick.RemoveAllListeners(); optionButton3.onClick.RemoveAllListeners(); // Change the text and add the correct listener for each button optionButton1Text.text = eventDataPhase1[randomVal1].getName(); optionButton1.onClick.AddListener(delegate { buttonEvent(outcome1.healthVal, outcome1.moraleVal, outcome1.cashVal, outcome1.eventText, outcome1.hasFriend); }); optionButton2Text.text = eventDataPhase1[randomVal2].getName(); optionButton2.onClick.AddListener(delegate { buttonEvent(outcome2.healthVal, outcome2.moraleVal, outcome2.cashVal, outcome2.eventText, outcome2.hasFriend); }); optionButton3Text.text = eventDataPhase1[randomVal3].getName(); optionButton3.onClick.AddListener(delegate { buttonEvent(outcome3.healthVal, outcome3.moraleVal, outcome3.cashVal, outcome3.eventText, outcome3.hasFriend); }); } }
public void RestartGameState() { Debug.Log("RESTARTING GAME"); isDestroyed = false; isGoalReached = false; camFollow.winnerOnStage = false; boxDT.position = initBoxPosition; boxDT.rotation = initRotation; trail.Clear(); trail.enabled = false; camFollow.GetComponent <Camera>().fieldOfView = camFollow.initFOV; UIManager.instance.RestartGameUI(); chest.SetInteger("openclose", 0); //chest.transform.position = chestInitPos; //chest.transform.rotation = chestInitRot; ResetPoles(); RestartTween(); outcome = outcome.undecided; }
/* Reads through the lines array splitting each line at the comma and reading in the values * Starts by making a gameEvent with the first value from the split line as the eventName * then uses the next 6 values read in to construct an outcome object and add it to the * gameEvent's outcomes list * * Splits up the events in the text file between phase1 and phase2 by checking whether * the line the loop is on reads "phase2" and if it does it switches over to inputting * the values into the eventDataPhase2 list instead of eventDataPhase1 */ void initializeEventData() { for (int i = 0; i < lines.Length; i++) { if (lines[i] != "phase2") { string[] words = lines[i].Split(','); gameEvent gameEvent = new gameEvent(words[0]); for (int k = 1; k < words.Length; k += 6) { outcome outcome = new outcome(int.Parse(words[k].Trim()), int.Parse(words[k + 1].Trim()), int.Parse(words[k + 2].Trim()), words[k + 3], bool.Parse(words[k + 4].Trim()), bool.Parse(words[k + 5].Trim())); Debug.Log(outcome.ToString()); gameEvent.addOutcome(outcome); } eventDataPhase1.Add(gameEvent); } else { for (int j = i + 1; j < lines.Length; j++) { string[] words = lines[j].Split(','); gameEvent gameEvent = new gameEvent(words[0]); for (int l = 1; l < words.Length; l += 6) { outcome outcome = new outcome(int.Parse(words[l].Trim()), int.Parse(words[l + 1].Trim()), int.Parse(words[l + 2].Trim()), words[l + 3], bool.Parse(words[l + 4].Trim()), bool.Parse(words[l + 5].Trim())); Debug.Log(outcome.ToString()); gameEvent.addOutcome(outcome); } eventDataPhase2.Add(gameEvent); } break; } } }
/// <summary> /// Apply a minmax method to decide on a guess from the list of possible guesses. /// </summary> /// <param name="_outcomes">An array of all possible outcomes</param> /// <param name="_combinations">All possible combinations</param> /// <param name="_guesses">Current eligible guesses</param> /// <param name="_feedback">The previous guess feedback</param> /// <returns></returns> private char[] applyMinMax(outcome[] _outcomes, List <char[]> _combinations, List <char[]> _guesses, outcome _feedback) { int min = int.MaxValue; char[] minCombination = null; foreach (var guess in _guesses) { int max = 0; foreach (var outcome in _outcomes) { var count = 0; foreach (var solution in m_combinations) { outcome o = check(guess, solution); //Static function Check to compare the guess to the solution if (o == outcome) { count++; } } if (count > max) { max = count; } } if (max < min) { min = max; minCombination = guess; } } m_prevGuess = minCombination; return(minCombination); }
public abstract void AddGame(string guildName, string player1, string player2, outcome winner);
/// <summary> /// Call various methods to generate and return a guess. /// </summary> /// <param name="_feedback">Previous guess feedback</param> /// <param name="_initialGuess">An initial guess boolean to check if first guess</param> /// <returns></returns> public char[] guess(outcome _feedback, bool _initialGuess) { outcome[] outcomes = new[] { new outcome { m_white = 0, m_black = 0 }, new outcome { m_white = 0, m_black = 1 }, new outcome { m_white = 0, m_black = 2 }, new outcome { m_white = 0, m_black = 3 }, new outcome { m_white = 0, m_black = 4 }, new outcome { m_white = 1, m_black = 0 }, new outcome { m_white = 1, m_black = 1 }, new outcome { m_white = 1, m_black = 2 }, new outcome { m_white = 1, m_black = 3 }, new outcome { m_white = 2, m_black = 0 }, new outcome { m_white = 2, m_black = 1 }, new outcome { m_white = 2, m_black = 2 }, new outcome { m_white = 3, m_black = 0 }, new outcome { m_white = 4, m_black = 0 } }; if (_initialGuess == false) { char[] initialguess = new char[4]; initialguess[0] = '1'; initialguess[1] = '1'; initialguess[2] = '2'; initialguess[3] = '2'; m_prevGuess = initialguess; return(initialguess); } else { m_guesses = elimination(outcomes, m_guesses, _feedback, m_prevGuess); //Eliminate guesses based on the feedback from the previous guess return(applyMinMax(outcomes, m_combinations, m_guesses, _feedback)); //Use Knuths algorithm to decide the next guess } }
/// <summary> /// Compare the guess made with the winning code and generate feedback /// </summary> /// <param name="_guess">The guess made</param> /// <param name="_solution">The winning code</param> /// <returns></returns> public outcome check(char[] _guess, char[] _solution) { char[] tempCode = new char[4]; char[] tempGuess = new char[4]; for (int i = 0; i < 4; i++) { tempCode[i] = _solution[i]; } for (int i = 0; i < 4; i++) { tempGuess[i] = _guess[i]; } outcome o = new outcome(); //Number of black and white pins int white = 0; int black = 0; //Iterate through the code and guess arrays to find matching pairs for (int i = 0; i < 4; i++) { if (tempCode[i] == tempGuess[i]) { //change the values so they won't match anymore tempCode[i] = '-'; tempGuess[i] = '.'; //Add one to the number of white pins black++; } } //Iterate through the remaining values and foreach (char c in tempGuess) { for (int i = 0; i < 4; i++) { if (tempCode[i] == c) { tempCode[i] = '-'; //Add one to the number of black pins white++; break; } } } while (black > 0) { o.m_black++; black--; } while (white > 0) { o.m_white++; white--; } return(o); }
public void addOutcome(outcome o) { outcomes.Add(o); }
public ActionResult APost(FileViewModels model) { projectEntities db = new projectEntities(); process pro = new process(); Excel.Application xlApp; Excel.Workbook xlWorkBook1; Excel.Worksheet xlWorkSheet1; Excel.Range range; int str; int rCnt; int cCnt; int rw = 0; int cl = 0; xlApp = new Excel.Application(); if (xlApp == null) { TempData["flag"] = 1; TempData["MessageTitle"] = "Generate Plan"; TempData["MessagePrompt"] = "Error occured, please check Excel Software"; return(RedirectToAction("MainPage", "Home")); } int qtr_ref = model.quarter; int sy_ref = model.year; string[] so = ListSO(); string[] course = ListCourse(); string[] pi = ListPI(); string[] asstool = ListAT(); float[] studtarget = ListTarget(); int[] atid = ListATID(); int studpass = 0; int studtot = 0; int studpassall = 0; int studtotall = 0; double studpassave; double studpassallave = 0; int ctr; int qtr = 1; int sy = 1; int qtr1 = 1; int qtr2 = 1; int qtr3 = 1; int qtr4 = 1; int sy1 = 1516; int sy2 = 1516; int sy3 = 1516; int sy4 = 1516; List <int> studpass1 = new List <int>(); List <int> studtot1 = new List <int>(); List <int> studpassall1 = new List <int>(); List <int> studtotall1 = new List <int>(); List <double> studpassave1 = new List <double>(); List <double> studpassallave1 = new List <double>(); List <double> result = new List <double>(); pro.quarter = model.quarter; pro.year = model.year; pro.copiatt_id = 1; db.processes.Add(pro); db.SaveChanges(); //Generate File Location if (Session["accID"] == null) { return(RedirectToAction("Login", "Account")); } int accid = (int)Session["accID"]; string filepath = Server.MapPath("~/Uploads"); string filepath1 = Server.MapPath("~/UserFiles/" + accid + "/AssessmentPlan_" + accid + "_" + pro.pid + ".xlsx"); for (int i = 0; i < 24; i++) { ctr = 0; do { studpass = 0; studtot = 0; if (ctr == 0) { qtr = qtr_ref; sy = sy_ref; qtr1 = qtr; sy1 = sy; } else if (ctr == 1) { qtr2 = qtr1; sy2 = sy1; if (qtr1 == 4) { qtr2 = 1; qtr = qtr2; sy2 += 101; sy = sy2; } else { qtr2++; qtr = qtr2; } } else if (ctr == 2) { qtr3 = qtr2; sy3 = sy2; if (qtr3 == 4) { qtr3 = 1; qtr = qtr3; sy3 += 101; sy = sy3; } else { qtr3++; qtr = qtr3; } } else if (ctr == 3) { qtr4 = qtr3; sy4 = sy3; if (qtr4 == 4) { qtr4 = 1; qtr = qtr4; sy4 += 101; sy = sy4; } else { qtr4++; qtr = qtr4; } } List <int> grades = new List <int>(); string[] files = Directory.GetFiles(filepath, qtr + "QSY" + sy + "_" + course[i] + "_*.xlsx"); foreach (string file in files) { xlWorkBook1 = xlApp.Workbooks.Open(file, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorkSheet1 = (Excel.Worksheet)xlWorkBook1.Worksheets.get_Item(1); range = xlWorkSheet1.UsedRange; rw = range.Rows.Count; cl = range.Columns.Count; for (cCnt = 1; cCnt <= cl; cCnt++) { if (xlWorkSheet1.Cells[1, cCnt].Value2 != null) { string columnName = xlWorkSheet1.Cells[1, cCnt].Value2; ViewBag.id = atid[i]; string[] atcase = ATcase(); for (int j = 0; j < atcase.Length; j++) { string match = atcase[j]; if (Regex.IsMatch(columnName, match, RegexOptions.IgnoreCase | RegexOptions.Singleline)) { str = 0; for (rCnt = 2; rCnt <= rw; rCnt++) { str = (int)(range.Cells[rCnt, cCnt] as Excel.Range).Value2; grades.Add(str); } break; } } } } xlWorkBook1.Close(true, null, null); Marshal.ReleaseComObject(xlWorkSheet1); Marshal.ReleaseComObject(xlWorkBook1); } int a = 0; foreach (float val in grades) { if (val >= 70) { studpass++; } studtot++; a++; } studpass1.Add(studpass); studtot1.Add(studtot); studpassall += studpass; studtotall += studtot; studpassave = ((double)studpass / (double)studtot) * 100; studpassave1.Add(studpassave); if (ctr == 3) { studpassall1.Add(studpassall); studtotall1.Add(studtotall); studpassallave = ((double)studpassall / (double)studtotall) * 100; studpassallave1.Add(studpassallave); result.Add(studpassallave); studpassall = 0; studtotall = 0; } ctr++; } while (ctr < 4); } //Generate Assessment Plan Excel.Workbook xlWorkBook2; Excel.Worksheet xlWorkSheet2; object misValue = System.Reflection.Missing.Value; xlWorkBook2 = xlApp.Workbooks.Add(misValue); xlWorkSheet2 = (Excel.Worksheet)xlWorkBook2.Worksheets.get_Item(1); Excel.Range last = xlWorkSheet2.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing); range = xlWorkSheet2.get_Range("A1", last); range.Style.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; range.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; range.Style.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter; range.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter; range.Style.WrapText = true; xlWorkSheet2.Columns[1].ColumnWidth = 18; range = xlWorkSheet2.get_Range("A1", "BU1"); range.Merge(misValue); range.Value2 = "STUDENT OUTCOMES AND EVALUATION PLAN FOR COMPUTER ENGINEERING"; //Student Outcomes xlWorkSheet2.Rows[2].RowHeight = 70; xlWorkSheet2.Cells[2, 1] = "STUDENT OUTCOMES"; int index = 0; for (int i = 2; i <= 68; i += 6) { int j = i; Excel.Range r1 = xlWorkSheet2.Cells[2, j]; j += 5; Excel.Range r2 = xlWorkSheet2.Cells[2, j]; range = xlWorkSheet2.get_Range(r1, r2); range.Merge(misValue); range.Value2 = so[index++]; } range = xlWorkSheet2.get_Range("A2", "BU2"); range.Interior.Color = Color.PeachPuff; //Performance Indicators xlWorkSheet2.Rows[3].RowHeight = 70; xlWorkSheet2.Cells[3, 1] = "Performance Indicators"; index = 0; for (int i = 2; i <= 71; i += 3) { int j = i; Excel.Range r1 = xlWorkSheet2.Cells[3, j++]; Excel.Range r2 = xlWorkSheet2.Cells[3, ++j]; range = xlWorkSheet2.get_Range(r1, r2); range.Merge(misValue); range.Value2 = pi[index++]; } range = xlWorkSheet2.get_Range("A3", "BU3"); range.Interior.Color = Color.Yellow; //Course xlWorkSheet2.Cells[4, 1] = "Course"; index = 0; for (int i = 2; i <= 71; i += 3) { int j = i; Excel.Range r1 = xlWorkSheet2.Cells[4, j++]; Excel.Range r2 = xlWorkSheet2.Cells[4, ++j]; range = xlWorkSheet2.get_Range(r1, r2); range.Merge(misValue); range.Value2 = course[index++]; } range = xlWorkSheet2.get_Range("A4", "BU4"); range.Interior.Color = Color.LimeGreen; //Assessment Tool xlWorkSheet2.Rows[5].RowHeight = 30; xlWorkSheet2.Cells[5, 1] = "Assessment Tool"; index = 0; for (int i = 2; i <= 71; i += 3) { int j = i; Excel.Range r1 = xlWorkSheet2.Cells[5, j++]; Excel.Range r2 = xlWorkSheet2.Cells[5, ++j]; range = xlWorkSheet2.get_Range(r1, r2); range.Merge(misValue); range.Value2 = asstool[index++]; } range = xlWorkSheet2.get_Range("A5", "BU5"); range.Interior.Color = Color.Orange; //Assessment Targets and Results xlWorkSheet2.Cells[6, 1] = "Assessment Targets and Results"; for (int i = 2; i <= 71; i += 3) { int j = i; xlWorkSheet2.Cells[6, i] = "Target"; Excel.Range r1 = xlWorkSheet2.Cells[6, ++j]; Excel.Range r2 = xlWorkSheet2.Cells[6, ++j]; range = xlWorkSheet2.get_Range(r1, r2); range.Merge(misValue); range.Value2 = "Results"; } range = xlWorkSheet2.get_Range("A6", "BU6"); range.Interior.Color = Color.Aqua; //Periods xlWorkSheet2.Cells[7, 1] = "Period: Q" + qtr1 + " SY" + sy1; xlWorkSheet2.Cells[8, 1] = "Period: Q" + qtr2 + " SY" + sy2; xlWorkSheet2.Cells[9, 1] = "Period: Q" + qtr3 + " SY" + sy3; xlWorkSheet2.Cells[10, 1] = "Period: Q" + qtr4 + " SY" + sy4; xlWorkSheet2.Cells[11, 1] = "Overall Results (Q" + qtr1 + " SY" + sy1 + " to Q" + qtr4 + " SY" + sy4; range = xlWorkSheet2.get_Range("A11", "BU11"); range.Interior.Color = Color.HotPink; int b = 0; for (int i = 2; i <= 71; i += 3) { Excel.Range r1 = xlWorkSheet2.Cells[7, i]; Excel.Range r2 = xlWorkSheet2.Cells[11, i]; range = xlWorkSheet2.get_Range(r1, r2); range.Merge(misValue); range.Value2 = studtarget[b] + "% of students should obtain a rating of at least 3.5"; b++; } //computation int index1 = 0; int index2 = 0; for (int i = 3; i <= 72; i += 3) { for (int j = 7; j <= 11; j++) { if (j == 11) { int l = i; xlWorkSheet2.Cells[j, l] = studpassall1[index2] + " out of " + studtotall1[index2]; xlWorkSheet2.Cells[j, ++l] = studpassallave1[index2] + "%"; index2++; } else { int l = i; xlWorkSheet2.Cells[j, l] = studpass1[index1] + " of " + studtot1[index1] + " students enrolled"; xlWorkSheet2.Cells[j, ++l] = studpassave1[index1] + "%"; index1++; } } } //Evaluation, Recommendation and Effectivity xlWorkSheet2.Cells[12, 1] = "Evaluation"; xlWorkSheet2.Cells[12, 1].Interior.Color = Color.PaleGreen; xlWorkSheet2.Rows[13].RowHeight = 90; xlWorkSheet2.Cells[13, 1] = "Recommendation"; xlWorkSheet2.Cells[14, 1] = "Effectivity"; range = xlWorkSheet2.get_Range("A14", "BU14"); range.Interior.Color = Color.Beige; index = 0; int col = 2; if (qtr4 == 4) { qtr4 = 1; sy4 += 101; } else { qtr4++; } int c = 0; foreach (float res in result) { int col1 = col; Excel.Range r1 = xlWorkSheet2.Cells[12, col1++]; Excel.Range r2 = xlWorkSheet2.Cells[12, ++col1]; range = xlWorkSheet2.get_Range(r1, r2); range.Merge(misValue); col1 = col; Excel.Range r11 = xlWorkSheet2.Cells[13, col1++]; Excel.Range r21 = xlWorkSheet2.Cells[13, ++col1]; if (res >= studtarget[c]) { range.Value2 = "Target Achieved"; range.Interior.Color = Color.PaleGreen; range = xlWorkSheet2.get_Range(r11, r21); range.Merge(misValue); range.Value2 = "Retain Performance Indicator, Assessment Tool and Targets for the course " + course[index++]; } else if (res < studtarget[c]) { range.Value2 = "Target Not Achieved"; range.Interior.Color = Color.Red; range = xlWorkSheet2.get_Range(r11, r21); range.Merge(misValue); range.Value2 = "Modify Performance Indicator, Assessment Tool and Targets for the course " + course[index++]; } else { range.Value2 = "Evaluation N/A"; range.Interior.Color = Color.LightGray; range = xlWorkSheet2.get_Range(r11, r21); range.Merge(misValue); range.Value2 = "Recommendation for the course " + course[index++] + " N/A"; } col1 = col; Excel.Range r12 = xlWorkSheet2.Cells[14, col1++]; Excel.Range r22 = xlWorkSheet2.Cells[14, ++col1]; range = xlWorkSheet2.get_Range(r12, r22); range.Merge(misValue); range.Value2 = qtr4 + "Q AY " + sy4; col += 3; c++; } range = xlWorkSheet2.get_Range("A1", "BU14"); range.Borders.LineStyle = Excel.XlLineStyle.xlContinuous; range.Borders.Weight = Excel.XlBorderWeight.xlThick; xlWorkBook2.SaveAs(filepath1, Excel.XlFileFormat.xlOpenXMLWorkbook, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); xlWorkBook2.Close(true, misValue, misValue); xlApp.Quit(); Marshal.ReleaseComObject(xlWorkSheet2); Marshal.ReleaseComObject(xlWorkBook2); Marshal.ReleaseComObject(xlApp); //Update outcome table DateTime dt = DateTime.Now; outcome oc = new outcome(); oc.pid = pro.pid; oc.acc_id = accid; oc.filename = "AssessmentPlan_" + accid + "_" + pro.pid + ".xlsx"; oc.cdate = dt; db.outcomes.Add(oc); db.SaveChanges(); //Delete Files in Upload Folder System.IO.DirectoryInfo di = new DirectoryInfo(filepath); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } TempData["flag"] = 1; TempData["MessageTitle"] = "Generate Plan"; TempData["MessagePrompt"] = "Assessment Plan has been created, check Downloads"; if ((int)Session["type"] != 0) { return(RedirectToAction("MainPage", "Home")); } return(RedirectToAction("AdminPage", "Home")); }
public override void AddGame(string guildName, string player1, string player2, outcome winner) { if (winner == outcome.P1) { _leaderboard.Winner(guildName, player1); _leaderboard.Loser(guildName, player2); } else if (winner == outcome.P2) { _leaderboard.Winner(guildName, player2); _leaderboard.Loser(guildName, player1); } else if (winner == outcome.TIE) { _leaderboard.Tie(guildName, player1, player2); } }