SaveFamDataToCsv() публичный Метод

Save Family Data to File
public SaveFamDataToCsv ( string filePath ) : void
filePath string Where we going?
Результат void
Пример #1
0
        /// <summary>
        ///   Get the Data
        /// </summary>
        private void ProcessData()
        {
            try
            {
                //Populate Lists of Categoreies split by function
                _s.OrganizeCategorySets();
            }
            catch
            {
                using (var x = new TaskDialog("Error"))
                {
                    x.TitleAutoPrefix = false;
                    x.MainContent     = "Could not capture Category Data. Contact CASE.";
                    x.MainInstruction = "Error on Data Capture";
                    x.Show();
                }

                Close();
            }

            if (FolderBrowser1.ShowDialog() == DialogResult.OK)
            {
                // Save the Data to File
                if (!string.IsNullOrEmpty(FolderBrowser1.SelectedPath))
                {
                    string path = Path.Combine(FolderBrowser1.SelectedPath, _s.DocTitle());
                    //Export Annotation Categories if Checked
                    if (AnnotationCatCheck.Checked)
                    {
                        try
                        {
                            _s.SaveDataToCsv(path + "-Annoation-OS.txt", _s.AnnoCatSet);
                        }
                        catch (Exception exception)
                        {
                            Debug.WriteLine(exception.Message);
                        }
                    }

                    //Export Analytical Categories if Checked
                    if (AnalyticalCatCheck.Checked)
                    {
                        try
                        {
                            _s.SaveDataToCsv(path + "-Analytical-OS.txt", _s.AnalyticalCatSet);
                        }
                        catch (Exception exception)
                        {
                            Debug.WriteLine(exception.Message);
                        }
                    }

                    //Export Model Categories if Checked
                    if (ModelCatCheck.Checked)
                    {
                        try
                        {
                            _s.SaveDataToCsv(path + "-Model-OS.txt", _s.ModelCatSet);
                        }
                        catch (Exception exception)
                        {
                            Debug.WriteLine(exception.Message);
                        }
                    }
                    progressBar1.Increment(1);

                    if (FamSourceCheckBox.Checked)
                    {
                        var famList = new List <Family>();

                        if (AnnotationCatCheck.Checked)
                        {
                            progressBar1.Value = 0;

                            try
                            {
                                foreach (Category c in _s.AnnoCatSet)
                                {
                                    try
                                    {
                                        List <Family> catFams = _s.FamiliesByCategory(c);
                                        famList.AddRange(catFams);
                                        progressBar1.Maximum += catFams.Count;
                                    }
                                    catch (Exception exception)
                                    {
                                        Debug.WriteLine(exception.Message);
                                    }
                                }

                                foreach (Family f in famList)
                                {
                                    progressBar1.Increment(1);
                                    Document fd = _s.ActiveDoc.EditFamily(f);
                                    _s.FamReport.Add(new clsFamData(fd, f));
                                }
                                _s.SaveFamDataToCsv(path + "-FamilySource-Annotation-OS.txt");
                                famList.Clear();
                            }
                            catch (Exception exception)
                            {
                                Debug.WriteLine(exception.Message);
                            }
                        }

                        if (ModelCatCheck.Checked)
                        {
                            progressBar1.Value = 0;

                            try
                            {
                                foreach (Category c in _s.ModelCatSet)
                                {
                                    try
                                    {
                                        List <Family> catFams = _s.FamiliesByCategory(c);
                                        famList.AddRange(catFams);
                                        progressBar1.Maximum += catFams.Count;
                                    }
                                    catch (Exception exception)
                                    {
                                        Debug.WriteLine(exception.Message);
                                    }
                                }

                                foreach (Family f in famList)
                                {
                                    progressBar1.Increment(1);
                                    Document fd = _s.ActiveDoc.EditFamily(f);
                                    _s.FamReport.Add(new clsFamData(fd, f));
                                }

                                _s.SaveFamDataToCsv(path + "-FamilySource-Model-OS.txt");
                                famList.Clear();
                            }
                            catch (Exception exception)
                            {
                                Debug.WriteLine(exception.Message);
                            }
                        }
                    }
                }
            }
            else
            {
                using (var x = new TaskDialog("No Results"))
                {
                    x.TitleAutoPrefix = false;
                    x.MainContent     = "No Object Styles exist? Well somethings off there. Contact CASE.";
                    x.MainInstruction = "Nothing to Report";
                    x.Show();
                }
            }

            // Close
            Close();
        }