Exemple #1
0
 public FileManager()
 {
     if (CurrentTables.FirstOrDefault(d => d.Name == openfile) == null)
     {
         CurrentTables.Insert(0, new TableInfo(openfile, this));
     }
 }
Exemple #2
0
        private IEnumerable <FreeDocument> GetEntities2(
            string tableName, int mount = -1, int skip = 0)
        {
            TableInfo table = null;

            LastFileName = tableName;
            List <string> fileNames = new List <string>();

            if (tableName == openfile && MainDescription.IsUIForm)
            {
                var ofd2 = new OpenFileDialog();
                ofd2.DefaultExt  = "*";
                ofd2.Filter      = FileConnector.GetDataFilter();
                ofd2.Multiselect = true;
                if (ofd2.ShowDialog() == true)
                {
                    fileNames.AddRange(ofd2.FileNames);
                }
            }
            else
            {
                table = TableNames.Collection.FirstOrDefault(d => d.Name == tableName);
                if (table != null)
                {
                    if ((File.Exists(table.Description) == false))
                    {
                        CurrentTables.Remove(table);
                        TableNames.InformPropertyChanged("Collection");
                        return(new List <FreeDocument>());
                    }
                    fileNames.Add(table.Description);
                }
            }

            if (fileNames.Count() == 1)
            {
                var filename = fileNames.FirstOrDefault();
                LastFileName = Path.GetFileName(filename);
                table        = AddTable(LastFileName, filename);
            }



            return(fileNames.SelectMany(d =>
            {
                var connector = FileConnector.SmartGetExport(d);
                var tableConnector2 = connector as FileConnectorTable;
                if (tableConnector2 != null)
                {
                    tableConnector2.EncodingType = this.EncodingType;
                }
                if (mount > 0)
                {
                    return connector.ReadFile().Skip(skip).Take(mount);
                }

                return connector.ReadFile().Skip(skip);
            }));
        }