Passing Template Startup Command for more than 3 templates not working フォローする

0
Avatar
Pratip Bagchi

I am planning to cache 7 templates that we use in our application before starting the Bartender engines. The moment I am adding more than 3 templates in the start up command  I am getting error "The task queue must be running before submission of tasks are accepted. Restart all print engines and resubmit the task"

Is there a limitation on number of template can be used in the template startup command? 

Note : we are running this code in the box where we have 5 printer licenses.

TemplateStartupCommand:/F="\\Tcodata\APP_DATA\PrintTemplate\1.btw"/F="\\Tcodata\APP_DATA\PrintTemplate\2.btw"/F="\\Tcodata\APP_DATA\PrintTemplate\TicketPrint\PrintTemplate\3.btw"/F="\\Tcodata\APP_DATA\PrintTemplate\4.btw"

 

Code:

public class TaskManagerWrapper : IDisposable
{

// TaskManager field
TaskManager m_taskManager = null;
ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// This object should be locked when manipulating the TaskManager field
// This is for thread safety in this class and child classes

protected object m_taskManagerLock = new object();
// Returns true if TaskManager is currently instantiated, otherwise false
protected bool IsTaskManagerInstantiated
{
get
{
lock (m_taskManagerLock)
{
return m_taskManager != null;
}
}
}

internal string TemplateStartupCommand { get; set; }

// This property provides lazy instantiation for the TaskManager
// Most methods in this class should utilize this property to access
// the TaskManager

protected TaskManager BtTaskManager
{
get
{

lock (m_taskManagerLock)
{
// If the TaskManager hasn't been created yet, then create it
if (!IsTaskManagerInstantiated)
{
int initialEngineCount = 5;
m_taskManager = new TaskManager();

//This gets all distinct templates from the source DB
var templates = TemplateHelper.GetTemplates().DistinctBy(t => t.BarTenderFileName).ToList();

foreach (var template in templates)
{
string printerTemplateLocation = ConfigurationManager.AppSettings["PrintTemplateMappingPath"] + template.BarTenderFileName;
TemplateStartupCommand = TemplateStartupCommand + string.Format("/F=\"{0}\"", printerTemplateLocation);
}
m_taskManager.StartupCommand = TemplateStartupCommand;
Log.Info("TemplateStartupCommand:" + TemplateStartupCommand);
// Starting five engines will create five BarTender processes
Log.Info("Starting Engines Count:" + initialEngineCount);

m_taskManager.Start(initialEngineCount);

}

return m_taskManager;
}
}
}
// Implement IDisposable
public virtual void Dispose()
{
// Lock to manipulate TaskManager field
lock (m_taskManagerLock)
{
// Only dispose of the taskManager if it was created. Be sure to use
// the field here, using the property may cause it to be created.
if (m_taskManager != null)
{
// Give the TaskManager ten seconds to stop, if it doesn't, then force terminate
m_taskManager.Stop(10000, true);
m_taskManager.Dispose();
}
}
}
// This method will print the given format to the printer with PrinterName
public void PrintLabelFormat(PrintLabelFormatTask printTask)
{
lock (m_taskManagerLock)
{
try
{
// Queue the task so it will be processed asynchronously
BtTaskManager.TaskQueue.QueueTask(printTask);
}
catch(Exception ex)
{

Log.Error("Error in creating PrintLabelFormat. Message:" + ex.Message + "Stack Trace:" + ex.StackTrace);
}
}
}


}

 

ログインしてコメントを残してください。