Ejemplo n.º 1
0
        private void btnRebuilder_Rebuild_Click(object sender, EventArgs e)
        {
            if (checkRebuilderInputs())
            {
                datafile      dataFile   = new datafile();
                XmlSerializer serializer = new XmlSerializer(typeof(datafile));
                TextReader    textReader = new StreamReader(tbRebuilder_Datafile.Text);
                dataFile = (datafile)serializer.Deserialize(textReader);
                textReader.Close();

                RebuilderWorker.RebuildSetsStruct vRebuildSetsStruct = new RebuilderWorker.RebuildSetsStruct();
                vRebuildSetsStruct.pSourceDir         = tbRebuilder_SourceDir.Text;
                vRebuildSetsStruct.pDestinationDir    = tbRebuilder_DestinationDir.Text;
                vRebuildSetsStruct.pDatFile           = dataFile;
                vRebuildSetsStruct.pRemoveSource      = cbRebuilder_RemoveSource.Checked;
                vRebuildSetsStruct.pOverwriteExisting = cbRebuilder_Overwrite.Checked;
                vRebuildSetsStruct.ScanOnly           = cbRebuilder_ScanOnly.Checked;
                vRebuildSetsStruct.pCompressOutput    = cbRebuilder_CompressOutput.Checked;

                try
                {
                    vRebuildSetsStruct.totalFiles = Directory.GetFiles(tbRebuilder_SourceDir.Text, "*.*", SearchOption.AllDirectories).Length;

                    base.backgroundWorker_Execute(vRebuildSetsStruct);
                }
                catch (Exception exception2)
                {
                    tbOutput.Text += exception2.Message;
                }
            }
        }
Ejemplo n.º 2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selectedNode != null)
            {
                treeViewTools.SelectedNode = selectedNode;

                game sourceGame = null;
                rom  sourceRom  = null;

                if (selectedNode.Tag is rom)
                {
                    sourceRom  = (rom)selectedNode.Tag;
                    sourceGame = (game)selectedNode.Parent.Tag;
                }
                else
                {
                    sourceGame = (game)selectedNode.Tag;
                }

                this.datafileObject = AuditingUtil.DeleteItemFromDatafile(this.datafileObject, sourceGame, sourceRom);
                this.loadDataFileIntoTree(this.datafileObject);
            }
            else
            {
                MessageBox.Show(ConfigurationManager.AppSettings["Form_DatafileEditor_ErrorDatafileSelectedNode"],
                                ConfigurationManager.AppSettings["Form_DatafileEditor_ErrorDatafileSelectedNodeTitle"]);
            }
        }
Ejemplo n.º 3
0
        private void checkDatafile(DatafileCheckerStruct pDatafileCheckerStruct, DoWorkEventArgs e)
        {
            StreamWriter sw;

            datafile      dataFile   = new datafile();
            XmlSerializer serializer = new XmlSerializer(dataFile.GetType());
            TextReader    textReader = new StreamReader(pDatafileCheckerStruct.datafilePath);

            dataFile = (datafile)serializer.Deserialize(textReader);
            textReader.Close();

            AuditingUtil auditingUtil = new AuditingUtil(dataFile);

            // Check for duplicates
            string dupePath = pDatafileCheckerStruct.outputPath + Path.DirectorySeparatorChar + "_DUPE.TXT";

            if (File.Exists(dupePath))
            {
                File.Delete(dupePath);
            }
            sw = File.CreateText(dupePath);

            // Update max items
            maxItems = auditingUtil.ChecksumHash.Count;

            this.checkForDupes(auditingUtil, sw);

            sw.Close();
            sw.Dispose();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Simple constructor taking input pDatafile
 /// </summary>
 /// <param name="pDatafile">Datafile to use for building lists.</param>
 public AuditingUtil(datafile pDatafile)
 {
     datafile        = pDatafile;
     checksumHash    = this.BuildChecksumHash();
     HasVgmtSizeFlag = false;
     // this.addCachedChecksumsToHash();
 }
Ejemplo n.º 5
0
 public void ReadFile(Stream stream)
 {
     using (StreamReader reader = new StreamReader(stream))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(datafile));
         Contents = (datafile)serializer.Deserialize(reader);
     }
 }
