How To Cache The Template? S’abonner

0
Avatar
Legacy Poster

As the subtitle , I have 6 different templates. now my code is to read the template as a LabelFormate before to create a task each time.

 

I want to cache the templates to increase the print speed, but i try to save them into memory, when print some labels. the printer always print out the same label ? 

 

Can give me some solutions?

 

 

----------------------------

 

As mentioned above. After I load the template using GetLabelFormateTask , I replced the key values using in Substring. I have checked , the values are different when using substring to replaced the values for each different label , but it always print out the same labels as the first one. 

5 commentaires

0
Avatar
Shotaro Ito
Actions pour les commentaires Permalien

TaskManager.StartupCommand Property can pre-load some documents in each BarTender process.
This demo shows two BarTender processes with pre-loaded. try pre-load and non - preload.

 

Place this code on C# Form's command button event.

 

            string btw1 = Application.StartupPath + @"\test.btw";
            string btw2 = Application.StartupPath + @"\test2.btw";
            
            // Initialize a new TaskManager object. 
            using (Seagull.BarTender.PrintServer.TaskManager btTaskManager = new Seagull.BarTender.PrintServer.TaskManager())
            {

                // Start a task engine with preloading a document. you can preload bunches
                btTaskManager.StartupCommand = string.Format("/F=\"{0}\" /F=\"{1}\"", btw1, btw2);

                //start BarTenders
                btTaskManager.Start(2);

                // show all bartenders
                foreach (Seagull.BarTender.PrintServer.TaskEngine te in btTaskManager.TaskEngines)
                {
                    te.VisibleWindows = Seagull.BarTender.Print.VisibleWindows.All;
                }

                // Just wait 5 secs
                System.Threading.Thread.Sleep(5000);

                // Create a new print task. 
                // The new PrintLabelFormatTask will contain an uninitialized LabelFormat. 
                Seagull.BarTender.PrintServer.Tasks.PrintLabelFormatTask btTask = new Seagull.BarTender.PrintServer.Tasks.PrintLabelFormatTask(btw1);

                // Specify to not close the format after print
                btTask.CloseFormatAfterCompletion = false;
                
                // Set the value of a SubString, it will be cached until print time. 
                // If "NAME" is not on this label format, then this generates a message at print time. 
                // Those message are accessible from the PrintLabelFormatTask.Messages property. 
                btTask.LabelFormat.SubStrings.SetSubString("NAME", "Value1");

                // Execute the task and wait for completion. 
                // Use preloaded format if matches, or load specified format.
                // then apply SetSubString, then print.
                btTaskManager.TaskQueue.QueueTaskAndWait(btTask, 60000);

                // show messages. 
                string str = "";
                foreach (Seagull.BarTender.Print.Message m in btTask.Messages)
                {
                   str += string.Format("{0} Message: {1}\r\n", m.Severity, m.Text);
                }
                MessageBox.Show(str);

                // Stop the task engine
                btTaskManager.Stop(5000, true);

            } 

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

TaskManager.StartupCommand Property can pre-load some documents in each BarTender process.
This demo shows two BarTender processes with pre-loaded. try pre-load and non - preload.

 

Place this code on C# Form's command button event.

 

            string btw1 = Application.StartupPath + @"\test.btw";
            string btw2 = Application.StartupPath + @"\test2.btw";
            
            // Initialize a new TaskManager object. 
            using (Seagull.BarTender.PrintServer.TaskManager btTaskManager = new Seagull.BarTender.PrintServer.TaskManager())
            {

                // Start a task engine with preloading a document. you can preload bunches
                btTaskManager.StartupCommand = string.Format("/F=\"{0}\" /F=\"{1}\"", btw1, btw2);

                //start BarTenders
                btTaskManager.Start(2);

                // show all bartenders
                foreach (Seagull.BarTender.PrintServer.TaskEngine te in btTaskManager.TaskEngines)
                {
                    te.VisibleWindows = Seagull.BarTender.Print.VisibleWindows.All;
                }

                // Just wait 5 secs
                System.Threading.Thread.Sleep(5000);

                // Create a new print task. 
                // The new PrintLabelFormatTask will contain an uninitialized LabelFormat. 
                Seagull.BarTender.PrintServer.Tasks.PrintLabelFormatTask btTask = new Seagull.BarTender.PrintServer.Tasks.PrintLabelFormatTask(btw1);

                // Specify to not close the format after print
                btTask.CloseFormatAfterCompletion = false;
                
                // Set the value of a SubString, it will be cached until print time. 
                // If "NAME" is not on this label format, then this generates a message at print time. 
                // Those message are accessible from the PrintLabelFormatTask.Messages property. 
                btTask.LabelFormat.SubStrings.SetSubString("NAME", "Value1");

                // Execute the task and wait for completion. 
                // Use preloaded format if matches, or load specified format.
                // then apply SetSubString, then print.
                btTaskManager.TaskQueue.QueueTaskAndWait(btTask, 60000);

                // show messages. 
                string str = "";
                foreach (Seagull.BarTender.Print.Message m in btTask.Messages)
                {
                   str += string.Format("{0} Message: {1}\r\n", m.Severity, m.Text);
                }
                MessageBox.Show(str);

                // Stop the task engine
                btTaskManager.Stop(5000, true);

            } 

