Ejemplo n.º 1
0
        public bool AddRecord(params string[] lines)
        {
            for (var i = 0; i < lines.Length; i++)
            {
                lines[i] = lines[i].Trim();
            }

            var record = new Record(lines);

            for (var i = 0; i < this.Records.Count; i++)
            {
                if (this.Records[i] == record)
                {
                    record.AddUnunique(i);
                }
            }

            this.Records.Add(record);
            AppLogAndEventHelper.Instance.RaiseEvent(EventType.Result, record);
            this.csvWriter_.Write(record);

            return(record.HasUnuniques());
        }
Ejemplo n.º 2
0
        public void ImportFromCSV(FileInfo fi)
        {
            if (!fi.Exists)
            {
                return;
            }

            var lines = fi.ReadFile().Split(new[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries).ToList();

            if (lines.Count <= 1)
            {
                return;
            }

            if (lines[0] != (new Record()).Header)
            {
                AppLogAndEventHelper.Instance.RaiseError("Wrong header of backup file", lines[0], new Record().Header);
                return;
            }

            foreach (var line in lines.Skip(1).Where(l => l.Length > 5))
            {
                var parts = line.Split(';').Select(s => s.Trim('\"', '\'', ' ')).ToArray();

                var record = new Record(parts);

                for (var i = 0; i < this.Records.Count; i++)
                {
                    if (this.Records[i] == record)
                    {
                        record.AddUnunique(i);
                    }
                }

                this.Records.Add(record);
            }
        }