/// <summary> /// Initializes a new instance of the <see cref="ServiceProblemNote" /> struct. /// </summary> /// <param name="serviceProblem">The problem.</param> /// <param name="serviceBuildingId">The service building.</param> /// <param name="targetBuildingId">The target building.</param> /// <param name="problemWeight">The problem weight.</param> public ServiceProblemNote(ServiceProblem serviceProblem, ushort serviceBuildingId, ushort targetBuildingId, uint problemWeight) { this.ServiceProblem = serviceProblem; this.ProblemFrame = Global.CurrentFrame; this.BuildingKey = MakeBuildingKey(serviceBuildingId, targetBuildingId); this.ProblemWeight = problemWeight; }
/// <summary> /// Gets the service problem weight. /// </summary> /// <param name="serviceProblem">The service problem.</param> /// <returns>The service problem weight.</returns> private byte GetServiceProblemWeight(ServiceProblem serviceProblem) { byte weight; if (this.ServiceProblemWeights.TryGetValue(serviceProblem, out weight)) { return(weight); } return(this.defaultWeight); }
public ServiceProblemException(ServiceProblem problem) : base(problem) { }
/// <summary> /// Notes a problem. /// </summary> /// <param name="problem">The problem.</param> /// <param name="serviceBuildingId">The service building identifier.</param> /// <param name="targetBuildingId">The target building identifier.</param> public void Add(ServiceProblem problem, ushort serviceBuildingId, ushort targetBuildingId) { if (this.broken) { return; } try { if (Log.LogALot) { Log.Debug( this, "Add", problem, serviceBuildingId, targetBuildingId, BuildingHelper.GetBuildingName(serviceBuildingId), BuildingHelper.GetDistrictName(serviceBuildingId), BuildingHelper.GetBuildingName(targetBuildingId), BuildingHelper.GetDistrictName(targetBuildingId)); } uint key = MakeBuildingKey(serviceBuildingId, targetBuildingId); byte weight = this.GetServiceProblemWeight(problem); uint newValue; uint oldValue; BuildingProblem newProblem; BuildingProblem oldProblem; bool gotSize = this.ProblemSizes.TryGetValue(key, out oldValue); bool gotProblem = this.TargetBuildingProblems.TryGetValue(targetBuildingId, out oldProblem); if (gotSize) { newValue = oldValue + weight; } else { oldValue = 0; newValue = weight; } if (gotProblem) { newProblem = new BuildingProblem(oldProblem, weight, !gotSize); } else { newProblem = new BuildingProblem(weight); } this.ProblemSizes[key] = newValue; this.TargetBuildingProblems[targetBuildingId] = newProblem; //if (Log.LogALot) //{ // DevLog("Add", // Log.Data("ServiceBuilding", serviceBuildingId, BuildingHelper.GetBuildingName(serviceBuildingId)), // Log.Data("TargetBuilding", targetBuildingId, BuildingHelper.GetBuildingName(targetBuildingId)), // Log.Data("Actions", (gotSize ? "Set" : "Add"), (gotProblem ? "Set" : "Add"), weight), // "Problem", problem, // "Key", key, // "OldValue", oldValue, // "OldCount", oldProblem.Count, // "OldSize", oldProblem.Size, // "NewValue", newValue, // "NewCount", newProblem.Count, // "NewSize", newProblem.Size); //} } catch (Exception ex) { this.broken = true; Log.Error(this, "Add", ex); } }
public GetProblemsService(IConfiguration config, ILogger <GetProblemsService> logger) : base(config) { this.logger = logger; this.config = config; serviceProblem = new ServiceProblem(config); }