Пример #1
0
        void LoadFile()
        {
            string filename = Utils.GetFile();

            if (filename.Length < 1)
            {
                return;
            }

            FileIsLoading = true;

            try
            {
                worker = new BackgroundWorker();
                worker.WorkerReportsProgress = true;

                DataRepository repository
                    = new DataRepository(filename, DataSourceType.CSV);


                repository.FileOpening += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);
                repository.FileLoading += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);
                repository.FileLoaded  += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);


                worker.DoWork += delegate(object sender, DoWorkEventArgs args)
                {
                    DataTable data = repository.GetAllData();

                    SessionColumnCollection collection = new SessionColumnCollection(data);
                    if (!sessionCollections.Contains(collection))
                    {
                        sessionCollections.Add(collection);
                    }
                    //need a better way to convert this collection to multithreaded oibservable
                    ObservableCollection <ISessionColumn> colClxn = new MultiThreadObservableCollection <ISessionColumn>();
                    foreach (SessionColumn sc in collection.Columns)
                    {
                        colClxn.Add(sc);
                    }
                    collection.Columns = colClxn;
                    if (MainWorkSpace != null)
                    {
                        this.Dispatcher.Invoke(DispatcherPriority.DataBind, new Action
                                               (
                                                   delegate()
                        {
                            MainWorkSpace = new ProcessingViewModel(sessionCollections);
                        }));
                    }

                    FileIsLoading = false;
                };

                worker.RunWorkerAsync();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #2
0
        void LoadFile()
        {
            Filename = WindART.Utils.GetFile();

            if (Filename.Length < 1)
            {
                return;
            }

            FileIsLoading = true;
            if (AllConfigsVM == null)
            {
                AllConfigsVM = new AllConfigsViewModel();
            }
            Workspace = AllConfigsVM;
            try
            {
                worker = new BackgroundWorker();
                worker.WorkerReportsProgress = true;

                DataRepository repository
                    = new DataRepository(Filename, DataSourceType.CSV);


                repository.FileOpening += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);
                repository.FileLoading += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);
                repository.FileLoaded  += new DataRepository.FileProgressEventHandler(repository_UpdateProgress);


                worker.DoWork += delegate(object sender, DoWorkEventArgs args)
                {
                    DataTable             data       = repository.GetAllData();
                    SingleConfigViewModel thisConfig = new SingleConfigViewModel(new SessionColumnCollection(data), data);
                    thisConfig.DisplayName = Path.GetFileNameWithoutExtension(Filename);
                    this.Dispatcher.Invoke(DispatcherPriority.DataBind, new Action
                                           (
                                               delegate()
                    {
                        AllConfigsVM.Configs.Add(thisConfig);
                    }));



                    //need a better way to convert this collection to multithreaded oibservable
                    ObservableCollection <ISessionColumn> colClxn = new MultiThreadObservableCollection <ISessionColumn>();
                    foreach (SessionColumn sc in thisConfig.ColumnCollection.Columns)
                    {
                        colClxn.Add(sc);
                    }

                    //add to an observable collection
                    thisConfig.LiveCollection = colClxn;


                    FileIsLoading = false;
                };

                worker.RunWorkerAsync();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #3
