Exemple #1
0
        private void Filter_Click(object sender, RoutedEventArgs e)
        {
            _workingdir = @"" + DirPath.Text;
            // Simple rename test snippet for code , please set break point
            if (_workingdir.Contains(".RAW"))
            {
                var newpath = _workingdir.Substring(0, _workingdir.Length - System.IO.Path.GetExtension(_workingdir).Length);
                var newPath = newpath + ".tel";
                File.Move(_workingdir, newPath);
            }
            //end
            try
            {
                if (Directory.Exists(_workingdir))
                {
                    Directory.SetCurrentDirectory(_workingdir);
                    int         size = Directory.EnumerateDirectories(_workingdir).Count();
                    IEnumerator iter = Directory.EnumerateDirectories(_workingdir).GetEnumerator();

                    pbStatus.Value = (100 / size);
                    while (iter.MoveNext())
                    {
                        pbStatus.Value += pbStatus.Value;

                        string dir = iter.Current as string;

                        // to factor '\' the slash
                        string    ats     = dir.Substring(_workingdir.Length + 1);
                        string [] atsinfo = ats.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);

                        // Might have to remove the prefix before proceed
                        int val = 0;
                        int.TryParse(atsinfo.ElementAtOrDefault(1), out val);

                        atslist.Add(new ATS()
                        {
                            Name = ats, ID = val, Date = atsinfo.ElementAtOrDefault(2), TimeStamp = atsinfo.ElementAtOrDefault(3)
                        });
                    }



                    //Sort ATS by Date then by Timestamp
                    ATSComparer atscmp = new ATSComparer();
                    atslist.Sort(atscmp);

                    Task <List <TPS> > TpsListTask = GenerateTpsList();

                    tpslist = TpsListTask.Result;
                    atslist.Clear();
                }
            }
            catch (DirectoryNotFoundException ex)
            {
                // Configure the message box to be displayed
                string           messageBoxText = ex.Message;
                string           caption        = "Error";
                MessageBoxButton button         = MessageBoxButton.OK;
                MessageBoxImage  icon           = MessageBoxImage.Error;
                MessageBox.Show(messageBoxText, caption, button, icon);
            }

            Filepaths = new ListCollectionView(tpslist);
            Filepaths.GroupDescriptions.Add(new PropertyGroupDescription("Date"));
            ListTPSView.ItemsSource = Filepaths;
            //pbStatus.Value = 0;
        }
Exemple #2
0
        private void Filter_Click(object sender, RoutedEventArgs e)
        {
            _workingdir = @"" + DirPath.Text;
            // Simple rename test snippet for code , please set break point
            if(_workingdir.Contains(".RAW"))
            {
                var newpath = _workingdir.Substring(0,_workingdir.Length - System.IO.Path.GetExtension(_workingdir).Length);
                var newPath = newpath + ".tel";
                File.Move(_workingdir, newPath);
            }
            //end
            try
            {
                if (Directory.Exists(_workingdir))
                {
                    Directory.SetCurrentDirectory(_workingdir);
                    int size = Directory.EnumerateDirectories(_workingdir).Count();
                    IEnumerator iter = Directory.EnumerateDirectories(_workingdir).GetEnumerator();

                    pbStatus.Value = (100/size);
                    while (iter.MoveNext())
                    {
                        pbStatus.Value += pbStatus.Value;

                        string dir = iter.Current as string;

                        // to factor '\' the slash
                        string ats = dir.Substring(_workingdir.Length+1);
                        string [] atsinfo = ats.Split(new char[] { '_' },StringSplitOptions.RemoveEmptyEntries);

                        // Might have to remove the prefix before proceed
                        int val = 0;
                        int.TryParse(atsinfo.ElementAtOrDefault(1), out val);

                        atslist.Add(  new ATS(){ Name = ats, ID = val, Date = atsinfo.ElementAtOrDefault(2), TimeStamp = atsinfo.ElementAtOrDefault(3) }  );
                    }

                    //Sort ATS by Date then by Timestamp
                    ATSComparer atscmp = new ATSComparer();
                    atslist.Sort(atscmp);

                    Task<List<TPS>> TpsListTask = GenerateTpsList();

                    tpslist = TpsListTask.Result;
                    atslist.Clear();
                }
            }
            catch (DirectoryNotFoundException ex)
            {
                // Configure the message box to be displayed
                string messageBoxText = ex.Message;
                string caption = "Error";
                MessageBoxButton button = MessageBoxButton.OK;
                MessageBoxImage icon = MessageBoxImage.Error;
                MessageBox.Show(messageBoxText, caption, button, icon);

            }

            Filepaths = new ListCollectionView(tpslist);
            Filepaths.GroupDescriptions.Add(new PropertyGroupDescription("Date"));
            ListTPSView.ItemsSource = Filepaths;
            //pbStatus.Value = 0;
        }