MessageRegister.cs 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. //----------------------------------------------------------------
  2. //Module Name: WindowMessengerRegister
  3. //Purpose:
  4. //CopyRight: Muchinfo
  5. //History:
  6. //----------------------------------------------------------------
  7. //DateTime Author Description
  8. //----------------------------------------------------------------
  9. //2014-04-03 deng.yinping Create
  10. //----------------------------------------------------------------
  11. using GalaSoft.MvvmLight.Ioc;
  12. using GalaSoft.MvvmLight.Threading;
  13. using Muchinfo.MTPClient.Account.ViewModels;
  14. using Muchinfo.MTPClient.Account.ViewModels.Notices;
  15. using Muchinfo.MTPClient.Account.Views;
  16. using Muchinfo.MTPClient.Account.Views.Notices;
  17. using Muchinfo.MTPClient.Data;
  18. using Muchinfo.MTPClient.Data.Enums;
  19. using Muchinfo.MTPClient.Data.Helper;
  20. using Muchinfo.MTPClient.Data.Model;
  21. using Muchinfo.MTPClient.Data.Model.Account;
  22. using Muchinfo.MTPClient.Data.Model.Delivery;
  23. using Muchinfo.MTPClient.Data.Model.GoodRules;
  24. //using Muchinfo.MTPClient.Data.Model.Listing;
  25. using Muchinfo.MTPClient.Data.Quote;
  26. using Muchinfo.MTPClient.Delivery.ViewModels;
  27. using Muchinfo.MTPClient.Data.Model.Message;
  28. using Muchinfo.MTPClient.Delivery.Views;
  29. using Muchinfo.MTPClient.Infrastructure.Cache;
  30. using Muchinfo.MTPClient.Infrastructure.Helpers;
  31. using Muchinfo.MTPClient.Infrastructure.LinkProxy;
  32. using Muchinfo.MTPClient.Infrastructure.MessageBox;
  33. using Muchinfo.MTPClient.Infrastructure.MessengerArgs;
  34. using Muchinfo.MTPClient.Infrastructure.Utilities;
  35. using Muchinfo.MTPClient.IService;
  36. using Muchinfo.MTPClient.Listing.ViewModel;
  37. using Muchinfo.MTPClient.Listing.Views;
  38. using Muchinfo.MTPClient.Report;
  39. using Muchinfo.MTPClient.Resources;
  40. using Muchinfo.MTPClient.Trade.ViewModels;
  41. using Muchinfo.MTPClient.Trade.Views;
  42. using Muchinfo.MTPClient.UI.ViewModels;
  43. using Muchinfo.MTPClient.UI.Views;
  44. using Muchinfo.PC.Common.Extensions;
  45. using System;
  46. using System.Collections.Generic;
  47. using System.Linq;
  48. using System.Threading;
  49. using System.Threading.Tasks;
  50. using System.Windows;
  51. using Muchinfo.MTPClient.Account.Views.AllOrderView;
  52. using Muchinfo.MTPClient.Sale.Views;
  53. using Muchinfo.MTPClient.Data.Model.Sale;
  54. namespace Muchinfo.MTPClient.UI.Utilities
  55. {
  56. public class MessageRegister
  57. {
  58. private static MainPage _homePage;
  59. // private static Muchinfo.MTPClient.FinancingAndInvestment.ViewModels
  60. /// <summary>
  61. /// 消息注册
  62. /// </summary>
  63. /// <param name="homePage">The home page.</param>
  64. public static void Register(MainPage homePage)
  65. {
  66. _homePage = homePage;
  67. #region 图表
  68. ////打开图表窗口
  69. //MessengerHelper.DefaultRegister<OpenQuoteChartWindowArg>(homePage, MessengerTokens.OpenQuoteChartWindow, WindowHelper.OpenQuoteChartWindow);
  70. ////打开自定义周期窗口
  71. //MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.OpenEditCustomCycleWindow, (e) => WindowHelper.OpenEditCustomCycleWindow());
  72. ////更新图表周期
  73. //MessengerHelper.DefaultRegister<UpateChartCycleTypeArgs>(homePage, MessengerTokens.UpateChartCycleType, UpateChartCycleType);
  74. #endregion
  75. #region 行情
  76. //打开行情窗口
  77. MessengerHelper.DefaultRegister<OpenWindowArg>(homePage, MessengerTokens.OpenQuoteWindow, WindowHelper.OpenWindow);
  78. //注册行情订阅消息
  79. // MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.QuoteSubscribe, (s) => QuoteSubscribeHelper.QuoteSubscribe());
  80. #endregion
  81. #region 帐户、查询
  82. //用户离线通知
  83. MessengerHelper.DefaultRegister<RestartType>(homePage, MessengerTokens.UserOfflineNoticeToken, UserOfflineNotice);
  84. //用户离线通知(结算)
  85. MessengerHelper.DefaultRegister<RestartType>(homePage, MessengerTokens.UserOfflineNoticesSttle, UserOfflineNotice);
  86. //链路检查失败处理
  87. MessengerHelper.DefaultRegister<ErrorEntity>(homePage, MessengerTokens.UserOfflineNoticeToken, LogoutFail);
  88. //链路检查失败处理
  89. MessengerHelper.DefaultRegister<ErrorEntity>(homePage, MessengerTokens.ConnectCheckedToken, CheckTokenFail);
  90. //公告和风控
  91. // MessengerHelper.DefaultRegister<Announcement>(homePage, MessengerTokens.AnnouncementMessage, MessageNotice);
  92. //账户报表
  93. MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.AccountReport, AccountReportQuety);
  94. #endregion
  95. #region 银行
  96. //签约申请
  97. MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.BankSign, BankSignMessage);
  98. //解约申请
  99. MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.BankCancelSign, BankBrokenSign);
  100. //银行变更
  101. MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.BankUpdate, ChanageBankMessage);
  102. //打开出入金申请窗口
  103. MessengerHelper.DefaultRegister<FundsApplyType>(homePage, MessengerTokens.FundsApply, WindowHelper.ShowAmountManager);
  104. #endregion
  105. #region 交易单据
  106. //建仓消息
  107. MessengerHelper.DefaultRegister<OrderMessage>(homePage, MessengerTokens.OrderMessageToken, ShowOrderDialog);
  108. //挂牌申报消息
  109. //MessengerHelper.DefaultRegister<Direction>(homePage, MessengerTokens.OrderListingToken, ShowListingOrderDialog);
  110. //单据变动 (成交通知更新委托单)
  111. MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.OrderNoticeToken, OrderNotice);
  112. //挂牌通知
  113. // MessengerHelper.DefaultRegister<ListingNoticeModel>(homePage, MessengerTokens.ListingNotice, ListingNotice);
  114. //预埋单更新
  115. //MessengerHelper.DefaultRegister<bool>(homePage, MessengerTokens.PreOrderUpdate,PreOrderNotice);
  116. //交收申报
  117. //MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.DeliveryDeclare, DeliveryMessage);
  118. //交收申报-带参数
  119. //MessengerHelper.DefaultRegister<DeliveryOrderMessage>(homePage, MessengerTokens.DeliveryDeclareParameter, DeliveryMessageParameter);
  120. //写单据成交日志
  121. // MessengerHelper.DefaultRegister<OrderCompleteArg>(homePage, MessengerTokens.WriteOrderCompleteLog, LogManager.WriteOrderCompleteLog);
  122. //止盈止损下单
  123. MessengerHelper.DefaultRegister<OrderMessage>(homePage, MessengerTokens.ShowSPSLToken, ShowSPSLDialog);
  124. #endregion
  125. //重新登录
  126. MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.RerunApplication, (s) =>
  127. {
  128. ////保存布局及列表行情抬头
  129. MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
  130. WindowHelper.RerunApplication();
  131. });
  132. //风控通知
  133. MessengerHelper.DefaultRegister<RiskControl>(homePage, MessengerTokens.RiskControl, RiskControl);
  134. //账户信息改变通知
  135. MessengerHelper.DefaultRegister<AccountMessage>(homePage, MessengerTokens.AccountInfoChange, AccountRaiseChange);
  136. ////市场开始通知(已修改,未使用)
  137. // MessengerHelper.DefaultRegister<string[]>(homePage, MessengerTokens.Market_OpenToken, MarketOpenNotice);
  138. //开休市计划通知
  139. AppMessengerHelper.MarketStatusChangeNotifyMessage.Register(homePage, MarketStatusChangeNotifyAction);
  140. ////收到修改商品信息的通知
  141. MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.UpdateCacheGoodsToken, UpdateTradeGoods);
  142. ////收到修改账号参数信息的通知
  143. MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.AccountParamChangeToken, QueryAccountParam);
  144. //提货申请-弹出窗口
  145. MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.TakeDeliveryGoodsApply, TakeDeliveryGoodsApplyEvent);
  146. //交收申报配对-弹出窗口
  147. MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DeliveryEntrustOrder>(homePage, MessengerTokens.DeliveryMatchDeclare, DeliveryMatchMessage);
  148. //交割单详情-弹出窗口
  149. MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DryHoldDetail>(homePage, MessengerTokens.DeliveryOrderDetail, DeliveryOrderDetailMessage);
  150. //申报单详情-弹出窗口
  151. MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DeliveryEntrustOrder>(homePage, MessengerTokens.DeliveryEntructOrderDetail, DeliveryEntructOrderDetailMessage);
  152. //持仓单详情-弹出窗口
  153. MessengerHelper.DefaultRegister<HoldingOrder>(homePage, MessengerTokens.HoldOrderDetail, HoldOrderDetailMessage);
  154. //持仓汇总下的持仓明细
  155. MessengerHelper.DefaultRegister<HoldingSummary>(homePage, MessengerTokens.HoldOrderLst, HoldOrderLstMessage);
  156. //委托单详情-弹出窗口
  157. MessengerHelper.DefaultRegister<OrderDetail>(homePage, MessengerTokens.LimitOrderDetail, LimitOrderDetailMessage);
  158. //预埋单详情-弹出窗口
  159. MessengerHelper.DefaultRegister<PrePostDetail>(homePage, MessengerTokens.PreLimitOrderDetail, PreLimitOrderDetailMessage);
  160. //成交明细详情-弹出窗口
  161. MessengerHelper.DefaultRegister<CloseOrder>(homePage, MessengerTokens.TransactionOrderDetail, TransactionOrderDetailMessage);
  162. //配号中签详情-弹出窗口
  163. MessengerHelper.DefaultRegister<DistributeBallot>(homePage, MessengerTokens.DistributeBallotDetail, DistributeBallotDetailMessage);
  164. //提货详情-弹出窗口
  165. MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.TakaDeliveryGoodsQueryModel>(homePage, MessengerTokens.TakeGoodsMoreDetail, TakeGoodsMoreDetailMessage);
  166. //确认货票-弹出窗口
  167. MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DryHoldDetail>(homePage, MessengerTokens.ComfirmGoodsTickets, ComfirmGoodsTicketsMessage);
  168. //仓单提货信息填写-弹出窗口
  169. MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DeliveryWarehouse>(homePage, MessengerTokens.WarehouseRecieveInfo, WarehouseRecieveInfoMessage);
  170. ////公告小窗口
  171. MessengerHelper.DefaultRegister<NoticeMsg>(homePage, MessengerTokens.AnnouncementMessage, ShowNotice);
  172. ////显示公告详情
  173. MessengerHelper.DefaultRegister<NoticeMsg>(homePage, MessengerTokens.AnnouncementDetail, ShowAnnouncement);
  174. ////菜单显示窗口
  175. MessengerHelper.DefaultRegister<NoticesBase>(homePage, MessengerTokens.AnnouncementDetail, ShowNoticeWin);
  176. ////打开风控信息
  177. MessengerHelper.DefaultRegister<RiskControl>(homePage, MessengerTokens.AnnouncementMessage, RiskControlMsg);
  178. ////弹出公告或风控信息
  179. MessengerHelper.DefaultRegister<MsgTypeEnum>(homePage, MessengerTokens.AnnouncementMessage, ShowNoticeWindow);
  180. ////提货通知
  181. MessengerHelper.DefaultRegister < OutStoreAuditNtfModel>(homePage, MessengerTokens.OutStoreAuditToken,
  182. (model) =>
  183. {
  184. var messge = new NoticeMsg();
  185. {
  186. messge.TITLE = model.Content;
  187. }
  188. messge.IsClicked = true;
  189. messge.SmallWinTitle = Client_Resource.Text_OutStoreAuditNotice;
  190. ShowNotice(messge);
  191. });
  192. ////交割商品到期提货通知
  193. MessengerHelper.DefaultRegister<GoodsCloseDateNtfModel>(homePage, MessengerTokens.GoodsCloseDateToken,
  194. (model) =>
  195. {
  196. var messge = new NoticeMsg();
  197. {
  198. messge.TITLE = model.MsgContent;
  199. }
  200. messge.IsClicked = true;
  201. messge.SmallWinTitle = Client_Resource.Text_GoodsCloseDateTokenNotice;
  202. ShowNotice(messge);
  203. });
  204. ////会员风控通知
  205. MessengerHelper.DefaultRegister<RiskControlMemberModel>(homePage, MessengerTokens.RiskControlMemberToken,
  206. (model) =>
  207. {
  208. var messge = new NoticeMsg();
  209. {
  210. messge.TITLE = model.MsgContent;
  211. }
  212. messge.IsClicked = true;
  213. messge.RiskLevel = model.RiskLevel;
  214. messge.SmallWinTitle = Client_Resource.Moduels_Notify;
  215. ShowNotice(messge);
  216. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  217. {
  218. if ((eAccountStatus)model.AccountStatus != UserManager.CurrentTradeAccount.AccountStatus)
  219. {
  220. //更新 用户状态
  221. UserManager.CurrentTradeAccount.AccountStatus = (eAccountStatus)model.AccountStatus;
  222. MessengerHelper.DefaultSend((eAccountStatus)model.AccountStatus, MessengerTokens.AccountStautsChange);
  223. }
  224. }));
  225. });
  226. ////投资者风控通知
  227. MessengerHelper.DefaultRegister<RiskControlInvestorModel>(homePage, MessengerTokens.RiskControlInvestorToken,
  228. (model) =>
  229. {
  230. /*if (isShowF)// 因为服务端一直推送斩仓通知的消息。这个只是测试代码,一定要记得去掉,要不有2次斩仓通知的话,那就完犊子了。
  231. {
  232. return;
  233. }
  234. isShowF = true;*/
  235. RiskControlMsg msg = Newtonsoft.Json.JsonConvert.DeserializeObject<RiskControlMsg>(model.MsgContent);
  236. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  237. {
  238. var messge = new NoticeMsg();
  239. {
  240. messge.TITLE = msg.Content;
  241. }
  242. messge.IsClicked = true;
  243. messge.RiskLevel = msg.SendType;
  244. messge.SmallWinTitle = Client_Resource.Moduels_Notify;
  245. ShowNotice(messge);
  246. if ((eAccountStatus)model.AccountStatus != UserManager.CurrentTradeAccount.AccountStatus)
  247. {
  248. //更新 用户状态
  249. UserManager.CurrentTradeAccount.AccountStatus = (eAccountStatus)model.AccountStatus;
  250. MessengerHelper.DefaultSend((AccountStatus)model.AccountStatus, MessengerTokens.AccountStautsChange);
  251. }
  252. }));
  253. });
  254. ////通用通知
  255. MessengerHelper.DefaultRegister<CommonNotifyModel>(homePage, MessengerTokens.CommonMessageToken,
  256. (model) =>
  257. {
  258. var messge = new NoticeMsg();
  259. {
  260. messge.TITLE = model.Content;
  261. messge.SmallWinTitle = model.Title;
  262. }
  263. messge.IsClicked = true;
  264. ShowNotice(messge);
  265. });
  266. ////弹出修改密码窗口
  267. MessengerHelper.DefaultRegister<bool>(homePage, MessengerTokens.ShowModifyPwd, ShowModifyPwdDialog);
  268. }
  269. private static bool isShowF = false;
  270. /// <summary>
  271. /// Shows the modify password dialog.
  272. /// </summary>
  273. /// <param name="isUnforceUpdate">if set to <c>true</c> [is unforce update].</param>
  274. private static void ShowModifyPwdDialog(bool isUnforceUpdate)
  275. {
  276. // 风管云平台不需要修改密码
  277. //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  278. //{
  279. // var view = new TradePWDModifyView(isUnforceUpdate)
  280. // {
  281. // Owner = Application.Current.MainWindow,
  282. // WindowStartupLocation = WindowStartupLocation.CenterOwner
  283. // };
  284. // view.ShowDialog();
  285. //}));
  286. }
  287. /// <summary>
  288. /// 提货申请-弹出窗口
  289. /// </summary>
  290. /// <param name="tradeAccount">交易账号</param>
  291. private static void TakeDeliveryGoodsApplyEvent(TradeAccount tradeAccount)
  292. {
  293. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  294. {
  295. var deliveryDeclareView = new TakaDeliveryGoodsApplyView
  296. {
  297. Owner = Application.Current.MainWindow
  298. };
  299. deliveryDeclareView.ShowDialog();
  300. }));
  301. }
  302. /// <summary>
  303. /// 取消消息注册
  304. /// </summary>
  305. public static void Cleanup()
  306. {
  307. if (_homePage == null) return;
  308. MessengerHelper.DefaultUnregister(_homePage);
  309. }
  310. /// <summary>
  311. /// 市场开始通知
  312. /// </summary>
  313. /// <param name="goodsCodes"></param>
  314. private static void MarketOpenNotice(string[] goodsCodes)
  315. {
  316. //实时行情断后重新订阅商品
  317. QuoteProxyHelper.QuoteSubscribe(GoodsFromScr.All);
  318. //var goodReadTimeService = SimpleIoc.Default.GetInstance<IGoodsService>();
  319. //goodReadTimeService.MarketOpenUpdateDayQuote(goodsCodes);
  320. }
  321. /// <summary>
  322. /// 开休市计划通知【行为】
  323. /// </summary>
  324. /// <param name="model">MarketStatusChangeModel</param>
  325. private static void MarketStatusChangeNotifyAction(List<MarketTypeStatus> marketstatus)
  326. {
  327. var models = marketstatus.Select((item) => item.Type);
  328. string signals = string.Empty;
  329. foreach (var model in models)
  330. {
  331. signals += "," + model;
  332. }
  333. LogInfoHelper.WriteInfo("开休市计划通知" + signals);
  334. if (models.Contains((uint)SignalTypeEnum.SystemSettlement))
  335. {
  336. //切断链路
  337. LinkManager.Instance.Dispose();
  338. //当控制信号类型为系统结算时
  339. //提示框:系统结算,重新连接
  340. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  341. {
  342. ////保存布局及列表行情抬头
  343. MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
  344. MessageBoxHelper.ShowInfo(Client_Resource.SystemMessage_SystemSettlement_Relink, Client_Resource.Warning_Tips);
  345. //重新启动应用程序
  346. WindowHelper.RerunApplication();
  347. }));
  348. }
  349. else if (models.Contains((uint) SignalTypeEnum.QuoteGoodClear) ||
  350. models.Contains((uint) SignalTypeEnum.MarketOpen))
  351. {
  352. //当控制信号类型为市场开市时
  353. //实时行情断后重新订阅商品
  354. Task.Factory.TryStartNew(() =>
  355. {
  356. QuoteProxyHelper.QuoteClear(GoodsFromScr.All);
  357. //LinkManager.Instance.QuoteTcpLinkProxy.ClearQuote();
  358. var random = new Random();
  359. var second = random.Next(1000, 3000);
  360. Thread.Sleep(second);
  361. QuoteProxyHelper.QuoteSubscribe(GoodsFromScr.All);
  362. CacheManager.TradeDayPlan.Clear(); ////清除开休市时间
  363. MessengerHelper.DefaultSend(string.Empty, MessengerTokens.Market_OpenToken); ////图表更新
  364. });
  365. }
  366. CheckMarketStatusChange(marketstatus);
  367. }
  368. /// <summary>
  369. /// 市场开收市
  370. /// </summary>
  371. /// <param name="marketstatus"></param>
  372. private static void CheckMarketStatusChange(List<MarketTypeStatus> marketstatus)
  373. {
  374. if (marketstatus != null && marketstatus.Any())
  375. {
  376. foreach (var marketChange in marketstatus)
  377. {
  378. if (CacheManager.MarketStatus.ContainsKey(marketChange.Id))
  379. {
  380. switch ((SignalTypeEnum)marketChange.Type)
  381. {
  382. case SignalTypeEnum.MarketOpen:
  383. CacheManager.MarketStatus[marketChange.Id] =(int) MarketStatus.MarketOpen;
  384. break;
  385. case SignalTypeEnum.MarketClose:
  386. CacheManager.MarketStatus[marketChange.Id] =(int) MarketStatus.MarketClose;
  387. break;
  388. default:
  389. break;
  390. }
  391. }
  392. }
  393. }
  394. if (UserManager.CurrentTradeAccount.AccountType != eUserType.USERTYPE_INVESTOR)
  395. {
  396. var allMarketType = CacheManager.MarketStatus.Values.Any((status) => status == (int)MarketStatus.MarketOpen);
  397. MessengerHelper.DefaultSend(allMarketType, MessengerTokens.MemberTraderUpdate);
  398. }
  399. }
  400. /// <summary>
  401. /// 修改商品信息时更新缓存商品
  402. /// </summary>
  403. private static void UpdateTradeGoods(string message)
  404. {
  405. var loginService = SimpleIoc.Default.GetInstance<ILoginService>();
  406. if (UserManager.CurrentTradeAccount != null)
  407. {
  408. loginService.AccountBaseInfoInit(UserManager.CurrentTradeAccount.AccountId, QueryGoodsSuccess, null);
  409. }
  410. }
  411. /// <summary>
  412. /// 更新商品信息后取盘面,订阅行情
  413. /// </summary>
  414. /// <param name="accountInfo"></param>
  415. private static void QueryGoodsSuccess(AccountInfoEntity accountInfo)
  416. {
  417. //实时行情断后重新订阅商品
  418. QuoteProxyHelper.QuoteSubscribe(GoodsFromScr.All);
  419. //todo:基本信息的账号资金不正确
  420. var accountid = UserManager.CurrentTradeAccount.AccountId;
  421. //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
  422. //{
  423. // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  424. //}
  425. var loginService = SimpleIoc.Default.GetInstance<ILoginService>();
  426. // loginService.QueryTaAccount(accountid, null, null);
  427. ////更新资金信息
  428. MessengerHelper.DefaultSend(accountid+string.Empty, MessengerTokens.MoneyNoticeToken);
  429. loginService.QueryAccountGoodsParams(accountid, QueryGoodsParamsUpdate, null);
  430. }
  431. /// <summary>
  432. /// /更新参数
  433. /// </summary>
  434. /// <param name="dictionary"></param>
  435. private static void QueryGoodsParamsUpdate(Dictionary<int, TradeGoodsFeeRule> dictionary)
  436. {
  437. MessengerHelper.DefaultSend(string.Empty, MessengerTokens.RefreshGoodsToken);
  438. }
  439. /// <summary>
  440. /// 修改账号参数时更新账号信息
  441. /// </summary>
  442. /// <param name="message"></param>
  443. private static void QueryAccountParam(string message)
  444. {
  445. var accountid = UserManager.CurrentTradeAccount.AccountId;
  446. //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
  447. //{
  448. // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  449. //}
  450. var loginService = SimpleIoc.Default.GetInstance<ILoginService>();
  451. if (UserManager.CurrentTradeAccount != null)
  452. {
  453. loginService.QueryAccountGoodsParams(accountid, QueryGoodsParamsUpdate, null);
  454. }
  455. MessengerHelper.DefaultSend( string.Empty, MessengerTokens.MoneyNoticeToken);
  456. }
  457. #region 消息方法
  458. /// <summary>
  459. /// 更新图表周期消息
  460. /// </summary>
  461. private static void UpateChartCycleType(UpateChartCycleTypeArgs arg)
  462. {
  463. //粤国际:取消此功能
  464. //if (_homePage == null) return;
  465. //var activeChartView = _homePage.MainPanel.Children[0] as QuoteChartView;
  466. //if (activeChartView == null) return;
  467. //activeChartView.SetCycleType(arg.CycleType, arg.TimSpan);
  468. }
  469. /// <summary>
  470. /// 成交通知
  471. /// </summary>
  472. private static void OrderNotice(TradeAccount completeArg)
  473. {
  474. UserManager.InitializeTradeCacheData(completeArg);
  475. //按单据类型发通知
  476. MessengerHelper.DefaultSend(completeArg, MessengerTokens.OrderNotify);
  477. }
  478. /// <summary>
  479. /// 预埋单更新通知
  480. /// </summary>
  481. /// <param name="IsCompleteNotice"></param>
  482. private static void PreOrderNotice(bool IsCompleteNotice)
  483. {
  484. if (IsCompleteNotice)
  485. {
  486. UserManager.InitializeTradeCacheData(UserManager.CurrentTradeAccount);
  487. //按单据类型发通知
  488. MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.OrderNotify);
  489. }
  490. else
  491. {
  492. var cacheData = UserManager.GetTradeCacheData(UserManager.CurrentTradeAccount.AccountId);
  493. cacheData.OpenPrePostOrderFlag = false;
  494. MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.PreOrderNoticeToken);
  495. }
  496. }
  497. private static void LogoutFail(ErrorEntity error)
  498. {
  499. //切断链路
  500. LinkManager.Instance.Dispose();
  501. ////有弹出信息窗口,需要跳到UI线程
  502. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  503. {
  504. ////保存布局及列表行情抬头
  505. MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
  506. ErrorManager.ShowReturnError(error, Client_Resource.UI2014_Tips);
  507. ////重新运行
  508. WindowHelper.RerunApplication();
  509. }));
  510. }
  511. private static void CheckTokenFail(ErrorEntity error)
  512. {
  513. //切断链路
  514. LinkManager.Instance.Dispose();
  515. ////有弹出信息窗口,需要跳到UI线程
  516. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  517. {
  518. ////保存布局及列表行情抬头
  519. MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
  520. MessageBoxHelper.ShowInfo(Client_Resource.CheckToken_Error_ReStart, Client_Resource.UI2014_Tips);
  521. // ErrorManager.ShowReturnError(Client_Resource.CheckToken_Error_ReStart, Client_Resource.UI2014_Tips);
  522. ////重新运行
  523. WindowHelper.RerunApplication();
  524. }));
  525. }
  526. /// <summary>
  527. /// 用户离线通知
  528. /// </summary>
  529. private static void UserOfflineNotice(RestartType flag)
  530. {
  531. //切断链路
  532. LinkManager.Instance.Dispose();
  533. //重新运行
  534. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  535. {
  536. string logoutMsg = string.Empty;
  537. switch (flag)
  538. {
  539. case RestartType.LoginOut:
  540. logoutMsg = Client_Resource.Mes_Logout;
  541. break;
  542. case RestartType.TradeCheckedFail:
  543. logoutMsg = Client_Resource.Message_TradeCheckFail;
  544. break;
  545. case RestartType.QuoteCheckedFail:
  546. logoutMsg = Client_Resource.Message_QuoteCheckFail;
  547. break;
  548. case RestartType.LinkFail:
  549. logoutMsg = Client_Resource.Link_Fail;
  550. break;
  551. case RestartType.SttleLoginOut:
  552. logoutMsg = Client_Resource.Sttle_LoginOut;
  553. break;
  554. default:
  555. logoutMsg = Client_Resource.Mes_LogoutCommon;
  556. break;
  557. }
  558. ////保存布局及列表行情抬头
  559. MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
  560. MessageBoxHelper.ShowInfo(logoutMsg, Client_Resource.Warning_Tips);
  561. ////重新运行
  562. WindowHelper.RerunApplication();
  563. }));
  564. }
  565. private static void ShowOrderDialog(OrderMessage orderMessage)
  566. {
  567. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  568. {
  569. TradeOrderViewModel viewModel;
  570. if (orderMessage.OpenCloseMode == OpenCloseMode.BUILDTYPE_OPEN)
  571. {
  572. var homeViewModel = SimpleIoc.Default.GetInstance<HomeViewModel>();
  573. QuoteGoods quoteGoods;
  574. if (CacheManager.FromType == eOrderFormType.Listting)//是否挂牌模式
  575. {
  576. quoteGoods = homeViewModel.SelectedCommissionQuoteGoods;
  577. quoteGoods.formType = eOrderFormType.Listting;
  578. quoteGoods.OrderId_Listing = orderMessage.OrderId;
  579. quoteGoods.OrderPrice_Listing = orderMessage.OrderPrice;
  580. }
  581. else
  582. {
  583. quoteGoods = homeViewModel.SelectedQuoteGoods;
  584. quoteGoods.formType = eOrderFormType.Commom;
  585. quoteGoods.OrderId_Listing = orderMessage.OrderId;
  586. }
  587. if (quoteGoods == null)
  588. {
  589. MessageBoxHelper.ShowInfo(Client_Resource.Select_Goods_Error, Client_Resource.APP_Tips);
  590. return;
  591. }
  592. if ((quoteGoods.ContainsGoodsSrc & (int)GoodsFromScr.Trade) != (int)GoodsFromScr.Trade) ////浏览的商品
  593. {
  594. var errorMsg = string.Format(Client_Resource.Goods_WithOutTrade_Power, quoteGoods.Name);
  595. MessageBoxHelper.ShowInfo(errorMsg, Client_Resource.APP_Tips);
  596. return ;
  597. }
  598. if (CacheManager.CacheGoodsBaseInfos == null || !CacheManager.CacheGoodsBaseInfos.Any())
  599. {
  600. MessageBoxHelper.ShowInfo(Client_Resource.Trade_WidthoutTradeGoods, Client_Resource.APP_Tips);
  601. return;
  602. }
  603. //j是否是
  604. if (orderMessage.Direction == Direction.Ask && quoteGoods.GoodsParameters.MoneyMode == eMoneyMode.MONEYMODE_PAY)
  605. {
  606. var holdingOrders = UserManager.GetCacheOrders<HoldingOrder>();
  607. if (holdingOrders == null || !holdingOrders.Any())
  608. {
  609. MessageBoxHelper.ShowInfo(Client_Resource.Quick_OrderHasNoHolds, Client_Resource.MessageBox_Error_Title);
  610. return;
  611. }
  612. var holds =
  613. holdingOrders.Where(
  614. (item) =>
  615. item.GoodsId == quoteGoods.GoodsParameters.GoodsId && item.Direction == Direction.Bid)
  616. .ToList();
  617. if (!holds.Any())
  618. {
  619. MessageBoxHelper.ShowInfo(Client_Resource.Quick_OrderHasNoHolds, Client_Resource.MessageBox_Error_Title);
  620. return;
  621. }
  622. }
  623. if (ApplicationParameter._LockType == LockType.Lock &&
  624. UserManager.GetCurrentLayoutStyle() == LayoutStyle.Tradition)
  625. {
  626. return;
  627. }
  628. viewModel = new TradeOrderViewModel(quoteGoods, orderMessage.Direction);
  629. }
  630. else
  631. {
  632. CacheManager.FundsAccountId = orderMessage.AccountID;
  633. viewModel = new TradeOrderViewModel(orderMessage.Order, orderMessage.OrderPriceMode);
  634. }
  635. if (UserManager.GetCurrentLayoutStyle() == LayoutStyle.Tradition)
  636. {
  637. //这种布局不弹出下单窗口
  638. MessengerHelper.DefaultSend(viewModel, MessengerTokens.OrderMessage);
  639. }
  640. else
  641. {
  642. var openWindow = new EntrustOrderView(viewModel)
  643. {
  644. Owner = Application.Current.MainWindow,
  645. WindowStartupLocation = WindowStartupLocation.CenterOwner
  646. };
  647. openWindow.ShowDialog();
  648. }
  649. }));
  650. }
  651. /// <summary>
  652. /// Shows the SPSL dialog.
  653. /// </summary>
  654. /// <param name="orderMessage">The order message.</param>
  655. private static void ShowSPSLDialog(OrderMessage orderMessage)
  656. {
  657. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  658. {
  659. CacheManager.FundsAccountId = orderMessage.AccountID;
  660. var viewModel = new TradeOrderViewModel(orderMessage.Order, orderMessage.OrderPriceMode, OrderModel.SPSL);
  661. var openWindow = new EntrustOrderView(viewModel)
  662. {
  663. Owner = Application.Current.MainWindow,
  664. WindowStartupLocation = WindowStartupLocation.CenterOwner
  665. };
  666. openWindow.ShowDialog();
  667. }));
  668. }
  669. /// <summary>
  670. /// 交收申请消息
  671. /// </summary>
  672. /// <param name="tradeAccount">交易账号</param>
  673. private static void DeliveryMessage(TradeAccount tradeAccount)
  674. {
  675. //todo:uncomment
  676. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  677. {
  678. var deliveryDeclareView = new NDeliveryOrderView//DeliveryOrderView
  679. {
  680. Owner = Application.Current.MainWindow
  681. };
  682. deliveryDeclareView.ShowDialog();
  683. }));
  684. }
  685. /// <summary>
  686. /// 交收申请消息-带参数
  687. /// </summary>
  688. /// <param name="tradeAccount">交易账号</param>
  689. private static void DeliveryMessageParameter(DeliveryOrderMessage parameter)
  690. {
  691. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  692. {
  693. var deliveryDeclareView = new NDeliveryOrderView(parameter)
  694. {
  695. Owner = Application.Current.MainWindow
  696. };
  697. deliveryDeclareView.ShowDialog();
  698. }));
  699. }
  700. /// <summary>
  701. /// 仓单提货人信息填写窗口
  702. /// </summary>
  703. /// <param name="WarehouseID"></param>
  704. private static void WarehouseRecieveInfoMessage(Muchinfo.MTPClient.Data.Model.Delivery.DeliveryWarehouse item)
  705. {
  706. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  707. {
  708. var declareView = new RecieveInfoView(item)
  709. {
  710. Owner = Application.Current.MainWindow
  711. };
  712. declareView.ShowDialog();
  713. }));
  714. }
  715. /// <summary>
  716. /// 确认货票消息
  717. /// </summary>
  718. /// <param name="DryHoldDetail">交割查询实体</param>
  719. private static void ComfirmGoodsTicketsMessage(Muchinfo.MTPClient.Data.Model.Delivery.DryHoldDetail itemOrder)
  720. {
  721. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  722. {
  723. var newView = new ComfirmGoodsTicketsView(itemOrder)
  724. {
  725. Owner = Application.Current.MainWindow
  726. };
  727. newView.ShowDialog();
  728. }));
  729. }
  730. /// <summary>
  731. /// 提货详情消息
  732. /// </summary>
  733. /// <param name="TakaDeliveryGoodsQueryModel">交割提货查询</param>
  734. private static void TakeGoodsMoreDetailMessage(Muchinfo.MTPClient.Data.Model.Delivery.TakaDeliveryGoodsQueryModel itemOrder)
  735. {
  736. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  737. {
  738. var newView = new TakeGoodsMoreDetailView(itemOrder)
  739. {
  740. Owner = Application.Current.MainWindow
  741. };
  742. newView.ShowDialog();
  743. }));
  744. }
  745. /// <summary>
  746. /// 交割单详情消息
  747. /// </summary>
  748. /// <param name="tradeAccount">交割查询实体</param>
  749. private static void DeliveryOrderDetailMessage(Muchinfo.MTPClient.Data.Model.Delivery.DryHoldDetail itemOrder)
  750. {
  751. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  752. {
  753. var newView = new DryHoldMoreDetailView(itemOrder)
  754. {
  755. Owner = Application.Current.MainWindow
  756. };
  757. newView.ShowDialog();
  758. }));
  759. }
  760. /// <summary>
  761. /// 申报单详情消息
  762. /// </summary>
  763. /// <param name="tradeAccount">交割查询实体</param>
  764. private static void DeliveryEntructOrderDetailMessage(Muchinfo.MTPClient.Data.Model.Delivery.DeliveryEntrustOrder itemOrder)
  765. {
  766. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  767. {
  768. var newView = new DeliveryEntructOrderDetail(itemOrder)
  769. {
  770. Owner = Application.Current.MainWindow
  771. };
  772. newView.ShowDialog();
  773. }));
  774. }
  775. /// <summary>
  776. /// 持仓单详情消息
  777. /// </summary>
  778. /// <param name="HoldingOrder">HoldingOrder</param>
  779. private static void HoldOrderDetailMessage(HoldingOrder itemOrder)
  780. {
  781. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  782. {
  783. var newView = new MOHoldMoreDetailView(itemOrder)
  784. {
  785. Owner = Application.Current.MainWindow
  786. };
  787. newView.ShowDialog();
  788. }));
  789. }
  790. private static void HoldOrderLstMessage(HoldingSummary summary)
  791. {
  792. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  793. {
  794. var newView = new MOHoldLstBySummary(summary)
  795. {
  796. Owner = Application.Current.MainWindow
  797. };
  798. newView.ShowDialog();
  799. }));
  800. }
  801. /// <summary>
  802. /// 委托单详情消息
  803. /// </summary>
  804. /// <param name="OrderDetail">OrderDetail</param>
  805. private static void LimitOrderDetailMessage(OrderDetail itemOrder)
  806. {
  807. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  808. {
  809. var newView = new MOOrderMoreDetailView(itemOrder)
  810. {
  811. Owner = Application.Current.MainWindow
  812. };
  813. newView.ShowDialog();
  814. }));
  815. }
  816. /// <summary>
  817. /// 预埋单详情消息
  818. /// </summary>
  819. /// <param name="PreLimitOrderDetail">PreLimitOrderDetail</param>
  820. private static void PreLimitOrderDetailMessage(PrePostDetail itemOrder)
  821. {
  822. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  823. {
  824. var newView = new MOPrePostMoreDetailView(itemOrder)
  825. {
  826. Owner = Application.Current.MainWindow
  827. };
  828. newView.ShowDialog();
  829. }));
  830. }
  831. /// <summary>
  832. /// 成交明细详情消息
  833. /// </summary>
  834. /// <param name="PreLimitOrderDetail">PreLimitOrderDetail</param>
  835. private static void TransactionOrderDetailMessage(CloseOrder itemOrder)
  836. {
  837. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  838. {
  839. var newView = new MOTransactionMoreDetailView(itemOrder)
  840. {
  841. Owner = Application.Current.MainWindow
  842. };
  843. newView.ShowDialog();
  844. }));
  845. }
  846. /// <summary>
  847. /// 配号中签详情
  848. /// </summary>
  849. /// <param name="HoldingOrder">HoldingOrder</param>
  850. private static void DistributeBallotDetailMessage(DistributeBallot itemOrder)
  851. {
  852. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  853. {
  854. var newView = new DistributeBallotDetailView(itemOrder)
  855. {
  856. Owner = Application.Current.MainWindow
  857. };
  858. newView.ShowDialog();
  859. }));
  860. }
  861. /// <summary>
  862. /// 交收配对消息
  863. /// </summary>
  864. /// <param name="tradeAccount">交易账号</param>
  865. private static void DeliveryMatchMessage(Muchinfo.MTPClient.Data.Model.Delivery.DeliveryEntrustOrder itemOrder)
  866. {
  867. //todo:uncomment
  868. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  869. {
  870. var deliveryDeclareView = new DeliveryMatchView(itemOrder)
  871. {
  872. Owner = Application.Current.MainWindow
  873. };
  874. // DeliveryMatchView matchWindow = new DeliveryMatchView(viewModel);
  875. deliveryDeclareView.ShowDialog();
  876. }));
  877. }
  878. /// <summary>
  879. /// 报表查询
  880. /// </summary>
  881. /// <param name="tradeAccount">交易账号</param>
  882. private static void AccountReportQuety(TradeAccount tradeAccount)
  883. {
  884. DispatcherHelper.RunAsync(() =>
  885. {
  886. var reportView = new InvestorReportView()
  887. {
  888. Owner = Application.Current.MainWindow
  889. };
  890. reportView.ShowDialog();
  891. });
  892. }
  893. /// <summary>
  894. /// 银行变更
  895. /// </summary>
  896. /// <param name="tradeAccount">交易账号</param>
  897. private static void ChanageBankMessage(TradeAccount tradeAccount)
  898. {
  899. //todo:uncomment
  900. return;
  901. //DispatcherHelper.RunAsync(() =>
  902. //{
  903. // var view = new Bank.Views.BankUpdateView { Owner = Application.Current.MainWindow };
  904. // var viewModel = new Muchinfo.MTPClient.Bank.ViewModels.BankUpdateViewModel(view);
  905. // view.DataContext = viewModel;
  906. // //if (viewModel.CurrentSigningBank != null)
  907. // view.ShowDialog();
  908. //});
  909. }
  910. /// <summary>
  911. /// 解约申请
  912. /// </summary>
  913. /// <param name="tradeAccount">交易账号</param>
  914. private static void BankBrokenSign(TradeAccount tradeAccount)
  915. {
  916. //todo:uncomment
  917. return;
  918. //DispatcherHelper.RunAsync(() =>
  919. //{
  920. // var view = new Bank.Views.BankTerminationView { Owner = Application.Current.MainWindow };
  921. // var viewModel = new Muchinfo.MTPClient.Bank.ViewModels.BankTerminationViewModel(view);
  922. // view.DataContext = viewModel;
  923. // //if (viewModel.CurrentSigningBank != null)
  924. // view.ShowDialog();
  925. //});
  926. }
  927. /// <summary>
  928. /// 签约申请
  929. /// </summary>
  930. /// <param name="tradeAccount">交易账号</param>
  931. private static void BankSignMessage(TradeAccount tradeAccount)
  932. {
  933. //todo:uncomment
  934. return;
  935. //DispatcherHelper.RunAsync(() =>
  936. //{
  937. // var view = new Bank.Views.BankSigningView { Owner = Application.Current.MainWindow };
  938. // view.ShowDialog();
  939. //});
  940. }
  941. private static NoticesView _notices;
  942. /// <summary>
  943. /// 查询未读公告,通知
  944. /// </summary>
  945. /// <param name="MsgType"></param>
  946. private static void ShowNoticeWindow(MsgTypeEnum MsgType)
  947. {
  948. NoticesBase noticebase;
  949. if (MsgType == MsgTypeEnum.Bulletin)
  950. {
  951. noticebase = new NoticesViewModel();
  952. }
  953. else
  954. {
  955. noticebase = new TradeMessageViewModel();
  956. }
  957. //var window = new NoticesView();
  958. //window.DataContext = noticebase;
  959. //window.Owner = Application.Current.MainWindow;
  960. //window.ShowInTaskbar = false;
  961. //window.ShowDialog();
  962. ShowNoticeWin(noticebase);
  963. }
  964. /// <summary>
  965. /// 显示窗口
  966. /// </summary>
  967. /// <param name="noticebase"></param>
  968. private static void ShowNoticeWin(NoticesBase noticebase)
  969. {
  970. if (_notices != null)
  971. {
  972. if (_notices.IsVisible)
  973. {
  974. _notices.Close();
  975. }
  976. }
  977. _notices = new NoticesView()
  978. {
  979. Owner = Application.Current.MainWindow,
  980. WindowStartupLocation = WindowStartupLocation.CenterOwner
  981. };
  982. _notices.DataContext = noticebase;
  983. _notices.Show();
  984. }
  985. /// <summary>
  986. /// 处理风控信息
  987. /// </summary>
  988. /// <param name="risk"></param>
  989. private static void RiskControlMsg(RiskControl risk)
  990. {
  991. //NoticeMsg noticeMsg=new NoticeMsg()
  992. //{
  993. //};
  994. //DateTime dateTime;
  995. //DateTime.TryParse(risk.Date, out dateTime);
  996. //noticeMsg.SCHEDULE_TIME = dateTime;
  997. // noticeMsg.CONTENT= string.Format(Client_Resource.Msg_TotalContent);
  998. //var window = new NoticesView();
  999. //window.DataContext = new TradeMessageViewModel();
  1000. //window.Owner = Application.Current.MainWindow;
  1001. //window.ShowInTaskbar = false;
  1002. //window.ShowDialog();
  1003. var noticebase= new TradeMessageViewModel();
  1004. ShowNoticeWin(noticebase);
  1005. }
  1006. /// <summary>
  1007. /// 会员交易员风控通知提示
  1008. /// </summary>
  1009. /// <param name="riskControl"></param>
  1010. private static void RiskControl(RiskControl riskControl)
  1011. {
  1012. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  1013. {
  1014. riskControl.MsgRate = riskControl.MsgRate * 100; //推过来的是百分比
  1015. riskControl.RealRate = riskControl.RealRate * 100;
  1016. //if (Application.Current.Properties["RiskControlNoticeView"] == null)
  1017. //{
  1018. ShowRiskControl(riskControl);
  1019. //}
  1020. //else
  1021. //{
  1022. //RiskControlNoticeView riskControlNoticeView =
  1023. // (RiskControlNoticeView)Application.Current.Properties["RiskControlNoticeView"];
  1024. //if (riskControlNoticeView != null)
  1025. //{
  1026. //if (riskControlNoticeView.Opacity != 0)
  1027. //{
  1028. // MessengerHelper.DefaultSend(TradeTreeMenu.Ntf, MessengerTokens.AccountFunction);
  1029. //}
  1030. //else
  1031. //{
  1032. // ShowRiskControl(riskControl);
  1033. //}
  1034. //}
  1035. // }
  1036. if (riskControl.AccountStatus != UserManager.CurrentTradeAccount.AccountStatus)
  1037. {
  1038. //更新 用户状态
  1039. UserManager.CurrentTradeAccount.AccountStatus = riskControl.AccountStatus;
  1040. MessengerHelper.DefaultSend(riskControl.AccountStatus, MessengerTokens.AccountStautsChange);
  1041. }
  1042. }));
  1043. }
  1044. private static void ShowRiskControl(RiskControl riskControl)
  1045. {
  1046. if (Application.Current.Properties["RiskControlView"] == null)
  1047. {
  1048. RiskControlView riskControlView = new RiskControlView() { Owner = Application.Current.MainWindow };
  1049. riskControlView.DataContext = riskControl;
  1050. Application.Current.Properties["RiskControlView"] = riskControlView;
  1051. riskControlView.Show();
  1052. }
  1053. else
  1054. {
  1055. RiskControlView riskControlView = (RiskControlView)Application.Current.Properties["RiskControlView"];
  1056. if (riskControlView != null)
  1057. {
  1058. riskControlView.Owner = Application.Current.MainWindow;
  1059. riskControlView.DataContext = riskControl;
  1060. riskControlView.Shows();
  1061. }
  1062. }
  1063. }
  1064. /// <summary>
  1065. /// 公告通知提示
  1066. /// </summary>
  1067. /// <param name="riskControl"></param>
  1068. private static void ShowNotice(NoticeMsg notice)
  1069. {
  1070. // NoticeViewModel noticeViewModel = new NoticeViewModel(notice);
  1071. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  1072. {
  1073. if (Application.Current.Properties["NoticeView"] == null)
  1074. {
  1075. NoticeView noticeView = new NoticeView() { Owner = Application.Current.MainWindow };
  1076. noticeView.DataContext = notice;
  1077. if (string.IsNullOrWhiteSpace(notice.SmallWinTitle))
  1078. {
  1079. noticeView.Title = Client_Resource.NoticeView_Title;
  1080. }
  1081. else
  1082. {
  1083. noticeView.Title = notice.SmallWinTitle;
  1084. }
  1085. Application.Current.Properties["NoticeView"] = noticeView;
  1086. noticeView.SetWindow();
  1087. noticeView.Show();
  1088. }
  1089. else
  1090. {
  1091. NoticeView noticeView = (NoticeView)Application.Current.Properties["NoticeView"];
  1092. if (noticeView != null)
  1093. {
  1094. if (string.IsNullOrWhiteSpace(notice.SmallWinTitle))
  1095. {
  1096. noticeView.Title = Client_Resource.NoticeView_Title;
  1097. }
  1098. else
  1099. {
  1100. noticeView.Title = notice.SmallWinTitle;
  1101. }
  1102. noticeView.Owner = Application.Current.MainWindow;
  1103. noticeView.DataContext = notice;
  1104. noticeView.SetWindow();
  1105. noticeView.Shows();
  1106. }
  1107. }
  1108. }));
  1109. }
  1110. /// <summary>
  1111. /// 投资者风控提示
  1112. /// </summary>
  1113. private static void ShowRisk(Announcement riskMessage)
  1114. {
  1115. RiskViewModel riskViewModel = new RiskViewModel(riskMessage);
  1116. DispatcherHelper.RunAsync(() =>
  1117. {
  1118. if (Application.Current.Properties["RiskView"] == null)
  1119. {
  1120. RiskView riskView = new RiskView() { Owner = Application.Current.MainWindow };
  1121. riskView.DataContext = riskViewModel;
  1122. Application.Current.Properties["RiskView"] = riskView;
  1123. riskView.SetWindow();
  1124. riskView.Show();
  1125. }
  1126. else
  1127. {
  1128. RiskView riskView = (RiskView)Application.Current.Properties["RiskView"];
  1129. if (riskView != null)
  1130. {
  1131. riskView.Owner = Application.Current.MainWindow;
  1132. riskView.DataContext = riskViewModel;
  1133. riskView.SetWindow();
  1134. riskView.Shows();
  1135. }
  1136. }
  1137. });
  1138. }
  1139. /// <summary>
  1140. ///用户状态改变通知
  1141. /// </summary>
  1142. private static void AccountRaiseChange(AccountMessage account)
  1143. {
  1144. if (account.AccountStatus != UserManager.CurrentTradeAccount.AccountStatus)
  1145. {
  1146. UserManager.CurrentTradeAccount.AccountStatus = account.AccountStatus;
  1147. MessengerHelper.DefaultSend<eAccountStatus>(account.AccountStatus, MessengerTokens.AccountStautsChange);
  1148. }
  1149. if (account.RiskRateID != UserManager.CurrentTradeAccount.RiskRateId)
  1150. {
  1151. //todo:查询风险率类型
  1152. Task.Factory.TryStartNew(() =>
  1153. {
  1154. var loginService = SimpleIoc.Default.GetInstance<ILoginService>();
  1155. if (UserManager.CurrentTradeAccount != null)
  1156. {
  1157. }
  1158. }, () => { });
  1159. }
  1160. }
  1161. /// <summary>
  1162. /// 显示公告窗口
  1163. /// </summary>
  1164. /// <param name="notice"></param>
  1165. protected static void ShowAnnouncement(NoticeMsg notice)
  1166. {
  1167. //var window = new NoticesView();
  1168. //window.DataContext = new NoticesViewModel(notice);
  1169. //window.Owner = Application.Current.MainWindow;
  1170. //window.ShowInTaskbar = false;
  1171. //window.ShowDialog();
  1172. var noticebase = new NoticesViewModel(notice);
  1173. ShowNoticeWin(noticebase);
  1174. }
  1175. #endregion
  1176. /// <summary>
  1177. /// 显示挂牌委托界面
  1178. /// </summary>
  1179. /// <param name="parameter">挂牌窗口</param>
  1180. private static void ShowListingOrderDialog(Direction parameter)
  1181. {
  1182. var deliveryGoodsView = SimpleIoc.Default.GetInstance<ListingDeliveryGoodsViewModel>();
  1183. var entrust = new ListingEntrustView(deliveryGoodsView.ListingGoodsess, deliveryGoodsView.CurrentGoods,parameter)
  1184. {
  1185. Owner = Application.Current.MainWindow,
  1186. ShowInTaskbar = false,
  1187. WindowStartupLocation = WindowStartupLocation.CenterOwner,
  1188. };
  1189. entrust.ShowDialog();
  1190. }
  1191. }
  1192. }