Thanks Moderators.

 

I have another problem:

 

I make out a wcf service running in iis, which has remote database control action, but when i initialize the taskmanager to start engine, it throw an exception, message is "Unable to start requested number of Engines".

 

I have add the startup item for make sure bartender can run in .net 4.0 in my config file,but still throw the same exception.

 

My question is that is the bartender sdk auto against the starting because my bartender software is trial version 10.1.2 SR2 ? Can`t I do remote database action with the trial version ?

0
Avatar
Shotaro Ito
Actions pour les commentaires Permalien

My question is that is the bartender sdk auto against the starting because my bartender software is trial version 10.1.2 SR2 ? Can`t I do remote database action with the trial version ?

I'm not good at WCF - You may need the web app to allow access local resource like these post:

http://forums.seagullscientific.com/index.php?/topic/944-the-bartender-engine-could-not-be-started/

http://forums.seagullscientific.com/index.php?/topic/2099-printing-on-webserver/

 

Hope that helps.

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

TaskManager.StartupCommand Property can pre-load some documents in each BarTender process.
This demo shows two BarTender processes with pre-loaded. try pre-load and non - preload.

 

Place this code on C# Form's command button event.

 

            string btw1 = Application.StartupPath + @"\test.btw";
            string btw2 = Application.StartupPath + @"\test2.btw";
            
            // Initialize a new TaskManager object. 
            using (Seagull.BarTender.PrintServer.TaskManager btTaskManager = new Seagull.BarTender.PrintServer.TaskManager())
            {

                // Start a task engine with preloading a document. you can preload bunches
                btTaskManager.StartupCommand = string.Format("/F=\"{0}\" /F=\"{1}\"", btw1, btw2);

                //start BarTenders
                btTaskManager.Start(2);

                // show all bartenders
                foreach (Seagull.BarTender.PrintServer.TaskEngine te in btTaskManager.TaskEngines)
                {
                    te.VisibleWindows = Seagull.BarTender.Print.VisibleWindows.All;
                }

                // Just wait 5 secs
                System.Threading.Thread.Sleep(5000);

                // Create a new print task. 
                // The new PrintLabelFormatTask will contain an uninitialized LabelFormat. 
                Seagull.BarTender.PrintServer.Tasks.PrintLabelFormatTask btTask = new Seagull.BarTender.PrintServer.Tasks.PrintLabelFormatTask(btw1);

                // Specify to not close the format after print
                btTask.CloseFormatAfterCompletion = false;
                
                // Set the value of a SubString, it will be cached until print time. 
                // If "NAME" is not on this label format, then this generates a message at print time. 
                // Those message are accessible from the PrintLabelFormatTask.Messages property. 
                btTask.LabelFormat.SubStrings.SetSubString("NAME", "Value1");

                // Execute the task and wait for completion. 
                // Use preloaded format if matches, or load specified format.
                // then apply SetSubString, then print.
                btTaskManager.TaskQueue.QueueTaskAndWait(btTask, 60000);

                // show messages. 
                string str = "";
                foreach (Seagull.BarTender.Print.Message m in btTask.Messages)
                {
                   str += string.Format("{0} Message: {1}\r\n", m.Severity, m.Text);
                }
                MessageBox.Show(str);

                // Stop the task engine
                btTaskManager.Stop(5000, true);

            } 

I used this code but it is giving me "Unable to start the requested number of print engines." when published to production Server.

I am struggling to this problem since 30 days even raised the tickets on forum.

Please need your urgent attention.

0
Avatar
Shotaro Ito
Actions pour les commentaires Permalien

Make sure you run the application (or service) by a user account which has enough access rights.

(such as run by SYSTEM account, run as local administrator group's account etc.)

 

If you're running ASP.net web application, Enable 32 bit application pool (for BarTender 10.1 or before, or 32-bit version of BarTender).

Also change application pool's ID to SYSTEM (local system account) like case below.

 

http://forums.seagullscientific.com/index.php?/topic/2099-printing-on-webserver/

 

Note that once Trial period is expired, you cannot run BarTender via .net SDK.

Vous devez vous connecter pour laisser un commentaire.