LogManager.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. //using Muchinfo.PC.Common.Bosn;
  2. //using Muchinfo.MTPClient.Data.Enums;
  3. //using Muchinfo.MTPClient.Data.Model;
  4. //using Muchinfo.MTPClient.Data.Model.Account;
  5. //using Muchinfo.MTPClient.Data.Model.Bank;
  6. //using Muchinfo.MTPClient.Data.Model.Delivery;
  7. //using Muchinfo.MTPClient.Resources;
  8. //using System;
  9. //using System.Collections.Generic;
  10. //using System.IO;
  11. //using System.Linq;
  12. //using System.Text;
  13. //namespace Muchinfo.MTPClient.Infrastructure.Utilities
  14. //{
  15. // public class LogManager
  16. // {
  17. // private static readonly object _lockObject = new object();
  18. // /// <summary>
  19. // /// 获取特定时间日志
  20. // /// </summary>
  21. // /// <param name="dateTime">The date time.</param>
  22. // /// <returns>List{Data.Model.Account.Log}.</returns>
  23. // public static List<Data.Model.Account.Log> GetLog(DateTime dateTime)
  24. // {
  25. // lock (_lockObject)
  26. // {
  27. // var filePath = Path.Combine(UserManager.UserSettingsFolder, "Log", UserManager.CurrentTradeAccount.LoginCode, dateTime.ToString("yyyyMMdd") + ".log");
  28. // if (!File.Exists(filePath))
  29. // {
  30. // return null;
  31. // }
  32. // var result = BsonHelper.LoadData<Data.Model.Account.Log>(filePath);
  33. // if (result == null)
  34. // {
  35. // return null;
  36. // }
  37. // return result.OrderByDescending(z => z.Time).ToList();
  38. // }
  39. // }
  40. // #region 写日志
  41. // /// <summary>
  42. // /// 写登录日志
  43. // /// </summary>
  44. // /// <param name="tradeAccount">The trade account.</param>
  45. // public static void WriteLoginLog(TradeAccount tradeAccount)
  46. // {
  47. // var content = Client_Resource.Infrastructure_UerLogin + tradeAccount.LoginCode + "(" + tradeAccount.AccountCode + ")";
  48. // WriteLog(LogType.Login, content);
  49. // }
  50. // /// <summary>
  51. // /// 写登出日志
  52. // /// </summary>
  53. // /// <param name="tradeAccount">The trade account.</param>
  54. // public static void WriteLogoutLog(TradeAccount tradeAccount)
  55. // {
  56. // var content = Client_Resource.Infrastructure_UerLogout + tradeAccount.LoginCode + "(" + tradeAccount.AccountCode + ")";
  57. // WriteLog(LogType.Logout, content);
  58. // }
  59. // /// <summary>
  60. // /// 写委托日志
  61. // /// </summary>
  62. // /// <param name="entrustOrder">entrustOrder</param>
  63. // /// <param name="goodsName">goodsName</param>
  64. // public static void WriteEntrustLog(NewEntrustOrder entrustOrder, string goodsName)
  65. // {
  66. // if (entrustOrder == null)
  67. // {
  68. // return;
  69. // }
  70. // var content = new StringBuilder();
  71. // content.Append(Client_Resource.Infrastructure_Entrust);
  72. // var logType = LogType.OpenOrder;
  73. // //switch (entrustOrder.OrderType)
  74. // //{
  75. // // case OrderType.MarketOpenOrder:
  76. // // case OrderType.LimitOpenOrder:
  77. // // logType = LogType.OpenOrder;
  78. // // content.Append(Client_Resource.Infrastructure_OpenPosition);
  79. // // break;
  80. // // case OrderType.MarketCloseOrder:
  81. // // logType = LogType.CloseOrder;
  82. // // content.Append(Client_Resource.Infrastructure_ClosePosition);
  83. // // break;
  84. // //}
  85. // content.Append(entrustOrder.BuyOrSell == Direction.Bid ? Client_Resource.Infrastructure_buy : Client_Resource.Infrastructure_sell);
  86. // content.Append(goodsName + " ");
  87. // content.Append(entrustOrder.EntrustQuantity + " ");
  88. // content.Append(entrustOrder.EntrustPrice);
  89. // if (entrustOrder.RelationTicket != 0)
  90. // {
  91. // content.Append(" " + entrustOrder.RelationTicket);
  92. // }
  93. // WriteLog(logType, content.ToString());
  94. // }
  95. // /// <summary>
  96. // /// 写撤单日志
  97. // /// </summary>
  98. // /// <param name="entrustId">The entrust identifier.</param>
  99. // public static void WriteCancelOrderLog(long entrustId)
  100. // {
  101. // var content = Client_Resource.Infrastructure_Cancellation + entrustId;
  102. // WriteLog(LogType.CancelOrder, content);
  103. // }
  104. // /// <summary>
  105. // /// 写交收申请日志
  106. // /// </summary>
  107. // /// <param name="deliveryApply">The delivery apply.</param>
  108. // /// <param name="goodsName">Name of the goods.</param>
  109. // public static void WriteDeliveryApplyLog(EntrustDeliveryDetail deliveryApply, string goodsName)
  110. // {
  111. // if (deliveryApply == null)
  112. // {
  113. // return;
  114. // }
  115. // var content = new StringBuilder();
  116. // content.Append(Client_Resource.Infrastructure_ApplicationDelivery + goodsName);
  117. // content.Append(deliveryApply.DeliveryPrice + " ");
  118. // var count = deliveryApply.HoldDetail.Sum(z => z.HoldQty);
  119. // content.Append(count + " ");
  120. // content.Append(deliveryApply.DeliveryAmount + " ");
  121. // WriteLog(LogType.DeliveryApply, content.ToString());
  122. // }
  123. // /// <summary>
  124. // /// 写单据成交日志
  125. // /// </summary>
  126. // /// <param name="orderCompleteArg">The order complete argument.</param>
  127. // public static void WriteOrderCompleteLog(OrderCompleteArg orderCompleteArg)
  128. // {
  129. // var content = Client_Resource.Infrastructure_Deal + (orderCompleteArg.OrderCompleteType == OrderCompleteType.Open ? Client_Resource.Infrastructure_OpenPosition : Client_Resource.Infrastructure_ClosePosition) + orderCompleteArg.TradeQuantity + " " + orderCompleteArg.Amount + " " + orderCompleteArg.OrderId;
  130. // WriteLog(LogType.OrderComplete, content);
  131. // }
  132. // /// <summary>
  133. // /// 写出入金申请人日志
  134. // /// </summary>
  135. // /// <param name="applyType">Type of the apply.</param>
  136. // /// <param name="tradeAccount">The trade account.</param>
  137. // /// <param name="amount">The amount.</param>
  138. // /// <param name="bankAccountInfo">The bank account information.</param>
  139. // public static void WriteFundApplyLog(FundsApplyType applyType, TradeAccount tradeAccount, decimal amount, SigningBank bankAccountInfo)
  140. // {
  141. // var content = applyType == FundsApplyType.Withdraw ? Client_Resource.Infrastructure_WithdrawRequest : Client_Resource.Infrastructure_DepositRequest;
  142. // content += tradeAccount.LoginCode + " " + amount;
  143. // if (bankAccountInfo != null)
  144. // {
  145. // content += bankAccountInfo.Name + " " + bankAccountInfo.AccountName;
  146. // }
  147. // WriteLog(applyType == FundsApplyType.Withdraw ? LogType.Withdraw : LogType.Deposit, content);
  148. // }
  149. // /// <summary>
  150. // /// 写银行签约解约日志
  151. // /// </summary>
  152. // /// <param name="type">0:签约, 1:解约</param>
  153. // /// <param name="signingBank">The signing bank.</param>
  154. // /// <param name="tradeAccount">The trade account.</param>
  155. // public static void WriteBankApplyLog(int type, SigningBank signingBank, TradeAccount tradeAccount)
  156. // {
  157. // if (signingBank == null)
  158. // {
  159. // return;
  160. // }
  161. // var content = tradeAccount.LoginCode + " " + (type == 0 ? Client_Resource.Infrastructure_BankSignRequest : Client_Resource.Infrastructure_BankCancellationRequest) + signingBank.BranchBankName + " " + signingBank.AccountName + " " + signingBank.BankAccount;
  162. // WriteLog(type == 0 ? LogType.BankContractApply : LogType.BankCaneclSignApply, content);
  163. // }
  164. // /// <summary>
  165. // /// 写修改密码日志
  166. // /// </summary>
  167. // /// <param name="tradeAccount">The trade account.</param>
  168. // /// <param name="type">The type.</param>
  169. // public static void WritePassWordModifyLog(TradeAccount tradeAccount, int type)
  170. // {
  171. // string value = string.Empty;
  172. // switch (type)
  173. // {
  174. // case 1:
  175. // value = Client_Resource.Infrastructure_ChangePhPassword;
  176. // break;
  177. // case 2:
  178. // value = Client_Resource.Infrastructure_ChangeComPassword;
  179. // break;
  180. // case 3:
  181. // value = Client_Resource.Infrastructure_ChangeFundPassword;
  182. // break;
  183. // case 4:
  184. // value = Client_Resource.Infrastructure_ChangeTradingPassword;
  185. // break;
  186. // }
  187. // var content = tradeAccount.LoginCode + " " + value;
  188. // WriteLog(LogType.PassWordModify, content);
  189. // }
  190. // /// <summary>
  191. // /// 写日志
  192. // /// </summary>
  193. // /// <param name="logType">Type of the log.</param>
  194. // /// <param name="content">The content.</param>
  195. // private static void WriteLog(LogType logType, string content)
  196. // {
  197. // if (string.IsNullOrWhiteSpace(content))
  198. // {
  199. // return;
  200. // }
  201. // lock (_lockObject)
  202. // {
  203. // var folderPath = Path.Combine(UserManager.UserSettingsFolder, "Log", UserManager.CurrentTradeAccount.LoginCode);
  204. // if (!Directory.Exists(folderPath))
  205. // {
  206. // Directory.CreateDirectory(folderPath);
  207. // }
  208. // var log = new Log()
  209. // {
  210. // LogType = logType,
  211. // Time = DateTime.Now,
  212. // Content = content
  213. // };
  214. // BsonHelper.SaveData<Log>(Path.Combine(folderPath, DateTime.Now.ToString("yyyyMMdd") + ".log"), log, new LogComparer(), false);
  215. // //todo:发送写日志消息通知操作日志页面
  216. // }
  217. // }
  218. // #endregion
  219. // }
  220. //}