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