コード例 #1
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;
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
0
        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;
            }
        }