电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

套打.二开案例.表单插件中获取默认打印机

来源:金蝶云社区作者:金蝶2024-09-238

套打.二开案例.表单插件中获取默认打印机

<0>效果

image.webp


<1>实现

通过前端QueryPrinterInfo指令获取打印机信息。image.webp

image.webp

image.webp

[Kingdee.BOS.Util.HotUpdate]

    [Description("获取打印机信息")]

    public class PrinterSamplePlugIn : AbstractListPlugIn

    {

        //超时时间

        private int timeoutMilliseconds = 10000;

        //默认打印机线程同步开关

        private ManualResetEvent manualEvent = new ManualResetEvent(false);

        //打印机查询信息结果

        private KDPrinterQueryInfoResult printerQueryInfoResult;

        //打印机查询信息请求

        private KDPrinterQueryInfoArg printerQueryInfoArg;


        private static readonly string QueryPrinterInfo = "QueryPrinterInfo";


        public override void CustomEvents(CustomEventsArgs e)

        {

            if (e == null)

                return;

            if (e.EventName == QueryPrinterInfo)

            {

                try

                {

                    KDPrinterQueryInfoResult result = JSONObject.Parse(e.EventArgs).ConvertToObject<KDPrinterQueryInfoResult>();

                    //命令区分

                    if (result.JobId == printerQueryInfoArg.JobId)

                        printerQueryInfoResult = result;

                }

                catch

                {

                    //代码跑到这个位置代表着转换失败,考虑是否插件没有升级,打印服务有没有升级的兼容

                }

                finally

                {

                    manualEvent.Set();

                }

            }

        }


        public override void BarItemClick(BarItemClickEventArgs e)

        {

            if (e.BarItemKey.EqualsIgnoreCase("GetDefPrinter"))

                if (printerQueryInfoArg != null)

                {

                    return;

                }

            manualEvent.Reset();

            printerQueryInfoResult = null;

            printerQueryInfoArg = new KDPrinterQueryInfoArg()

            {

                IsDialog = false,

                IsDefaultInfo = true,

                IncludeAll = false,

                JobId = Guid.NewGuid().ToString(),

                PrintAddress = string.Empty,

            };

            this.View.AddAction(QueryPrinterInfo, printerQueryInfoArg);

            this.View.ShowProcessForm((x) =>

            {

                var result = GetPrinterResult();

                this.View.ShowOperateResult(result);

                printerQueryInfoResult = null;

                printerQueryInfoArg = null;

            }, "获取默认打印机配置...");

            MainWorker.QuequeTask(this.View.Context, () =>

            {

                try

                {

                    System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));

                    manualEvent.WaitOne(timeoutMilliseconds);

                }

                catch (Exception ex)

                {


                }

                finally

             

套打.二开案例.表单插件中获取默认打印机

<0>效果<1>实现通过前端QueryPrinterInfo指令获取打印机信息。[Kingdee.BOS.Util.HotUpdate] [Description("获取打印机信息")] p...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信