コード例 #1
0
 public void SSSTTT()
 {
     var    lines      = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);
     var    wrappers   = lines.Select(w => w.ToWrapper(Constants.DataObjectMap));
     var    myWrappers = wrappers.Where(w => w is BirthRegistrationInformationType).Select(w => w as BirthRegistrationInformationType).ToArray();
     var    withText   = myWrappers.Where(w => !string.IsNullOrEmpty(w.AdditionalBirthRegistrationText)).ToArray();
     var    noText     = myWrappers.Where(w => string.IsNullOrEmpty(w.AdditionalBirthRegistrationText)).ToArray();
     object o          = "";
 }
コード例 #2
0
ファイル: P_0909610028.cs プロジェクト: magenta-aps/cprbroker
        public void ToWrapper()
        {
            //var txt = System.IO.File.ReadAllText(@"C:\Magenta Workspace\PART\Doc\Data Providers\CPR Direct\Test data\U12170-P opgavenr 110901 ADRNVN FE");
            //var txt = System.IO.File.ReadAllText(@"C:\Magenta Workspace\PART\Source\CprBroker\CPRDirect.Tests\Resources\Test\PNR_0909610028.txt", Constants.DefaultEncoding);
            var txt   = Properties.Resources.PNR_0909610028;
            var lines = LineWrapper.ParseBatch(txt);

            var line = lines.Where(l => l.Code == "017" && l.PNR == this.GetPNR()).First();
            var w    = line.ToWrapper(Constants.DataObjectMap);
            var ss   = "";
        }
コード例 #3
0
 public void TestLines()
 {
     var lines      = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);
     var wrappers   = lines.Select(w => w.ToWrapper(Constants.DataObjectMap));
     var myWrappers = wrappers.Where(w => w is CurrentNameInformationType).Select(w => w as CurrentNameInformationType);
     var first      = myWrappers.Select(w => w.FirstNameMarker).Distinct().ToArray();
     var middle     = myWrappers.Select(w => w.MiddleNameMarker).Distinct().ToArray();
     var last       = myWrappers.Select(w => w.LastNameMarker).Distinct().ToArray();
     var allText    = myWrappers.Select(w => w.Contents).ToArray();
     var found      = myWrappers.Where(w => w.MiddleNameMarker == '*').First();
 }
コード例 #4
0
            public void Constructor_Parse_CorrectEnd()
            {
                var lines    = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);
                var wrappers = lines.Select(l => l.ToWrapper(Constants.DataObjectMap).Contents).ToArray();
                var newText  = string.Join("", wrappers);

                var parseResult = new ExtractParseResult(newText, Constants.DataObjectMap);
                var extract     = parseResult.ToExtract();

                Assert.AreEqual(lines.Last().Contents, extract.EndRecord);
            }
コード例 #5
0
            public void Constructor_Parse_CorrectCount()
            {
                var lines = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);

                var wrappers = lines.Select(l => l.ToWrapper(Constants.DataObjectMap).Contents).ToArray();
                var newText  = string.Join("", wrappers);

                var parseResult  = new ExtractParseResult(newText, Constants.DataObjectMap);
                var extract      = parseResult.ToExtract();
                var extractItems = parseResult.ToExtractItems(extract.ExtractId, Constants.DataObjectMap, Constants.RelationshipMap, Constants.MultiRelationshipMap);

                Assert.AreEqual(lines.Length - 2, extractItems.Count);
            }
コード例 #6
0
            public void GetPerson_PersonNotExists_Null(
                [ValueSource(typeof(Utilities), "RandomCprNumberStrings5")] string cprNumber)
            {
                var lines       = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);
                var wrappers    = lines.Select(l => l.ToWrapper(Constants.DataObjectMap).Contents).ToArray();
                var newText     = string.Join("", wrappers);
                var parseResult = new ExtractParseResult(newText, Constants.DataObjectMap);

                var extract      = parseResult.ToExtract("", true, 0);
                var extractItems = parseResult.ToExtractItems(extract.ExtractId, Constants.DataObjectMap, Constants.RelationshipMap, Constants.MultiRelationshipMap);

                extract.ExtractItems.AddRange(extractItems);

                var person = Extract.GetPersonFromLatestExtract(cprNumber, extract.ExtractItems.AsQueryable(), Constants.DataObjectMap);

                Assert.Null(person);
            }
