コード例 #1
0
        void GetConfigs(string oldid)
        {
            if (Configs != null)
            {
                Configs.Clear();
            }
            ConfigDates.Clear();
            string    site   = oldid.Split('-')[1];
            string    state  = oldid.Split('-')[0];
            string    sql    = "select siteid from tblsite where oldid ='" + site + "' and state like '" + state + "'";
            DataTable tbl    = data.GetData(sql);
            int       siteid = int.Parse(tbl.Rows[0][0].ToString());

            tbl.Clear();

            sql = "exec procsiteconfig " + siteid + "; delete from tblprocesskeyconfig; ";
            tbl = data.GetData(sql);


            List <string> localConfigs = new List <string>();
            int           i            = 0;


            foreach (DataRow dr in tbl.Rows)
            {
                DateTime start = DateTime.Parse(dr[0].ToString());
                DateTime end   = DateTime.Parse(dr[1].ToString().Length == 0 ? DateTime.Today.ToString() : dr[1].ToString());

                //store date ranges for later
                ConfigDates.Add(i, new DateTime[2] {
                    start, end
                });

                //for list box
                StringBuilder sbldr = new StringBuilder();
                sbldr.Append(start.ToShortDateString());
                sbldr.Append("  to  ");
                sbldr.Append(end.ToShortDateString());

                localConfigs.Add(sbldr.ToString());
                i++;
            }
            tbl = null;

            Configs = new SelectionList <string>(localConfigs);
        }
コード例 #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()
        {
            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()
        {
            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;
            }
        }