PublicModuleService.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:PublicModuleService.cs
  5. * 2.功能描述:公开查询模块服务
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2015/11/03 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.IO;
  13. using System.ServiceModel;
  14. using System.ServiceModel.Activation;
  15. using Dongke.IBOSS.PRD.Basics.Library;
  16. using Dongke.IBOSS.PRD.Service.DKIBOSSPRDLogic;
  17. using Dongke.IBOSS.PRD.Service.PublicModuleService;
  18. using Dongke.IBOSS.PRD.WCF.Contracts;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. namespace Dongke.IBOSS.PRD.WCF.Services
  21. {
  22. /// <summary>
  23. /// 公开查询模块服务
  24. /// </summary>
  25. // 服务实现类,继承服务声明接口
  26. // 该标签声明该服务可以在ASP.NET下运行
  27. [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  28. [ServiceBehavior(ConfigurationName = "PublicModuleService",
  29. InstanceContextMode = InstanceContextMode.PerCall,
  30. ConcurrencyMode = ConcurrencyMode.Multiple,
  31. UseSynchronizationContext = false)]
  32. public class PublicModuleService : IPublicModule
  33. {
  34. #region 客户端升级
  35. /// <summary>
  36. /// 客户端升级判断
  37. /// </summary>
  38. /// <param name="version">客户端版本号</param>
  39. /// <returns>客户端是否需要更新信息</returns>
  40. public NeedUpgradeResultEntity IsNeedUpgrade(string version)
  41. {
  42. try
  43. {
  44. string serverVersion = INIUtility.Instance(INIUtility.IniFile.Config).ReadIniData("VersionSetting", "PublicClientVersion");
  45. NeedUpgradeResultEntity result = new NeedUpgradeResultEntity();
  46. result.ServerVersion = serverVersion;
  47. result.UpgradeState = false;
  48. result.GradeInfo = "";
  49. string[] versions = version.Split('.');
  50. string[] serverVersions = serverVersion.Split('.');
  51. if (versions == null || serverVersions == null || versions.Length != 4 || serverVersions.Length != 4)
  52. {
  53. return result;
  54. }
  55. for (int j = 0; j < versions.Length; j++)
  56. {
  57. if (Convert.ToInt32(serverVersions[j]) > Convert.ToInt32(versions[j]))
  58. {
  59. result.UpgradeState = true;
  60. break;
  61. }
  62. }
  63. return result;
  64. }
  65. catch (Exception ex)
  66. {
  67. OutputLog.TraceLog(LogPriority.Error,
  68. this.ToString(),
  69. System.Reflection.MethodBase.GetCurrentMethod().Name,
  70. ex.ToString(),
  71. LocalPath.LogExePath);
  72. throw ex;
  73. }
  74. }
  75. /// <summary>
  76. /// 升级文件读取时,用的统一锁。
  77. /// </summary>
  78. private static object _downloadUpgradeFile = new object();
  79. /// <summary>
  80. /// 下载更新程序
  81. /// </summary>
  82. /// <returns>更新程序</returns>
  83. public byte[] DownloadUpgradeFile()
  84. {
  85. try
  86. {
  87. string filePath = INIUtility.Instance(INIUtility.IniFile.Config).ReadIniData("PathSetting", "UpgradePublicDownLoadPath");//ConfigurationManager.AppSettings["UpgradeDownLoadPath"];
  88. // 取得WEB服务器上的文件全路径
  89. string fileFullPath = System.AppDomain.CurrentDomain.BaseDirectory + filePath;
  90. lock (_downloadUpgradeFile)
  91. {
  92. if (!Directory.Exists(fileFullPath))
  93. {
  94. Directory.CreateDirectory(fileFullPath);
  95. }
  96. // zip 压缩
  97. string zipPath = fileFullPath + @"-UpgradePublic.up";
  98. if (!File.Exists(zipPath))
  99. {
  100. ZipFileClass.DirectoryToZip(fileFullPath, zipPath);
  101. }
  102. // 文件存在,则将文件读入文件流中返回
  103. if (File.Exists(zipPath))
  104. {
  105. using (FileStream fileStream = new FileStream(zipPath, FileMode.Open, FileAccess.Read))
  106. {
  107. BinaryReader binaryReader = new BinaryReader(fileStream);
  108. return binaryReader.ReadBytes((int)fileStream.Length);
  109. }
  110. }
  111. }
  112. return null;
  113. }
  114. catch (Exception ex)
  115. {
  116. OutputLog.TraceLog(LogPriority.Error,
  117. this.ToString(),
  118. System.Reflection.MethodBase.GetCurrentMethod().Name,
  119. ex.ToString(),
  120. LocalPath.LogExePath);
  121. throw ex;
  122. }
  123. }
  124. #endregion
  125. /// <summary>
  126. /// 取得FP00002画面(工号产量质量)的查询数据
  127. /// </summary>
  128. /// <param name="usercode">工号</param>
  129. /// <returns>查询结果</returns>
  130. public ServiceResultEntity GetFP00002Data(int accountID, string usercode, DateTime date)
  131. {
  132. return ServiceInvoker.Invoke(this, () => PublicModuleLogic.GetFP00002Data(accountID, usercode, date));
  133. }
  134. public ServiceResultEntity GetRptProcedureModule(int accountID)
  135. {
  136. return ServiceInvoker.Invoke(this, () => PublicModuleLogic.GetRptProcedureModule(accountID));
  137. }
  138. public ServiceResultEntity GetRptSourceProcedureModule(int accountid, int? RptProcedureID)
  139. {
  140. return ServiceInvoker.Invoke(this, () => PublicModuleLogic.GetRptSourceProcedureModule(accountid, RptProcedureID));
  141. }
  142. }
  143. }