/// <summary> /// /// </summary> /// <param name="ca"></param> /// <param name="wellIdsInsideCA">The well IDs for the CA as returned by a spatial query.</param> /// <returns></returns> private Dictionary<int, JsonErrorCondition> GetMeterInstallationErrors(ContiguousAcres ca, IEnumerable<int> wellIdsInsideCA) { var ret = new Dictionary<int, JsonErrorCondition>(); var mdalc = new MeterDalc(); var rptgDalc = new ReportingDalc(); if (ca.Wells == null) { ca.Wells = new WellDalc().GetWells(wellIdsInsideCA.ToArray()).ToArray(); } // Check for irregularities in meter installations. // 1. If a meter has a well associated with it that's outside the CA, note it. foreach (var well in ca.Wells) { try { foreach (var miid in well.MeterInstallationIds) { var wids = mdalc.GetAssociatedWells(miid).Select(x => x.WellId).Except(wellIdsInsideCA); if (wids.Count() > 0) { // There's a well associated that's not in the CA. // Check to see if there's a user response. ret[miid] = new JsonErrorCondition() { wellIds = wids.ToArray(), errorCondition = "Associted well IDs " + string.Join(", ", wids.Select(x => "#" + x.ToString())) + " are outside the contiguous area.", userResponse = rptgDalc.GetMeterInstallationErrorResponse(miid, ActualUser.ActingAsUserId ?? ActualUser.Id) }; } } } catch (MeterNotFoundException ex) { // Suggests that the meter installation was deleted, // but is still associated with the well for some reason. // TODO: Not sure how to handle this. } } return ret; }