Ejemplo n.º 6
0
 public void ReadFile(Stream stream)
 {
     using (StreamReader reader = new StreamReader(stream))
     {
         Contents = new datafile();
         ReadHeader(reader);
         ReadGames(reader);
     }
 }
Ejemplo n.º 7
0
        private void loadDataFileIntoTree(datafile datafileObject)
        {
            TreeNode workingGameNode;
            TreeNode workingRomNode;

            TreeNode workingGameNameNode;
            TreeNode workingRomSizeNode;
            TreeNode workingRomCrcNode;
            TreeNode workingRomMd5Node;
            TreeNode workingRomSha1Node;

            // clear tree
            this.treeViewTools.Nodes.Clear();

            foreach (game g in datafileObject.game)
            {
                workingGameNode     = new TreeNode(g.description);
                workingGameNode.Tag = g.DeepCopy();

                workingGameNameNode = new TreeNode(String.Format("Folder: {0}", g.name));
                workingGameNode.Nodes.Add(workingGameNameNode);

                if (g.rom != null)
                {
                    foreach (rom r in g.rom)
                    {
                        workingRomNode     = new TreeNode(r.name);
                        workingRomNode.Tag = r.DeepCopy();

                        workingRomSizeNode = new TreeNode(String.Format("Size: {0}", r.size));
                        workingRomCrcNode  = new TreeNode(String.Format("CRC32: {0}", r.crc));
                        workingRomMd5Node  = new TreeNode(String.Format("MD5: {0}", r.md5));
                        workingRomSha1Node = new TreeNode(String.Format("SHA1: {0}", r.sha1));

                        workingRomNode.Nodes.Add(workingRomSizeNode);
                        workingRomNode.Nodes.Add(workingRomCrcNode);
                        workingRomNode.Nodes.Add(workingRomMd5Node);
                        workingRomNode.Nodes.Add(workingRomSha1Node);

                        workingGameNode.Nodes.Add(workingRomNode);
                    }
                }

                if (g.disk != null)
                {
                    foreach (disk d in g.disk)
                    {
                        workingRomNode     = new TreeNode(d.name);
                        workingRomNode.Tag = d.DeepCopy();

                        workingGameNode.Nodes.Add(workingRomNode);
                    }
                }

                this.treeViewTools.Nodes.Add(workingGameNode);
            }
        }
Ejemplo n.º 8
0
        private datafile getDataFileObject()
        {
            datafile      datafileObject = new datafile();
            XmlSerializer serializer     = new XmlSerializer(typeof(datafile));

            using (FileStream xmlFs = File.OpenRead(this.datafileSourcePath.Text))
            {
                using (XmlTextReader textReader = new XmlTextReader(xmlFs))
                {
                    datafileObject = (datafile)serializer.Deserialize(textReader);
                }
            }

            return(datafileObject);
        }
Ejemplo n.º 9
0
        public static void AddCsvInformationToDataFile(string pCsvPath,
                                                       string pSourceDataFilePath, string pDestinationDataFilePath)
        {
            // Initialize CSV
            HootCsv hootCsvFile = new HootCsv();

            hootCsvFile.LoadFromFile(pCsvPath);

            // Initialize Source DAT
            datafile      dataFile   = new datafile();
            XmlSerializer serializer = new XmlSerializer(typeof(datafile));
            TextReader    textReader = new StreamReader(pSourceDataFilePath);

            dataFile = (datafile)serializer.Deserialize(textReader);
            textReader.Close();
            textReader.Dispose();

            // Get Csv HashTable
            Hashtable csvHashtable = getCsvHashTable(hootCsvFile);

            // Add Data to DAT File
            foreach (VGMToolbox.format.auditing.game g in dataFile.game)
            {
                if (csvHashtable.ContainsKey(g.name))
                {
                    HootCsvEntry csvEntry = (HootCsvEntry)csvHashtable[g.name];
                    g.description  = csvEntry.EnglishName;
                    g.board        = csvEntry.System + " [" + csvEntry.Chip + "]";
                    g.manufacturer = csvEntry.Company;
                    g.year         = csvEntry.ReleaseYear;

                    g.comment    = new string[1];
                    g.comment[0] = csvEntry.Composer;
                }
            }

            // Output DAT File
            TextWriter textWriter = new StreamWriter(pDestinationDataFilePath);

            serializer.Serialize(textWriter, dataFile);
            textWriter.Close();
            textWriter.Dispose();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Browse to the source file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void browseSourceButton_Click(object sender, EventArgs e)
        {
            this.datafileSourcePath.Text = base.browseForFile(sender, e);

            if ((!String.IsNullOrEmpty(this.datafileSourcePath.Text)) &&
                (TreeViewVgmtForm.checkFileExists(this.datafileSourcePath.Text, this.grpSource.Text)))
            {
                try
                {
                    this.datafileObject = this.getDataFileObject();
                    this.loadDataFileIntoTree(this.datafileObject);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        String.Format(ConfigurationManager.AppSettings["Form_DatafileEditor_ErrorDatafileParse"], ex.Message, Environment.NewLine), "Error");
                }
            }
        }
