using System; using System.Linq; using System.Collections.ObjectModel; using Muchinfo.MTPClient.Adapter.Abstract; using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Data.Model; using Muchinfo.MTPClient.Data.Model.Account; using Muchinfo.MTPClient.Infrastructure.LinkProxy; using Muchinfo.MTPClient.Infrastructure.Utilities; using Muchinfo.MTPClient.IService; using Muchinfo.MTPClient.NetworkCore; using Muchinfo.PC.Common.Extensions; using Muchinfo.MTPClient.Data.Model.Message; using System.Collections.Generic; using Muchinfo.MTPClient.Service.Utilities; using Muchinfo.MTPClient.Resources; namespace Muchinfo.MTPClient.Service { public class AnnouncementService : IAnnouncementService { private readonly AnnouncementAdapter _announcementapter; public AnnouncementService() { _announcementapter = LinkManager.Instance.TradeAdapterFactory.CreateAnnouncementAdapter(); } /// /// 公告 /// /// /// 公告/消息集合(已倒序排序) public ObservableCollection QueryClientBM(DateTime startDate, DateTime endDate, string title, MsgTypeEnum msgTypeEnum, TradeAccount tradeAccount) { return null; #region 已经注释 //if (tradeAccount == null) return null; //var proxy = LinkerHelper.GetBizServiceProxy(tradeAccount.LoginCode); //if (proxy == null) return null; //var riskNtfType = ClientRiskNtfType.InvestorRiskNtfType; //switch (tradeAccount.AccountType) //{ // case eLoginUserType.LOGINUSERTYPE_TRADER: // riskNtfType = ClientRiskNtfType.InvestorRiskNtfType; // break; // case ClientAccountType.MemberTradeAccount: // riskNtfType = ClientRiskNtfType.MemberRiskNtfType; // break; //} //var reqeust = new ClientBMRequest() //{ // StartDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0), // EndDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59), // MsgType = (Tas.BusinessManager.DataContract.Enum.MsgTypeEnum)msgTypeEnum, // //todo:将Int改成枚举 // AccountType = (int)tradeAccount.AccountType, // RiskNtfType = (int)riskNtfType, // TradeCode = tradeAccount.TradeCode,//AccountCode // AreaCode = tradeAccount.AreaCode, // MemberCode = tradeAccount.MemberCode, // Title = title, // IsValid = IsValidType.Valid, //}; //reqeust.RequestPage = new RequestPageInfo() { NeedTotalCount = 20, Number = 0 }; // modify by justin.huang 由原来的取100条变为取前20条。 //var result = proxy.QueryClientBM(reqeust); //if (result == null) throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); //if (result.ReturnCode != 0) //{ // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(AnnouncementService)); //} //var adapter = new OrderResponseAdapter(); //ObservableCollection announcementList = adapter.ToLocalObservableCollection(result.Rsps.ToList()); //var list = from announcement in announcementList // orderby announcement.PublishDate descending // select announcement; //return new ObservableCollection(list); #endregion } /// /// 修改公告状态 /// /// /// /// public bool ModifyBulletinNotifyStatus(TradeAccount tradeAccount, Announcement announcement) { return false; #region 已经注释 //bool status = false; //if (tradeAccount == null) //{ // return false; //} //var proxy = LinkerHelper.GetBizServiceProxy(tradeAccount.LoginCode); //if (proxy == null) //{ // return false; //} //var request = new ModifyBulletinNotifyStatusRequest() //{ // ClientType = 2, // MsgId = announcement.MsgID, // MsgType = (int)announcement.MsgType, // AccountCode = tradeAccount.TradeCode //}; //var result = proxy.ModifyBulletinNotifyStatus(request); //if (result == null) //{ // status = false; // throw new MuchinfoException(ExceptionManager.ReqeustTimeOutError); //} //if (result.ReturnCode != 0) //{ // status = false; // throw new MuchinfoException(result.ReturnCode, result.ReturnDesc, typeof(AnnouncementService)); //} //else if (result.ReturnCode == 0) //{ // status = true; //} //return status; #endregion } /// /// 交易客户端消息中心查询 /// /// /// /// public void QueryClientBM(QueryClientBMParam clientBMPar, Action> successAction, Action errorAction) { return; //if (clientBMPar.TradeAccount == null) return; //var tradeCacheData = UserManager.GetTradeCacheData(clientBMPar.TradeAccount.AccountId); //if (tradeCacheData == null) return; //var request = _announcementapter.ToRequestQueryClientBM(clientBMPar); //var packgage = new TCPPackage() { Content = request, FunCode = FuncCode.FID_QueryClientBMReq }; //LinkManager.Instance.TradeTcpLinkProxy.SendPackage(packgage, new Action((revPackgage) => //{ // var responeEntity = _announcementapter.ToLocalQueryClientBM(revPackgage.Content); // if (responeEntity.RetCode == 0) // { // if (clientBMPar.MsgTypeEnum == MsgTypeEnum.Bulletin) // { // tradeCacheData.MessageAnnouncementOrders = responeEntity.Entity.ToObservableCollection(); // } // else if(clientBMPar.MsgTypeEnum == MsgTypeEnum.NTF) // { // tradeCacheData.MessageNoticeOrders=responeEntity.Entity.ToObservableCollection(); // } // successAction(responeEntity.Entity); // } // else // { // if (errorAction != null) // { // errorAction(new ErrorEntity() // { // ReturnCode = responeEntity.RetCode, // ReturnDesc = responeEntity.RetMessage // }); // } // } //}), new Action((errorCode, errorDesc) => //{ // ////通信错误 // if (errorAction != null) // { // //RequestFunc = "消息中心查询" // errorAction(new ErrorEntity() { ReturnCode = errorCode, ReturnDesc = errorDesc, RequestFunc = Client_Resource.Resources_Service_QueryMessageCenter }); // } //})); } /// /// 查询公告信息NEW /// /// /// public void QueryNoticeMsg(List queryCommonParams, Action> successAction, Action errorAction, PageInfo pageInfo) { //#if DEBUG //if (null != pageInfo) //{ // var page = new PageInfo() // { // TotalCount =10000, // RecordPerPage = pageInfo.RecordPerPage, // PageNumber = pageInfo.PageNumber, // }; // var list = new List(); // for (int i = 0; i < 20; i++) // { // var notice = new NoticeMsg(); // notice.TITLE = "MTP产品的基本规则"; // notice.CONTENT = "为了提高小组的工作效率,让团队聚焦在产品交付上,保障公司的核心产品MTP研发的高效推进,就产品研发过程的一些基本规则进行定义。"; // notice.END_DATE = DateTime.Now.AddHours(-50); // if (i%3 == 0) // { // notice.STATUS = (NoticeReadStatus)1; // } // else // { // notice.STATUS = 0; // } // list.Add(notice); // } // page.QueryResults = list; // if (successAction != null) // { // successAction(page); // } //} //return; //#endif QueryCommonHelper.QueryCommon(QueryStatement.QueryNoticeMsg, queryCommonParams, new Action>((notice) => { // notice = notice.OrderByDescending((item) => item.SCHEDULE_TIME).ToList(); if (successAction != null) { successAction(notice); } }), (error) => { if (errorAction != null) { //RequestFunc = "查询公告信息" error.RequestFunc = Client_Resource.Resources_Service_QueryNoticeMessage; errorAction(error); } }, pageInfo); } /// /// 查询通知信息NEW /// /// /// public void QueryNotifyMsg(List queryCommonParams, Action> successAction, Action errorAction, PageInfo pageInfo) { QueryCommonHelper.QueryCommon(QueryStatement.QueryNotifyMsg, queryCommonParams, new Action>((notice) => { // notice = notice.OrderByDescending((item) => item.RecordTime).ToList(); if (successAction != null) { successAction(notice); } }), (error) => { if (errorAction != null) { //RequestFunc = "查询通知信息" error.RequestFunc = Client_Resource.Resources_Service_QueryNotifyMessage; errorAction(error); } }, pageInfo); } /// /// 更新通知信息状态NEW /// /// /// public void UpdateNoticeMsgStatus(TradeAccount tradeAccount, NoticeMsg notice, Action successAction, Action errorAction) { return; //var reqeust = _announcementapter.ToReqeustModifyBulletinNotifyStatus(tradeAccount.AccountId, notice.MSG_ID, (int)MsgTypeEnum.Bulletin); //var packgage = new TCPPackage() { Content = reqeust, FunCode = FuncCode.FID_UpdMsgReadStatus }; //LinkManager.Instance.TradeTcpLinkProxy.SendPackage(packgage, new Action((revPackgage) => //{ // ////不处理回应 // if (successAction != null) // { // successAction(); // } //}), null); } /// /// 更新公告信息状态NEW /// /// /// public void UpdateNotifyMsgStatus(TradeAccount tradeAccount, NoticeMsg notify, Action successAction, Action errorAction) { return; //var reqeust = _announcementapter.ToReqeustModifyBulletinNotifyStatus(tradeAccount.AccountId, notify.MSG_ID, (int)MsgTypeEnum.NTF); //var packgage = new TCPPackage() { Content = reqeust, FunCode = FuncCode.FID_UpdMsgReadStatus }; //LinkManager.Instance.TradeTcpLinkProxy.SendPackage(packgage, new Action((revPackgage) => //{ // ////不处理回应 // if (successAction != null) // { // successAction(); // } //}), null); } public void QueryNoticeCount(uint accountId, Action> successAction, Action errorAction) { var queryCommonParams = new List(); queryCommonParams.Add(new QueryCommonParam() { ParamKey = "accountId", ParamValue = accountId + string.Empty }); QueryCommonHelper.QueryCommon(QueryStatement.QueryNoticeCount, queryCommonParams, new Action>((noticeCount) => { // notice = notice.OrderByDescending((item) => item.SCHEDULE_TIME).ToList(); if (successAction != null) { successAction(noticeCount.QueryResults); } }), (error) => { if (errorAction != null) { //RequestFunc = "查询公告信息" error.RequestFunc = Client_Resource.Resources_Service_QueryNoticeMessage; errorAction(error); } }); } } }