Exemplo n.º 1
0
        public static IDataFileReader Create(DataFileType type)
        {
            IDataFileReader newReader = null;

            switch (type)
            {
            case DataFileType.pdat:
                newReader = new PDATFileReader();
                break;

            case DataFileType.csv:
                newReader = new CSVFileReader();
                break;

            case DataFileType.powHQ:
                break;

            case DataFileType.PI:
                break;

            case DataFileType.OpenHistorian:
                break;

            default:
                break;
            }
            return(newReader);
        }
Exemplo n.º 2
0
        private List <string> ReadIt(List <IColumn> columns)
        {
            List <string> data;

            using (_fileReader = DataFileReaderFactory.CreateInstance(_dataFileName))
            {
                data = _fileReader.ReadLine(columns);
            }
            return(data);
        }
Exemplo n.º 3
0
        public void TestReadLine_When_StringIsNULL()
        {
            CreateFile("'NULL',1,\n");
            List <IColumn> columns = CreateTwoColumns();

            using (_fileReader = DataFileReaderFactory.CreateInstance(_dataFileName))
            {
                var data = _fileReader.ReadLine(columns);
                data.Should().Equal("NULL", "1");
            }
        }
Exemplo n.º 4
0
        public void TestTwoLines_When_StringAndInt()
        {
            CreateFile("'A unicode ﺽ string',1,\n'test',2,\n");
            List <IColumn> columns = CreateTwoColumns();

            using (_fileReader = DataFileReaderFactory.CreateInstance(_dataFileName))
            {
                var data = _fileReader.ReadLine(columns);
                data.Should().Equal("A unicode ﺽ string", "1");
                data = _fileReader.ReadLine(columns);
                data.Should().Equal("test", "2");
            }
        }
Exemplo n.º 5
0
    public void SearchLoi()
    {
        if (!isFound)
        {
            //sql
            string key = Request.QueryString["TenBH"].ToString();
            string sql = "";
            if (char.IsUpper(key, 0))
            {
                sql = "select * from BAIHAT where LoiBaiHat like N'%" + key + " %'";
            }
            else
            {
                sql = "select * from BAIHAT where LoiBaiHat like N'% " + key + " %'";
            }

            DataTable  all = x.GetDaTa(sql);
            DataColumn col = new DataColumn();
            col.DataType   = Type.GetType("System.String");
            col.ColumnName = "TimKiem";
            all.Columns.Add(col);

            DataTable lbh = new DataView(all).ToTable(false, "LoiBaiHat");

            for (int i = 0; i < all.Rows.Count; i++)
            {
                ls       = new LuceneService();
                readfile = new DataFileReader();
                DataRow rlbh = lbh.Rows[i];
                DataFileRows = readfile.ReadAllRows(rlbh);
                ls.BuildIndex(DataFileRows);
                //lucene search
                var results = ls.Search(Request.QueryString["TenBH"].ToString().ToLower());
                ls.CloseWriter();
                var result = results.FirstOrDefault();
                //create tim kiem
                if (result == null)
                {
                    all.Rows[i]["TimKiem"] = "Không tìm thấy lời bài hát yêu cầu!";
                }
                else
                {
                    all.Rows[i]["TimKiem"] = result.LineText;
                }
            }

            dlSearch.DataSource = all;
            dlSearch.DataBind();
        }
    }
Exemplo n.º 6
0
        public void TestCompressedFile_With_HighUnicodeValue()
        {
            _dataFileName += ".dz";
            const string sampleString = "abﺽ cﺽ";

            CreateCompressedFile(sampleString);
            List <IColumn> columns = CreateTwoColumns();

            using (_fileReader = DataFileReaderFactory.CreateInstance(_dataFileName))
            {
                var val = _fileReader.ReadLine(columns);
                val[0].Should().Be(sampleString);
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dataFileReader">DataFileReader used to read models from the files</param>
 /// <param name="dataFileWriter">DataFileWriter used to write models to the files</param>
 public RecordsController(IDataFileReader dataFileReader, IDataFileWriter dataFileWriter)
 {
     _dataFileReader = dataFileReader;
     _dataFileWriter = dataFileWriter;
     _files          = Directory.GetFiles(_directory, "*.*", SearchOption.AllDirectories);
 }
Exemplo n.º 8
0
 public CandidateListBuilder(IDataFileReader reader, IDataToNameConverter toNameConverter)
 {
     _reader = reader;
     _toNameConverter = toNameConverter;
 }
 public void TearDown()
 {
     dataFileReader = null;
 }
 public void Initialize()
 {
     dataFileReader = new FileDataReader();
 }