コード例 #7
0
        public static void BulkImport()
        {
            CprBroker.Engine.BrokerContext.Initialize(CprBroker.Utilities.Constants.BaseApplicationToken.ToString(), "");
            int batchCount     = 1000;
            var personRepeates = 2;

            var data = Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE;

            var lines = new List <LineWrapper>(LineWrapper.ParseBatch(data));
            var start = lines.First();
            var end   = lines.Last();

            lines.RemoveAt(0);
            lines.RemoveAt(lines.Count - 1);

            var groupsByPerson = lines.GroupBy(l => l.PNR).ToArray();

            for (int iBatch = 0; iBatch < batchCount; iBatch++)
            {
                Console.WriteLine(string.Format("Creating batch <{0}> of <{1}>", iBatch + 1, batchCount));

                StringBuilder fullData = new StringBuilder(data.Length * personRepeates);
                fullData.AppendLine(start.Contents);


                for (int iPerson = 0; iPerson < groupsByPerson.Count(); iPerson++)
                {
                    var personLines = groupsByPerson[iPerson];
                    Console.WriteLine(string.Format("Inserting person<{0}> of <{1}>", iPerson + 1, groupsByPerson.Count()));

                    var personData = new List <LineWrapper>(personLines.ToArray());
                    var pnr        = personData[0].PNR;
                    for (int iRepeat = 0; iRepeat < personRepeates; iRepeat++)
                    {
                        Console.WriteLine(string.Format("Batch <{0}> of <{1}> ; person<{2}> of <{3}> repeat <{4}> of <{5}>", iBatch + 1, batchCount, iPerson + 1, groupsByPerson.Count(), iRepeat + 1, personRepeates));
                        var newPnr     = Utilities.RandomCprNumberString();
                        var personText = string.Join(Environment.NewLine, personData.Select(l => l.Contents).ToArray());
                        personText = personText.Replace(pnr, newPnr);
                        fullData.AppendLine(personText);
                    }
                }
                fullData.AppendLine(end.Contents);

                ExtractManager.ImportText(fullData.ToString());
            }
        }
コード例 #8
0
            public void Constructor_Parse_CorrectReconstruction()
            {
                var lines    = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);
                var wrappers = lines.Select(l => l.ToWrapper(Constants.DataObjectMap).Contents).ToArray();
                var newText  = string.Join("", wrappers);

                var parseResult  = new ExtractParseResult(newText, Constants.DataObjectMap);
                var extract      = parseResult.ToExtract();
                var extractItems = parseResult.ToExtractItems(extract.ExtractId, Constants.DataObjectMap, Constants.RelationshipMap, Constants.MultiRelationshipMap);
                var result       = extractItems.Select(i => i.Contents).ToList();

                result.Insert(0, extract.StartRecord);
                result.Add(extract.EndRecord);
                for (int i = 0; i < lines.Length; i++)
                {
                    Assert.AreEqual(wrappers[i], result[i]);
                }
            }
コード例 #9
0
            public void GetPerson_PersonExists_Correct(
                [Range(1, 1098, 20)] int lineNumber)
            {
                var lines       = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);
                var wrappers    = lines.Select(l => l.ToWrapper(Constants.DataObjectMap).Contents).ToArray();
                var newText     = string.Join("", wrappers);
                var parseResult = new ExtractParseResult(newText, Constants.DataObjectMap);

                var extract      = parseResult.ToExtract("", true, 0);
                var extractItems = parseResult.ToExtractItems(extract.ExtractId, Constants.DataObjectMap, Constants.RelationshipMap, Constants.MultiRelationshipMap);

                extract.ExtractItems.AddRange(extractItems);

                var pnr    = lines[2].PNR;
                var person = Extract.GetPersonFromLatestExtract(pnr, extract.ExtractItems.AsQueryable(), Constants.DataObjectMap);

                Assert.NotNull(person);
                Assert.AreEqual(pnr, person.PersonInformation.PNR);
            }
コード例 #10
0
        public void SSS()
        {
            var persons = IndividualResponseType.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);
            var ordered = persons.OrderByDescending(p =>
            {
                var ret = 0;
                ret    += p.HistoricalCivilStatus.Count;
                ret    += p.HistoricalName != null ? 1 : 0;
                return(ret);
            });
            var allLines = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE)
                           .Where(l => l.IntCode > 0 && l.IntCode < 99)
                           .GroupBy(l => l.PNR)
                           .Select(p => new { Lines = p.OrderBy(l => l.IntCode).Select(l => l.Contents).ToArray(), History = p.ToArray().Where(l => l.IntCode >= 22 && l.IntCode <= 30).Count() })
                           .OrderByDescending(p => p.History)
                           .ToArray();

            var mostHistory = allLines.First();
            var o           = "";
        }
