public virtual void SetMessages(IDbConnection connection, IChannelMessageRepository mesR, int skip = 0)
        {
            var provider = mesR.Provider;
            var msg      = provider.GetChannelMessages(connection, ChannelId, skip, PerPage).ToList();

            Messages = !msg.Any()
                ? new Dictionary <long, ChannelMessageDataModel>()
                : msg.Select(mesR.ConvertToWorkModel).ToDictionary(i => i.Id, i => i);
        }
Exemplo n.º 2
0
        public ChannelService(IChannelConnectionRepository channelConnRepo,
                              IChannelMessageRepository channelMessageRepo,
                              IChannelRepository channelRepo)
        {
            _channelConnRepo = (ChannelConnectionRepository)channelConnRepo;

            _channelMessageRepo = channelMessageRepo;

            _channelRepo = channelRepo;
        }
        public void SetChannelsTabsData(IDbConnection connection, IChannelRepository channelR, IChannelMessageRepository mesR, IChannelConnectionRepository conR, int userId, int allianceId,
                                        bool allianceRoleMessageSend)
        {
            var privateCollection = new Dictionary <int, IBaseChannelOut>();
            var groupCollection   = new Dictionary <int, IBaseChannelOut>();
            Dictionary <int, IBaseChannelOut> allianceCollection = null;
            var provider = channelR.Provider;
            var channelConnectionTbName = conR.SchemeTableName;
            var channelTableName        = channelR.SchemeTableName;
            var ch          = ChannelExtensions.SqlAliaceChannel;
            var chCon       = ChannelExtensions.SqlAliaceChannelConnection;
            var sqlChannels = $"SELECT {chCon}.messageSend as messageSend, {ch}.* FROM {channelConnectionTbName} AS {chCon} " +
                              $"JOIN {channelTableName} AS {ch} ON {ch}.Id = {chCon}.channelId " +
                              $"WHERE {chCon}.userId={userId} AND {chCon}.messageRead=1 AND {ch}.password={chCon}.password";

            var channelData = provider.Text <dynamic>(connection, sqlChannels);
            var channels    = channelData.Select(i => new {
                channelData = channelR.ConvertToWorkModel(((object)i).ToSerealizeString().ToSpecificModel <channel>()),
                messageSend = (bool)i.messageSend
            }
                                                 );

            foreach (var channel in channels)
            {
                switch (channel.channelData.ChannelType)
                {
                case ChannelTypes.Group:
                    var gChOut = new GroupChannelOut(channel.channelData, userId);
                    gChOut.SetMessages(connection, mesR);
                    gChOut.SetComplexButtonView();
                    gChOut.SetBtnSend(channel.messageSend);
                    gChOut.SetUsersIfCanMansge(connection, conR);
                    groupCollection.Add(gChOut.ChannelId, gChOut);


                    break;

                case ChannelTypes.Private:
                    var pChOut = new PrivateChannelOut(channel.channelData);
                    pChOut.SetMessages(connection, mesR);
                    pChOut.SetComplexButtonView();
                    pChOut.SetBtnSend(channel.messageSend);

                    privateCollection.Add(pChOut.ChannelId, pChOut);
                    break;

                case ChannelTypes.Alliance:
                    if (allianceCollection != null)
                    {
                        throw new NotImplementedException("AllianceChannel !=null");
                    }
                    var allianceChannel = new AllianceChannelOut(channel.channelData);
                    allianceChannel.SetMessages(connection, mesR);
                    allianceChannel.SetComplexButtonView();
                    allianceChannel.SetBtnSend(allianceRoleMessageSend);

                    allianceCollection = new Dictionary <int, IBaseChannelOut>(1)
                    {
                        { allianceChannel.ChannelId, allianceChannel }
                    };
                    break;

                default:
                    throw new NotImplementedException();
                }
            }


            Private = new ChannelTab(privateCollection);
            Group   = new ChannelTab(groupCollection)
            {
                MaxChannelsLimit = (int)MaxLenghtConsts.GroupChannelsLimit
            };
            Alliance = new ChannelTab(allianceCollection);
        }
Exemplo n.º 4
0
 public ChannelMessageService(IChannelMessageRepository channelMessageRepository, IChannelInfoRepository channelInfoRepository)
 {
     _channelMessageRepository = channelMessageRepository;
     _channelInfoRepository    = channelInfoRepository;
 }
Exemplo n.º 5
0
 public ChannelMessageLocalStorageCache(IChannelMessageRepository repository)
     : base(repository)
 {
     throw new NotImplementedException(Error.NotUsedServerMethod);
 }