Ejemplo n.º 11
0
        private datafile datafile_rec(double days, double x, datafile rec)
        {
            if (rec == null || rec.year < 1)
            {
                rec               = new datafile();
                rec.year          = days;
                rec.radius        = 0.0;
                rec.concentration = x;
                log.Add(string.Format("{0}: year = {1}; Radius = {2}; concentration (0 + {3}) = {4}",
                                      DateTime.Now, rec.year, rec.radius, rec.concentration, rec.concentration));
            }
            else
            {
                log.Add(string.Format("{0}: year = {1}; Radius = {2}; concentration ({3} + {4}) = {5}",
                                      DateTime.Now, rec.year, rec.radius, rec.concentration, x, rec.concentration + x));
                rec.concentration += x;
            }

            return(rec);
        }
Ejemplo n.º 12
0
        private void datafileCreatorWorker_WorkComplete(object sender,
                                                        RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                toolStripStatusLabel1.Text =
                    ConfigurationManager.AppSettings["Form_AuditDatafileCreator_MessageCancel"];
                tbOutput.Text +=
                    ConfigurationManager.AppSettings["Form_Global_OperationCancelled"];
            }
            else
            {
                lblProgressLabel.Text = String.Empty;

                datafile dataFile = new datafile();
                dataFile.header = DatafileCreatorWorker.buildHeader(tbDatCreator_Author.Text, tbDatCreator_Category.Text,
                                                                    tbDatCreator_Comment.Text, tbDatCreator_Date.Text, tbDatCreator_Description.Text,
                                                                    tbDatCreator_Email.Text, tbDatCreator_Homepage.Text, tbDatCreator_Name.Text,
                                                                    tbDatCreator_Url.Text, tbDatCreator_Version.Text);

                dataFile.game = (VGMToolbox.format.auditing.game[])e.Result;

                XmlSerializer serializer = new XmlSerializer(dataFile.GetType());

                TextWriter textWriter = new StreamWriter(tbDatCreator_OutputDat.Text);
                serializer.Serialize(textWriter, dataFile);
                textWriter.Close();
                textWriter.Dispose();

                toolStripStatusLabel1.Text =
                    ConfigurationManager.AppSettings["Form_AuditDatafileCreator_MessageComplete"];
            }

            // update node color
            setNodeAsComplete();
        }
