• <video id="g6cmf"></video>
    C# 調(diào)用打印機(jī)API - APISample c# 標(biāo)簽打印范例代碼,,C# 打印, C#實(shí)現(xiàn)打印,C#調(diào)用打印機(jī), C# 打印API,C# 打印報(bào)表,CSharp標(biāo)簽打印,CSharp單據(jù)打印 ,CCPrintingAPI , C# 打印范例代碼,C#標(biāo)簽打印,條碼,二維碼標(biāo)簽,C# 單據(jù)打印,很容易集成。
    CCPrintingAPI XI
    輕量、簡(jiǎn)潔、穩(wěn)定、可靠,通用的打印機(jī)API接口,支持近百個(gè)品牌,數(shù)千個(gè)型號(hào)打印機(jī)。
    打印機(jī)接口API C# 范例代碼
    C#
    CCPrintingAPI C# API打印范例代碼,C#調(diào)用打印機(jī),調(diào)用CCPrintingAPI打印機(jī)接口API。

    1. 引入 CCPrintingApiNet.dll
    引入CCPrintingApiNet.dll后,即可使用API的相關(guān)方法,進(jìn)行設(shè)置和打印操作。
    CCPrintingApiNet CCPrintingAPI = null;
    CCPrintingAPI = new CCPrintingApiNet();
    //獲取HID
    GetHID(m_OpenId, m_Tokens);
    //獲取所有打印機(jī)
    GetPrinters(m_OpenId, m_Tokens,6789);    
    //打印
    Print(m_OpenId, m_Tokens,6789);  
    2. 獲取打印機(jī)
    獲取計(jì)算機(jī)上所有打印機(jī), 打印時(shí),指定該列表的打印機(jī)名稱。如果能確保打印機(jī)名稱不變,該操作也可省去。
    public void GetPrinters(String openid,String token,int itemid){
         ConfigPrintSettings cfgData = new ConfigPrintSettings() ;
         cfgData.XAction = "Printers";
         cfgData.XOpenId = openid;
         cfgData.XTokens = token;
         cfgData.ItemID = itemid;
         CCPrintingAPI.Excute(cfgData, (status, arg0, sessionid) =>
                {
                    Console.WriteLine(string.Format("Excute Status:{0}, SessionId:{1}", status, sessionid));
                    if (arg0 == null || arg0.Length == 0) return;
                    Console.WriteLine(string.Format("Excute Result:{0}", string.Join(" ", arg0)));
                });
    }
    3. 打印
    進(jìn)行相關(guān)參數(shù)設(shè)置后(指定打印機(jī),設(shè)置模板,設(shè)置打印數(shù)據(jù)),將指令通過(guò)API傳給打印機(jī)。
    public void Print(String openid,String token,int itemid){
    ConfigPrintSettings cfgData = GetPrintSettings(openid, token, itemid);
    CCPrintingAPI.Excute(cfgData, (status, arg0, sessionid) =>
    {
         Console.WriteLine(string.Format("Excute Status:{0}, SessionId:{1}", status, sessionid));
          if (arg0 == null || arg0.Length == 0) return;
          Console.WriteLine(string.Format("Excute Result:{0}", string.Join(" ", arg0)));
      });
    }
    
      
    private ConfigPrintSettings GetPrintSettings(string openid, string token, int itemid)
    {
            DataTable prtdata = new DataTable("PrintData");
            prtdata.Columns.Add("Field1", typeof(string));
            prtdata.Columns.Add("Field2", typeof(string));
            prtdata.Columns.Add("Field3", typeof(string));
            prtdata.Columns.Add("Field4", typeof(string));
    
            DataRow row = prtdata.NewRow();
            row["Field1"] = "CCPrintingAPI";
            row["Field2"] = ".Net 標(biāo)簽打印開(kāi)發(fā)接口";
            row["Field3"] = "901201251002404";
            row["Field4"] = "325435";
            prtdata.Rows.Add(row);
            prtdata.AcceptChanges();
    
            //指定打印機(jī)名稱
            string selPrinter = "Deli DL-888C";
            /*打印參數(shù)配置,打印數(shù)據(jù)設(shè)置*/
            ConfigPrintSettings cfgData = new ConfigPrintSettings();
            cfgData.XAction = "Print";
            cfgData.XOpenId = openid;
            cfgData.XTokens = token;
            cfgData.ItemID = itemid;
            /*指定打印機(jī)名稱,不使用默認(rèn)打印機(jī)時(shí),為空,則使用配置的打印機(jī)*/
            cfgData.PrinterName = selPrinter;
            /*0-打印,3-獲取打印預(yù)覽*/
            cfgData.Preview = 0;
            /*模板方式,0-客戶端模板,1-遠(yuǎn)程模板,2-如果本地模板存在,使用本地,不存在使用遠(yuǎn)程模板,3-不使用模板*/
            cfgData.TemplateMode = 1;
            /*遠(yuǎn)程模板URL*/
            cfgData.TemplateURL = "http://img.51321.cn/web/chicore/VPrinting/API";
            //cfgPrintSettings.TemplateURL = "E:\\臨時(shí)數(shù)據(jù)\\打印\\打印樣本\\智能制造";
            cfgData.TemplateName = "984.Lblx";
            /*打印數(shù)據(jù)的類型,0-數(shù)組,1-Json數(shù)組,元素為JSON對(duì)象,字段:值 , JSON.stringify(prtData) 2 Datatable*/
            cfgData.PrintDataType = 2;
            /*打印數(shù)據(jù)*/
            cfgData.PrintData = prtdata;
            return cfgData;
    }
    4. 讀取客戶端HID
    讀取安裝CCPrintingAPI的客戶端計(jì)算機(jī)HID,該HID可以用來(lái)標(biāo)識(shí)計(jì)算機(jī)。該方法,根據(jù)需要使用。
    public void GetHID(String openid,String token){
    ConfigPrintSettings cfgData = new ConfigPrintSettings() ;
    cfgData.XAction = "HID";
    cfgData.XOpenId = openid;
    cfgData.XTokens = token;
    CCPrintingAPI.Excute(cfgData, (status, arg0, sessionid) =>
     {
            Console.WriteLine(string.Format("Excute Status:{0}, SessionId:{1}", status, sessionid));
             if (arg0 == null || arg0.Length == 0) return;
             Console.WriteLine(string.Format("Excute Result:{0}", string.Join(" ", arg0)));
       });
    }
    亚洲日本乱码一区二区在线二产线_亚洲欧美色中文字幕在线_国产精品美女久久久免费_加勒比无码专区中文字幕

  • <video id="g6cmf"></video>
    亚洲福利院在线看AV | 熟女50岁一区二区 | 亚洲无AV码一区二区三区 | 欧美日韩精品一区二区在线播放 | 久久精品男人资源 | 亚洲女性性爱视频在线观看 |