Commander Trigger File And Bartender Template 关注

0
Avatar
Legacy Poster

I'm new to Bartender and the Commander software, and have a question about setting up a task. The workflow I want to accomplish is as follows.

1. Trigger file is generated from our warehouse management system. In this file is the label template name, the product number for the label, and the quantity of labels to print.

2. File is moved to the appropriate folder, and commander trigger is fired. The file is parsed to know which label format to open up, the product number is passed to Bartender to be used in a database query to gather additional information for the label, and the number of labels to print is passed to the appropriate place.

I have the label template created, and functioning properly (if I print label, it opens a prompt for the product number, and retrieves appropriate data from my product database)
I have the commander program receiving the trigger file, and I can parse the file to extract information.

I'm lost on how to connect the 2 to get the information passed between the two pieces and get the appropriate label template opened, and product and print data passed to Bartender.

6 评论

0
Avatar
Michael Toupin (mtoupin
评论操作 固定链接

The first thing you're going to want to do is to review the [url="http://s3.amazonaws.com/SeagullBarTender/ftp/WhitePapers/WhitePaper_CommanderExamples_English.pdf"]Commander Examples white paper[/url]. Specifically example 3, using Commander script.

An appropriate Commander script trigger file for processing based off of your requirements should look something like this:

%BTW% /AF="C:\labelfilelocation\labelformatname.btw" /PRN="printer" /?QueryPromptName="QueryData" /C=1 /P
%END%


Basically there are 5 commands that you're going to want to use.

/AF - specifies the active format to use
/PRN - specifies the printer to use
/? - used with the name of the query prompt or prompts to populate the query prompt on the label
/C - specifies number of copies to print
/P - tells BarTender to print the label

For a full list of commands that can be used, as well as appropriate syntax if necessary, go into BarTender's help and search on 'Command Line Parameter Summary'. Just makes sure to encapsulate your commands in the %BTW% and %END% commands so that Commander can use it, and make sure to specify 'Commander Script' as the data type in your Commander task.
0
Avatar
Legacy Poster
评论操作 固定链接

Mike, Thanks for the reply. I reviewed the white paper, and I think I understand the command line options well enough now to get them working.
The only remaining question I have is regarding parsing the trigger file to get the information to the correct prompt.
For example, given trigger file with this line in it
LABEL1.btw, PRODUCTXYZ, PRINTERXXX, 14

How do I get the data parsed and into the command as follows?
%BTW% /AF="C:\labelfilelocation\LABEL1.btw" /PRN="PRINTERXXX" /?QueryPromptName="PRODUCTXYZ" /C=14 /P

Thanks,
0
Avatar
Michael Toupin (mtoupin
评论操作 固定链接

[quote name='RAB_ERIC' timestamp='1345037897' post='3086']
Mike, Thanks for the reply. I reviewed the white paper, and I think I understand the command line options well enough now to get them working.
The only remaining question I have is regarding parsing the trigger file to get the information to the correct prompt.
For example, given trigger file with this line in it
LABEL1.btw, PRODUCTXYZ, PRINTERXXX, 14

How do I get the data parsed and into the command as follows?
%BTW% /AF="C:\labelfilelocation\LABEL1.btw" /PRN="PRINTERXXX" /?QueryPromptName="PRODUCTXYZ" /C=14 /P

Thanks,
[/quote]

There's a couple of ways to do that. The recommended way would be to set up your application so that it outputs the data in the right format.

If that's not doable for whatever reason, you could conceivably write a vbscript or powershell script to parse the data into the appropriate format, then just execute that using an Operating System command in Commander to use it. Would be as easy as setting up the script to read the first line of the data, populate an array with it, then use that array to populate the command string.
0
Avatar
Legacy Poster
评论操作 固定链接

s

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

s

 

 

 

 

 

 

 

 

s

 

 

 

 

 

s

0
Avatar
Legacy Poster
评论操作 固定链接

Hi,

 

I'm trying to solve exactly the same problem like RAB_ERIC mentioned in the first post.

 

Please, do you have some approach how to elegantly parse the data from txt file and move it to the Commander.

 

There's a couple of ways to do that. The recommended way would be to set up your application so that it outputs the data in the right format. 

 

What exactly is the right format?

 

I'm stuck in this step so I would be really grateful for any help.

 

 

Thank you,

Tomáš

0
Avatar
Legacy Poster
评论操作 固定链接

Hello,

I finally solve this problem with a little bit of programming in .NET

The key is to use FileSystemWatcher class

 

Here is the code:

 

private void fileSystemWatcher_Created(object sender, FileSystemEventArgs e)
        {
            if (e.Name.Substring(e.Name.Length - 4, 4) == ".txt") //if file is *.txt
            {
                if (new FileInfo(e.FullPath).Length != 0) //if file is not empty
                {
                    //read file
                    using (StreamReader sr = new StreamReader(e.FullPath))
                    {
                        string[] str = File.ReadAllLines(e.FullPath); //read all lines


                        /*
                         * 
                         * ADD LOGIC FOR OBTAINING DATA
                         * 
                         */


                        if (str[0] != null) //if string is not empty
                        {
                            try
                            {
                                using (Engine btEngine = new Engine(true))
                                {
                                    //LabelFormatDocument btFormat = btEngine.Documents.Open(@"path"); //open appropriate layout
                                    LabelFormatDocument btFormat = btEngine.Documents.Open(Properties.Settings.Default.layoutfile); //open appropriate layout
                                    btFormat.SubStrings["UID"].Value = str[0]; //prompt data in layout
                                    btFormat.PrintSetup.IdenticalCopiesOfLabel = 1; //set copies of labels to 1
                                    btFormat.Print(); //print label
                                }
                            }
                            catch
                            {
                                MessageBox.Show("Message. \n\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //show messagebox with exception
                            }
                        }
                    }
                }
            }
            //Delete file
            if (File.Exists(e.FullPath))
            {
                File.Delete(e.FullPath);
            }
        }

 

请先登录再写评论。