0
        void LoadInputFile()
        {
            string filename = Utils.GetFile();

            if (filename.Length < 1)
            {
                return;
            }

            try
            {
                worker = new BackgroundWorker();
                worker.WorkerReportsProgress = true;

                worker.DoWork += delegate(object sender, DoWorkEventArgs args)
                {
                    //get the tags from the repository
                    DataRepository repository = new DataRepository(filename, DataSourceType.XL2007);
                    DataTable      data       = repository.GetAllData();
                    int            RowCount   = data.Rows.Count;
                    string         val        = string.Empty;

                    for (int i = 0; i < RowCount; i++)
                    {
                        if (data.Rows[i][0].GetType().ToString() == "System.DBNull")
                        {
                            val = default(string);
                        }
                        else
                        {
                            val = data.Rows[i][0].ToString();
                        }
                        Tag thisTag = new Tag();
                        thisTag.TagName  = val;
                        thisTag.TagIndex = i;
                        _tags.Add(thisTag);
                    }

                    TagManager manager = new TagManager(_tags);


                    MultiThreadObservableCollection <SelectionItem <ProjectViewModel> > projects
                        = new MultiThreadObservableCollection <SelectionItem <ProjectViewModel> >();

                    foreach (Project proj in manager.ProjectList.Values)
                    {
                        ProjectViewModel pvm = new ProjectViewModel(proj)
                        {
                            start = start, end = end
                        };
                        projects.Add(new SelectionItem <ProjectViewModel>(pvm));
                    }

                    ProjectList = new SelectionList <SelectionItem <ProjectViewModel> >(projects);
                };

                worker.RunWorkerAsync();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #4
0
        void LoadInputFile(bool getfile)
        {
            string sourcefile = string.Empty;

            if (getfile)
            {
                sourcefile = Utils.GetFile();
            }

            try
            {
                worker = new BackgroundWorker();
                worker.WorkerReportsProgress = true;
                _tags.Clear();
                worker.DoWork += delegate(object sender, DoWorkEventArgs args)
                {
                    //get the tags from the repository
                    List <string> file = new List <string>();
                    //string sourcefile =
                    if (getfile && sourcefile.Length > 0)
                    {
                        DataRepository repository = new DataRepository(sourcefile, DataSourceType.CSV);
                        filename = string.Empty;
                        DataTable data = repository.GetAllData();
                        foreach (DataRow row in data.Rows)
                        {
                            file.Add(row[0].ToString());
                        }
                    }
                    //    else
                    //{
                    //     file = Properties.Resources.SourceTags.Split(',').Where(c => c.Length > 0).Select(c => c.Replace("\r\n", "")).ToList();
                    //}

                    //int RowCount = data.Rows.Count;
                    string val = string.Empty;
                    //create add the tags that belong to this project to the project objects tag object  store
                    foreach (string line in file)
                    {
                        if (line == null)
                        {
                            val = default(string);
                        }
                        else
                        {
                            val = line;
                        }
                        Tag thisTag = new Tag();
                        thisTag.TagName = val;
                        //thisTag.TagIndex = i;
                        _tags.Add(thisTag);
                    }

                    TagManager manager = new TagManager(_tags);



                    MultiThreadObservableCollection <SelectionItem <ProjectViewModel> > projects
                        = new MultiThreadObservableCollection <SelectionItem <ProjectViewModel> >();

                    foreach (Project proj in manager.ProjectList.Values)
                    {
                        ProjectViewModel pvm = new ProjectViewModel(proj, _dataSource)
                        {
                            start = start, end = end
                        };
                        projects.Add(new SelectionItem <ProjectViewModel>(pvm));
                    }

                    ProjectList = new SelectionList <SelectionItem <ProjectViewModel> >(projects);
                    // Console.WriteLine("finished loading source file");

                    this.Dispatcher.Invoke(DispatcherPriority.Render, new Action
                                           (
                                               delegate()
                    {
                        ProjectList = new SelectionList <SelectionItem <ProjectViewModel> >(projects);
                    }));
                };

                worker.RunWorkerAsync();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        void LoadInputFile()
        {
            try
            {
                worker = new BackgroundWorker();
                worker.WorkerReportsProgress = true;

                worker.DoWork += delegate(object sender, DoWorkEventArgs args)
                {
                    //get the tags from the repository

                    string sourcefile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Resources\SourceTags.xlsx";

                    DataRepository repository = new DataRepository(sourcefile, DataSourceType.XL2007);
                    filename = string.Empty;
                    DataTable data     = repository.GetAllData();
                    int       RowCount = data.Rows.Count;
                    string    val      = string.Empty;

                    for (int i = 0; i < RowCount; i++)
                    {
                        if (data.Rows[i][0].GetType().ToString() == "System.DBNull")
                        {
                            val = default(string);
                        }
                        else
                        {
                            val = data.Rows[i][0].ToString();
                        }
                        Tag thisTag = new Tag();
                        thisTag.TagName  = val;
                        thisTag.TagIndex = i;
                        _tags.Add(thisTag);
                    }

                    TagManager manager = new TagManager(_tags);



                    MultiThreadObservableCollection <SelectionItem <ProjectViewModel> > projects
                        = new MultiThreadObservableCollection <SelectionItem <ProjectViewModel> >();

                    foreach (Project proj in manager.ProjectList.Values)
                    {
                        ProjectViewModel pvm = new ProjectViewModel(proj, DataSourceType.WindART_PI)
                        {
                            start = start, end = end
                        };
                        projects.Add(new SelectionItem <ProjectViewModel>(pvm));
                    }

                    ProjectList = new SelectionList <SelectionItem <ProjectViewModel> >(projects);
                    //Console.WriteLine("finished loading source file");
                };

                worker.RunWorkerAsync();
            }
            catch (Exception e)
            {
                throw e;
            }
        }