static void FinishTheEdits(int _lastConflict, string _claimNo, Dictionary <string, ClaimLinesIndex> _claimLinesList, Dictionary <string, Findings> _dic, int errLine) { string startId = _claimNo + "|" + (_lastConflict + 1).ToString(); string endId = _claimNo + "|z"; foreach (var pair in _claimLinesList) { if (pair.Key.CompareTo(startId) >= 0 && pair.Key.CompareTo(endId) < 0) { ClaimLinesIndex _cli = pair.Value; if (_cli.hasDU) { Findings findings = new Findings(); findings.id = _claimNo; findings.claimIndex = _cli.claimIndex; findings.editType = "Review"; findings.mnemonic = "mMP"; findings.editConflit = "mMP"; findings.description = "PNS3 Multiple Procedure Reduction " + _cli.percentage; try { _dic.Add(String.Format("{0}{1}{2}", _claimNo, _cli.claimIndex, (++errLine).ToString()), findings); }catch (Exception mex) { log.LogError("In FinishTheEdits " + mex.Message); } } } } }
private void FindingsChanged() { var findings = _searcher.GetFindings(); if (findings == _lastFindings) { return; } var now = DateTime.UtcNow; if (now < _noUpdatesBefore) { Task.Delay(_noUpdatesBefore - now + TimeSpan.FromMilliseconds(100)).ContinueWith( task => Dispatcher.Invoke(FindingsChanged) ); return; } _trace.TraceVerbose("Detected new findings"); CurrentFindings.Clear(); if (findings != null) { foreach (var item in findings.FoundItems) { CurrentFindings.Add(item); } } _lastFindings = findings; }
static void MergeFindings(Dictionary <string, Findings> _dic, Dictionary <string, ClaimLinesIndex> _claimLinesList, List <string> _thisRun) { string lastClaim = String.Empty; int errLine = 0; foreach (var pair in _claimLinesList) { ClaimLinesIndex _cli = pair.Value; if (!_thisRun.Contains(_cli.claim)) { continue; } if (_cli.claim.CompareTo(lastClaim) != 0) { errLine = 0; } if (_cli.percentage != null) { Findings findings = new Findings(); findings.id = _cli.claim; findings.claimIndex = _cli.claimIndex; findings.editType = "Review"; findings.mnemonic = "mMP"; findings.editConflit = "mMP"; findings.description = "PNS4 Multiple Procedure Reduction " + _cli.percentage; try { _dic.Add(String.Format("{0}{1}{2}", _cli.claim, _cli.claimIndex, (++errLine).ToString()), findings); }catch (Exception mex) { log.LogError("MergeFindings " + mex.Message); } } } }
private void ValidateInspectParametersFindings(Findings findings) { Assert.IsTrue(findings.AreFatal); Assert.AreEqual(4, findings.Count); Assert.IsTrue(findings[0] is ParameterValueIsMissingFactum); Assert.IsTrue(findings[1] is ParameterValueIsMissingFactum); Assert.IsTrue(findings[2] is ParameterValueIsNeverUsedFactum); Assert.IsTrue(findings[3] is ParameterIsMutatedSeveralTimesFactum); var pvim1 = findings[0] as ParameterValueIsMissingFactum; Assert.AreEqual("[a1.a2, a1.b1, a1]", pvim1.Bottle.ToString()); Assert.AreEqual("a1.b1.b12", pvim1.Param.ToString()); Assert.AreEqual("a1.b1", pvim1.Nodes.Single().ToString()); var pvim2 = findings[1] as ParameterValueIsMissingFactum; Assert.AreEqual("[a1.a2, a1.b1, a1]", pvim2.Bottle.ToString()); Assert.AreEqual("a1.b1.b14", pvim2.Param.ToString()); Assert.AreEqual("a1.b1", pvim2.Nodes.Single().ToString()); var pvinuf = findings[2] as ParameterValueIsNeverUsedFactum; Assert.AreEqual("[a1.a2, a1.b1, a1]", pvinuf.Bottle.ToString()); Assert.AreEqual("a1.a2.a22", pvinuf.Param.ToString()); var pimstf = findings[3] as ParameterIsMutatedSeveralTimesFactum; Assert.AreEqual("[a1.a2, a1.b1, a1]", pimstf.Bottle.ToString()); Assert.AreEqual("a1.a11", pimstf.Param.ToString()); AssertHelper.SequenceIsomorphic(new[]{"a1", "a1.a2"}, pimstf.Nodes.Select(n => n.ToString())); }
public async Task <Findings> GetFindingsByID(long id) { var param = new DynamicParameters(); param.Add("@ID", id); var mapper = new FindingsMapper(); return((await SqlMapper.QueryAsync(_unitOfWork.Connection, "GetFindingsByID", new[] { typeof(Findings), typeof(Attachment), typeof(FindingsLineItem), typeof(Attachment), typeof(Officer) }, obj => { Findings f = obj[0] as Findings; Attachment fatt = obj[1] as Attachment; FindingsLineItem fl = obj[2] as FindingsLineItem; Attachment at = obj[3] as Attachment; Officer o = obj[4] as Officer; return mapper.Map(f, fatt, fl, at, o); }, param, splitOn: "ID,FindingsAttachmentID,FindingsLineItemID,AttachmentID,OfficerID", commandType: CommandType.StoredProcedure, transaction: _unitOfWork.Transaction)).FirstOrDefault()); }
private static void InspectViewManager() { var finding = new DiagnosticFinding( "Data binding to non-observable collection OR uage of non-observable collection together with CollectionViewSource causes higher memory footpint." + "This is no real memory leak - the memory will be released after some 'Purge cylces' of the ViewManager. See http://referencesource.microsoft.com/PresentationFramework/Framework/MS/Internal/Data/ViewManager.cs.html", "If you need to free the memory as soon as it is no longer needed by your application consider converting this collection into one which implements INotifyCollectionChanged (e.g. ObservableCollection<>) - even if the collection is immutable."); var type = typeof(Binding).Module.GetType("MS.Internal.Data.ViewManager"); var viewManager = (IDictionary)type.GetProperty("Current", BindingFlags.Static | BindingFlags.NonPublic) .GetValue(null); if (viewManager == null) { return; } var inactiveViewTables = (IDictionary)type.GetField("_inactiveViewTables", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(viewManager); if (inactiveViewTables == null) { return; } if (inactiveViewTables.Count == 0) { return; } var entries = inactiveViewTables.OfType <DictionaryEntry>().ToList(); foreach (var entry in entries) { var viewTable = (IEnumerable)entry.Key; var entryWithViewRecord = (DictionaryEntry)viewTable.OfType <object>().First(); var collectionView = (ICollectionView)entryWithViewRecord.Value.GetType() .GetProperty("View", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(entryWithViewRecord.Value); var sourceCollection = collectionView.SourceCollection; if (collectionView.IsEmpty) { continue; } finding.AddLocation("CollectionType={0}, Count={1}", collectionView.SourceCollection.GetType().FullName, collectionView.SourceCollection.OfType <object>().Count()); } if (finding.Locations.Any()) { Findings.Add(finding); } }
// resolution: RemoveValueChanged() private static void InspectDPCustomTypeDescriptor() { var finding = new DiagnosticFinding( "Observation of DependencyProperty using DependencyPropertyDescriptor.AddValueChanged() causes memory leak", "Call DependencyPropertyDescriptor.RemoveValueChanged() to remove the event handler."); var type = typeof(DependencyObject).Module.GetType("MS.Internal.ComponentModel.DPCustomTypeDescriptor"); var propertyMap = (IDictionary)type.GetField("_propertyMap", BindingFlags.Static | BindingFlags.NonPublic) .GetValue(null); if (propertyMap == null) { return; } foreach (DictionaryEntry entry in propertyMap) { var dependencyObjectPropertyDescriptor = entry.Value; if (dependencyObjectPropertyDescriptor == null) { continue; } var trackers = GetTrackersFieldFromDependencyObjectPropertyDescriptor(dependencyObjectPropertyDescriptor); if (trackers == null) { continue; } foreach (DictionaryEntry trackerEntry in trackers) { var tracker = trackerEntry.Value; var changedHandler = (EventHandler)tracker.GetType() .GetField("Changed", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(tracker); if (changedHandler == null) { continue; } finding.AddLocation("ObservedType={0}, ObservedProperty={1}, HandlerTarget={2}, HandlerName={3}", tracker.GetType().GetField("_object", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(tracker).GetType().FullName, ((DependencyProperty)tracker.GetType().GetField("_property", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(tracker)).Name, changedHandler.Target.GetType().FullName, changedHandler.Method.Name); } } if (finding.Locations.Any()) { Findings.Add(finding); } }
// http://code.logos.com/blog/2008/10/detecting_bindings_that_should_be_onetime.html // resolution: OneTime, INotifyPropertyChanged private static void InspectReflectTypeDescriptionProvider() { var finding = new DiagnosticFinding( "Data binding to non-observable property causes memory leak", "Choose one of the following options:" + Environment.NewLine + " a) convert to DependencyProperty" + Environment.NewLine + " b) implement INotifyPropertyChanged in owning type" + Environment.NewLine + " c) bind with BindingMode=OneTime"); var type = typeof(PropertyDescriptor).Module.GetType("System.ComponentModel.ReflectTypeDescriptionProvider"); var propertyCache = (Hashtable)type .GetField("_propertyCache", BindingFlags.Static | BindingFlags.NonPublic) .GetValue(null); if (propertyCache == null) { return; } // try to make a copy of the hashtable as quickly as possible (this object can be accessed by other threads) var entries = new DictionaryEntry[propertyCache.Count]; propertyCache.CopyTo(entries, 0); var valueChangedHandlersFieldInfo = typeof(PropertyDescriptor) .GetField("valueChangedHandlers", BindingFlags.Instance | BindingFlags.NonPublic); foreach (var entry in entries) { var propertyDescriptors = (PropertyDescriptor[])entry.Value; if (propertyDescriptors == null) { continue; } foreach (var propertyDescriptor in propertyDescriptors) { var valueChangedHandlers = (Hashtable)valueChangedHandlersFieldInfo.GetValue(propertyDescriptor); if (valueChangedHandlers == null || valueChangedHandlers.Count == 0) { continue; } finding.AddLocation("ObservedType={0}, ObservedProperty={1}, HandlerCount={2}", entry.Key, propertyDescriptor.Name, valueChangedHandlers.Count); } } if (finding.Locations.Any()) { Findings.Add(finding); } }
public Findings Map( Findings findings, Attachment findingsattachment, FindingsLineItem findingsLineItem, Attachment attachment, Officer officer) { if (!_findingsCache.TryGetValue(findings.ID, out Findings result)) { _findingsCache[findings.ID] = findings; result = findings; } if (officer.ID != Guid.Empty && !_officerCache.ContainsKey(officer.ID)) { findings.Officer = new Officer(); _officerCache[officer.ID] = officer; findings.Officer = officer; } if (findingsattachment.ID != 0 && !_findingsattachmentCache.ContainsKey(findingsattachment.ID)) { findings.Attachment = new Attachment(); _findingsattachmentCache[findingsattachment.ID] = findingsattachment; findings.Attachment = findingsattachment; } if (findingsLineItem.ID != 0) { if (!_findingslineitemCache.TryGetValue( findingsLineItem.ID, out FindingsLineItem liOut)) { findings.LineItems = new List <FindingsLineItem>(); findingsLineItem.Attachments = new List <Attachment>(); _findingslineitemCache[findingsLineItem.ID] = findingsLineItem; liOut = findingsLineItem; findings.LineItems.Add(findingsLineItem); } if (attachment.ID != 0 && !_attachmentCache.ContainsKey(attachment.ID)) { liOut.Attachments.Add(attachment); _attachmentCache[attachment.ID] = attachment; } } return(result); }
public FindingWorkflowData Add(FindingWorkflowData finding) { using (var scope = _serviceProvider.CreateScope()) { var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper; var _ctx = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext; Findings mappedFinding = _mapper.Map <FindingWorkflowData, Findings>(finding); Findings createdFinding = _ctx.Findings.Add(mappedFinding).Entity; _ctx.SaveChanges(); return(_mapper.Map <Findings, FindingWorkflowData>(createdFinding)); } }
public bool UpdateExpirationDate(Finding finding) { using (var scope = _serviceProvider.CreateScope()) { var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper; var _ctx = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext; Findings f = _mapper.Map <Finding, Findings>(finding); var updateOperation = _ctx.Findings.Attach(f); updateOperation.Property(x => x.ExpirationDate).IsModified = true; updateOperation.Property(x => x.FindingStateID).IsModified = true; _ctx.SaveChanges(); return(true); } }
public static void CollectStatistics() { Findings.Clear(); InspectReflectTypeDescriptionProvider(); InspectDPCustomTypeDescriptor(); InspectViewManager(); if (WriteToDebugConsole) { using (var writer = new DebugTextWriter()) { foreach (var finding in Findings) { finding.WriteTo(writer); writer.WriteLine(); } } } }
public async Task <Findings> Post([FromBody] Findings findings) { return(await _findingsService.Submit(findings)); }
/// <summary> /// Gets a fields value as a string suitable for things like, oh, a velocity template /// </summary> /// <param name="field">A FormFields enum value</param> /// <returns>The value of the field, OR, and error message</returns> public string GetFieldAsString(FormFields field) { try { switch (field) { case FormFields.MainType: { return(MainType.Label); } case FormFields.SubTypes: { return(String.Join(", ", SubTypes.Select(st => st.Label))); } case FormFields.Stages: { return(String.Join(", ", Stages.Select(stg => stg.Label)));; } case FormFields.Findings: { return(String.Join(", ", Findings.Select(fin => fin.Label))); } case FormFields.Age: { return(Age.ToString()); } case FormFields.Phrase: { return(Phrase); } case FormFields.HealthyVolunteers: { switch (_healthyVols) { case HealthyVolunteerType.Healthy: { return("Only Accepting Healthy Volunteers"); } case HealthyVolunteerType.Infirmed: { return("Not Accepting Healthy Volunteers"); } default: { return("Accepting All Volunteers"); } } } case FormFields.Gender: { return(Gender); } case FormFields.TrialTypes: { return(String.Join(", ", TrialTypes.Select(tt => tt.Label))); } case FormFields.Drugs: { return(String.Join(", ", Drugs.Select(d => d.Label))); } case FormFields.OtherTreatments: { return(String.Join(", ", OtherTreatments.Select(ot => ot.Label)));; } case FormFields.TrialPhases: { return(String.Join(", ", TrialPhases.Select(tp => tp.Label))); } case FormFields.TrialIDs: { return(String.Join(", ", TrialIDs)); } case FormFields.Investigator: { return(Investigator); } case FormFields.LeadOrg: { return(LeadOrg); } case FormFields.IsVAOnly: { if (IsVAOnly) { return("True"); } else { return("False"); } } case FormFields.AtNIH: case FormFields.City: case FormFields.State: case FormFields.Country: case FormFields.Hospital: case FormFields.ZipCode: case FormFields.ZipRadius: { return(GetLocFieldAsString(field)); } default: { return("Error Retrieving Field"); } } } catch (Exception) { return("Error Retrieving Field"); } }
static void SendFiles(string _fileName, string _dir) { TextWriter tw = null; var dic = new Dictionary <string, Findings>(); if (optumFindings == null) { optumFindings = new List <Findings>(); } else { optumFindings.Clear(); } List <string> thisRun = new List <string>(); int loop = 0; int lineCounter = 0; try { log.LogInformation(String.Format("In SendFiles {0} {1}", _fileName, _dir)); string user = "******"; string password = "******"; string claimsDotXml = _fileName; WebRequest req = WebRequest.Create("https://realtimeecontent.com/ws/claims5x"); req.Method = "POST"; req.ContentType = "application/xml"; req.Credentials = new NetworkCredential(user, password); FileStream fs = new FileStream(claimsDotXml, FileMode.Open); string outFile = String.Format(@"{0}\OUT\{1}.out", _dir, Path.GetFileName(_fileName)); string outFile2 = String.Format(@"{0}\OUT\{1}2.out", _dir, Path.GetFileName(_fileName)); if (File.Exists(outFile)) { File.Delete(outFile); } log.LogInformation(String.Format("Creating File {0} ", outFile)); tw = File.CreateText(outFile); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; using (Stream reqStream = req.GetRequestStream()) { byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0) { reqStream.Write(buffer, 0, bytesRead); } fs.Close(); } System.Net.HttpWebResponse resp = req.GetResponse() as System.Net.HttpWebResponse; if (resp.StatusCode == System.Net.HttpStatusCode.OK) { System.Xml.XPath.XPathDocument xmlDoc = new System.Xml.XPath.XPathDocument(resp.GetResponseStream()); System.Xml.XPath.XPathNavigator nav = xmlDoc.CreateNavigator(); //Console.WriteLine("Claim A5 had {0} Edits.", nav.Evaluate("count(/claim-responses/claim-response[@claim-id='43']/edit)")); //Console.WriteLine(nav.Evaluate("/claim-responses/claim-response/edit")); lineCounter++; loop = 1; XPathNodeIterator xPathIterator = nav.Select("/claim-responses//claim-response"); int errLine = 0; int lastConflictFound = 0, iClaimLine = 0; string lastClaim = ""; foreach (XPathNavigator claimResponse in xPathIterator) { XPathNavigator onav = claimResponse.SelectSingleNode("@claim-id"); string id = onav == null ? string.Empty : onav.Value; try { thisRun.Add(id); }catch (Exception mex) { log.LogError(mex.Message); } if (id.CompareTo("20170309T33K00018") == 0) { errLine = 0; } XPathNodeIterator ixPathIterator = claimResponse.Select("edit"); bool hasEdits = false; int noOfEdits = 0; foreach (XPathNavigator editLines in ixPathIterator) { hasEdits = true; noOfEdits++; onav = editLines.SelectSingleNode("@line"); string claimLine = onav == null ? string.Empty : onav.Value; string key = id.Trim() + "|" + claimLine.Trim(); ClaimLinesIndex _cli; try { iClaimLine = int.Parse(claimLine); } catch (Exception ex) { iClaimLine = 0; } if (iClaimLine > lastConflictFound) { string myId = ""; lastConflictFound = iClaimLine; } XPathNavigator inav = editLines.SelectSingleNode("description"); string description = editLines == null ? string.Empty : inav.Value; //if (description.Contains("[Pattern 10372]")) // hasEdits = false; //inav = editLines.SelectSingleNode("edit-conflict"); string editConflict = ""; // editLines == null ? string.Empty : inav.Value; inav = editLines.SelectSingleNode("edit-type"); string editType = editLines == null ? string.Empty : inav.Value; inav = editLines.SelectSingleNode("mnemonic"); string mnemonic = editLines == null ? string.Empty : inav.Value; Findings opFind = new Findings(); opFind.id = id; opFind.lineNo = claimLine; opFind.editType = editType; opFind.mnemonic = mnemonic; opFind.editConflit = editConflict; opFind.description = description; optumFindings.Add(opFind); if (!claimLinesList.ContainsKey(key)) { log.LogError(String.Format("The claim does not contain {0}", key)); _cli = new ClaimLinesIndex(); _cli.claim = id; _cli.hasDU = true; _cli.lineNo = "-99"; _cli.claimIndex = "-99"; } else { _cli = claimLinesList[key]; } if (!_cli.hasDU) { if (!description.Contains("50.0%")) // Ignore Optum { Findings findings = new Findings(); findings.id = id; findings.claimIndex = _cli.claimIndex; findings.editType = editType; findings.mnemonic = mnemonic; findings.editConflit = editConflict; findings.description = description; try { dic.Add(String.Format("{0}{1}{2}", id, _cli.claimIndex, (++errLine).ToString()), findings); }catch (Exception mex) { log.LogError(mex.Message); } } else { if (noOfEdits == 1) // this is the only edit for the claim and it's a wrong one mMP { hasEdits = false; } noOfEdits--; } } } if (hasEdits == false) { // claim does not have any edits //string percentage = ""; //ClaimLinesIndex _cli; //int found = 0; //if (found == 0) //{ if (IsCleanClaim(id, claimLinesList)) { Findings findings = new Findings(); findings.id = id; findings.claimIndex = "0"; findings.editType = ""; findings.mnemonic = ""; findings.editConflit = ""; findings.description = ""; try { dic.Add(String.Format("{0}{1}{2}", id, findings.claimIndex, (++errLine).ToString()), findings); }catch (Exception mex) { log.LogError(mex.Message); } } //tw.WriteLine("************ Claim {0} is clean ********", id); //} } } //FinishTheEdits(lastConflictFound - 1, lastClaim, claimLinesList, dic, errLine); } ReviewClaimLineList(tw); optumFindings.Clear(); dic.Clear(); dic = null; tw.Close(); } catch (Exception ex) { log.LogError(String.Format("Sending Files {0}", ex.Message)); } finally { //claimLinesList.Clear(); thisRun.Clear(); } }
public void Init() { findings = new(); }
public async Task <long> InsertFindings(Findings findings) { var param = new DynamicParameters(); param.Add("@Remarks", findings.Remarks); param.Add("@OfficerID", findings.Officer?.ID); param.Add("@OfficerName", findings.Officer?.Name); param.Add("@JobID", findings.JobID); param.Add("@ID", dbType: DbType.Int64, direction: ParameterDirection.Output); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertFindings", param, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); var result = param.Get <long>("@ID"); if (findings.Attachment != null) { var attachmentsTable = new DataTable(); attachmentsTable.Columns.Add("A", typeof(long)); attachmentsTable.Columns.Add("B", typeof(long)); var aParam = new DynamicParameters(); aParam.Add("@FileID", findings.Attachment.FileID); aParam.Add("@FileName", findings.Attachment.FileName); aParam.Add("@Extension", findings.Attachment.Extension); aParam.Add("@Size", findings.Attachment.Size); aParam.Add("@ID", dbType: DbType.Int64, direction: ParameterDirection.Output); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertAttachment", aParam, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); attachmentsTable.Rows.Add(result, aParam.Get <long>("@ID")); // Insert findings attachment mapping entities var findingsAttachmentParam = new DynamicParameters(); findingsAttachmentParam.Add( "@IDMappingType", attachmentsTable.AsTableValuedParameter("dbo.IDMappingType")); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertFindingsAttachments", findingsAttachmentParam, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); } // Insert lineitem section if (findings.LineItems?.Any() ?? false) { foreach (var li in findings.LineItems) { var lineItemParam = new DynamicParameters(); lineItemParam.Add("@Scheme", li.Scheme); lineItemParam.Add("@SubScheme", li.SubScheme); lineItemParam.Add("@Index", li.Index); lineItemParam.Add("@ChecklistCategoryID", li.ChecklistCategoryID); lineItemParam.Add("@ChecklistCategoryText", li.ChecklistCategoryText); lineItemParam.Add("@ChecklistItemID", li.ChecklistItemID); lineItemParam.Add("@ChecklistItemText", li.ChecklistItemText); lineItemParam.Add("@Remarks", li.Remarks); lineItemParam.Add("@Complied", li.Complied); lineItemParam.Add("@FindingsID", result); lineItemParam.Add("@ID", dbType: DbType.Int64, direction: ParameterDirection.Output); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertFindingsLineItem", lineItemParam, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); var lineItemID = lineItemParam.Get <long>("@ID"); // Insert lineitem attachments section if (li.Attachments?.Any() ?? false) { var attachmentsTable = new DataTable(); attachmentsTable.Columns.Add("A", typeof(long)); attachmentsTable.Columns.Add("B", typeof(long)); foreach (var a in li.Attachments) { var aParam = new DynamicParameters(); aParam.Add("@FileID", a.FileID); aParam.Add("@FileName", a.FileName); aParam.Add("@Extension", a.Extension); aParam.Add("@Size", a.Size); aParam.Add("@ID", dbType: DbType.Int64, direction: ParameterDirection.Output); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertAttachment", aParam, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); attachmentsTable.Rows.Add(lineItemID, aParam.Get <long>("@ID")); } // Insert lineitem attachment mapping entities var liAttachmentParam = new DynamicParameters(); liAttachmentParam.Add( "@IDMappingType", attachmentsTable.AsTableValuedParameter("dbo.IDMappingType")); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "InsertFindingsLineItemAttachments", liAttachmentParam, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); } } } return(result); }
public Task <Findings> Submit(Findings findings) { return(Execute(new SubmitFindingsCommand(findings))); }
public Model.JobOrder Map(Model.JobOrder joborder, JobOrderLineItem lineitem = null, Premise premise = null, Customer customer = null, Person person = null, ContactInfo contactInfo = null, Attendee attendee = null, Officer officer = null, Attachment attachment = null, Officer invitee = null, Log log = null, Findings findings = null, Officer findingsOfficer = null, FindingsLineItem findingsLineItem = null, Attachment findingsLineItemAttachment = null, Attachment signature = null) { if (!dict.TryGetValue(joborder.ID, out Model.JobOrder result)) { dict[joborder.ID] = joborder; if (!string.IsNullOrEmpty(officer?.Name)) { joborder.Officer = officer; } if (!string.IsNullOrEmpty(customer?.Name)) { joborder.Customer = customer; } result = joborder; } if ((lineitem?.ID ?? 0) > 0 && !_liCache.ContainsKey(lineitem.ID)) { _liCache[lineitem.ID] = lineitem; if (result.LineItems == null) { result.LineItems = new List <JobOrderLineItem>(); } result.LineItems.Add(lineitem); } if ((premise?.ID ?? 0) > 0 && (result.Premises?.FirstOrDefault(e => e.ID == premise.ID) == null)) { if (result.Premises == null) { result.Premises = new List <Premise>(); } result.Premises.Add(premise); } if ((attendee?.ID ?? 0) > 0 && !_attendeeCache.ContainsKey(attendee.ID)) { _attendeeCache[attendee.ID] = attendee; if (result.Attendees == null) { result.Attendees = new List <Attendee>(); } result.Attendees.Add(attendee); } if ((log?.ID ?? 0) > 0 && !_logCache.ContainsKey(log.ID)) { _logCache[log.ID] = log; if (result.Logs == null) { result.Logs = new List <Log>(); } result.Logs.Add(log); } if (!string.IsNullOrEmpty(invitee?.Name) && result.Invitees?.FirstOrDefault(e => e.ID == invitee.ID) == null) { if (result.Invitees == null) { result.Invitees = new List <Officer>(); } result.Invitees.Add(invitee); } Findings outFindings = null; if ((findings?.ID ?? 0) > 0 && !_findingsCache.TryGetValue(findings.ID, out outFindings)) { _findingsCache[findings.ID] = findings; if (result.Findings == null) { result.Findings = new List <Findings>(); } if (!string.IsNullOrEmpty(findingsOfficer?.Name)) { findings.Officer = findingsOfficer; } if ((signature?.ID ?? 0) > 0) { findings.Attachment = signature; } result.Findings.Add(findings); outFindings = findings; } FindingsLineItem outFindingsLineItem = null; if ((findingsLineItem?.ID ?? 0) > 0 && !_findingsLineItemCache.TryGetValue(findingsLineItem.ID, out outFindingsLineItem)) { _findingsLineItemCache[findingsLineItem.ID] = findingsLineItem; if (outFindings.LineItems == null) { outFindings.LineItems = new List <FindingsLineItem>(); } outFindings.LineItems.Add(findingsLineItem); outFindingsLineItem = findingsLineItem; } if ((findingsLineItemAttachment?.ID ?? 0) > 0 && !_findingsLineItemAttachmentCache.ContainsKey(findingsLineItemAttachment.ID)) { _findingsLineItemAttachmentCache[findingsLineItemAttachment.ID] = findingsLineItemAttachment; if (outFindingsLineItem.Attachments == null) { outFindingsLineItem.Attachments = new List <Attachment>(); } outFindingsLineItem.Attachments.Add(findingsLineItemAttachment); } Person outContactPerson = null; if (person?.ID != null && person.ID != Guid.Empty && !_personCache.TryGetValue(person.ID, out outContactPerson)) { _personCache[person.ID] = person; outContactPerson = person; } result.ContactPerson = outContactPerson; if ((contactInfo?.ID ?? 0L) != 0L && !_contactInfoCache.ContainsKey(contactInfo.ID)) { _contactInfoCache[contactInfo.ID] = contactInfo; if (outContactPerson.ContactInfos == null) { outContactPerson.ContactInfos = new List <ContactInfo>(); } outContactPerson.ContactInfos.Add(contactInfo); } return(result); }
public FatalFindingsException(Findings findings) : base(CocacolaExceptionType.FatalFindings) { Findings = findings; }