コード例 #11
0
ファイル: Utilities.cs プロジェクト: magenta-aps/cprbroker
        static Utilities()
        {
            var all = IndividualResponseType.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);

            PNRs = all.Select(p => p.PersonInformation.PNR).OrderBy(p => p).ToArray();


            var lines = new List <LineWrapper>(LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE));

            StartLine = lines.First();
            EndLine   = lines.Last();
            lines.Remove(StartLine);
            lines.Remove(EndLine);

            var groups = lines.GroupBy(l => l.PNR).ToArray();

            PersonLineWrappers = groups.ToDictionary(g => g.Key, g => g.ToArray());

            var extract = new Extract()
            {
                ExtractId = Guid.NewGuid(), ExtractDate = DateTime.Now, StartRecord = StartLine.Contents, EndRecord = EndLine.Contents, Filename = "", ImportDate = DateTime.Now, Ready = true, ProcessedLines = lines.Count
            };
            var allItems = new List <ExtractItem>();

            PersonExtractItems = groups.ToDictionary(
                g => g.Key,
                g =>
            {
                var items = g.ToArray()
                            .Select(l => l.ToExtractItem(extract.ExtractId, Constants.DataObjectMap, Constants.RelationshipMap, Constants.MultiRelationshipMap))
                            .ToArray();
                extract.ExtractItems.AddRange(items);
                allItems.AddRange(items);
                return(items);
            }
                );
            AllExtractItems = allItems.ToArray();
        }
コード例 #12
0
ファイル: Person.cs プロジェクト: magenta-aps/cprbroker
        public static void Split()
        {
            var enc = Encoding.GetEncoding(1252);

            var txt = "";

            txt = Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE;
            //txt = System.IO.File.ReadAllText(@"C:\Magenta Workspace\PART\Doc\Data Providers\CPR Direct\Test data\U12170-P opgavenr 110901 ADRNVN FE", enc);
            var dataLines   = LineWrapper.ParseBatch(txt);
            var allWrappers = dataLines.ToList();

            var startRecord = allWrappers.Where(lw => lw.Code == "000").First();
            var endRecord   = allWrappers.Where(lw => lw.Code == "999").First();

            allWrappers.Remove(startRecord);
            allWrappers.Remove(endRecord);

            var groupedWrapers = allWrappers
                                 .Where(w => w != null)
                                 .GroupBy(w => w.PNR)
                                 .ToList();

            foreach (var individualWrappersGrouping in groupedWrapers)
            {
                var individualLines = individualWrappersGrouping.ToList();
                var pnr             = individualWrappersGrouping.First().PNR;
                var myLines         = new List <LineWrapper>(individualWrappersGrouping);
                myLines.Insert(0, startRecord);
                myLines.Add(endRecord);
                var txtLines = myLines.Select(lw => lw.Contents);
                System.IO.File.WriteAllLines(
                    string.Format(@"..\..\Resources\PNR_{0}.txt", pnr),
                    txtLines.ToArray(),
                    enc
                    );
            }
        }
コード例 #13
0
            public void SSS()
            {
                var all = LineWrapper.ParseBatch(Properties.Resources.U12170_P_opgavenr_110901_ADRNVN_FE);
                var map = new Dictionary <string, Type>();

                map["026"] = typeof(HistoricalNameType);

                var rel = all
                          .Where(l => l.Code == "026")
                          .Select(l => l.ToWrapper(map) as HistoricalNameType)
                          .OrderBy(l => l.NameStartDate)
                          .GroupBy(l => l.PNR)
                          .Select(g => g.OrderBy(l => l.NameStartDate).First())
                          .GroupBy(p =>
                {
                    var key = "";
                    if (!p.NameStartDate.HasValue)
                    {
                        return("Null");
                    }

                    var date = PartInterface.Strings.PersonNumberToDate(p.PNR).Value;
                    if (p.NameStartDate.Value.Date == date)
                    {
                        return("Same Day");
                    }
                    if ((date - p.NameStartDate.Value).TotalDays < 30)
                    {
                        return("Month or less");
                    }
                    return("More than month");
                })
                          .Select(g => new { Text = g.Key, Data = g.ToArray() })
                          .ToArray();
                var oo = "";
            }