예제 #1
0
        public static List <ImportRow> GetImportRows()
        {
            List <Check>     researchChecks = CheckManager.GetResearchChecks();
            List <ImportRow> importRows     = new List <ImportRow>();

            // Each resolved check creates a new import row or updates an existing one.
            foreach (CheckViewModel resolvedCheck in CheckManager.GetResolvedChecksAsList())
            {
                string disposition = resolvedCheck.Disposition;   //GetDispositionFromCheck(resolvedCheck);

                if (disposition != null && !disposition.Equals("Unknown"))
                {
                    List <ImportRow> irows = (from irow in importRows
                                              where irow.LBVDCheckNum == resolvedCheck.Num ||
                                              irow.LBVDCheckNum2 == resolvedCheck.Num ||
                                              irow.LBVDCheckNum3 == resolvedCheck.Num ||
                                              irow.TIDCheckNum == resolvedCheck.Num ||
                                              irow.TIDCheckNum2 == resolvedCheck.Num ||
                                              irow.TIDCheckNum3 == resolvedCheck.Num ||
                                              irow.TDLCheckNum == resolvedCheck.Num ||
                                              irow.TDLCheckNum2 == resolvedCheck.Num ||
                                              irow.TDLCheckNum3 == resolvedCheck.Num ||
                                              irow.MBVDCheckNum == resolvedCheck.Num ||
                                              irow.MBVDCheckNum2 == resolvedCheck.Num ||
                                              irow.MBVDCheckNum3 == resolvedCheck.Num

                                              // Supporting document checks

                                              /*
                                              || irow.SDCheckNum1 == resolvedCheck.Num
                                              || irow.SDCheckNum2 == resolvedCheck.Num
                                              || irow.SDCheckNum3 == resolvedCheck.Num
                                              ||
                                              || irow.SDCheckNum12 == resolvedCheck.Num
                                              || irow.SDCheckNum22 == resolvedCheck.Num
                                              || irow.SDCheckNum32 == resolvedCheck.Num
                                              ||
                                              || irow.SDCheckNum13 == resolvedCheck.Num
                                              || irow.SDCheckNum23 == resolvedCheck.Num
                                              || irow.SDCheckNum33 == resolvedCheck.Num
                                              */

                                              // Does resolvedCheck match an existing importRow by ID?
                                              // This is the case where there is more than one check on an import row, IR,
                                              // and resolvedCheck will be used to update row IR.
                                              || (resolvedCheck.InterviewRecordID != 0 && irow.InterviewRecordID == resolvedCheck.InterviewRecordID) ||
                                              (resolvedCheck.RecordID != 0 && irow.RecordID == resolvedCheck.RecordID)
                                              select irow).ToList();

                    if (irows.Count() == 0)
                    {
                        // There is no import row representing this resolved check.
                        // Create one.
                        importRows.Add(NewImportRow(researchChecks, resolvedCheck, disposition));
                    }
                    else
                    {
                        bool added = false;

                        foreach (ImportRow irow in irows)
                        {
                            if ((resolvedCheck.Service == "LBVD" || resolvedCheck.Service == "LBVD2" || resolvedCheck.Service == "LBVD3" ||
                                 resolvedCheck.Service == "TID" || resolvedCheck.Service == "TID2" || resolvedCheck.Service == "TID3" ||
                                 resolvedCheck.Service == "TDL" || resolvedCheck.Service == "TDL2" || resolvedCheck.Service == "TDL3" ||
                                 resolvedCheck.Service == "MBVD" || resolvedCheck.Service == "MBVD2" || resolvedCheck.Service == "MBVD3")
                                &&
                                ((resolvedCheck.InterviewRecordID != 0 && resolvedCheck.InterviewRecordID != irow.InterviewRecordID)
                                 ||
                                 (resolvedCheck.RecordID != 0 && resolvedCheck.RecordID != irow.RecordID)))
                            {
                                // Case of same check number being used for multiple
                                // birth certificates.
                                if (!added)
                                {
                                    // Log.Debug(string.Format("resolvedCheck: RecordID {0}, InterviewRecordID {1}, Num: {2}, Name: {3}", resolvedCheck.RecordID, resolvedCheck.InterviewRecordID, resolvedCheck.Num, resolvedCheck.Name));
                                    importRows.Add(NewImportRow(researchChecks, resolvedCheck, disposition));
                                    // Prevent the same resolved check from being added twice.
                                    added = true;
                                }
                            }
                            else
                            {
                                // Found row among existing import rows. There is more than one check
                                // number on this row. In other words, the client had more than
                                // one check written for the visit this row corresponds to.
                                UpdateExistingImportRow(resolvedCheck, disposition, irow);
                            }
                        }
                    }
                }
            }

            return(importRows);
        }