コード例 #1
0
ファイル: Form1.cs プロジェクト: NickNirus/EchoprintRadioScan
        public void GetCodeGen(object state)
        {
            string[] files = Directory.GetFiles(textBox2.Text);

            if (files.Length > 2)
            {
                Program.SetMetaData("[");
            }

            using (var codegen = new NCodegen(Convert.ToInt32(textBox4.Text), Convert.ToInt32(textBox5.Text)))
            {
                codegen.Start((data) =>
                {
                    // CodeGen = data;
                    if (files.Length > 2)
                    {
                        Program.SetMetaData(",");
                    }
                    Program.SetMetaData(string.Empty);
                    Program.SetMetaData(JsonConvert.SerializeObject(data, Formatting.Indented));
                });
                foreach (var item in files)
                {
                    Program.Message(string.Format("{0:HH:mm:ss} - {1}", DateTime.Now, item));

                    codegen.AddFile(item);
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: NickNirus/EchoprintRadioScan
        public void CallBack(object state)
        {
            string[] files = Directory.GetFiles(textBox2.Text ?? ConfigurationManager.AppSettings["samplefiles"], "*.mp3", SearchOption.AllDirectories);
            // var result = new List<_Code>();
            // var api = new EchonestAPI();
            //  repairCompositionMetadata();
            int index = 0;

            using (var codegen = new NCodegen(Convert.ToInt32(textBox4.Text), Convert.ToInt32(textBox5.Text)))
            {
                codegen.Start((data) =>
                {
                    doProgress(++index);

                    if (string.IsNullOrEmpty(data.metadata.title))
                    {
                        Program.Message(string.Format("metadata.title is Empty {0:HH:mm:ss} - {1}", DateTime.Now, data.metadata.filename));
                        data.metadata.title = GetTitle(data.metadata.filename);
                        Program.Message(string.Format("auto repair with: {0}", data.metadata.title));
                    }

                    if (string.IsNullOrEmpty(data.metadata.release))
                    {
                        Program.Message(string.Format("metadata.release is Empty  {0:HH:mm:ss} - {1}", DateTime.Now, data.metadata.filename));
                        data.metadata.release = data.metadata.filename;
                        Program.Message(string.Format("repair with: {0}", data.metadata.release));
                    }


                    if (string.IsNullOrEmpty(data.metadata.artist))
                    {
                        Program.Message(string.Format("metadata.artist is Empty {0:HH:mm:ss} - {1}", DateTime.Now, data.metadata.filename));
                        data.metadata.artist = GetArtist(data.metadata.filename);
                        Program.Message(string.Format("repair with: {0}", data.metadata.artist));
                    }

                    resultListNest.Add(data);
                    Program.SetMetaData(JsonConvert.SerializeObject(data, Formatting.Indented));
                });


                numberOfFiles = files.Length;

                if (progressBar1.InvokeRequired)
                {
                    progressBar1.Invoke((MethodInvoker) delegate
                    {
                        progressBar1.Maximum = numberOfFiles;
                        progressBar1.Minimum = 1;
                        progressBar1.Step    = 1;
                    });
                }
                else
                {
                    progressBar1.Maximum = numberOfFiles;
                    progressBar1.Minimum = 1;
                    progressBar1.Step    = 1;
                }


                if (progressBar4.InvokeRequired)
                {
                    progressBar4.Invoke((MethodInvoker) delegate
                    {
                        progressBar4.Maximum = numberOfFiles;
                        progressBar4.Minimum = 1;
                        progressBar4.Step    = 1;
                    });
                }
                else
                {
                    progressBar4.Maximum = numberOfFiles;
                    progressBar4.Minimum = 1;
                    progressBar4.Step    = 1;
                }


                for (int i = 0; i < files.Count(); i++)
                {
                    Program.Message(string.Format("{0:HH:mm:ss} - {1}", DateTime.Now, files[i]));
                    codegen.AddFile(files[i]);
                    doProgressImportedFields(i + 1);
                }
            }
        }