Ejemplo n.º 1
0
        private void DelModify_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            DBHoleData = new List <DBHoleInfos>();
            string TemplateFolder    = "";
            string Path              = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8, System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Length - 8);
            string directory         = System.IO.Path.GetDirectoryName(Path);
            double Tolerance         = 0;
            bool   UseMethod         = false;
            bool   DepthFromTop      = false;
            bool   AllowTagDuplicate = true;


            //Get the template from the option page
            TagHoles.ExtractINIData(out MachineCells);
            TagHoles.GetActiveMachineCellInfos(MachineCell_Drop.Text, MachineCells, out CSVPath, out TemplateFolder, out Tolerance, out UseMethod, out DepthFromTop, out AllowTagDuplicate);
            TagHoles.ExtractNewDatabaseData(CSVPath, out DBHoleData);

            LoadFamilyTypes();
        }
Ejemplo n.º 2
0
        public void UpdateCSVFile(bool Modify)
        {
            string Line              = null;
            string TempFileName      = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DrillingAutomation\\Temp.csv";
            string TemplateFolder    = "";
            double Tolerance         = 0;
            bool   UseMethod         = false;
            string FullLine          = "";
            bool   DepthFromTop      = false;
            bool   AllowTagDuplicate = true;

            //Get the template from the option page
            TagHoles.ExtractINIData(out MachineCells);
            TagHoles.GetActiveMachineCellInfos(MachineCell_Drop.Text, MachineCells, out CSVPath, out TemplateFolder, out Tolerance, out UseMethod, out DepthFromTop, out AllowTagDuplicate);

            if (File.Exists(TempFileName))
            {
                File.Delete(TempFileName);
            }
            File.Copy(CSVPath, TempFileName);
            File.Delete(CSVPath);

            using (StreamReader reader = new StreamReader(TempFileName))
            {
                using (StreamWriter writer = new StreamWriter(CSVPath))
                {
                    while ((Line = reader.ReadLine()) != null)
                    {
                        if (Line != "")
                        {
                            if (Line.Substring(0, 1) != "*")
                            {
                                // Split the Line
                                string[] CurrentHole = Regex.Split(Line, ";");

                                if (CurrentHole.Count() >= 3)
                                {
                                    if (CurrentHole[1] == HoleTypes.Text)
                                    {
                                        if (Modify)
                                        {
                                            HoleFullSignature(out FullLine, true);
                                            SearchForExistingHole(CSVPath, FullLine, Modify, AllowTagDuplicate, out bool HoleExist);
                                            if (HoleExist)
                                            {
                                                if (AllowTagDuplicate)
                                                {
                                                    MessageBox.Show("Hole already exist in the database", "Error");
                                                }
                                                else
                                                {
                                                    MessageBox.Show("Hole tag already exist in the database", "Error");
                                                }
                                            }
                                            else
                                            {
                                                writer.WriteLine(FullLine);
                                            }
                                        }
                                        continue;
                                    }
                                }
                            }
                            writer.WriteLine(Line);
                        }
                    }
                    writer.Close();
                }
                reader.Close();
            }
            File.Delete(TempFileName);
            TagHoles.ExtractNewDatabaseData(CSVPath, out DBHoleData);
        }