Ejemplo n.º 13
0
        public void buildHSS(char delim, int start, int end, string path)
        {
            List <cellData> files = new List <cellData>();
            Dictionary <string, List <datafile> > data = new Dictionary <string, List <datafile> >();
            hssFile hss = new hssFile();

            log = new List <string>();
            string log_str = "";

            foreach (hss_data_files file in source)
            {
                if (file.i != null && file.i != "" && file.j != null && file.j != "")
                {
                    string   datFileName = String.Format("i{0}j{1}_HSS.dat", file.i, file.j);
                    cellData cell        = files.Where(f => f.HSSFileName == file.source).FirstOrDefault();
                    if (cell == null || cell.HSSFileName == null)
                    {
                        log.Add(string.Format("{0}:  processing file '{1}'; column {2}; cell {3}-{4}; time frame {5} - {6} ",
                                              DateTime.Now, file.source, file.col, file.i, file.j, start, end));
                        cell             = new cellData();
                        cell.HSSFileName = datFileName;
                        cell.iHSSComp    = "COPC";
                        cell.inHSSFile   = "";//file.id.ToString();
                        cell.iSource     = file.i.ToString();
                        cell.jSource     = file.j.ToString();
                        if (water_lvl.Keys.Contains(int.Parse(file.i)) && water_lvl[int.Parse(file.i)].Keys.Contains(int.Parse(file.j)))
                        {
                            cell.kSource = water_lvl[int.Parse(file.i)][int.Parse(file.j)].ToString();
                        }
                        else
                        {
                            cell.kSource = file.k.ToString();
                        }
                        cell.SourceName = file.id.ToString();
                        files.Add(cell);
                    }
                    int col_year = source.Where(s => s.source == file.source && s.time == true).Select(s => s.col).First();
                    IEnumerable <string> lines = File.ReadLines(file.source);
                    double prev_year           = start;
                    double days       = 0;
                    bool   start_year = true;

                    foreach (string line in lines)
                    {
                        string[] temp = line.Split(new[] { delim }, StringSplitOptions.None);
                        double   year = 0;

                        if (!data.ContainsKey(datFileName))
                        {
                            data.Add(datFileName, new List <datafile>());
                        }

                        if (double.TryParse(temp[col_year], out year))
                        {
                            if (year >= start && year <= end)
                            {
                                double x = 0;

                                if (double.TryParse(temp[file.col], out x))
                                {
                                    if (x > 0)
                                    {
                                        x = x / 365.25;
                                    }
                                    //if the first record is > than the start date, then backfill previous years.
                                    if (start_year)
                                    {
                                        if (year > start)
                                        {
                                            log.Add(string.Format("{0}:  Backfilling missing years ({1} - {2}",
                                                                  DateTime.Now, start, year - 1));
                                            for (int i = start; i < year; i++)
                                            {
                                                if (i > start)
                                                {
                                                    log_str = string.Format("{0}:  year calc: (({1} - {2}) * 365.25) + {3} = ",
                                                                            DateTime.Now, i, i - 1, days);
                                                    days += year_to_days(i - 1, i);
                                                    log.Add(log_str + days.ToString());
                                                }

                                                datafile rec = data[datFileName].FirstOrDefault(d => d.year == days);
                                                data[datFileName].Add(datafile_rec(days, 0, data[datFileName].FirstOrDefault(d => d.year == days)));
                                                if (days > 0)
                                                {
                                                    data[datFileName].Add(datafile_rec(days, 0, data[datFileName].FirstOrDefault(d => d.year == days)));
                                                }
                                                prev_year = i;
                                            }
                                            log.Add(string.Format("{0}:  End of backfilled years",
                                                                  DateTime.Now, start, year - 1));
                                        }
                                        start_year = false;
                                    }
                                    if (year > start)
                                    {
                                        log_str = string.Format("{0}:  year calc: (({1} - {2}) * 365.25) + {3} = ",
                                                                DateTime.Now, year, prev_year, days);
                                        days += year_to_days(prev_year, year);
                                        log.Add(log_str + days.ToString());
                                    }
                                    data[datFileName].Add(datafile_rec(days, x, data[datFileName].FirstOrDefault(d => d.year == days)));
                                    if (days > 0)
                                    {
                                        data[datFileName].Add(datafile_rec(days, x, data[datFileName].FirstOrDefault(d => d.year == days)));
                                    }
                                    prev_year = year;
                                }
                            }
                        }
                    }
                }
            }
            hss.MaxHSSSource = files.Count;
            hss.MaxHSSCells  = files.Count;
            hss.nHSSSource   = files.Count;
            hss.MaxHSSStep   = (end - start) + 2;
            string  units  = "";
            outputs output = new outputs(units);

            output.build_hss_file(path, hss, files);
            output.build_hss_dat_files(path, data);
            output.build_log_file(path, log);
            log = new List <string>();
        }
Ejemplo n.º 14
0
 public TDCDat_Text()
 {
     Contents = new datafile();
 }
Ejemplo n.º 15
0
 public TosecDat_Text()
 {
     Contents = new datafile();
     PopulateProperties();
 }