/// <summary> /// Place aléatoirement une panne dans le vaisseau. /// Si un module a déjà une panne, on en cherche un autre. /// Si tous les modules sont en panne. On n'ajoute pas la panne. /// </summary> /// <param name="breakdown"></param> /// <returns></returns> public Ship PlaceBreakdown(Breakdown breakdown) { bool placed = false; bool fullBreakdowns = true; foreach (Module module in _modules) { if (module.breakdown == null) { fullBreakdowns = false; break; } } if (fullBreakdowns == false) { while (!placed) { Module module = _modules.ElementAt(Dice.Rand.Next(0, _modules.Count)); if (module.breakdown == null) { module.breakdown = breakdown; placed = true; } } } return(this); }
private void UpdatedIndex(SelectionChangedEventArgs args) { Paused = SelectedHistory != 0; var localIndex = SelectedHistory; if (localIndex == -1) { localIndex = 0; } if (localIndex >= HistoryBreakdown.Count) { return; } var stringOfBreakdown = HistoryBreakdown[localIndex]; var success = HistoryList.TryGetValue(stringOfBreakdown, out ObservableCollection <IDelegateBreakdown> localHistory); if (success == false) { return; } TitleText = "Delegate - PAUSED"; Breakdown.Clear(); foreach (var breakdowns in localHistory) { Breakdown.Add(breakdowns); } UpdatedCounter++; }
/// <summary> /// Returns true if ResponseFares instances are equal /// </summary> /// <param name="other">Instance of ResponseFares to be compared</param> /// <returns>Boolean</returns> public bool Equals(ResponseFares other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Breakdown == other.Breakdown || Breakdown != null && other.Breakdown != null && Breakdown.SequenceEqual(other.Breakdown) ) && ( TicketsTotal == other.TicketsTotal || TicketsTotal != null && other.TicketsTotal != null && TicketsTotal.SequenceEqual(other.TicketsTotal) )); }
private void StopAngerTimer(Breakdown bd) { if (bd.Anger_Routine != null) { StopCoroutine(bd.Anger_Routine); } }
public async Task <IActionResult> CreateBreakdown(Breakdown model) { if (ModelState.IsValid) { try { Breakdown breakdown = new Breakdown() { partID = model.partID, workerID = model.workerID, orderID = model.orderID }; await db.Breakdowns.AddAsync(breakdown); await db.SaveChangesAsync(); return(RedirectToAction("Breakdowns", new { id = model.orderID })); } catch (Exception ex) { } } ViewBag.orderID = model.orderID; return(View(model)); }
public void ModelAssigning() { WfPredictionResult result = new WfPredictionResult { Breakdown = "breakdown", Note = "note", PredictedEmployment = new PredictedEmployment[1], Soc = 12 }; var breakdown = result.Breakdown; var note = result.Note; var predictedEmployment = result.PredictedEmployment; var soc = result.Soc; var breakdownModel = new Breakdown { Code = Region.London, Employment = 2, Name = "Name", Note = "Note" }; var code = breakdownModel.Code; var employment = breakdownModel.Note; var name = breakdownModel.Name; var noteBreakdown = breakdownModel.Note; }
private void CreateBreakdown() { if (BD_SpawnList.Count > 0) { Breakdown newBD = Instantiate(BD_Prefab, RandomSpawnPoint()).GetComponent <Breakdown>(); newBD.AssignRandomBDType(); breakdownList.Add(newBD); } }
private void CreateBreakdown() { if (BD_SpawnList.Count > 0) { Breakdown newBD = Instantiate(BD_Prefab, RandomSpawnPoint()).GetComponent <Breakdown>(); newBD.AssignRandomBDType(); //newBD.Anger_Routine = StartCoroutine(ReduceAngerTimer(newBD)); breakdownList.Add(newBD); } }
public async Task <bool> ShouldDelete(IQuerySession session, Trip trip, Breakdown breakdown) { var anyRepairShopsInState = await session.Query <RepairShop>() .Where(x => x.State == trip.State) .AnyAsync(); // Delete the trip if there are no repair shops in // the current state return(!anyRepairShopsInState); }
private static void DoFilesWithWildCards(Operations operations, Breakdown bd) { var searchOptions = operations.DoSubFolderProcessing ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; string[] FilesToProcess = Directory.GetFiles(bd.path, bd.filter, SearchOption.AllDirectories); foreach (string filename in FilesToProcess) { UpdateFileDateTime(filename, operations); } }
public AddBreakdownViewModel( IWorkplaceService entityService, IBreakdownService breakdownService) : base(entityService) { this.breakdownService = breakdownService; SendCommand = new RelayCommand(Send, () => CanSend); Breakdown = new Breakdown(); }
private void removeBD(Breakdown bd) { Debug.Log("Test removeBD: " + bd); if (bd != null) { // quitar de lista freeSpawnPoint(bd); breakdownList.Remove(bd); Destroy(bd.gameObject); } }
private void removeBD(Breakdown bd) { if (bd != null) { // quitar de lista freeSpawnPoint(bd); StopAngerTimer(bd); breakdownList.Remove(bd); Destroy(bd.gameObject); } }
public async Task <IActionResult> DeleteBreakdown(int?id) { Breakdown breakdown = await db.Breakdowns.FirstOrDefaultAsync(t => t.breakdownID == id); int breakdownID = breakdown.orderID; db.Breakdowns.Remove(breakdown); await db.SaveChangesAsync(); return(RedirectToAction("Breakdowns", new { id = breakdownID })); }
public IActionResult NewBreakdown(Breakdown b) { if (ModelState.IsValid) { DbContext.Breakdowns.Add(b); this.DbContext.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(BadRequest()); }
public async Task <IActionResult> EditBreakdown(int?id) { if (id != null) { Breakdown breakdown = await db.Breakdowns.FirstOrDefaultAsync(t => t.breakdownID == id); if (breakdown == null) { ErrorViewModel error = new ErrorViewModel { RequestId = "Ошибка! В базе данных отсутствует запись с переданным id = " + id }; return(View("Error", error)); } Dictionary <string, int> parts = new Dictionary <string, int>(); Dictionary <string, int> workers = new Dictionary <string, int>(); Dictionary <string, int> orders = new Dictionary <string, int>(); foreach (var item in db.Parts) { parts.Add(item.partName, item.partID); } foreach (var item in db.Workers) { workers.Add(item.fioWorker, item.workerID); } foreach (var item in db.Orders.Include("Car")) { orders.Add(item.Car.stateNumber.ToString() + " " + item.dateReceipt.ToString("dd.MM.yyyy"), item.orderID); } EditBreakdownViewModel model = new EditBreakdownViewModel { Id = breakdown.breakdownID, partID = breakdown.Part.partID, workerID = breakdown.Worker.workerID, orderID = breakdown.Order.orderID }; ViewBag.parts = parts; ViewBag.workers = workers; ViewBag.orders = orders; return(View(model)); } else { ErrorViewModel error = new ErrorViewModel { RequestId = "Ошибка! Отсутствует id в параметрах запроса" }; return(View("Error", error)); } }
public async Task <IActionResult> EditBreakdown(EditBreakdownViewModel model) { try { Breakdown breakdown = await db.Breakdowns.Include("Part").Include("Worker").Include(x => x.Order).ThenInclude(x => x.Car).FirstOrDefaultAsync(t => t.breakdownID == model.Id); if (ModelState.IsValid) { if (breakdown == null) { ErrorViewModel error = new ErrorViewModel { RequestId = "Ошибка! Прислана пустая модель" }; return(View("Error", error)); } breakdown.orderID = model.orderID; breakdown.partID = model.partID; breakdown.workerID = model.workerID; db.SaveChanges(); return(RedirectToAction("Breakdowns", new { id = model.orderID })); } Dictionary <string, int> parts = new Dictionary <string, int>(); Dictionary <string, int> workers = new Dictionary <string, int>(); Dictionary <string, int> orders = new Dictionary <string, int>(); foreach (var item in db.Parts) { parts.Add(item.partName, item.partID); } foreach (var item in db.Workers) { workers.Add(item.fioWorker, item.workerID); } foreach (var item in db.Orders.Include("Car")) { orders.Add(item.Car.stateNumber.ToString() + " " + item.dateReceipt.ToString("dd.MM.yyyy"), item.orderID); } ViewBag.parts = parts; ViewBag.workers = workers; ViewBag.orders = orders; return(View(model)); } catch (Exception ex) { return(RedirectToAction("Account", "AccessDenied")); } }
/// <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 (Breakdown != null) { hashCode = hashCode * 59 + Breakdown.GetHashCode(); } if (TicketsTotal != null) { hashCode = hashCode * 59 + TicketsTotal.GetHashCode(); } return(hashCode); } }
private bool FindWordVerticalB(char[,] matrix, string word, int rowBase, int columnBase) { try { var wordLength = word.Length; var rowMin = rowBase - wordLength; if (rowMin >= 0) { var temporalWord = string.Empty; for (int x = rowBase; x > rowMin; x--) { temporalWord += matrix[x, columnBase]; } if (word == temporalWord) { PuzzelSolution solution = new PuzzelSolution(); solution.word = word; for (int x = rowBase; x > rowMin; x--) { Breakdown breakdown = new Breakdown() { character = matrix[x, columnBase].ToString(), row = x, column = columnBase }; solution.breakdown.Add(breakdown); } puzzelSolutions.Add(solution); return(true); } } return(false); } catch (Exception ex) { return(false); } }
private bool FindWordDiagonalLeftB(char[,] matrix, string word, int rowBase, int columnBase) { try { var wordLength = word.Length; var rowMax = rowBase - wordLength; var columnMax = columnBase + wordLength; if (rowMax >= 0 && columnMax <= matrix.GetLength(1)) { var temporalWord = string.Empty; for (int i = 0; i < wordLength; i++) { temporalWord += matrix[rowBase - i, columnBase + i]; } if (word == temporalWord) { PuzzelSolution solution = new PuzzelSolution(); solution.word = word; for (int i = 0; i < wordLength; i++) { Breakdown breakdown = new Breakdown() { character = matrix[rowBase - i, columnBase + i].ToString(), row = rowBase - i, column = columnBase + i }; solution.breakdown.Add(breakdown); } puzzelSolutions.Add(solution); return(true); } } return(false); } catch (Exception ex) { return(false); } }
public bool FindWordHorizontal(char[,] matrix, string word, int rowBase, int columnBase) { try { var wordLength = word.Length; var columnMax = columnBase + wordLength; if (columnMax <= matrix.GetLength(1)) { var temporalWord = string.Empty; for (int y = columnBase; y < columnMax; y++) { temporalWord += matrix[rowBase, y]; } if (word == temporalWord) { PuzzelSolution solution = new PuzzelSolution(); solution.word = word; for (int y = columnBase; y < columnMax; y++) { Breakdown breakdown = new Breakdown() { character = matrix[rowBase, y].ToString(), row = rowBase, column = y }; solution.breakdown.Add(breakdown); } puzzelSolutions.Add(solution); return(true); } } return(false); } catch (Exception ex) { return(false); } }
private static void PerformOperations(Operations operations) { if (operations.DoFolderProcessing) { DateTime dtHighest = Fold(operations.StartingPoint, operations); UpdateFolderDateTime(operations.StartingPoint, operations, dtHighest); return; } Breakdown bd = BreakDownFilePath(operations.StartingPoint); if (!bd.hasWildcards) { UpdateFileDateTime(operations.StartingPoint, operations); return; } DoFilesWithWildCards(operations, bd); }
public ActionResult Save(Breakdown breakdown) { if (!ModelState.IsValid) { var viewModel = new BreakdownFormViewModel(breakdown) { PaymentTypes = _context.PaymentTypes.ToList() }; return(View("BreakdownForm", viewModel)); } if (breakdown.Id == 0) { //breakdown.TimeOfBreakdown = DateTime.Now; _context.Breakdowns.Add(breakdown); } else { var breakdownInDb = _context.Breakdowns.Single(b => b.Id == breakdown.Id); breakdownInDb.Id = breakdown.Id; breakdownInDb.Equipment = breakdown.Equipment; breakdownInDb.TimeOfBreakdown = breakdown.TimeOfBreakdown; breakdownInDb.Operator = breakdown.Operator; breakdownInDb.Location = breakdown.Location; breakdownInDb.ProblemDescription = breakdown.ProblemDescription; breakdownInDb.ActionDescription = breakdown.ActionDescription; breakdownInDb.WorkDoneBy = breakdown.WorkDoneBy; breakdownInDb.PaymentTypeId = breakdown.PaymentTypeId; breakdownInDb.PaymentType = breakdown.PaymentType; breakdownInDb.IsFixed = breakdown.IsFixed; breakdownInDb.IsPaid = breakdown.IsPaid; breakdownInDb.IsResolved = breakdown.IsResolved; breakdownInDb.Comments = breakdown.Comments; } _context.SaveChanges(); return(RedirectToAction("Index", "Breakdowns")); }
private void OnCombatUpdated(object sender, CombatUpdatedArgs e) { DispatcherHelper.CheckBeginInvokeOnUI(() => { BuildHistory(); if (Paused) { TitleText = "Delegate - PAUSED"; return; } TitleText = "Delegate - Connected"; Breakdown.Clear(); foreach (var breakdowns in _combatControl.CombatHistory[_combatControl.CombatHistory.Count - 1]) { Breakdown.Add(breakdowns); } UpdatedCounter++; }); }
public ActionResult Save(Breakdown breakdown) { if (!ModelState.IsValid) { var viewModel = new BreakdownFormViewModel(breakdown) { PaymentTypes = _context.PaymentTypes.ToList() }; return(View("BreakdownForm", viewModel)); } if (breakdown.Id == 0) { breakdown.TimeOfBreakdown = DateTime.Now; _context.Breakdowns.Add(breakdown); } else { var breakdownInDb = _context.Breakdowns.Single(b => b.Id == breakdown.Id);
public async Task <List <Breakdown> > GetProjectActivities(string Project) { try { HttpClient client = new HttpClient(); var requestContent = new XElement("request", new XElement("token", Token.Token), new XElement("project", Project)); var response = await client.PostAsync("https://api.timewax.com/project/breakdown/list/", new StringContent(requestContent.ToString())); var responseContent = await response.Content.ReadAsStringAsync(); XElement root = XElement.Parse(responseContent); if (root.Element("valid").Value == "yes") { var xmlEntries = root.Element("breakdowns").Elements(); XmlSerializer serializer = new XmlSerializer(typeof(Breakdown)); List <Breakdown> breakdownEntries = new List <Breakdown>(); foreach (var xmlEntry in xmlEntries) { Breakdown breakdown = serializer.Deserialize(new StringReader(xmlEntry.ToString())) as Breakdown; breakdownEntries.Add(breakdown); } return(breakdownEntries); } else { string error = logApiError(requestContent, root); throw new Exception(error); } } catch (Exception exception) { throw exception; } }
private static Breakdown BreakDownFilePath(string filename) { Breakdown bd = new Breakdown(); bd.filename = filename = filename.Trim(); int posLastWack = filename.LastIndexOf("\\"); if (posLastWack < 0) { posLastWack = filename.LastIndexOf(":"); } if (posLastWack < 0) { bd.hasPath = false; bd.path = ""; bd.filter = filename; } else { bd.hasPath = true; bd.path = filename.Substring(0, posLastWack + 1); bd.hasPath = true; bd.filter = filename.Substring(posLastWack + 1); } if (bd.filter.IndexOfAny(new char[] { '*', '?' }) >= 0) { bd.hasWildcards = true; } if (bd.filter.Length > 0) { bd.hasFilter = true; } if (bd.path.EndsWith("\\")) { bd.path = bd.path = bd.path.Substring(0, bd.path.Length - 1); } return(bd); }
private List <List <double> > RunCarlo(Breakdown breakdown, PDFType pdf) { Ziggurat zigg; switch (pdf) { case PDFType.Normal: zigg = Startup.normalZigg; break; case PDFType.Laplace: zigg = Startup.laplaceZigg; break; case PDFType.T: zigg = Startup.tZigg; break; default: zigg = Startup.normalZigg; break; } Carlo carlo = Task.Run(() => new Carlo(breakdown.expectedReturn, breakdown.volatility, asset.yearsOfAdd + asset.yearsOfWith, zigg)).Result; List <List <double> > rates = new List <List <double> >(carlo.rates.Count); List <double> rate; for (int i = 0; i < carlo.rates.Count; i++) { rate = new List <double>(carlo.rates[i].Count); for (int j = 0; j < carlo.rates[i].Count; j++) { rate.Add(carlo.rates[i][j] * breakdown.portfolioWeight); } rates.Add(rate); } return(rates); }
// The current Trip aggregate would be deleted if // the Breakdown event is "critical" public bool ShouldDelete(Breakdown breakdown) => breakdown.IsCritical;
// Alternatively, delete the aggregate if the trip // is currently in New Mexico and the breakdown is critical public bool ShouldDelete(Trip trip, Breakdown breakdown) => breakdown.IsCritical && trip.State == "New Mexico";