Exemple #1
0
        public static void FormatData(VehicleDataSource vds)
        {
            var sep = '-';

            Stock         = vds.Stock;
            FormattedText = "";
            foreach (Part p in vds.Parts)
            {
                string priceStr;
                if (p.ProjectedPrice == 0 || p.Skip == true)
                {
                    priceStr = "None";
                }
                else
                {
                    priceStr = p.ProjectedPrice.ToString();
                }
                if (FormattedText == "")
                {
                    FormattedText += p.Name + sep + priceStr;
                }
                else
                {
                    FormattedText += '\n' + p.Name + sep + priceStr;
                }
            }
        }
Exemple #2
0
        public static void RunPyScript(VehicleDataSource vds)
        {
            FormatData(vds);
            WriteToFile();

            string batFileName = Application.StartupPath + @"\" + Guid.NewGuid() + ".bat";

            using (StreamWriter batFile = new StreamWriter(batFileName))
            {
                batFile.WriteLine(DependencyCheck.PythonPath + " " + DependencyCheck.PyScriptPath + " " + Application.StartupPath + "\\" + Stock + ".txt" + " " + true.ToString());
            }

            ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe", "/c " + batFileName);

            processStartInfo.UseShellExecute = false;
            processStartInfo.CreateNoWindow  = true;

            Process p = new Process();

            p.StartInfo = processStartInfo;
            p.Start();
            p.WaitForExit();

            File.Delete(batFileName);
            File.Delete(Application.StartupPath + "\\" + Stock + ".txt");
        }
Exemple #3
0
 public static void SaveSession(VehicleDataSource vds, string path)
 {
     using (var s = new FileStream(path, FileMode.Create, FileAccess.Write))
     {
         IFormatter formatter = new BinaryFormatter();
         formatter.Serialize(s, vds);
     }
 }
Exemple #4
0
        public static void FormatData(VehicleDataSource vds, bool forFile)
        {
            var sep       = '\t';
            var titleLine = vds.Stock + " " + vds.Year + " " + vds.Model + ": " + vds.Parts.Count.ToString() + " parts" + '\n';

            FormattedText = "";
            foreach (Part p in vds.Parts)
            {
                var s = "";
                if (FormattedText == "")
                {
                    s = "\n";
                }
                var nameStr = p.Name;
                if (p.Side != "")
                {
                    nameStr += "-" + p.Side;
                }
                else
                {
                    nameStr += "  ";
                }
                var icStr = p.IC;
                if (string.IsNullOrWhiteSpace(icStr))
                {
                    icStr = "NoIC  ";
                }
                string priceStr;
                if (p.ProjectedPrice == 0)
                {
                    priceStr = "None ";
                }
                else
                {
                    priceStr = PriceToLength("$" + p.ProjectedPrice.ToString());
                }
                FormattedText += s + nameStr + sep + icStr + sep + " " + priceStr + sep + p.IncludedItems.Count.ToString() + "/" + p.ExcludedItems.Count.ToString() + "\n";
            }
            FormattedText = titleLine + FormattedText;
        }
Exemple #5
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     oFD.FileName         = "";
     oFD.Title            = "Open Session";
     oFD.Filter           = "Session|*.sess";
     oFD.InitialDirectory = settings.ExportPath;
     oFD.FileName         = "";
     oFD.ShowDialog();
     if (oFD.FileName == "")
     {
         return;
     }
     try
     {
         vehicleDataSource = Exporter.OpenSession(oFD.FileName);
         ShowPartList();
     }
     catch (Exception)
     {
         MessageBox.Show("File could not be opened!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #6
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var startup = new ImportForm();

            startup.ShowDialog();
            if (startup.Tag != null)
            {
                return;
            }
            try
            {
                var rawText = startup.ClipText;
                vehicleDataSource = new VehicleDataSource(rawText);
                LoadListAsync();
            }
            catch (Exception)
            {
                MessageBox.Show("Clipboard data was not formatted correctly.\n" +
                                "Try again or see the help page for more \n" +
                                "instructions on copying data.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }