Bartender is an excellent bar code printing software, can support many types of bar code design and printing, specific you can refer to his official website (http://www.seagullscientific.com/aspx/products.aspx), here not much introduction.
When I first came into contact with bartender, I found that there was very little information on the Internet. I read all the information on their official website, what white papers, and guides. Our system is implemented by ASP. NET. After a period of learning, we know several integration modes of bartender. ActiveX COM integration, Commander triggered integration, and. Net SDK support after version 9.0. Let's briefly talk about these methods:
1. ActiveX COM: After bartender is installed on your machine, a com will be registered on the machine. You can call this COM in the program and use the methods and Attributes provided by it, program-level control of barrier. This integration method is more practical and has low requirements for the bartender version. However, because it is a basic use of COM, you are required to be familiar with the COM interface, the calling process and details of the entire barrier are clear. For details about the COM interface, refer to automation. CHM help document (under the seagull \ barw.suite \ barloud directory ).
2. Commander's trigger integration: In simple terms, this is to configure bargainer so that he can monitor a file. When the program generates this file, it will trigger the wake-up bargainer to print the file, I think this method is not easy to use, so I don't know much about it. You are welcome to discuss it.
3 ,.. Net SDK: This is an application that is supported by version 9.0.. NET Framework SDK, which provides many classes for bartender control, because this SDK is also used.. net integration is very convenient, but because there are requirements for the version, you need to consider the cost of the customer to use.
I.. Net SDK
Our project was used at the beginning. net SDK, because at that time it was not clear whether the customer needs to print on the server or the client, the boss asked to start research first, this is very irritating! It took a long time to say that the customer was going to print everything he had done on the client ~~
. The. net sdk has two parts: one is standard and the other is server. The standard is to simply enable the bartender process to process print tasks, therefore, when multiple tasks are printed at the same time, you need to manage the task queue problem by yourself. The server version has the task queue mechanism, it is very convenient to manage task queues and bartender process resources. However, server must be installed in the enterprise version of barrack. orz ~~ What is money ~~
1. the SDK actually calls COM at the underlying layer, but it is encapsulated to allow developers to perform better operations. The standard SDK should look at the help documentation, and their methods and attributes. The following code represents the simplest typical use:
First, add a reference. In the. NET tab, you can find seagull. barull. Print.
Then, add the namespace reference "Using seagull. barparts. Print;" to the program ;"
The simple use of the program is as follows:
// New an bartender Engine
Engine engine = new engine (true );
// Use the engine to open a format document to return a labelformatdocument object
Labelformatdocument format = engine. Documents. Open ("C: \ test. BTW ");
// Use the labelformatdocument object to print
Format. Print ("select printer", out messages );
After use, remember to recycle related resources.
2. For the server version SDK, I will describe its queue management details here, but you do not need to know these things when using the SDK alone, the usage is as simple as the standard SDK. You only need to refer to the help documentation and samples to understand it. Write out his queue management details for discussion only ~~ When you look at this part of the source code, you should first look at the thread-related knowledge.
1) the core of the program process is: Put the task into the task queue. If the task queue detects that there is a task in the queue, it will throw the task to the engine management, select an idle engine to execute the task.
2) The management task queue mainly uses the btpool class. The consume function in this class constantly checks whether the queue is empty. If it is not empty, the task is submitted, first through the engine. status! = Taskenginestatus. Busy to detect idle engines, and then submit the tasks to the engine through engine. submittask (this. m_mastertaskqueue.
In the submittask function, we can see the sentence that pays the thrown task to the task corresponding to the current engine:
This. m_task = tasks. dequeue ();
Then we can check the main class taskengine of the management engine. We can see that there is also a consume function in it. It constantly checks whether the task corresponding to the current engine is empty, and starts to execute the task if it is not empty.
Therefore, when the submittask function assigns the task to the task of the current engine through this. m_task = tasks. dequeue (), the task. Run () method of the task is started.
In the task. Run () method, when calling this. onrun () according to the characteristics of polymorphism, The onrun () method of the printlabelformattask class is called. In the onrun () method of the printlabelformattask class, the task is sent to the printer or printed as a file.
Btpool manages task queues and engine pools. Taskengine corresponds to an engine. Taskqueue is the queue-related operation class. Taskengines is the class for operations related to taskengine.
3. You may see the web browser printing example, which is written to the client. The printing of this client is actually done on the server, but what the server does is output the printed result as a print file, and then transfer the file to the client. The client then calls the local printer through javescript to read the print file for printing. This requires that both the server and client have the same printer driver, and the printer driver used when the client is actually printing should be consistent with the printer driver used to generate the print file on the server. Here are some materials for this method, for your reference only:
1) weblabelprint client Printing
// Print to a file
Labelformat. printsetup. printtofile = true;
// Set the printer
Labelformat. printsetup. printername = compatibleserverprinter;
// Set the license for the printer
Labelformat. printsetup. printtofilelicense = request. Form. Get (_ listprinters. printlicenseuniqueid );
String tempfullpath = (string) application ["tempfolderfullpath"];
// Set the path of the printed File
Labelformat. printsetup. printtofilename = system. Io. Path. Combine (tempfullpath, guid. newguid (). tostring () + ". PRN ");
2) After setting the above items, send the task to the task queue just like printing on a normal server. When the printing is complete, call the taskprint_succeeded function, which includes printtask. the printcode is read and sent to the local printer for printing.
3) clientprinting. JS: The getclientprinters function is used on the printlist. ASPX page. The files bartenderprintclient. js and weblabelprintsample. js are used to print the client.
4) bartenderprintclient. the JS file mainly contains some printer operations, such as obtaining the printer list, matching the printer on the server and client, obtaining the license of the printer, and sending the print code to the corresponding printer.
5) The weblabelprintsample. js file includes filling the Client Printer list into the dropdownlist (printlistcontrol. ascx) and filling the Client Printer list into the table (printers. aspx ).
Ii. ActiveX com
After I had read the SDK for a long time and decompiled his source code for a few weeks, the boss said that he would print it on the client ~~ In a short time, you can see that ~~ I told the boss about the printing method of the kind of students above and then sent to the client. The boss said no. It is best to communicate less with the server because their network environment is not very good ~~ Depressed ~~ With the senior reminder, I started to study ActiveX ~~ The main idea is to create an ActiveX plug-in, install it on the client when entering the page, and then control bartender on the client machine ~~ Since ActiveX is used, you can use the simplest com provided by barrier ~
The main classes in COM are as follows:
1) application class: actually represents a bartender process. When you create a new class object, a new bartender process will appear.
2) format class: actually represents a format tag (BTW file). You can use application. formats. open () to open and return a format object. This class contains printing settings, tag parameter settings, and a series of other settings, a very important class.
3) namedsubstring class: manage all substring classes in the Tag file.
4) Database Class: manages all database links set in the Tag file.
5) querypromts class: class used to manage database query parameters in tag files.
Since the format class is an important class, its related attributes and methods are also described here:
1) print method: This is the most common printing method. You can set the printed Task Name, whether to wait for the printing to complete, wait for the timeout time, and print the output information.
2) Printout method: If you need to display the print Setting Dialog Box and status box during printing, you can select this method.
3) Save method: Save the changes to the format.
4) setnamedsubstringvalue method: sets the value of a specific substring. This method can be used to dynamically change the printed content.
5) setpromt method: The setnamedsubstringvalue method is similar to the setnamedsubstringvalue method. However, it is set to print the prompt value. Some labels can pop up a dialog box when printing, enter the value of some variables to change the printed content. This method is to dynamically set these variables. However, it is rarely used in integration.
6) identicalcopiesoflabel attribute: This attribute sets the number of identical tags to be printed during printing. The default setting is label.
7) numberserializedlabels attribute: This attribute is used for serialized printing. When your tag starts serialization, this attribute represents the number of printed copies. For example, if your initial serialization data is 1, if the increment value is 1 and the numberserializedlabels value is 5, the labels 1, 2, 3, 4, and 5 are printed.
8) printer attribute: Specifies the printer to be used. The default printer is specified by the system by default.
9) printtofile attribute: Indicates whether to print the physical object with the printer immediately or generate a print file.
Through the explanation of the above method, we can see that there are several ways to dynamically control the printed content. I used the above two methods in the project, one is to directly set the value of some variables through the setnamedsubstringvalue method, and then print them. This is suitable for a small amount of printing, because each time you call the application and format object for processing, therefore, it takes 100 calls to print one hundred copies, which is less efficient. However, you can flexibly set the content to be printed each time. Another method is to use serialized printing, which is more efficient, this is because he only calls the command to throw data to barriers once, and then generates printed content based on the serialization rules. However, this method lacks flexibility, only applicable to label content is a regular change of the large batch printing.
The database and querypromts classes are also mentioned above. These two classes are used to print the connected database. This is the third method I used to dynamically control the printed content. The main idea is to set the content in the tag, which corresponds to some fields of the database, and then set the query conditions to expose one or more query parameters, then, the querypromts class is used in the program to set these query parameters to query different database content, so as to dynamically change the printed content. Format. Databases. queryprompts. getqueryprompt () can be used to set specific query conditions, set the value by setting the value attribute, and print all query conditions.
The methods for dynamically controlling printed content are designed to work with Tag files and programs, but they are not flexible. In fact, they can be used for better dynamic configuration, but the boss said there was no need to give up. If a friend does not know the design of the Tag file, I have time to write an article dedicated to the design of the Tag file.
Iii. Integration
With the above introduction, you have a certain understanding of the Integration Information provided by barriers. I used ActiveX COM and printed it on the client. So I also made a pseudo ActiveX plug-in. Why is it "pseudo? It is called "pseudo" because it is not ActiveX in the traditional sense, but written in C # (regret that he didn't learn C ++ in the past ". On the production of pseudo ActiveX, there is a good tutorial on the internet, I am here to give a link to calculate (http://www.cnblogs.com/homer/archive/2005/01/04/86473.html ).
After ActiveX is deployed and determined, JavaScript is required to call ActiveX plug-in on the webpage. The following code is provided on the webpage where ActiveX is deployed:
<Object ID = "btdprintclient" classid = "CLSID: {0750a7b0-cf1e-4ead-8c73-e0c8f6d9e890}" codebase = "CAB/bartender_ax.cab"> </Object>
Here, we also remind you that the name of the second attribute is classid, and the first character of the string set in it is CLSID, which is different. I didn't pay attention to it at the time, it has been deployed for a long time.
Return to the Javascript call. During the call, the following code is used:
Printclient = new activexobject ("btdprintclient. printclient ");
It should be well understood here, that is, to create the printclient object in the btdprintclient object. After this sentence is completed, printclient is equivalent to a printclient object. You can call various method attributes of printclient in Javascript, so you can control the local bartender.
Iv. Summary
To integrate things, I think you must first understand the software to be integrated. You can search for materials and official documents online, the most important thing is some help documents and API documents of the software. The basic software information is included. In addition, I also contacted the technical support of Barkley's Asia Pacific region for this integration, which also brought me a lot of help, although they only need to purchase products to provide support, however, the preliminary support is still available. You only need to tell them that you are using their trial version for integration testing and decide whether to purchase products if you want to see the effect. Haha ~~ Lure ~~
We also recommend that you do more work when creating a new item. Do some demo to verify the idea and debug the tracing carefully. There is no way to understand one thing without doing it.