Program.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.IO;
  3. using System.Threading;
  4. namespace WebService.Test
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. //WebServiceClient.Instance.Polling();
  11. }
  12. }
  13. /// <summary>
  14. /// 导出为word
  15. /// </summary>
  16. public class ExportWordHelper
  17. {
  18. ///// <summary>
  19. ///// 导出html 到word
  20. ///// </summary>
  21. ///// <param name="info">待导出数据</param>
  22. ///// <param name="wordFilePath">导出磁盘地址</param>
  23. ///// <param name="fileTempPath">doc模板文件(含书签)磁盘地址</param>
  24. //public static void ExportHtmlToWord(string info, string wordFilePath, string fileTempPath)
  25. //{
  26. // //string fileTempPath = Server.MapPath("~/Templates/NCR.docx");
  27. // //载入模板
  28. // Aspose.Words.Document doc = new Aspose.Words.Document(fileTempPath);
  29. // Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  30. // builder.InsertHtml(content);//含html的文章内容
  31. // // doc.Save("E:/DownLoadWord/DocumentBuilder.InsertTableFromHtml Out.doc");
  32. // doc.Save(wordFilePath);
  33. //}
  34. }
  35. public class WebServiceClient
  36. {
  37. private static WebServiceClient _instance;
  38. public static WebServiceClient Instance => _instance ?? (_instance = new WebServiceClient());
  39. public WebServiceClient()
  40. {
  41. //Client = new SmartPlanWebServiceClient();
  42. _switch = true;
  43. }
  44. // public SmartPlanWebServiceClient Client { get; set; }
  45. private string Id { get; set; }
  46. private bool _switch;
  47. public void OnSwitch()
  48. {
  49. _switch = true;
  50. }
  51. public void OffSwitch()
  52. {
  53. _switch = false;
  54. }
  55. public void Polling()
  56. {
  57. while (_switch)
  58. {
  59. //Query();
  60. Thread.Sleep(1000 * 5);
  61. }
  62. }
  63. //public void Query()
  64. //{
  65. // var result = Client.QueryAction();
  66. // if (result.Success)
  67. // {
  68. // if (result.Id != Id)
  69. // {
  70. // Id = result.Id;
  71. // Console.WriteLine($"\r\n接受新指令 【{Id}】");
  72. // //TODO 接受到新指令需要做的 5-10s模拟程序处理
  73. // Thread.Sleep(1000 * new Random().Next(5, 10));
  74. // Complete();
  75. // }
  76. // else
  77. // {
  78. // Console.Write(".");
  79. // }
  80. // }
  81. // //return result;
  82. //}
  83. //public AjaxResultWs Complete()
  84. //{
  85. // var result = Client.CompleteAction(Id);
  86. // return result;
  87. //}
  88. }
  89. }