ADServiceHelper.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PDF_Master.Properties;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Drawing;
  7. using System.Drawing.Imaging;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Management;
  11. using System.Net;
  12. using System.Runtime.InteropServices;
  13. using System.Security.Cryptography;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. namespace PDF_Master.Helper
  17. {
  18. //本辅助类不使用viewmodel,因为同时在PDFreaderPro上使用
  19. public static class ADServiceHelper
  20. {
  21. #if DEBUG
  22. public static string RequestHost = "http://test-store.kdan.cn:3019";
  23. #else
  24. public static string RequestHost = "https://store.filmagepro.com:3018";
  25. #endif
  26. public static string AdUrl = "/api/advertise-new";
  27. public static String GetAD(string appname)
  28. {
  29. string FileNameMac = App.CachePath.ADFilePath + "\\" + "Mac" + ".png";
  30. string FileNameiPad = App.CachePath.ADFilePath + "\\" + "iPad" + ".png";
  31. string FileNameAndroid = App.CachePath.ADFilePath + "\\" + "Android" + ".png";
  32. string FileNameComPDFKit = App.CachePath.ADFilePath + "\\" + "ComPDFKit" + ".png";
  33. string FileNameComVideoKit = App.CachePath.ADFilePath + "\\" + "ComVideoKit" + ".png";
  34. string FileNameSignFlow = App.CachePath.ADFilePath + "\\" + "SignFlow" + ".png";
  35. string FileNameFilmageEditor = App.CachePath.ADFilePath + "\\" + "FilmageEditor" + ".png";
  36. string FileNameFilmageScreen = App.CachePath.ADFilePath + "\\" + "FilmageScreen" + ".png";
  37. string FileNameFreePDFTemplates = App.CachePath.ADFilePath + "\\" + "FreePDFTemplates" + ".png";
  38. string FileNameBlackFriday = App.CachePath.ADFilePath + "\\" + "advertisement" + ".png";
  39. HttpWebResponse response = null;
  40. ServicePointManager.DefaultConnectionLimit = 200;
  41. string post = $"?app_name={appname}";
  42. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + AdUrl+post);
  43. request.Method = "Get";
  44. request.ContentType = "text/html;charset=UTF-8";
  45. //request.Accept = "application/vnd.api+json;version=1";
  46. request.Timeout = 20000;
  47. request.ServicePoint.Expect100Continue = false;
  48. try
  49. {
  50. response = (HttpWebResponse)request.GetResponse();
  51. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  52. {
  53. string responseData = reader.ReadToEnd();
  54. Console.WriteLine(responseData);
  55. reader.Close();
  56. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  57. if (response != null)
  58. {
  59. response.Close();
  60. }
  61. if (request != null)
  62. {
  63. request.Abort();
  64. }
  65. Console.WriteLine(responseData);
  66. if (jobject["code"].ToObject<string>().ToLower() == "200")
  67. {
  68. // 从 JObject 获取 list 数组
  69. JArray list = (JArray)jobject["list"];
  70. JObject RecommondContentPDFPro = (JObject)JObject.Parse(list[0]["detail"].ToString())["recommondContent"][0]["RecommondContentPDFPro"];
  71. JObject RecommondContentOther = (JObject)JObject.Parse(list[0]["detail"].ToString())["recommondContent"][0]["RecommondContentOther"];
  72. JArray advertisement = (JArray)JObject.Parse(list[0]["detail"].ToString())["advertisement"];
  73. #region RecommondContentPDFPro参数配置
  74. Settings.Default.ADDate.RecommondContentPDFPro_nameen = RecommondContentPDFPro["name"]["en"].ToString();
  75. Settings.Default.ADDate.RecommondContentPDFPro_namezh_CN = RecommondContentPDFPro["name"]["zh_CN"].ToString();
  76. Settings.Default.ADDate.RecommondContentPDFPro_namezh_TW = RecommondContentPDFPro["name"]["zh_TW"].ToString();
  77. //RecommondPDFPro
  78. JArray RecommondPDFPro = (JArray)RecommondContentPDFPro["content"];
  79. //recommondPDF - Mac
  80. Settings.Default.ADDate.RecommondPDFPro_Macshow = RecommondPDFPro[0]["show"].ToString();
  81. Settings.Default.ADDate.RecommondPDFPro_Mactype = RecommondPDFPro[0]["type"].ToString();
  82. Settings.Default.ADDate.RecommondPDFPro_MacsubscriptionType = RecommondPDFPro[0]["subscriptionType"].ToString();
  83. Settings.Default.ADDate.RecommondPDFPro_MacstartTime = RecommondPDFPro[0]["startTime"].ToObject<long>();
  84. Settings.Default.ADDate.RecommondPDFPro_MacendTime = RecommondPDFPro[0]["endTime"].ToObject<long>();
  85. Settings.Default.ADDate.RecommondPDFPro_Macnameen = RecommondPDFPro[0]["name"]["en"].ToString();
  86. Settings.Default.ADDate.RecommondPDFPro_Macnamezh_CN = RecommondPDFPro[0]["name"]["zh_CN"].ToString();
  87. Settings.Default.ADDate.RecommondPDFPro_Macnamezh_TW = RecommondPDFPro[0]["name"]["zh_TW"].ToString();
  88. Settings.Default.ADDate.RecommondPDFPro_Mactooltipen = RecommondPDFPro[0]["tooltip"]["en"].ToString();
  89. Settings.Default.ADDate.RecommondPDFPro_Mactooltipzh_CN = RecommondPDFPro[0]["tooltip"]["zh_CN"].ToString();
  90. Settings.Default.ADDate.RecommondPDFPro_Mactooltipzh_TW = RecommondPDFPro[0]["tooltip"]["zh_TW"].ToString();
  91. Settings.Default.ADDate.RecommondPDFPro_MaclinkURLen = RecommondPDFPro[0]["linkURL"]["en"].ToString();
  92. Settings.Default.ADDate.RecommondPDFPro_MaclinkURLzh_CN = RecommondPDFPro[0]["linkURL"]["zh_CN"].ToString();
  93. Settings.Default.ADDate.RecommondPDFPro_MaclinkURLzh_TW = RecommondPDFPro[0]["linkURL"]["zh_TW"].ToString();
  94. Settings.Default.ADDate.RecommondPDFPro_Macimagenormal = RecommondPDFPro[0]["image"]["normal_Light"].ToString();
  95. Settings.Default.ADDate.RecommondPDFPro_Macimagehover = RecommondPDFPro[0]["image"]["hover_Light"].ToString();
  96. Settings.Default.ADDate.RecommondPDFPro_Macimageen = RecommondPDFPro[0]["image"]["en"].ToString();
  97. Settings.Default.ADDate.RecommondPDFPro_Macimagezh_CN = RecommondPDFPro[0]["image"]["zh_CN"].ToString();
  98. Settings.Default.ADDate.RecommondPDFPro_Macimagezh_TW = RecommondPDFPro[0]["image"]["zh_TW"].ToString();
  99. if (RecommondPDFPro[0]["version"].ToString() != Settings.Default.ADDate.RecommondPDFPro_Macversion|| File.Exists(FileNameMac) == false)
  100. {
  101. Settings.Default.ADDate.RecommondPDFPro_Macversion = RecommondPDFPro[0]["version"].ToString();
  102. if (File.Exists(FileNameMac) == true)
  103. {
  104. File.Delete(FileNameMac);
  105. }
  106. WebClient client = new WebClient();
  107. client.DownloadFile(Settings.Default.ADDate.RecommondPDFPro_Macimageen, FileNameMac);
  108. }
  109. //recommondPDF - iPad
  110. Settings.Default.ADDate.RecommondPDFPro_iPadshow = RecommondPDFPro[1]["show"].ToString();
  111. Settings.Default.ADDate.RecommondPDFPro_iPadtype = RecommondPDFPro[1]["type"].ToString();
  112. Settings.Default.ADDate.RecommondPDFPro_iPadsubscriptionType = RecommondPDFPro[1]["subscriptionType"].ToString();
  113. Settings.Default.ADDate.RecommondPDFPro_iPadstartTime = RecommondPDFPro[1]["startTime"].ToObject<long>();
  114. Settings.Default.ADDate.RecommondPDFPro_iPadendTime = RecommondPDFPro[1]["endTime"].ToObject<long>();
  115. Settings.Default.ADDate.RecommondPDFPro_iPadnameen = RecommondPDFPro[1]["name"]["en"].ToString();
  116. Settings.Default.ADDate.RecommondPDFPro_iPadnamezh_CN = RecommondPDFPro[1]["name"]["zh_CN"].ToString();
  117. Settings.Default.ADDate.RecommondPDFPro_iPadnamezh_TW = RecommondPDFPro[1]["name"]["zh_TW"].ToString();
  118. Settings.Default.ADDate.RecommondPDFPro_iPadtooltipen = RecommondPDFPro[1]["tooltip"]["en"].ToString();
  119. Settings.Default.ADDate.RecommondPDFPro_iPadtooltipzh_CN = RecommondPDFPro[1]["tooltip"]["zh_CN"].ToString();
  120. Settings.Default.ADDate.RecommondPDFPro_iPadtooltipzh_TW = RecommondPDFPro[1]["tooltip"]["zh_TW"].ToString();
  121. Settings.Default.ADDate.RecommondPDFPro_iPadlinkURLen = RecommondPDFPro[1]["linkURL"]["en"].ToString();
  122. Settings.Default.ADDate.RecommondPDFPro_iPadlinkURLzh_CN = RecommondPDFPro[1]["linkURL"]["zh_CN"].ToString();
  123. Settings.Default.ADDate.RecommondPDFPro_iPadlinkURLzh_TW = RecommondPDFPro[1]["linkURL"]["zh_TW"].ToString();
  124. Settings.Default.ADDate.RecommondPDFPro_iPadimagenormal = RecommondPDFPro[1]["image"]["normal_Light"].ToString();
  125. Settings.Default.ADDate.RecommondPDFPro_iPadimagehover = RecommondPDFPro[1]["image"]["hover_Light"].ToString();
  126. Settings.Default.ADDate.RecommondPDFPro_iPadimageen = RecommondPDFPro[1]["image"]["en"].ToString();
  127. Settings.Default.ADDate.RecommondPDFPro_iPadimagezh_CN = RecommondPDFPro[1]["image"]["zh_CN"].ToString();
  128. Settings.Default.ADDate.RecommondPDFPro_iPadimagezh_TW = RecommondPDFPro[1]["image"]["zh_TW"].ToString();
  129. if (RecommondPDFPro[1]["version"].ToString() != Settings.Default.ADDate.RecommondPDFPro_iPadversion|| File.Exists(FileNameiPad) == false)
  130. {
  131. Settings.Default.ADDate.RecommondPDFPro_iPadversion = RecommondPDFPro[1]["version"].ToString();
  132. if (File.Exists(FileNameiPad) == true)
  133. {
  134. File.Delete(FileNameiPad);
  135. }
  136. WebClient client = new WebClient();
  137. client.DownloadFile(Settings.Default.ADDate.RecommondPDFPro_iPadimageen, FileNameiPad);
  138. }
  139. //recommondPDF - Android
  140. Settings.Default.ADDate.RecommondPDFPro_Androidshow = RecommondPDFPro[2]["show"].ToString();
  141. Settings.Default.ADDate.RecommondPDFPro_Androidtype = RecommondPDFPro[2]["type"].ToString();
  142. Settings.Default.ADDate.RecommondPDFPro_AndroidsubscriptionType = RecommondPDFPro[2]["subscriptionType"].ToString();
  143. Settings.Default.ADDate.RecommondPDFPro_AndroidstartTime = RecommondPDFPro[2]["startTime"].ToObject<long>();
  144. Settings.Default.ADDate.RecommondPDFPro_AndroidendTime = RecommondPDFPro[2]["endTime"].ToObject<long>();
  145. Settings.Default.ADDate.RecommondPDFPro_Androidnameen = RecommondPDFPro[2]["name"]["en"].ToString();
  146. Settings.Default.ADDate.RecommondPDFPro_Androidnamezh_CN = RecommondPDFPro[2]["name"]["zh_CN"].ToString();
  147. Settings.Default.ADDate.RecommondPDFPro_Androidnamezh_TW = RecommondPDFPro[2]["name"]["zh_TW"].ToString();
  148. Settings.Default.ADDate.RecommondPDFPro_Androidtooltipen = RecommondPDFPro[2]["tooltip"]["en"].ToString();
  149. Settings.Default.ADDate.RecommondPDFPro_Androidtooltipzh_CN = RecommondPDFPro[2]["tooltip"]["zh_CN"].ToString();
  150. Settings.Default.ADDate.RecommondPDFPro_Androidtooltipzh_TW = RecommondPDFPro[2]["tooltip"]["zh_TW"].ToString();
  151. Settings.Default.ADDate.RecommondPDFPro_AndroidlinkURLen = RecommondPDFPro[2]["linkURL"]["en"].ToString();
  152. Settings.Default.ADDate.RecommondPDFPro_AndroidlinkURLzh_CN = RecommondPDFPro[2]["linkURL"]["zh_CN"].ToString();
  153. Settings.Default.ADDate.RecommondPDFPro_AndroidlinkURLzh_TW = RecommondPDFPro[2]["linkURL"]["zh_TW"].ToString();
  154. Settings.Default.ADDate.RecommondPDFPro_Androidimagenormal = RecommondPDFPro[2]["image"]["normal_Light"].ToString();
  155. Settings.Default.ADDate.RecommondPDFPro_Androidimagehover = RecommondPDFPro[2]["image"]["hover_Light"].ToString();
  156. Settings.Default.ADDate.RecommondPDFPro_Androidimageen = RecommondPDFPro[2]["image"]["en"].ToString();
  157. Settings.Default.ADDate.RecommondPDFPro_Androidimagezh_CN = RecommondPDFPro[2]["image"]["zh_CN"].ToString();
  158. Settings.Default.ADDate.RecommondPDFPro_Androidimagezh_TW = RecommondPDFPro[2]["image"]["zh_TW"].ToString();
  159. if (RecommondPDFPro[2]["version"].ToString() != Settings.Default.ADDate.RecommondPDFPro_Androidversion|| File.Exists(FileNameAndroid) == false)
  160. {
  161. Settings.Default.ADDate.RecommondPDFPro_Androidversion = RecommondPDFPro[2]["version"].ToString();
  162. if (File.Exists(FileNameAndroid) == true)
  163. {
  164. File.Delete(FileNameAndroid);
  165. }
  166. WebClient client = new WebClient();
  167. client.DownloadFile(Settings.Default.ADDate.RecommondPDFPro_Androidimageen, FileNameAndroid);
  168. }
  169. #endregion
  170. #region RecommondContentOther参数配置
  171. Settings.Default.ADDate.RecommondContentOther_version = RecommondContentOther["version"].ToString();
  172. Settings.Default.ADDate.RecommondContentOther_nameen = RecommondContentOther["name"]["en"].ToString();
  173. Settings.Default.ADDate.RecommondContentOther_namezh_CN = RecommondContentOther["name"]["zh_CN"].ToString();
  174. Settings.Default.ADDate.RecommondContentOther_namezh_TW = RecommondContentOther["name"]["zh_TW"].ToString();
  175. //RecommondOther
  176. JArray RecommondOther = (JArray)RecommondContentOther["content"];
  177. //recommondPDF-ComPDFKit
  178. Settings.Default.ADDate.RecommondOther_ComPDFKitshow = RecommondOther[0]["show"].ToString();
  179. Settings.Default.ADDate.RecommondOther_ComPDFKittype = RecommondOther[0]["type"].ToString();
  180. Settings.Default.ADDate.RecommondOther_ComPDFKitsubscriptionType = RecommondOther[0]["subscriptionType"].ToString();
  181. Settings.Default.ADDate.RecommondOther_ComPDFKitstartTime = RecommondOther[0]["startTime"].ToObject<long>();
  182. Settings.Default.ADDate.RecommondOther_ComPDFKitendTime = RecommondOther[0]["endTime"].ToObject<long>();
  183. Settings.Default.ADDate.RecommondOther_ComPDFKitnameen = RecommondOther[0]["name"]["en"].ToString();
  184. Settings.Default.ADDate.RecommondOther_ComPDFKitnamezh_CN = RecommondOther[0]["name"]["zh_CN"].ToString();
  185. Settings.Default.ADDate.RecommondOther_ComPDFKitnamezh_TW = RecommondOther[0]["name"]["zh_TW"].ToString();
  186. Settings.Default.ADDate.RecommondOther_ComPDFKittooltipen = RecommondOther[0]["tooltip"]["en"].ToString();
  187. Settings.Default.ADDate.RecommondOther_ComPDFKittooltipzh_CN = RecommondOther[0]["tooltip"]["zh_CN"].ToString();
  188. Settings.Default.ADDate.RecommondOther_ComPDFKittooltipzh_TW = RecommondOther[0]["tooltip"]["zh_TW"].ToString();
  189. Settings.Default.ADDate.RecommondOther_ComPDFKitlinkURLen = RecommondOther[0]["linkURL"]["en"].ToString();
  190. Settings.Default.ADDate.RecommondOther_ComPDFKitlinkURLzh_CN = RecommondOther[0]["linkURL"]["zh_CN"].ToString();
  191. Settings.Default.ADDate.RecommondOther_ComPDFKitlinkURLzh_TW = RecommondOther[0]["linkURL"]["zh_TW"].ToString();
  192. Settings.Default.ADDate.RecommondOther_ComPDFKitimagenormal = RecommondOther[0]["image"]["normal_Light"].ToString();
  193. Settings.Default.ADDate.RecommondOther_ComPDFKitimagehover = RecommondOther[0]["image"]["hover_Light"].ToString();
  194. Settings.Default.ADDate.RecommondOther_ComPDFKitimageen = RecommondOther[0]["image"]["en"].ToString();
  195. Settings.Default.ADDate.RecommondOther_ComPDFKitimagezh_CN = RecommondOther[0]["image"]["zh_CN"].ToString();
  196. Settings.Default.ADDate.RecommondOther_ComPDFKitimagezh_TW = RecommondOther[0]["image"]["zh_TW"].ToString();
  197. if (RecommondOther[0]["version"].ToString() != Settings.Default.ADDate.RecommondOther_ComPDFKitversion|| File.Exists(FileNameComPDFKit) ==false)
  198. {
  199. Settings.Default.ADDate.RecommondOther_ComPDFKitversion = RecommondOther[0]["version"].ToString();
  200. if (File.Exists(FileNameComPDFKit) == true)
  201. {
  202. File.Delete(FileNameComPDFKit);
  203. }
  204. WebClient client = new WebClient();
  205. client.DownloadFile(Settings.Default.ADDate.RecommondOther_ComPDFKitimageen, FileNameComPDFKit);
  206. }
  207. //recommondPDF-ComVideoKit
  208. Settings.Default.ADDate.RecommondOther_ComVideoKitshow = RecommondOther[1]["show"].ToString();
  209. Settings.Default.ADDate.RecommondOther_ComVideoKittype = RecommondOther[1]["type"].ToString();
  210. Settings.Default.ADDate.RecommondOther_ComVideoKitsubscriptionType = RecommondOther[1]["subscriptionType"].ToString();
  211. Settings.Default.ADDate.RecommondOther_ComVideoKitstartTime = RecommondOther[1]["startTime"].ToObject<long>();
  212. Settings.Default.ADDate.RecommondOther_ComVideoKitendTime = RecommondOther[1]["endTime"].ToObject<long>();
  213. Settings.Default.ADDate.RecommondOther_ComVideoKitnameen = RecommondOther[1]["name"]["en"].ToString();
  214. Settings.Default.ADDate.RecommondOther_ComVideoKitnamezh_CN = RecommondOther[1]["name"]["zh_CN"].ToString();
  215. Settings.Default.ADDate.RecommondOther_ComVideoKitnamezh_TW = RecommondOther[1]["name"]["zh_TW"].ToString();
  216. Settings.Default.ADDate.RecommondOther_ComVideoKittooltipen = RecommondOther[1]["tooltip"]["en"].ToString();
  217. Settings.Default.ADDate.RecommondOther_ComVideoKittooltipzh_CN = RecommondOther[1]["tooltip"]["zh_CN"].ToString();
  218. Settings.Default.ADDate.RecommondOther_ComVideoKittooltipzh_TW = RecommondOther[1]["tooltip"]["zh_TW"].ToString();
  219. Settings.Default.ADDate.RecommondOther_ComVideoKitlinkURLen = RecommondOther[1]["linkURL"]["en"].ToString();
  220. Settings.Default.ADDate.RecommondOther_ComVideoKitlinkURLzh_CN = RecommondOther[1]["linkURL"]["zh_CN"].ToString();
  221. Settings.Default.ADDate.RecommondOther_ComVideoKitlinkURLzh_TW = RecommondOther[1]["linkURL"]["zh_TW"].ToString();
  222. Settings.Default.ADDate.RecommondOther_ComVideoKitimagenormal = RecommondOther[1]["image"]["normal_Light"].ToString();
  223. Settings.Default.ADDate.RecommondOther_ComVideoKitimagehover = RecommondOther[1]["image"]["hover_Light"].ToString();
  224. Settings.Default.ADDate.RecommondOther_ComVideoKitimageen = RecommondOther[1]["image"]["en"].ToString();
  225. Settings.Default.ADDate.RecommondOther_ComVideoKitimagezh_CN = RecommondOther[1]["image"]["zh_CN"].ToString();
  226. Settings.Default.ADDate.RecommondOther_ComVideoKitimagezh_TW = RecommondOther[1]["image"]["zh_TW"].ToString();
  227. if (RecommondOther[1]["version"].ToString() != Settings.Default.ADDate.RecommondOther_ComVideoKitversion|| File.Exists(FileNameComVideoKit) == false)
  228. {
  229. Settings.Default.ADDate.RecommondOther_ComVideoKitversion = RecommondOther[1]["version"].ToString();
  230. if (File.Exists(FileNameComVideoKit) == true)
  231. {
  232. File.Delete(FileNameComVideoKit);
  233. }
  234. WebClient client = new WebClient();
  235. client.DownloadFile(Settings.Default.ADDate.RecommondOther_ComVideoKitimageen, FileNameComVideoKit);
  236. }
  237. //recommondPDF-SignFlow
  238. Settings.Default.ADDate.RecommondOther_SignFlowshow = RecommondOther[2]["show"].ToString();
  239. Settings.Default.ADDate.RecommondOther_SignFlowtype = RecommondOther[2]["type"].ToString();
  240. Settings.Default.ADDate.RecommondOther_SignFlowsubscriptionType = RecommondOther[2]["subscriptionType"].ToString();
  241. Settings.Default.ADDate.RecommondOther_SignFlowstartTime = RecommondOther[2]["startTime"].ToObject<long>();
  242. Settings.Default.ADDate.RecommondOther_SignFlowendTime = RecommondOther[2]["endTime"].ToObject<long>();
  243. Settings.Default.ADDate.RecommondOther_SignFlownameen = RecommondOther[2]["name"]["en"].ToString();
  244. Settings.Default.ADDate.RecommondOther_SignFlownamezh_CN = RecommondOther[2]["name"]["zh_CN"].ToString();
  245. Settings.Default.ADDate.RecommondOther_SignFlownamezh_TW = RecommondOther[2]["name"]["zh_TW"].ToString();
  246. Settings.Default.ADDate.RecommondOther_SignFlowtooltipen = RecommondOther[2]["tooltip"]["en"].ToString();
  247. Settings.Default.ADDate.RecommondOther_SignFlowtooltipzh_CN = RecommondOther[2]["tooltip"]["zh_CN"].ToString();
  248. Settings.Default.ADDate.RecommondOther_SignFlowtooltipzh_TW = RecommondOther[2]["tooltip"]["zh_TW"].ToString();
  249. Settings.Default.ADDate.RecommondOther_SignFlowlinkURLen = RecommondOther[2]["linkURL"]["en"].ToString();
  250. Settings.Default.ADDate.RecommondOther_SignFlowlinkURLzh_CN = RecommondOther[2]["linkURL"]["zh_CN"].ToString();
  251. Settings.Default.ADDate.RecommondOther_SignFlowlinkURLzh_TW = RecommondOther[2]["linkURL"]["zh_TW"].ToString();
  252. Settings.Default.ADDate.RecommondOther_SignFlowimagenormal = RecommondOther[2]["image"]["normal_Light"].ToString();
  253. Settings.Default.ADDate.RecommondOther_SignFlowimagehover = RecommondOther[2]["image"]["hover_Light"].ToString();
  254. Settings.Default.ADDate.RecommondOther_SignFlowimageen = RecommondOther[2]["image"]["en"].ToString();
  255. Settings.Default.ADDate.RecommondOther_SignFlowimagezh_CN = RecommondOther[2]["image"]["zh_CN"].ToString();
  256. Settings.Default.ADDate.RecommondOther_SignFlowimagezh_TW = RecommondOther[2]["image"]["zh_TW"].ToString();
  257. if (RecommondOther[2]["version"].ToString() != Settings.Default.ADDate.RecommondOther_SignFlowversion|| File.Exists(FileNameSignFlow) == false)
  258. {
  259. Settings.Default.ADDate.RecommondOther_SignFlowversion = RecommondOther[2]["version"].ToString();
  260. if (File.Exists(FileNameSignFlow) == true)
  261. {
  262. File.Delete(FileNameSignFlow);
  263. }
  264. WebClient client = new WebClient();
  265. client.DownloadFile(Settings.Default.ADDate.RecommondOther_SignFlowimageen, FileNameSignFlow);
  266. }
  267. //recommondPDF-FilmageEditor
  268. Settings.Default.ADDate.RecommondOther_FilmageEditorshow = RecommondOther[3]["show"].ToString();
  269. Settings.Default.ADDate.RecommondOther_FilmageEditortype = RecommondOther[3]["type"].ToString();
  270. Settings.Default.ADDate.RecommondOther_FilmageEditorsubscriptionType = RecommondOther[3]["subscriptionType"].ToString();
  271. Settings.Default.ADDate.RecommondOther_FilmageEditorstartTime = RecommondOther[3]["startTime"].ToObject<long>();
  272. Settings.Default.ADDate.RecommondOther_FilmageEditorendTime = RecommondOther[3]["endTime"].ToObject<long>();
  273. Settings.Default.ADDate.RecommondOther_FilmageEditornameen = RecommondOther[3]["name"]["en"].ToString();
  274. Settings.Default.ADDate.RecommondOther_FilmageEditornamezh_CN = RecommondOther[3]["name"]["zh_CN"].ToString();
  275. Settings.Default.ADDate.RecommondOther_FilmageEditornamezh_TW = RecommondOther[3]["name"]["zh_TW"].ToString();
  276. Settings.Default.ADDate.RecommondOther_FilmageEditortooltipen = RecommondOther[3]["tooltip"]["en"].ToString();
  277. Settings.Default.ADDate.RecommondOther_FilmageEditortooltipzh_CN = RecommondOther[3]["tooltip"]["zh_CN"].ToString();
  278. Settings.Default.ADDate.RecommondOther_FilmageEditortooltipzh_TW = RecommondOther[3]["tooltip"]["zh_TW"].ToString();
  279. Settings.Default.ADDate.RecommondOther_FilmageEditorlinkURLen = RecommondOther[3]["linkURL"]["en"].ToString();
  280. Settings.Default.ADDate.RecommondOther_FilmageEditorlinkURLzh_CN = RecommondOther[3]["linkURL"]["zh_CN"].ToString();
  281. Settings.Default.ADDate.RecommondOther_FilmageEditorlinkURLzh_TW = RecommondOther[3]["linkURL"]["zh_TW"].ToString();
  282. Settings.Default.ADDate.RecommondOther_FilmageEditorimagenormal = RecommondOther[3]["image"]["normal_Light"].ToString();
  283. Settings.Default.ADDate.RecommondOther_FilmageEditorimagehover = RecommondOther[3]["image"]["hover_Light"].ToString();
  284. Settings.Default.ADDate.RecommondOther_FilmageEditorimageen = RecommondOther[3]["image"]["en"].ToString();
  285. Settings.Default.ADDate.RecommondOther_FilmageEditorimagezh_CN = RecommondOther[3]["image"]["zh_CN"].ToString();
  286. Settings.Default.ADDate.RecommondOther_FilmageEditorimagezh_TW = RecommondOther[3]["image"]["zh_TW"].ToString();
  287. if (RecommondOther[3]["version"].ToString() != Settings.Default.ADDate.RecommondOther_FilmageEditorversion|| File.Exists(FileNameFilmageEditor) == false)
  288. {
  289. Settings.Default.ADDate.RecommondOther_FilmageEditorversion = RecommondOther[3]["version"].ToString();
  290. if (File.Exists(FileNameFilmageEditor) == true)
  291. {
  292. File.Delete(FileNameFilmageEditor);
  293. }
  294. WebClient client = new WebClient();
  295. client.DownloadFile(Settings.Default.ADDate.RecommondOther_FilmageEditorimageen, FileNameFilmageEditor);
  296. }
  297. //recommondPDF-FilmageScreen
  298. Settings.Default.ADDate.RecommondOther_FilmageScreenshow = RecommondOther[4]["show"].ToString();
  299. Settings.Default.ADDate.RecommondOther_FilmageScreentype = RecommondOther[4]["type"].ToString();
  300. Settings.Default.ADDate.RecommondOther_FilmageScreensubscriptionType = RecommondOther[4]["subscriptionType"].ToString();
  301. Settings.Default.ADDate.RecommondOther_FilmageScreenstartTime = RecommondOther[4]["startTime"].ToObject<long>();
  302. Settings.Default.ADDate.RecommondOther_FilmageScreenendTime = RecommondOther[4]["endTime"].ToObject<long>();
  303. Settings.Default.ADDate.RecommondOther_FilmageScreennameen = RecommondOther[4]["name"]["en"].ToString();
  304. Settings.Default.ADDate.RecommondOther_FilmageScreennamezh_CN = RecommondOther[4]["name"]["zh_CN"].ToString();
  305. Settings.Default.ADDate.RecommondOther_FilmageScreennamezh_TW = RecommondOther[4]["name"]["zh_TW"].ToString();
  306. Settings.Default.ADDate.RecommondOther_FilmageScreentooltipen = RecommondOther[4]["tooltip"]["en"].ToString();
  307. Settings.Default.ADDate.RecommondOther_FilmageScreentooltipzh_CN = RecommondOther[4]["tooltip"]["zh_CN"].ToString();
  308. Settings.Default.ADDate.RecommondOther_FilmageScreentooltipzh_TW = RecommondOther[4]["tooltip"]["zh_TW"].ToString();
  309. Settings.Default.ADDate.RecommondOther_FilmageScreenlinkURLen = RecommondOther[4]["linkURL"]["en"].ToString();
  310. Settings.Default.ADDate.RecommondOther_FilmageScreenlinkURLzh_CN = RecommondOther[4]["linkURL"]["zh_CN"].ToString();
  311. Settings.Default.ADDate.RecommondOther_FilmageScreenlinkURLzh_TW = RecommondOther[4]["linkURL"]["zh_TW"].ToString();
  312. Settings.Default.ADDate.RecommondOther_FilmageScreenimagenormal = RecommondOther[4]["image"]["normal_Light"].ToString();
  313. Settings.Default.ADDate.RecommondOther_FilmageScreenimagehover = RecommondOther[4]["image"]["hover_Light"].ToString();
  314. Settings.Default.ADDate.RecommondOther_FilmageScreenimageen = RecommondOther[4]["image"]["en"].ToString();
  315. Settings.Default.ADDate.RecommondOther_FilmageScreenimagezh_CN = RecommondOther[4]["image"]["zh_CN"].ToString();
  316. Settings.Default.ADDate.RecommondOther_FilmageScreenimagezh_TW = RecommondOther[4]["image"]["zh_TW"].ToString();
  317. if (RecommondOther[4]["version"].ToString() != Settings.Default.ADDate.RecommondOther_FilmageScreenversion|| File.Exists(FileNameFilmageScreen) == false)
  318. {
  319. Settings.Default.ADDate.RecommondOther_FilmageScreenversion = RecommondOther[4]["version"].ToString();
  320. if (File.Exists(FileNameFilmageScreen) == true)
  321. {
  322. File.Delete(FileNameFilmageScreen);
  323. }
  324. WebClient client = new WebClient();
  325. client.DownloadFile(Settings.Default.ADDate.RecommondOther_FilmageScreenimageen, FileNameFilmageScreen);
  326. }
  327. //recommondPDF-FreePDFTemplates
  328. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesshow = RecommondOther[5]["show"].ToString();
  329. Settings.Default.ADDate.RecommondOther_FreePDFTemplatestype = RecommondOther[5]["type"].ToString();
  330. Settings.Default.ADDate.RecommondOther_FreePDFTemplatessubscriptionType = RecommondOther[5]["subscriptionType"].ToString();
  331. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesstartTime = RecommondOther[5]["startTime"].ToObject<long>();
  332. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesendTime = RecommondOther[5]["endTime"].ToObject<long>();
  333. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesnameen = RecommondOther[5]["name"]["en"].ToString();
  334. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesnamezh_CN = RecommondOther[5]["name"]["zh_CN"].ToString();
  335. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesnamezh_TW = RecommondOther[5]["name"]["zh_TW"].ToString();
  336. Settings.Default.ADDate.RecommondOther_FreePDFTemplatestooltipen = RecommondOther[5]["tooltip"]["en"].ToString();
  337. Settings.Default.ADDate.RecommondOther_FreePDFTemplatestooltipzh_CN = RecommondOther[5]["tooltip"]["zh_CN"].ToString();
  338. Settings.Default.ADDate.RecommondOther_FreePDFTemplatestooltipzh_TW = RecommondOther[5]["tooltip"]["zh_TW"].ToString();
  339. Settings.Default.ADDate.RecommondOther_FreePDFTemplateslinkURLen = RecommondOther[5]["linkURL"]["en"].ToString();
  340. Settings.Default.ADDate.RecommondOther_FreePDFTemplateslinkURLzh_CN = RecommondOther[5]["linkURL"]["zh_CN"].ToString();
  341. Settings.Default.ADDate.RecommondOther_FreePDFTemplateslinkURLzh_TW = RecommondOther[5]["linkURL"]["zh_TW"].ToString();
  342. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesimagenormal = RecommondOther[5]["image"]["normal_Light"].ToString();
  343. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesimagehover = RecommondOther[5]["image"]["hover_Light"].ToString();
  344. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesimageen = RecommondOther[5]["image"]["en"].ToString();
  345. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesimagezh_CN = RecommondOther[5]["image"]["zh_CN"].ToString();
  346. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesimagezh_TW = RecommondOther[5]["image"]["zh_TW"].ToString();
  347. if (RecommondOther[5]["version"].ToString() != Settings.Default.ADDate.RecommondOther_FreePDFTemplatesversion|| File.Exists(FileNameFreePDFTemplates) == false)
  348. {
  349. Settings.Default.ADDate.RecommondOther_FreePDFTemplatesversion = RecommondOther[5]["version"].ToString();
  350. if (File.Exists(FileNameFreePDFTemplates) == true)
  351. {
  352. File.Delete(FileNameFreePDFTemplates);
  353. }
  354. WebClient client = new WebClient();
  355. client.DownloadFile(Settings.Default.ADDate.RecommondOther_FreePDFTemplatesimageen, FileNameFreePDFTemplates);
  356. }
  357. #endregion
  358. #region advertisement参数配置
  359. Settings.Default.ADDate.advertisement_BlackFridayshow = advertisement[0]["show"].ToString();
  360. Settings.Default.ADDate.advertisement_BlackFridaytype = advertisement[0]["type"].ToString();
  361. Settings.Default.ADDate.advertisement_BlackFridaysubscriptionType = advertisement[0]["subscriptionType"].ToString();
  362. Settings.Default.ADDate.advertisement_BlackFridaystartTime = advertisement[0]["startTime"].ToObject<long>();
  363. Settings.Default.ADDate.advertisement_BlackFridayendTime = advertisement[0]["endTime"].ToObject<long>();
  364. Settings.Default.ADDate.advertisement_BlackFridayshowCloseBtn = advertisement[0]["showCloseBtn"].ToString();
  365. Settings.Default.ADDate.advertisement_BlackFridaynameen = advertisement[0]["name"]["en"].ToString();
  366. Settings.Default.ADDate.advertisement_BlackFridaynamezh_CN = advertisement[0]["name"]["zh_CN"].ToString();
  367. Settings.Default.ADDate.advertisement_BlackFridaynamezh_TW = advertisement[0]["name"]["zh_TW"].ToString();
  368. Settings.Default.ADDate.advertisement_BlackFridaytooltipen = advertisement[0]["tooltip"]["en"].ToString();
  369. Settings.Default.ADDate.advertisement_BlackFridaytooltipzh_CN = advertisement[0]["tooltip"]["zh_CN"].ToString();
  370. Settings.Default.ADDate.advertisement_BlackFridaytooltipzh_TW = advertisement[0]["tooltip"]["zh_TW"].ToString();
  371. Settings.Default.ADDate.advertisement_BlackFridaylinkURLen = advertisement[0]["linkURL"]["en"].ToString();
  372. Settings.Default.ADDate.advertisement_BlackFridaylinkURLzh_CN = advertisement[0]["linkURL"]["zh_CN"].ToString();
  373. Settings.Default.ADDate.advertisement_BlackFridaylinkURLzh_TW = advertisement[0]["linkURL"]["zh_TW"].ToString();
  374. Settings.Default.ADDate.advertisement_BlackFridayimagenormal = advertisement[0]["image"]["normal_Light"].ToString();
  375. Settings.Default.ADDate.advertisement_BlackFridayimagehover = advertisement[0]["image"]["hover_Light"].ToString();
  376. Settings.Default.ADDate.advertisement_BlackFridayimageen = advertisement[0]["image"]["en"].ToString();
  377. Settings.Default.ADDate.advertisement_BlackFridayimagezh_CN = advertisement[0]["image"]["zh_CN"].ToString();
  378. Settings.Default.ADDate.advertisement_BlackFridayimagezh_TW = advertisement[0]["image"]["zh_TW"].ToString();
  379. if (advertisement[0]["version"].ToString() != Settings.Default.ADDate.advertisement_BlackFridayversion|| File.Exists(FileNameBlackFriday) == false)
  380. {
  381. if (File.Exists(FileNameBlackFriday) == true)
  382. {
  383. File.Delete(FileNameBlackFriday);
  384. }
  385. WebClient client = new WebClient();
  386. client.DownloadFile(Settings.Default.ADDate.advertisement_BlackFridayimageen, FileNameBlackFriday);
  387. }
  388. #endregion
  389. Settings.Default.Save();
  390. }
  391. return jobject["code"].ToObject<string>().ToLower();
  392. }
  393. }
  394. catch (System.Net.WebException)
  395. {
  396. return "404";
  397. }
  398. catch(Exception)
  399. {
  400. return "0000";
  401. }
  402. }
  403. public static void Down(string url, string dtnow)
  404. {
  405. WebRequest wreq = WebRequest.Create(url);
  406. HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse();
  407. Stream s = wresp.GetResponseStream();
  408. System.Drawing.Image img;
  409. img = System.Drawing.Image.FromStream(s);
  410. img.Save("E:\\" + dtnow, ImageFormat.Jpeg);
  411. MemoryStream ms = new MemoryStream();
  412. img.Save(ms, ImageFormat.Jpeg);
  413. img.Dispose();
  414. }
  415. }
  416. }