Example #1
0
        private void DoPrintJob(FileSystemEventArgs e)
        {
            var    fileInfo      = new System.IO.FileInfo(e.FullPath);
            string acceptpattern = Properties.Settings.Default.JobFilePattern;

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(acceptpattern);

            Log("SourceDirectory " + e.ChangeType.ToString() + " File: " + e.Name, EnumLogType.Info);
            if (regex.IsMatch(fileInfo.Name))
            {
                try
                {
                    Log("executing print....", EnumLogType.Info);
                    if (executePrintJob(JobFileHelper.loadJob(fileInfo.FullName)))
                    {
                        Log("executing print finished!", EnumLogType.Info);
                        MoveFileToArchive(fileInfo);
                    }
                    else
                    {
                        MoveFileToFailed(fileInfo);
                    }
                }
                catch (Exception ex)
                {
                    Log("Error executing print: " + ex.Message, EnumLogType.Error);


                    //System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath); // to start new instance of application
                    //this.Close(); //to turn off current app
                }

                //  System.IO.File.Delete(fileInfo.FullName);
            }
            else
            {
                Log("Filename not matching pattern - ignored." + e.Name, EnumLogType.Debug);
            }
            return;
        }
Example #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     JobFileHelper.save_testfile();
 }