Beispiel #1
0
        private void ValidateExcel()
        {
            SyncTimer.Stop();
            SetStateRunning();
            string excelfile = string.Format(@"{0}\Karaoke\CDG_MP3\Index\{1}", txtOneDriveRoot.Text.Trim(), txtExcel.Text.Trim());

            if (File.Exists(excelfile) == true)
            {
                try
                {
                    onedriveitems = new List <OneDriveItem>();
                    sv            = new SpreadsheetValidator(excelfile, blink);

                    int row   = 2;
                    int nrows = sv.nCnt;
                    while (row < nrows)
                    {
                        Application.DoEvents();
                        if (bstop == true)
                        {
                            bstop = false;
                            sb.AppendLine("Stopped by user");
                            richTextStatus.Text = sb.ToString();
                            richTextStatus.Refresh();
                            SetStateReady();
                            return;
                        }
                        OneDriveItem cellpath = sv.Run(row);
                        if (blink == true)
                        {
                            if (cellpath != null && cellpath.Path != null && cellpath.Path.Trim().Length > 0)
                            {
                                onedriveitems.Add(cellpath);
                            }
                        }
                        richTextStatus.Text = sb.ToString() + "\n\n" + sv.status;
                        row++;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Unexpected error");
                }
            }
            SetStateReady();
            if (blink == false)
            {
                SetTimer(WrapUp);
            }
            else
            {
                SetTimer(SetOneDriveLinks);
            }
        }
Beispiel #2
0
        private void ValidateFiles()
        {
            SyncTimer.Stop();
            SetStateRunning();
            string excelfile = string.Format(@"{0}\Karaoke\CDG_MP3\Index\{1}", txtOneDriveRoot.Text.Trim(), txtExcel.Text.Trim());

            if (File.Exists(excelfile) == true)
            {
                try
                {
                    onedriveitems = new List <OneDriveItem>();
                    sv            = new SpreadsheetValidator(excelfile, blink);
                    List <string> cdgfiles = new List <string>();
                    List <string> zipfiles = new List <string>();

                    int row   = 2;
                    int nrows = sv.nCnt;
                    while (row < nrows)
                    {
                        Application.DoEvents();
                        if (bstop == true)
                        {
                            bstop = false;
                            sb.AppendLine("Stopped by user");
                            richTextStatus.Text = sb.ToString();
                            richTextStatus.Refresh();
                            SetStateReady();
                            return;
                        }
                        OneDriveItem cellpath = sv.Run(row);
                        if (cellpath != null && cellpath.Path != null && cellpath.Path.Trim().Length > 0)
                        {
                            cdgfiles.Add(cellpath.PathCDG.ToLower());
                            zipfiles.Add(cellpath.PathZIP.ToLower());
                        }
                        richTextStatus.Text = sb.ToString() + "\n\n" + sv.status;
                        row++;
                    }
                    if (bzip == true)
                    {
                        string   rootfile    = string.Format(@"{0}\Karaoke\CDG_ZIP", txtOneDriveRoot.Text.Trim());
                        string[] files       = Directory.GetFiles(rootfile, "*.zip", SearchOption.AllDirectories);
                        var      missingzips = files.Where(n => zipfiles.Contains(n.ToLower()) == false);
                        foreach (string file in missingzips)
                        {
                            sb.AppendLine(file);
                        }
                    }
                    else
                    {
                        string   rootfile    = string.Format(@"{0}\Karaoke\CDG_MP3", txtOneDriveRoot.Text.Trim());
                        string[] files       = Directory.GetFiles(rootfile, "*.cdg", SearchOption.AllDirectories);
                        var      missingcdgs = files.Where(n => cdgfiles.Contains(n.ToLower()) == false);
                        foreach (string file in missingcdgs)
                        {
                            sb.AppendLine(file);
                        }
                    }
                    richTextStatus.Text = sb.ToString();
                    richTextStatus.Refresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Unexpected error");
                }
            }
            SetStateReady();
            SetTimer(WrapUp);
        }