コード例 #1
0
ファイル: Program.cs プロジェクト: MakoLab/blockgraph
        private static void Main(string[] args)
        {
            TryReadRecordsCount(args);
            List <string> leiCodes = new List <string>();
            var           counter  = 0;

            if (!File.Exists(@"leis.txt"))
            {
                var request  = WebRequest.CreateHttp(String.Format(Constants.SolrQueryUrl, RetrievalCount));
                var response = request.GetResponse();
                var stream   = response.GetResponseStream();

                using (StreamReader reader = new StreamReader(stream))
                    using (var fs = File.OpenWrite(@"leis.txt"))
                        using (var sw = new StreamWriter(fs))
                        {
                            var line = "";
                            while (line != null && !reader.EndOfStream)
                            {
                                line = reader.ReadLine();
                                if (!String.IsNullOrEmpty(line) && line.Trim().Length == 20)
                                {
                                    sw.WriteLine(line);
                                }
                            }
                        }
                Console.WriteLine("Retrieved records: {0}", leiCodes.Count);
            }
            using (var fs = File.OpenRead(@"leis.txt"))
                using (var sr = new StreamReader(fs))
                {
                    for (var i = 0; i < StartIndex; i++)
                    {
                        if (sr.EndOfStream)
                        {
                            break;
                        }
                        sr.ReadLine();
                    }
                    var line = "";
                    counter = 0;
                    while (!sr.EndOfStream && counter < Amount)
                    {
                        line = sr.ReadLine();
                        leiCodes.Add(line);
                        counter++;
                    }
                }
            AllegroGraphConnector allegroGraphConnector = CreateConnector();

            counter = 0;
            using (var fs = File.OpenWrite(@"output.nq"))
                using (var sw = new StreamWriter(fs))
                {
                    fs.Seek(0, SeekOrigin.End);
                    foreach (var record in leiCodes)
                    {
                        GetRecord(record, sw, allegroGraphConnector);
                        counter++;
                        if (counter % 1000 == 0)
                        {
                            Console.Write(String.Format("\rParsed {0} records.", counter));
                            allegroGraphConnector.Dispose();
                            allegroGraphConnector = CreateConnector();
                        }
                    }
                }

            //ZipRecords(di);
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
コード例 #2
0
 public void ShutDown()
 {
     _repository.Dispose();
     _allegroGraphConnector.Dispose();
 }