| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System;
- using System.IO;
- using System.Threading;
- namespace WebService.Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- //WebServiceClient.Instance.Polling();
- }
-
- }
- /// <summary>
- /// 导出为word
- /// </summary>
- public class ExportWordHelper
- {
- ///// <summary>
- ///// 导出html 到word
- ///// </summary>
- ///// <param name="info">待导出数据</param>
- ///// <param name="wordFilePath">导出磁盘地址</param>
- ///// <param name="fileTempPath">doc模板文件(含书签)磁盘地址</param>
- //public static void ExportHtmlToWord(string info, string wordFilePath, string fileTempPath)
- //{
- // //string fileTempPath = Server.MapPath("~/Templates/NCR.docx");
- // //载入模板
- // Aspose.Words.Document doc = new Aspose.Words.Document(fileTempPath);
- // Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
-
- // builder.InsertHtml(content);//含html的文章内容
- // // doc.Save("E:/DownLoadWord/DocumentBuilder.InsertTableFromHtml Out.doc");
- // doc.Save(wordFilePath);
- //}
- }
- public class WebServiceClient
- {
- private static WebServiceClient _instance;
- public static WebServiceClient Instance => _instance ?? (_instance = new WebServiceClient());
- public WebServiceClient()
- {
- //Client = new SmartPlanWebServiceClient();
- _switch = true;
- }
- // public SmartPlanWebServiceClient Client { get; set; }
- private string Id { get; set; }
- private bool _switch;
- public void OnSwitch()
- {
- _switch = true;
- }
- public void OffSwitch()
- {
- _switch = false;
- }
- public void Polling()
- {
- while (_switch)
- {
- //Query();
- Thread.Sleep(1000 * 5);
- }
- }
- //public void Query()
- //{
- // var result = Client.QueryAction();
- // if (result.Success)
- // {
- // if (result.Id != Id)
- // {
- // Id = result.Id;
- // Console.WriteLine($"\r\n接受新指令 【{Id}】");
- // //TODO 接受到新指令需要做的 5-10s模拟程序处理
- // Thread.Sleep(1000 * new Random().Next(5, 10));
- // Complete();
- // }
- // else
- // {
- // Console.Write(".");
- // }
- // }
- // //return result;
- //}
- //public AjaxResultWs Complete()
- //{
- // var result = Client.CompleteAction(Id);
- // return result;
- //}
- }
- }
|