| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- namespace ESCARLETPrint
- {
- public class ESCARLETPrint
- {
- /// <summary>
- /// 电子发票网址打印
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public string PrintESCARLETUrl(string input)
- {
- System.Diagnostics.Debugger.Launch();
- String errorCode = "0";
- String errorMessage = "";
- JObject output = new JObject();
- JArray fileStringArray = new JArray();
- try
- {
- Thread thread;
- dynamic inputobj = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(input);
- var paramsobj = inputobj["params"][0];
- thread = new Thread(() => Print());
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.Start();
- thread.Join();
- }
- catch (Exception ex)
- {
- errorMessage = ex.Message;
- }
- output.Add("errorCode", errorCode);
- output.Add("errorMessage", errorMessage);
- return output.ToString();
- }
- private JObject Print()
- {
- JObject output = new JObject();
- try
- {
- for (int i = 0; i < 50; i++)
- {
- Thread.Sleep(500);
- }
- }
- catch (Exception ex2)
- {
- }
- return output;
- }
- }
- }
|