Exemplo n.º 1
0
        private async Task Print()
        {
            await Task.Run(() =>
            {
                Log.Instance.Logger.Info($"触发打印!");
                if (this.SelectedBtwFile == null)
                {
                    Log.Instance.Logger.Error($"未选择任何文件,退出打印!");
                    return;
                }
                if (LabelOperator.isObjectExistingFile(this.SelectedBtwFile))
                {
                    if (this.BtEngine == null)
                    {
                        Log.Instance.Logger.Error($"bartender未正确初始化,无法打印!");
                        return;
                    }
                    Log.Instance.Logger.Info($"准备打印{this.SelectedBtwFile}!");

                    string obarcodeHistroySuffix;
                    LabelFormatDocument label =
                        this.SetLabelValues(this.SelectedBtwFile, out obarcodeHistroySuffix);
                    if (this.SelectedBtwFile == null)
                    {
                        Log.Instance.Logger.Error($"未选择任何文件,退出打印!");
                        return;
                    }
                    string BtwTemplate = this.SelectedBtwFile.Replace(
                        Constants.btwTopDir, "");
                    SqliteHistory.InsertPrintHistroy(
                        BtwTemplate,
                        obarcodeHistroySuffix);
#if DEBUG
                    this.Message = "DEBUG跳过真实打印";
#else
                    string msg = BtwPrintWrapper.PrintBtwFile(label, this.BtEngine);
                    //BtwPrintWrapper.PrintPreviewLabel2File(label, this.BtEngine);
                    this.Message = msg.Trim();
#endif
                }
                else
                {
                    Log.Instance.Logger.Error($"无法打印,文件不存在:{this.SelectedBtwFile}!");
                }
            });
        }