| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362 |
- //----------------------------------------------------------------
- //Module Name: WindowMessengerRegister
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime Author Description
- //----------------------------------------------------------------
- //2014-04-03 deng.yinping Create
- //----------------------------------------------------------------
- using GalaSoft.MvvmLight.Ioc;
- using GalaSoft.MvvmLight.Threading;
- using Muchinfo.MTPClient.Account.ViewModels;
- using Muchinfo.MTPClient.Account.ViewModels.Notices;
- using Muchinfo.MTPClient.Account.Views;
- using Muchinfo.MTPClient.Account.Views.Notices;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Helper;
- using Muchinfo.MTPClient.Data.Model;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Data.Model.Delivery;
- using Muchinfo.MTPClient.Data.Model.GoodRules;
- //using Muchinfo.MTPClient.Data.Model.Listing;
- using Muchinfo.MTPClient.Data.Quote;
- using Muchinfo.MTPClient.Delivery.ViewModels;
- using Muchinfo.MTPClient.Data.Model.Message;
- using Muchinfo.MTPClient.Delivery.Views;
- using Muchinfo.MTPClient.Infrastructure.Cache;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.LinkProxy;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.MessengerArgs;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- using Muchinfo.MTPClient.Listing.ViewModel;
- using Muchinfo.MTPClient.Listing.Views;
- using Muchinfo.MTPClient.Report;
- using Muchinfo.MTPClient.Resources;
- using Muchinfo.MTPClient.Trade.ViewModels;
- using Muchinfo.MTPClient.Trade.Views;
- using Muchinfo.MTPClient.UI.ViewModels;
- using Muchinfo.MTPClient.UI.Views;
- using Muchinfo.PC.Common.Extensions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- using Muchinfo.MTPClient.Account.Views.AllOrderView;
- using Muchinfo.MTPClient.Sale.Views;
- using Muchinfo.MTPClient.Data.Model.Sale;
- namespace Muchinfo.MTPClient.UI.Utilities
- {
- public class MessageRegister
- {
- private static MainPage _homePage;
- // private static Muchinfo.MTPClient.FinancingAndInvestment.ViewModels
- /// <summary>
- /// 消息注册
- /// </summary>
- /// <param name="homePage">The home page.</param>
- public static void Register(MainPage homePage)
- {
- _homePage = homePage;
- #region 图表
- ////打开图表窗口
- //MessengerHelper.DefaultRegister<OpenQuoteChartWindowArg>(homePage, MessengerTokens.OpenQuoteChartWindow, WindowHelper.OpenQuoteChartWindow);
- ////打开自定义周期窗口
- //MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.OpenEditCustomCycleWindow, (e) => WindowHelper.OpenEditCustomCycleWindow());
- ////更新图表周期
- //MessengerHelper.DefaultRegister<UpateChartCycleTypeArgs>(homePage, MessengerTokens.UpateChartCycleType, UpateChartCycleType);
- #endregion
- #region 行情
- //打开行情窗口
- MessengerHelper.DefaultRegister<OpenWindowArg>(homePage, MessengerTokens.OpenQuoteWindow, WindowHelper.OpenWindow);
- //注册行情订阅消息
- // MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.QuoteSubscribe, (s) => QuoteSubscribeHelper.QuoteSubscribe());
- #endregion
- #region 帐户、查询
- //用户离线通知
- MessengerHelper.DefaultRegister<RestartType>(homePage, MessengerTokens.UserOfflineNoticeToken, UserOfflineNotice);
- //用户离线通知(结算)
- MessengerHelper.DefaultRegister<RestartType>(homePage, MessengerTokens.UserOfflineNoticesSttle, UserOfflineNotice);
- //链路检查失败处理
- MessengerHelper.DefaultRegister<ErrorEntity>(homePage, MessengerTokens.UserOfflineNoticeToken, LogoutFail);
- //链路检查失败处理
- MessengerHelper.DefaultRegister<ErrorEntity>(homePage, MessengerTokens.ConnectCheckedToken, CheckTokenFail);
- //公告和风控
- // MessengerHelper.DefaultRegister<Announcement>(homePage, MessengerTokens.AnnouncementMessage, MessageNotice);
- //账户报表
- MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.AccountReport, AccountReportQuety);
- #endregion
- #region 银行
- //签约申请
- MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.BankSign, BankSignMessage);
- //解约申请
- MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.BankCancelSign, BankBrokenSign);
- //银行变更
- MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.BankUpdate, ChanageBankMessage);
- //打开出入金申请窗口
- MessengerHelper.DefaultRegister<FundsApplyType>(homePage, MessengerTokens.FundsApply, WindowHelper.ShowAmountManager);
- #endregion
- #region 交易单据
- //建仓消息
- MessengerHelper.DefaultRegister<OrderMessage>(homePage, MessengerTokens.OrderMessageToken, ShowOrderDialog);
- //挂牌申报消息
- //MessengerHelper.DefaultRegister<Direction>(homePage, MessengerTokens.OrderListingToken, ShowListingOrderDialog);
-
- //单据变动 (成交通知更新委托单)
- MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.OrderNoticeToken, OrderNotice);
- //挂牌通知
- // MessengerHelper.DefaultRegister<ListingNoticeModel>(homePage, MessengerTokens.ListingNotice, ListingNotice);
- //预埋单更新
- //MessengerHelper.DefaultRegister<bool>(homePage, MessengerTokens.PreOrderUpdate,PreOrderNotice);
- //交收申报
- //MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.DeliveryDeclare, DeliveryMessage);
- //交收申报-带参数
- //MessengerHelper.DefaultRegister<DeliveryOrderMessage>(homePage, MessengerTokens.DeliveryDeclareParameter, DeliveryMessageParameter);
-
- //写单据成交日志
- // MessengerHelper.DefaultRegister<OrderCompleteArg>(homePage, MessengerTokens.WriteOrderCompleteLog, LogManager.WriteOrderCompleteLog);
- //止盈止损下单
- MessengerHelper.DefaultRegister<OrderMessage>(homePage, MessengerTokens.ShowSPSLToken, ShowSPSLDialog);
- #endregion
- //重新登录
- MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.RerunApplication, (s) =>
- {
- ////保存布局及列表行情抬头
- MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
- WindowHelper.RerunApplication();
- });
- //风控通知
- MessengerHelper.DefaultRegister<RiskControl>(homePage, MessengerTokens.RiskControl, RiskControl);
- //账户信息改变通知
- MessengerHelper.DefaultRegister<AccountMessage>(homePage, MessengerTokens.AccountInfoChange, AccountRaiseChange);
- ////市场开始通知(已修改,未使用)
- // MessengerHelper.DefaultRegister<string[]>(homePage, MessengerTokens.Market_OpenToken, MarketOpenNotice);
- //开休市计划通知
- AppMessengerHelper.MarketStatusChangeNotifyMessage.Register(homePage, MarketStatusChangeNotifyAction);
- ////收到修改商品信息的通知
- MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.UpdateCacheGoodsToken, UpdateTradeGoods);
- ////收到修改账号参数信息的通知
- MessengerHelper.DefaultRegister<string>(homePage, MessengerTokens.AccountParamChangeToken, QueryAccountParam);
- //提货申请-弹出窗口
- MessengerHelper.DefaultRegister<TradeAccount>(homePage, MessengerTokens.TakeDeliveryGoodsApply, TakeDeliveryGoodsApplyEvent);
- //交收申报配对-弹出窗口
- MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DeliveryEntrustOrder>(homePage, MessengerTokens.DeliveryMatchDeclare, DeliveryMatchMessage);
- //交割单详情-弹出窗口
- MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DryHoldDetail>(homePage, MessengerTokens.DeliveryOrderDetail, DeliveryOrderDetailMessage);
-
- //申报单详情-弹出窗口
- MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DeliveryEntrustOrder>(homePage, MessengerTokens.DeliveryEntructOrderDetail, DeliveryEntructOrderDetailMessage);
- //持仓单详情-弹出窗口
- MessengerHelper.DefaultRegister<HoldingOrder>(homePage, MessengerTokens.HoldOrderDetail, HoldOrderDetailMessage);
- //持仓汇总下的持仓明细
- MessengerHelper.DefaultRegister<HoldingSummary>(homePage, MessengerTokens.HoldOrderLst, HoldOrderLstMessage);
- //委托单详情-弹出窗口
- MessengerHelper.DefaultRegister<OrderDetail>(homePage, MessengerTokens.LimitOrderDetail, LimitOrderDetailMessage);
- //预埋单详情-弹出窗口
- MessengerHelper.DefaultRegister<PrePostDetail>(homePage, MessengerTokens.PreLimitOrderDetail, PreLimitOrderDetailMessage);
- //成交明细详情-弹出窗口
- MessengerHelper.DefaultRegister<CloseOrder>(homePage, MessengerTokens.TransactionOrderDetail, TransactionOrderDetailMessage);
-
- //配号中签详情-弹出窗口
- MessengerHelper.DefaultRegister<DistributeBallot>(homePage, MessengerTokens.DistributeBallotDetail, DistributeBallotDetailMessage);
- //提货详情-弹出窗口
- MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.TakaDeliveryGoodsQueryModel>(homePage, MessengerTokens.TakeGoodsMoreDetail, TakeGoodsMoreDetailMessage);
- //确认货票-弹出窗口
- MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DryHoldDetail>(homePage, MessengerTokens.ComfirmGoodsTickets, ComfirmGoodsTicketsMessage);
- //仓单提货信息填写-弹出窗口
- MessengerHelper.DefaultRegister<Muchinfo.MTPClient.Data.Model.Delivery.DeliveryWarehouse>(homePage, MessengerTokens.WarehouseRecieveInfo, WarehouseRecieveInfoMessage);
- ////公告小窗口
- MessengerHelper.DefaultRegister<NoticeMsg>(homePage, MessengerTokens.AnnouncementMessage, ShowNotice);
-
- ////显示公告详情
- MessengerHelper.DefaultRegister<NoticeMsg>(homePage, MessengerTokens.AnnouncementDetail, ShowAnnouncement);
- ////菜单显示窗口
- MessengerHelper.DefaultRegister<NoticesBase>(homePage, MessengerTokens.AnnouncementDetail, ShowNoticeWin);
- ////打开风控信息
- MessengerHelper.DefaultRegister<RiskControl>(homePage, MessengerTokens.AnnouncementMessage, RiskControlMsg);
- ////弹出公告或风控信息
- MessengerHelper.DefaultRegister<MsgTypeEnum>(homePage, MessengerTokens.AnnouncementMessage, ShowNoticeWindow);
- ////提货通知
- MessengerHelper.DefaultRegister < OutStoreAuditNtfModel>(homePage, MessengerTokens.OutStoreAuditToken,
- (model) =>
- {
- var messge = new NoticeMsg();
- {
- messge.TITLE = model.Content;
- }
- messge.IsClicked = true;
- messge.SmallWinTitle = Client_Resource.Text_OutStoreAuditNotice;
- ShowNotice(messge);
- });
- ////交割商品到期提货通知
- MessengerHelper.DefaultRegister<GoodsCloseDateNtfModel>(homePage, MessengerTokens.GoodsCloseDateToken,
- (model) =>
- {
- var messge = new NoticeMsg();
- {
- messge.TITLE = model.MsgContent;
- }
- messge.IsClicked = true;
- messge.SmallWinTitle = Client_Resource.Text_GoodsCloseDateTokenNotice;
- ShowNotice(messge);
- });
- ////会员风控通知
- MessengerHelper.DefaultRegister<RiskControlMemberModel>(homePage, MessengerTokens.RiskControlMemberToken,
- (model) =>
- {
- var messge = new NoticeMsg();
- {
- messge.TITLE = model.MsgContent;
- }
- messge.IsClicked = true;
- messge.RiskLevel = model.RiskLevel;
- messge.SmallWinTitle = Client_Resource.Moduels_Notify;
- ShowNotice(messge);
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if ((eAccountStatus)model.AccountStatus != UserManager.CurrentTradeAccount.AccountStatus)
- {
- //更新 用户状态
- UserManager.CurrentTradeAccount.AccountStatus = (eAccountStatus)model.AccountStatus;
- MessengerHelper.DefaultSend((eAccountStatus)model.AccountStatus, MessengerTokens.AccountStautsChange);
- }
- }));
- });
- ////投资者风控通知
- MessengerHelper.DefaultRegister<RiskControlInvestorModel>(homePage, MessengerTokens.RiskControlInvestorToken,
- (model) =>
- {
- /*if (isShowF)// 因为服务端一直推送斩仓通知的消息。这个只是测试代码,一定要记得去掉,要不有2次斩仓通知的话,那就完犊子了。
- {
- return;
- }
- isShowF = true;*/
- RiskControlMsg msg = Newtonsoft.Json.JsonConvert.DeserializeObject<RiskControlMsg>(model.MsgContent);
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var messge = new NoticeMsg();
- {
- messge.TITLE = msg.Content;
- }
- messge.IsClicked = true;
- messge.RiskLevel = msg.SendType;
- messge.SmallWinTitle = Client_Resource.Moduels_Notify;
- ShowNotice(messge);
- if ((eAccountStatus)model.AccountStatus != UserManager.CurrentTradeAccount.AccountStatus)
- {
- //更新 用户状态
- UserManager.CurrentTradeAccount.AccountStatus = (eAccountStatus)model.AccountStatus;
- MessengerHelper.DefaultSend((AccountStatus)model.AccountStatus, MessengerTokens.AccountStautsChange);
- }
- }));
- });
- ////通用通知
- MessengerHelper.DefaultRegister<CommonNotifyModel>(homePage, MessengerTokens.CommonMessageToken,
- (model) =>
- {
- var messge = new NoticeMsg();
- {
- messge.TITLE = model.Content;
- messge.SmallWinTitle = model.Title;
- }
- messge.IsClicked = true;
- ShowNotice(messge);
- });
- ////弹出修改密码窗口
- MessengerHelper.DefaultRegister<bool>(homePage, MessengerTokens.ShowModifyPwd, ShowModifyPwdDialog);
- }
- private static bool isShowF = false;
- /// <summary>
- /// Shows the modify password dialog.
- /// </summary>
- /// <param name="isUnforceUpdate">if set to <c>true</c> [is unforce update].</param>
- private static void ShowModifyPwdDialog(bool isUnforceUpdate)
- {
- // 风管云平台不需要修改密码
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
- // var view = new TradePWDModifyView(isUnforceUpdate)
- // {
- // Owner = Application.Current.MainWindow,
- // WindowStartupLocation = WindowStartupLocation.CenterOwner
- // };
- // view.ShowDialog();
- //}));
- }
- /// <summary>
- /// 提货申请-弹出窗口
- /// </summary>
- /// <param name="tradeAccount">交易账号</param>
- private static void TakeDeliveryGoodsApplyEvent(TradeAccount tradeAccount)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var deliveryDeclareView = new TakaDeliveryGoodsApplyView
- {
- Owner = Application.Current.MainWindow
- };
- deliveryDeclareView.ShowDialog();
- }));
- }
- /// <summary>
- /// 取消消息注册
- /// </summary>
- public static void Cleanup()
- {
- if (_homePage == null) return;
- MessengerHelper.DefaultUnregister(_homePage);
- }
- /// <summary>
- /// 市场开始通知
- /// </summary>
- /// <param name="goodsCodes"></param>
- private static void MarketOpenNotice(string[] goodsCodes)
- {
- //实时行情断后重新订阅商品
- QuoteProxyHelper.QuoteSubscribe(GoodsFromScr.All);
-
- //var goodReadTimeService = SimpleIoc.Default.GetInstance<IGoodsService>();
- //goodReadTimeService.MarketOpenUpdateDayQuote(goodsCodes);
- }
- /// <summary>
- /// 开休市计划通知【行为】
- /// </summary>
- /// <param name="model">MarketStatusChangeModel</param>
- private static void MarketStatusChangeNotifyAction(List<MarketTypeStatus> marketstatus)
- {
- var models = marketstatus.Select((item) => item.Type);
- string signals = string.Empty;
- foreach (var model in models)
- {
- signals += "," + model;
- }
- LogInfoHelper.WriteInfo("开休市计划通知" + signals);
- if (models.Contains((uint)SignalTypeEnum.SystemSettlement))
- {
- //切断链路
- LinkManager.Instance.Dispose();
- //当控制信号类型为系统结算时
- //提示框:系统结算,重新连接
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ////保存布局及列表行情抬头
- MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
- MessageBoxHelper.ShowInfo(Client_Resource.SystemMessage_SystemSettlement_Relink, Client_Resource.Warning_Tips);
- //重新启动应用程序
- WindowHelper.RerunApplication();
- }));
- }
- else if (models.Contains((uint) SignalTypeEnum.QuoteGoodClear) ||
- models.Contains((uint) SignalTypeEnum.MarketOpen))
- {
- //当控制信号类型为市场开市时
- //实时行情断后重新订阅商品
- Task.Factory.TryStartNew(() =>
- {
- QuoteProxyHelper.QuoteClear(GoodsFromScr.All);
- //LinkManager.Instance.QuoteTcpLinkProxy.ClearQuote();
- var random = new Random();
- var second = random.Next(1000, 3000);
- Thread.Sleep(second);
- QuoteProxyHelper.QuoteSubscribe(GoodsFromScr.All);
- CacheManager.TradeDayPlan.Clear(); ////清除开休市时间
- MessengerHelper.DefaultSend(string.Empty, MessengerTokens.Market_OpenToken); ////图表更新
- });
- }
- CheckMarketStatusChange(marketstatus);
- }
-
- /// <summary>
- /// 市场开收市
- /// </summary>
- /// <param name="marketstatus"></param>
- private static void CheckMarketStatusChange(List<MarketTypeStatus> marketstatus)
- {
- if (marketstatus != null && marketstatus.Any())
- {
- foreach (var marketChange in marketstatus)
- {
- if (CacheManager.MarketStatus.ContainsKey(marketChange.Id))
- {
- switch ((SignalTypeEnum)marketChange.Type)
- {
- case SignalTypeEnum.MarketOpen:
- CacheManager.MarketStatus[marketChange.Id] =(int) MarketStatus.MarketOpen;
- break;
- case SignalTypeEnum.MarketClose:
- CacheManager.MarketStatus[marketChange.Id] =(int) MarketStatus.MarketClose;
- break;
- default:
- break;
- }
- }
- }
- }
- if (UserManager.CurrentTradeAccount.AccountType != eUserType.USERTYPE_INVESTOR)
- {
- var allMarketType = CacheManager.MarketStatus.Values.Any((status) => status == (int)MarketStatus.MarketOpen);
- MessengerHelper.DefaultSend(allMarketType, MessengerTokens.MemberTraderUpdate);
- }
-
-
- }
- /// <summary>
- /// 修改商品信息时更新缓存商品
- /// </summary>
- private static void UpdateTradeGoods(string message)
- {
- var loginService = SimpleIoc.Default.GetInstance<ILoginService>();
- if (UserManager.CurrentTradeAccount != null)
- {
- loginService.AccountBaseInfoInit(UserManager.CurrentTradeAccount.AccountId, QueryGoodsSuccess, null);
- }
- }
- /// <summary>
- /// 更新商品信息后取盘面,订阅行情
- /// </summary>
- /// <param name="accountInfo"></param>
- private static void QueryGoodsSuccess(AccountInfoEntity accountInfo)
- {
- //实时行情断后重新订阅商品
- QuoteProxyHelper.QuoteSubscribe(GoodsFromScr.All);
- //todo:基本信息的账号资金不正确
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- var loginService = SimpleIoc.Default.GetInstance<ILoginService>();
- // loginService.QueryTaAccount(accountid, null, null);
- ////更新资金信息
- MessengerHelper.DefaultSend(accountid+string.Empty, MessengerTokens.MoneyNoticeToken);
- loginService.QueryAccountGoodsParams(accountid, QueryGoodsParamsUpdate, null);
- }
- /// <summary>
- /// /更新参数
- /// </summary>
- /// <param name="dictionary"></param>
- private static void QueryGoodsParamsUpdate(Dictionary<int, TradeGoodsFeeRule> dictionary)
- {
- MessengerHelper.DefaultSend(string.Empty, MessengerTokens.RefreshGoodsToken);
- }
- /// <summary>
- /// 修改账号参数时更新账号信息
- /// </summary>
- /// <param name="message"></param>
- private static void QueryAccountParam(string message)
- {
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- var loginService = SimpleIoc.Default.GetInstance<ILoginService>();
- if (UserManager.CurrentTradeAccount != null)
- {
- loginService.QueryAccountGoodsParams(accountid, QueryGoodsParamsUpdate, null);
- }
- MessengerHelper.DefaultSend( string.Empty, MessengerTokens.MoneyNoticeToken);
-
- }
- #region 消息方法
- /// <summary>
- /// 更新图表周期消息
- /// </summary>
- private static void UpateChartCycleType(UpateChartCycleTypeArgs arg)
- {
- //粤国际:取消此功能
- //if (_homePage == null) return;
- //var activeChartView = _homePage.MainPanel.Children[0] as QuoteChartView;
- //if (activeChartView == null) return;
- //activeChartView.SetCycleType(arg.CycleType, arg.TimSpan);
- }
- /// <summary>
- /// 成交通知
- /// </summary>
- private static void OrderNotice(TradeAccount completeArg)
- {
- UserManager.InitializeTradeCacheData(completeArg);
- //按单据类型发通知
- MessengerHelper.DefaultSend(completeArg, MessengerTokens.OrderNotify);
- }
-
-
- /// <summary>
- /// 预埋单更新通知
- /// </summary>
- /// <param name="IsCompleteNotice"></param>
- private static void PreOrderNotice(bool IsCompleteNotice)
- {
- if (IsCompleteNotice)
- {
- UserManager.InitializeTradeCacheData(UserManager.CurrentTradeAccount);
- //按单据类型发通知
- MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.OrderNotify);
- }
- else
- {
- var cacheData = UserManager.GetTradeCacheData(UserManager.CurrentTradeAccount.AccountId);
- cacheData.OpenPrePostOrderFlag = false;
- MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.PreOrderNoticeToken);
- }
- }
- private static void LogoutFail(ErrorEntity error)
- {
- //切断链路
- LinkManager.Instance.Dispose();
- ////有弹出信息窗口,需要跳到UI线程
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ////保存布局及列表行情抬头
- MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
- ErrorManager.ShowReturnError(error, Client_Resource.UI2014_Tips);
- ////重新运行
- WindowHelper.RerunApplication();
- }));
- }
- private static void CheckTokenFail(ErrorEntity error)
- {
-
- //切断链路
- LinkManager.Instance.Dispose();
- ////有弹出信息窗口,需要跳到UI线程
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ////保存布局及列表行情抬头
- MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
- MessageBoxHelper.ShowInfo(Client_Resource.CheckToken_Error_ReStart, Client_Resource.UI2014_Tips);
- // ErrorManager.ShowReturnError(Client_Resource.CheckToken_Error_ReStart, Client_Resource.UI2014_Tips);
- ////重新运行
- WindowHelper.RerunApplication();
- }));
- }
-
- /// <summary>
- /// 用户离线通知
- /// </summary>
- private static void UserOfflineNotice(RestartType flag)
- {
- //切断链路
- LinkManager.Instance.Dispose();
- //重新运行
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- string logoutMsg = string.Empty;
- switch (flag)
- {
- case RestartType.LoginOut:
- logoutMsg = Client_Resource.Mes_Logout;
- break;
- case RestartType.TradeCheckedFail:
- logoutMsg = Client_Resource.Message_TradeCheckFail;
- break;
- case RestartType.QuoteCheckedFail:
- logoutMsg = Client_Resource.Message_QuoteCheckFail;
- break;
- case RestartType.LinkFail:
- logoutMsg = Client_Resource.Link_Fail;
- break;
- case RestartType.SttleLoginOut:
- logoutMsg = Client_Resource.Sttle_LoginOut;
- break;
- default:
- logoutMsg = Client_Resource.Mes_LogoutCommon;
- break;
- }
- ////保存布局及列表行情抬头
- MessengerHelper.DefaultSend(string.Empty, MessengerTokens.SaveLayout);
- MessageBoxHelper.ShowInfo(logoutMsg, Client_Resource.Warning_Tips);
- ////重新运行
- WindowHelper.RerunApplication();
- }));
- }
- private static void ShowOrderDialog(OrderMessage orderMessage)
- {
-
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- TradeOrderViewModel viewModel;
- if (orderMessage.OpenCloseMode == OpenCloseMode.BUILDTYPE_OPEN)
- {
- var homeViewModel = SimpleIoc.Default.GetInstance<HomeViewModel>();
- QuoteGoods quoteGoods;
- if (CacheManager.FromType == eOrderFormType.Listting)//是否挂牌模式
- {
- quoteGoods = homeViewModel.SelectedCommissionQuoteGoods;
- quoteGoods.formType = eOrderFormType.Listting;
- quoteGoods.OrderId_Listing = orderMessage.OrderId;
- quoteGoods.OrderPrice_Listing = orderMessage.OrderPrice;
-
- }
- else
- {
-
- quoteGoods = homeViewModel.SelectedQuoteGoods;
- quoteGoods.formType = eOrderFormType.Commom;
- quoteGoods.OrderId_Listing = orderMessage.OrderId;
- }
- if (quoteGoods == null)
- {
- MessageBoxHelper.ShowInfo(Client_Resource.Select_Goods_Error, Client_Resource.APP_Tips);
- return;
- }
- if ((quoteGoods.ContainsGoodsSrc & (int)GoodsFromScr.Trade) != (int)GoodsFromScr.Trade) ////浏览的商品
- {
- var errorMsg = string.Format(Client_Resource.Goods_WithOutTrade_Power, quoteGoods.Name);
- MessageBoxHelper.ShowInfo(errorMsg, Client_Resource.APP_Tips);
- return ;
- }
- if (CacheManager.CacheGoodsBaseInfos == null || !CacheManager.CacheGoodsBaseInfos.Any())
- {
- MessageBoxHelper.ShowInfo(Client_Resource.Trade_WidthoutTradeGoods, Client_Resource.APP_Tips);
- return;
- }
- //j是否是
- if (orderMessage.Direction == Direction.Ask && quoteGoods.GoodsParameters.MoneyMode == eMoneyMode.MONEYMODE_PAY)
- {
- var holdingOrders = UserManager.GetCacheOrders<HoldingOrder>();
- if (holdingOrders == null || !holdingOrders.Any())
- {
- MessageBoxHelper.ShowInfo(Client_Resource.Quick_OrderHasNoHolds, Client_Resource.MessageBox_Error_Title);
- return;
- }
- var holds =
- holdingOrders.Where(
- (item) =>
- item.GoodsId == quoteGoods.GoodsParameters.GoodsId && item.Direction == Direction.Bid)
- .ToList();
- if (!holds.Any())
- {
- MessageBoxHelper.ShowInfo(Client_Resource.Quick_OrderHasNoHolds, Client_Resource.MessageBox_Error_Title);
- return;
- }
- }
- if (ApplicationParameter._LockType == LockType.Lock &&
- UserManager.GetCurrentLayoutStyle() == LayoutStyle.Tradition)
- {
- return;
- }
- viewModel = new TradeOrderViewModel(quoteGoods, orderMessage.Direction);
- }
- else
- {
- CacheManager.FundsAccountId = orderMessage.AccountID;
- viewModel = new TradeOrderViewModel(orderMessage.Order, orderMessage.OrderPriceMode);
-
-
- }
- if (UserManager.GetCurrentLayoutStyle() == LayoutStyle.Tradition)
- {
- //这种布局不弹出下单窗口
- MessengerHelper.DefaultSend(viewModel, MessengerTokens.OrderMessage);
- }
- else
- {
- var openWindow = new EntrustOrderView(viewModel)
- {
- Owner = Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- openWindow.ShowDialog();
- }
- }));
- }
- /// <summary>
- /// Shows the SPSL dialog.
- /// </summary>
- /// <param name="orderMessage">The order message.</param>
- private static void ShowSPSLDialog(OrderMessage orderMessage)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- CacheManager.FundsAccountId = orderMessage.AccountID;
- var viewModel = new TradeOrderViewModel(orderMessage.Order, orderMessage.OrderPriceMode, OrderModel.SPSL);
- var openWindow = new EntrustOrderView(viewModel)
- {
- Owner = Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- openWindow.ShowDialog();
- }));
- }
-
- /// <summary>
- /// 交收申请消息
- /// </summary>
- /// <param name="tradeAccount">交易账号</param>
- private static void DeliveryMessage(TradeAccount tradeAccount)
- {
- //todo:uncomment
-
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var deliveryDeclareView = new NDeliveryOrderView//DeliveryOrderView
- {
- Owner = Application.Current.MainWindow
- };
- deliveryDeclareView.ShowDialog();
- }));
- }
- /// <summary>
- /// 交收申请消息-带参数
- /// </summary>
- /// <param name="tradeAccount">交易账号</param>
- private static void DeliveryMessageParameter(DeliveryOrderMessage parameter)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var deliveryDeclareView = new NDeliveryOrderView(parameter)
- {
- Owner = Application.Current.MainWindow
- };
- deliveryDeclareView.ShowDialog();
- }));
- }
- /// <summary>
- /// 仓单提货人信息填写窗口
- /// </summary>
- /// <param name="WarehouseID"></param>
- private static void WarehouseRecieveInfoMessage(Muchinfo.MTPClient.Data.Model.Delivery.DeliveryWarehouse item)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var declareView = new RecieveInfoView(item)
- {
- Owner = Application.Current.MainWindow
- };
- declareView.ShowDialog();
- }));
- }
-
-
- /// <summary>
- /// 确认货票消息
- /// </summary>
- /// <param name="DryHoldDetail">交割查询实体</param>
- private static void ComfirmGoodsTicketsMessage(Muchinfo.MTPClient.Data.Model.Delivery.DryHoldDetail itemOrder)
- {
-
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new ComfirmGoodsTicketsView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 提货详情消息
- /// </summary>
- /// <param name="TakaDeliveryGoodsQueryModel">交割提货查询</param>
- private static void TakeGoodsMoreDetailMessage(Muchinfo.MTPClient.Data.Model.Delivery.TakaDeliveryGoodsQueryModel itemOrder)
- {
-
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new TakeGoodsMoreDetailView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 交割单详情消息
- /// </summary>
- /// <param name="tradeAccount">交割查询实体</param>
- private static void DeliveryOrderDetailMessage(Muchinfo.MTPClient.Data.Model.Delivery.DryHoldDetail itemOrder)
- {
-
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new DryHoldMoreDetailView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 申报单详情消息
- /// </summary>
- /// <param name="tradeAccount">交割查询实体</param>
- private static void DeliveryEntructOrderDetailMessage(Muchinfo.MTPClient.Data.Model.Delivery.DeliveryEntrustOrder itemOrder)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new DeliveryEntructOrderDetail(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 持仓单详情消息
- /// </summary>
- /// <param name="HoldingOrder">HoldingOrder</param>
- private static void HoldOrderDetailMessage(HoldingOrder itemOrder)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new MOHoldMoreDetailView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- private static void HoldOrderLstMessage(HoldingSummary summary)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new MOHoldLstBySummary(summary)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 委托单详情消息
- /// </summary>
- /// <param name="OrderDetail">OrderDetail</param>
- private static void LimitOrderDetailMessage(OrderDetail itemOrder)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new MOOrderMoreDetailView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 预埋单详情消息
- /// </summary>
- /// <param name="PreLimitOrderDetail">PreLimitOrderDetail</param>
- private static void PreLimitOrderDetailMessage(PrePostDetail itemOrder)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new MOPrePostMoreDetailView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 成交明细详情消息
- /// </summary>
- /// <param name="PreLimitOrderDetail">PreLimitOrderDetail</param>
- private static void TransactionOrderDetailMessage(CloseOrder itemOrder)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new MOTransactionMoreDetailView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 配号中签详情
- /// </summary>
- /// <param name="HoldingOrder">HoldingOrder</param>
- private static void DistributeBallotDetailMessage(DistributeBallot itemOrder)
- {
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var newView = new DistributeBallotDetailView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
- newView.ShowDialog();
- }));
- }
- /// <summary>
- /// 交收配对消息
- /// </summary>
- /// <param name="tradeAccount">交易账号</param>
- private static void DeliveryMatchMessage(Muchinfo.MTPClient.Data.Model.Delivery.DeliveryEntrustOrder itemOrder)
- {
- //todo:uncomment
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var deliveryDeclareView = new DeliveryMatchView(itemOrder)
- {
- Owner = Application.Current.MainWindow
- };
-
- // DeliveryMatchView matchWindow = new DeliveryMatchView(viewModel);
-
-
- deliveryDeclareView.ShowDialog();
- }));
- }
- /// <summary>
- /// 报表查询
- /// </summary>
- /// <param name="tradeAccount">交易账号</param>
- private static void AccountReportQuety(TradeAccount tradeAccount)
- {
- DispatcherHelper.RunAsync(() =>
- {
- var reportView = new InvestorReportView()
- {
- Owner = Application.Current.MainWindow
- };
- reportView.ShowDialog();
- });
- }
- /// <summary>
- /// 银行变更
- /// </summary>
- /// <param name="tradeAccount">交易账号</param>
- private static void ChanageBankMessage(TradeAccount tradeAccount)
- {
- //todo:uncomment
- return;
- //DispatcherHelper.RunAsync(() =>
- //{
- // var view = new Bank.Views.BankUpdateView { Owner = Application.Current.MainWindow };
- // var viewModel = new Muchinfo.MTPClient.Bank.ViewModels.BankUpdateViewModel(view);
- // view.DataContext = viewModel;
- // //if (viewModel.CurrentSigningBank != null)
- // view.ShowDialog();
- //});
- }
- /// <summary>
- /// 解约申请
- /// </summary>
- /// <param name="tradeAccount">交易账号</param>
- private static void BankBrokenSign(TradeAccount tradeAccount)
- {
- //todo:uncomment
- return;
- //DispatcherHelper.RunAsync(() =>
- //{
- // var view = new Bank.Views.BankTerminationView { Owner = Application.Current.MainWindow };
- // var viewModel = new Muchinfo.MTPClient.Bank.ViewModels.BankTerminationViewModel(view);
- // view.DataContext = viewModel;
- // //if (viewModel.CurrentSigningBank != null)
- // view.ShowDialog();
- //});
- }
- /// <summary>
- /// 签约申请
- /// </summary>
- /// <param name="tradeAccount">交易账号</param>
- private static void BankSignMessage(TradeAccount tradeAccount)
- {
- //todo:uncomment
- return;
- //DispatcherHelper.RunAsync(() =>
- //{
- // var view = new Bank.Views.BankSigningView { Owner = Application.Current.MainWindow };
- // view.ShowDialog();
- //});
- }
- private static NoticesView _notices;
- /// <summary>
- /// 查询未读公告,通知
- /// </summary>
- /// <param name="MsgType"></param>
- private static void ShowNoticeWindow(MsgTypeEnum MsgType)
- {
- NoticesBase noticebase;
- if (MsgType == MsgTypeEnum.Bulletin)
- {
- noticebase = new NoticesViewModel();
- }
- else
- {
- noticebase = new TradeMessageViewModel();
- }
- //var window = new NoticesView();
- //window.DataContext = noticebase;
- //window.Owner = Application.Current.MainWindow;
- //window.ShowInTaskbar = false;
- //window.ShowDialog();
- ShowNoticeWin(noticebase);
- }
- /// <summary>
- /// 显示窗口
- /// </summary>
- /// <param name="noticebase"></param>
- private static void ShowNoticeWin(NoticesBase noticebase)
- {
- if (_notices != null)
- {
- if (_notices.IsVisible)
- {
- _notices.Close();
- }
- }
- _notices = new NoticesView()
- {
- Owner = Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- _notices.DataContext = noticebase;
- _notices.Show();
- }
- /// <summary>
- /// 处理风控信息
- /// </summary>
- /// <param name="risk"></param>
- private static void RiskControlMsg(RiskControl risk)
- {
- //NoticeMsg noticeMsg=new NoticeMsg()
- //{
-
- //};
- //DateTime dateTime;
- //DateTime.TryParse(risk.Date, out dateTime);
- //noticeMsg.SCHEDULE_TIME = dateTime;
- // noticeMsg.CONTENT= string.Format(Client_Resource.Msg_TotalContent);
- //var window = new NoticesView();
- //window.DataContext = new TradeMessageViewModel();
- //window.Owner = Application.Current.MainWindow;
- //window.ShowInTaskbar = false;
- //window.ShowDialog();
- var noticebase= new TradeMessageViewModel();
- ShowNoticeWin(noticebase);
- }
- /// <summary>
- /// 会员交易员风控通知提示
- /// </summary>
- /// <param name="riskControl"></param>
- private static void RiskControl(RiskControl riskControl)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- riskControl.MsgRate = riskControl.MsgRate * 100; //推过来的是百分比
- riskControl.RealRate = riskControl.RealRate * 100;
- //if (Application.Current.Properties["RiskControlNoticeView"] == null)
- //{
- ShowRiskControl(riskControl);
- //}
- //else
- //{
- //RiskControlNoticeView riskControlNoticeView =
- // (RiskControlNoticeView)Application.Current.Properties["RiskControlNoticeView"];
- //if (riskControlNoticeView != null)
- //{
- //if (riskControlNoticeView.Opacity != 0)
- //{
- // MessengerHelper.DefaultSend(TradeTreeMenu.Ntf, MessengerTokens.AccountFunction);
- //}
- //else
- //{
- // ShowRiskControl(riskControl);
- //}
- //}
- // }
- if (riskControl.AccountStatus != UserManager.CurrentTradeAccount.AccountStatus)
- {
- //更新 用户状态
- UserManager.CurrentTradeAccount.AccountStatus = riskControl.AccountStatus;
- MessengerHelper.DefaultSend(riskControl.AccountStatus, MessengerTokens.AccountStautsChange);
- }
- }));
- }
- private static void ShowRiskControl(RiskControl riskControl)
- {
- if (Application.Current.Properties["RiskControlView"] == null)
- {
- RiskControlView riskControlView = new RiskControlView() { Owner = Application.Current.MainWindow };
- riskControlView.DataContext = riskControl;
- Application.Current.Properties["RiskControlView"] = riskControlView;
- riskControlView.Show();
- }
- else
- {
- RiskControlView riskControlView = (RiskControlView)Application.Current.Properties["RiskControlView"];
- if (riskControlView != null)
- {
- riskControlView.Owner = Application.Current.MainWindow;
- riskControlView.DataContext = riskControl;
- riskControlView.Shows();
- }
- }
- }
- /// <summary>
- /// 公告通知提示
- /// </summary>
- /// <param name="riskControl"></param>
- private static void ShowNotice(NoticeMsg notice)
- {
- // NoticeViewModel noticeViewModel = new NoticeViewModel(notice);
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (Application.Current.Properties["NoticeView"] == null)
- {
- NoticeView noticeView = new NoticeView() { Owner = Application.Current.MainWindow };
- noticeView.DataContext = notice;
- if (string.IsNullOrWhiteSpace(notice.SmallWinTitle))
- {
- noticeView.Title = Client_Resource.NoticeView_Title;
- }
- else
- {
- noticeView.Title = notice.SmallWinTitle;
- }
- Application.Current.Properties["NoticeView"] = noticeView;
- noticeView.SetWindow();
- noticeView.Show();
- }
- else
- {
- NoticeView noticeView = (NoticeView)Application.Current.Properties["NoticeView"];
- if (noticeView != null)
- {
- if (string.IsNullOrWhiteSpace(notice.SmallWinTitle))
- {
- noticeView.Title = Client_Resource.NoticeView_Title;
- }
- else
- {
- noticeView.Title = notice.SmallWinTitle;
- }
- noticeView.Owner = Application.Current.MainWindow;
- noticeView.DataContext = notice;
- noticeView.SetWindow();
- noticeView.Shows();
- }
- }
- }));
- }
- /// <summary>
- /// 投资者风控提示
- /// </summary>
- private static void ShowRisk(Announcement riskMessage)
- {
- RiskViewModel riskViewModel = new RiskViewModel(riskMessage);
- DispatcherHelper.RunAsync(() =>
- {
- if (Application.Current.Properties["RiskView"] == null)
- {
- RiskView riskView = new RiskView() { Owner = Application.Current.MainWindow };
- riskView.DataContext = riskViewModel;
- Application.Current.Properties["RiskView"] = riskView;
- riskView.SetWindow();
- riskView.Show();
- }
- else
- {
- RiskView riskView = (RiskView)Application.Current.Properties["RiskView"];
- if (riskView != null)
- {
- riskView.Owner = Application.Current.MainWindow;
- riskView.DataContext = riskViewModel;
- riskView.SetWindow();
- riskView.Shows();
- }
- }
- });
- }
- /// <summary>
- ///用户状态改变通知
- /// </summary>
- private static void AccountRaiseChange(AccountMessage account)
- {
- if (account.AccountStatus != UserManager.CurrentTradeAccount.AccountStatus)
- {
- UserManager.CurrentTradeAccount.AccountStatus = account.AccountStatus;
- MessengerHelper.DefaultSend<eAccountStatus>(account.AccountStatus, MessengerTokens.AccountStautsChange);
- }
- if (account.RiskRateID != UserManager.CurrentTradeAccount.RiskRateId)
- {
- //todo:查询风险率类型
- Task.Factory.TryStartNew(() =>
- {
- var loginService = SimpleIoc.Default.GetInstance<ILoginService>();
- if (UserManager.CurrentTradeAccount != null)
- {
-
- }
- }, () => { });
- }
- }
- /// <summary>
- /// 显示公告窗口
- /// </summary>
- /// <param name="notice"></param>
- protected static void ShowAnnouncement(NoticeMsg notice)
- {
- //var window = new NoticesView();
- //window.DataContext = new NoticesViewModel(notice);
- //window.Owner = Application.Current.MainWindow;
- //window.ShowInTaskbar = false;
- //window.ShowDialog();
- var noticebase = new NoticesViewModel(notice);
- ShowNoticeWin(noticebase);
- }
- #endregion
- /// <summary>
- /// 显示挂牌委托界面
- /// </summary>
- /// <param name="parameter">挂牌窗口</param>
- private static void ShowListingOrderDialog(Direction parameter)
- {
- var deliveryGoodsView = SimpleIoc.Default.GetInstance<ListingDeliveryGoodsViewModel>();
- var entrust = new ListingEntrustView(deliveryGoodsView.ListingGoodsess, deliveryGoodsView.CurrentGoods,parameter)
- {
- Owner = Application.Current.MainWindow,
- ShowInTaskbar = false,
- WindowStartupLocation = WindowStartupLocation.CenterOwner,
- };
- entrust.ShowDialog();
- }
- }
- }
|