コード例 #1
0
ファイル: LojackDataImporter.cs プロジェクト: rsalit/CSBC
 public void FindMatchedRecordsandAddToDatabase()
 {
     using (var db = new LojackContext())
     {
         var rep = new MatchedLojackRepository(db);
         rep.GetNewMatches(rep.GetActiveDataMarts());
     }
 }
コード例 #2
0
        public void MatchedLojackHitUpdateInsertTest()
        {
            using (var db = new LojackContext())
            {
                var rep = new MatchedLojackHitUpdateRepository(db);
                var hitUpdate = new MatchedLojackHitUpdate
                {
                    UpdateGUID = Guid.NewGuid(),
                    UpdateDescription = "Test record for matched update",
                    UpdateTypeID = 1,
                    CreationDate = DateTime.Now,
                    IsDeleted = false,
                    UserGUID = _userGuid,
                    HitGUID = new Guid("3890C846-F9DA-4297-8B67-0A9320FFDB6B")
                };
                rep.Insert(hitUpdate);

            }
        }
コード例 #3
0
ファイル: LojackDataImporter.cs プロジェクト: rsalit/CSBC
        public int InsertRecords(List<string> blacklistedSerials, LojackImportFileRecord importRecord, int counter)
        {
            using (var db = new LojackContext())
            {
                DateTime date;
                var rep = new LojackEntryRepository(db);
                var lojack = new LojackEntry
                {
                    computracefile = importRecord.CompuTraceFile,
                    AgencyName = importRecord.AgencyName,
                    DateReportedToABT =
                        DateTime.TryParse(importRecord.DateReportedToAbt, out date) ? date : (DateTime?)null,
                    Make = importRecord.Make.Length > 30 ? importRecord.Make.Remove(30) : importRecord.Make,
                    Model = importRecord.Model.Length > 30 ? importRecord.Model.Remove(30) : importRecord.Model,
                    StolenDate = DateTime.TryParse(importRecord.StolenDate, out date) ? date : (DateTime?)null
                };

                if (importRecord.SerialNumber2 == importRecord.SerialNumber1 ||
                    importRecord.SerialNumber2 == importRecord.SerialNumber3) importRecord.SerialNumber2 = String.Empty;
                if (importRecord.SerialNumber3 == importRecord.SerialNumber1 ||
                    importRecord.SerialNumber3 == importRecord.SerialNumber2) importRecord.SerialNumber3 = String.Empty;
                int success = 0;
                for (int i = 1; i < 4; i++)
                {
                    string serialNo = String.Empty;
                    if (i == 1)
                        serialNo = importRecord.SerialNumber1;
                    if (i == 2)
                        serialNo = importRecord.SerialNumber2;
                    if (i == 3)
                        serialNo = importRecord.SerialNumber3;

                    if (!String.IsNullOrEmpty(serialNo) && !blacklistedSerials.Contains(serialNo))
                    {
                        lojack.ReportedSerialNumber = serialNo;
                        try
                        {
                            rep.Insert(lojack);
                            ConsoleInsertSuccessMessage(counter + 1, lojack.computracefile, lojack.ReportedSerialNumber);
                            success++;
                        }
                        catch (Exception)
                        {
                            ConsoleInsertFailureMessage(counter, lojack.computracefile, lojack.ReportedSerialNumber);
                        }
                    }

                }

                return success;
            }
        }
コード例 #4
0
ファイル: LojackDataImporter.cs プロジェクト: rsalit/CSBC
 private static void InsertLojackAuditRecord(string file, int counter, int totalRecords)
 {
     using (var db = new LojackContext())
     {
         var rep = new LojackAuditProcessRepository(db);
         var lojack = new LojackAuditProcess
         {
             FileName = file,
             ModificationDate = DateTime.Now,
             ProcessDateTime = DateTime.Now,
             RecordsProcessed = counter,
             TotalRecords = totalRecords,
             Status = "Processed"
         };
         rep.Insert(lojack);
     }
 }