private void Refresh()
 {
     IsRefreshing = true;
     Chats.Clear();
     LoadChats();
     IsRefreshing = false;
 }
Beispiel #2
0
 protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
 {
     c         = new Chats();
     c.TutorID = objStudent.userprofileID;
     c.TuteeID = Convert.ToInt32(e.Item.DataItem("UserProfileID"));
     LoadChatbox();
 }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Resources"/> class.
        /// </summary>
        internal static void Initialize()
        {
            Resources.Logger = LogManager.GetCurrentClassLogger(typeof(Resources));

            Factory.Initialize();
            CSV.Initialize();
            LevelFile.Initialize();
            Fingerprint.Initialize();
            Globals.Initialize();

            if (Constants.Database == DBMS.Mongo)
            {
                Mongo.Initialize();
            }

            Resources.Redis = new Redis();
            Resources.Regex = new Regex("[ ]{2,}", RegexOptions.Compiled);

            Resources.Players = new Players();
            Resources.Clans   = new Clans();
            Resources.Chats   = new Chats();
            Resources.Battles = new Battles();
            Resources.Random  = new XorShift();

            Resources.TCPGateway = new TCPServer();
            Resources.UDPGateway = new UDPServer();

            Resources.Started = true;

            Parser.Initialize();
            EventsHandler.Initialize();
        }
Beispiel #4
0
        private void OnTelegramServiceNewMessage(object sender, EventArgs.NewMessageEventArgs e)
        {
            _dispatcherService.InvokeIfRequired(async() =>
            {
                try
                {
                    var chat     = Chats.FirstOrDefault(x => x.Chat.Id == e.Message.Chat.Id);
                    bool newChat = chat == null;

                    if (newChat)
                    {
                        chat = ChatViewModel.Create(e.Message.Chat);
                        Chats.Add(chat);
                    }

                    chat.AddMessage(e.Message);
                    Chats.MoveItemToTop(chat);

                    if (newChat)
                    {
                        await chat.LoadImageAsync();
                    }
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            });
        }
        public async Task <List <ChatsDTO> > ListarChats(Chats chatParaListar)
        {
            using (SportsGoEntities context = new SportsGoEntities(false))
            {
                ChatsRepository          chatsRepo = new ChatsRepository(context);
                DateTimeHelperNoPortable helper    = new DateTimeHelperNoPortable();

                if (chatParaListar.FechaFiltroBase != DateTime.MinValue)
                {
                    chatParaListar.FechaFiltroBase = helper.ConvertDateTimeFromAnotherTimeZone(chatParaListar.ZonaHorariaGMTBase, helper.DifferenceBetweenGMTAndLocalTimeZone, chatParaListar.FechaFiltroBase);
                }

                List <ChatsDTO> listaChats = await chatsRepo.ListarChats(chatParaListar);

                if (listaChats != null && listaChats.Count > 0)
                {
                    foreach (var chat in listaChats)
                    {
                        chat.Creacion = helper.ConvertDateTimeFromAnotherTimeZone(chatParaListar.ZonaHorariaGMTBase, helper.DifferenceBetweenGMTAndLocalTimeZone, chat.Creacion);

                        if (chat.UltimoMensaje != null)
                        {
                            chat.UltimoMensaje.FechaMensaje = helper.ConvertDateTimeFromAnotherTimeZone(chatParaListar.ZonaHorariaGMTBase, helper.DifferenceBetweenGMTAndLocalTimeZone, chat.UltimoMensaje.FechaMensaje);
                        }
                    }
                }

                return(listaChats);
            }
        }
Beispiel #6
0
 protected void Button2_Click1(object sender, EventArgs e)
 {
     string chatName = Request.Form["chatName"];
     //Chats chat = ChatList.FirstOrDefault(x => x.ChatName == TextBox1.Text);
     Chats chat = ChatList.FirstOrDefault(x => x.ChatName == chatName);
     // DataHelper.AddChatUser(new ChatUsers() { ChatId = chat.Id, UserId = CurUser.UserId });
 }
Beispiel #7
0
        internal Clan(long ClanID = 0)
        {
            Clan_ID = ClanID;

            Members = new Members(this);
            Chats   = new Chats(this);
        }
 public override void ToStream(Stream output)
 {
     output.Write(TLUtils.SignatureToBytes(Signature));
     output.Write(Peer.ToBytes());
     output.Write(Chats.ToBytes());
     output.Write(Users.ToBytes());
 }
    public static int[] GetActionID(int chatID)
    {
        List <int> result = new List <int>();

        result.Add(chatID);
        Chat chat = Chats.GetChat(UserSession.LoginUser, chatID);

        if (chat == null)
        {
            return(null);
        }
        result.Add(chat == null || chat.ActionID == null ? -1 : (int)chat.ActionID);

        int?userID = null;

        if (chat.InitiatorType == ChatParticipantType.External)
        {
            ChatClients clients = new ChatClients(UserSession.LoginUser);
            clients.LoadByChatClientID(chat.InitiatorID);
            if (!clients.IsEmpty)
            {
                userID = clients[0].LinkedUserID;
            }
        }

        result.Add(chat.GetInitiatorLinkedUserID());

        return(result.ToArray());
    }
Beispiel #10
0
        internal Clan(long ClanID = 0)
        {
            this.Clan_ID = ClanID;

            this.Members = new Members(this);
            this.Chats   = new Chats(this);
        }
Beispiel #11
0
        public IHttpActionResult PostChats(Chats chats)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Chats.Add(chats);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (ChatsExists(chats.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = chats.Id }, chats));
        }
Beispiel #12
0
 public void RequestNewChat(string auctionId, string participant, Message message)
 {
     CurrentChat         = new Chat(auctionId, participant);
     CurrentChat.Message = message;
     Chats.Add(CurrentChat);
     OnChatCreated(EventArgs.Empty);
 }
        public void OnChatClosed(FrameworkElement vChat)
        {
            var data = vChat.Tag as Tuple <RatChat.Core.IChatSource, string>;

            data.Item1.OnNewMessagesArrived -= ichat_OnNewMessagesArrived;
            data.Item1.EndWork();


            RatChat.Core.IChatListener iListener = data.Item1 as RatChat.Core.IChatListener;
            if (iListener == null)
            {
                foreach (FrameworkElement fe in Chats)
                {
                    RatChat.Core.IChatSource   i  = ((Tuple <RatChat.Core.IChatSource, string>)fe.Tag).Item1;
                    RatChat.Core.IChatListener il = i as RatChat.Core.IChatListener;
                    if (il != null)
                    {
                        data.Item1.OnNewMessagesArrived -= il.OnNewMessageReceived;
                    }
                    //i.OnNewMessagesArrived += iListener.OnNewMessageReceived;
                }
            }
            else
            {
                foreach (FrameworkElement fe in Chats)
                {
                    RatChat.Core.IChatSource i = ((Tuple <RatChat.Core.IChatSource, string>)fe.Tag).Item1;
                    i.OnNewMessagesArrived -= iListener.OnNewMessageReceived;
                }
            }

            Chats.Remove(vChat);

            ChatConfigStorage.RemoveWithPrefix(data.Item1.ConfigPrefix);
        }
Beispiel #14
0
        public IHttpActionResult PutChats(int id, Chats chats)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != chats.Id)
            {
                return(BadRequest());
            }

            db.Entry(chats).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChatsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #15
0
        public static async Task UpdateChat(Chat chat)
        {
            var cachedChat = Chats.FirstOrDefault(x => x.Id == chat.Id);

            if (cachedChat is not null)
            {
                cachedChat.Locale               = chat.Locale;
                cachedChat.Introduction         = chat.Introduction;
                cachedChat.DisableAnnouncements = chat.DisableAnnouncements;
                cachedChat.DisableEvents        = chat.DisableEvents;

                await using var db = new Database();
                var dbChat = await db.Chats.FirstOrDefaultAsync(x => x.Id == chat.Id);

                if (dbChat is not null)
                {
                    dbChat.Locale               = chat.Locale;
                    dbChat.Introduction         = chat.Introduction;
                    dbChat.DisableAnnouncements = chat.DisableAnnouncements;
                    dbChat.DisableEvents        = chat.DisableEvents;

                    await db.SaveChangesAsync();
                }
            }
        }
Beispiel #16
0
        public async Task <ActionResult <Chats> > PostChats(Chats chats)
        {
            _context.Chats.Add(chats);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetChats", new { id = chats.Id }, chats));
        }
        public async Task <WrapperSimpleTypesDTO> CrearChat(Chats chatParaCrearOwner)
        {
            using (SportsGoEntities context = new SportsGoEntities(false))
            {
                ChatsRepository chatsRepo = new ChatsRepository(context);

                // Verifico si ya existe mi chat principal, si existe lo reactivo, si no lo creo
                bool existeChatOwner = await chatsRepo.VerificarSiYaExisteChat(chatParaCrearOwner);

                if (existeChatOwner)
                {
                    chatParaCrearOwner = await chatsRepo.ReactivarChat(chatParaCrearOwner);
                }
                else
                {
                    chatParaCrearOwner.EstadoChat = EstadosChat.Activo;
                    chatParaCrearOwner.Creacion   = DateTime.Now;
                    chatsRepo.CrearChat(chatParaCrearOwner);
                }

                Chats chatNoOwner = new Chats
                {
                    CodigoPersonaOwner   = chatParaCrearOwner.CodigoPersonaNoOwner,
                    CodigoPersonaNoOwner = chatParaCrearOwner.CodigoPersonaOwner
                };

                // Verifico si ya existe mi chat secundario de la persona a que le voy a enviar, si existe no hago nada, si no lo creo
                // Lo dejo en estado inactivo para que crear el chat principal no le cree un chat a la persona secundaria
                // Solo cuando un mensaje es mandado es que ambos son reactivados
                bool existeChatNoOwner = await chatsRepo.VerificarSiYaExisteChat(chatNoOwner);

                if (!existeChatNoOwner)
                {
                    chatNoOwner.EstadoChat = EstadosChat.PendienteParaBorrarMensajes;
                    chatNoOwner.Creacion   = DateTime.Now;
                    chatsRepo.CrearChat(chatNoOwner);
                }

                WrapperSimpleTypesDTO wrapperCrearChat = new WrapperSimpleTypesDTO();

                wrapperCrearChat.NumeroRegistrosAfectados = await context.SaveChangesAsync();

                if (wrapperCrearChat.NumeroRegistrosAfectados > 0 || chatParaCrearOwner.Consecutivo > 0)
                {
                    wrapperCrearChat.Exitoso           = true;
                    wrapperCrearChat.ConsecutivoCreado = chatParaCrearOwner.Consecutivo;

                    if (chatNoOwner.Consecutivo > 0)
                    {
                        wrapperCrearChat.ConsecutivoChatRecibe = chatNoOwner.Consecutivo;
                    }
                    else
                    {
                        wrapperCrearChat.ConsecutivoChatRecibe = await chatsRepo.BuscarConsecutivoChat(chatNoOwner);
                    }
                }

                return(wrapperCrearChat);
            }
        }
Beispiel #18
0
        public async Task <bool> VerificarSiSePuedenBorrarMensajesNoOwner(Chats chatParaVerificar)
        {
            int  codigoEstadoParaBorrar       = (int)EstadosChat.PendienteParaBorrarMensajes;
            bool sePuedeBorrarMensajesNoOwner = await _context.Chats.Where(x => x.CodigoPersonaOwner == chatParaVerificar.CodigoPersonaNoOwner && x.CodigoPersonaNoOwner == chatParaVerificar.CodigoPersonaOwner && x.CodigoEstado == codigoEstadoParaBorrar).AnyAsync();

            return(sePuedeBorrarMensajesNoOwner);
        }
        public SettingsViewModel(ISettingsDataService dataService, IGeneralDataService generalDataService)
        {
            settingsDataService = dataService;
            CurrentTheme        = Ubiquitous.Default.Config.AppConfig.ThemeName;
            settingsDataService.GetChatSettings((list) => {
                foreach (ChatConfig chatConfig in list)
                {
                    Chats.Add(new SettingsChatItemViewModel(chatConfig));
                }
            });

            var serviceList = generalDataService.Services.Select(service => new SettingsSectionViewModel(service));

            foreach (var service in serviceList)
            {
                ServiceItemViewModels.Add(service);
            }

            AppConfig = Ubiquitous.Default.Config.AppConfig;

            ThemeList = new ObservableCollection <ThemeDescription>(Theme.ThemesList);
            var currentTheme = ThemeList.FirstOrDefault(theme => theme.Title.Equals(Theme.CurrentTheme));

            if (currentTheme != null)
            {
                currentTheme.IsCurrent = true;
            }
        }
Beispiel #20
0
 public override void ToStream(Stream output)
 {
     output.Write(TLUtils.SignatureToBytes(Signature));
     Categories.ToStream(output);
     Chats.ToStream(output);
     Users.ToStream(output);
 }
Beispiel #21
0
        private void Transport_PhotoMessageReceived(object sender, EventArgs <BotPhotoMessage> e)
        {
            Core.Log.LibVerbose("Photo Message received...");
            var message = e.Item1;

            #region Get Chat
            if (Chats.TryGet(message.Chat.Id, out var storedChat))
            {
                message.Chat.State = storedChat.State;
            }
            else
            {
                Chats.Add(message.Chat);
            }
            #endregion

            #region Get User
            if (!Users.Contains(message.User.Id))
            {
                Users.Add(message.User);
            }
            #endregion

            OnPhotoMessageReceived?.Invoke(this, e);
        }
Beispiel #22
0
        public WebChat StartChat(WebClient owner, string roomName)
        {
            //Find out of the owner has already stated this chat
            WebChat chat = Chats.SingleOrDefault(c => c.Owner.Equals(owner) && c.RoomName.ToLowerInvariant().Equals(roomName.ToLowerInvariant()));

            //If there is already a chat with the same name
            if (null != chat)
            {
                //There is alredy a chat with the same name, return it
                return(chat);
            }
            else
            {
                //Ensure on one thread is adding a chat
                lock (m_Chats)
                {
                    //Create a new chat
                    chat = new WebChat(owner, roomName);
                    //Add it to the Server
                    m_Chats.Add(chat.RoomId, chat);
                }
            }
            //Return the chat
            return(chat);
        }
Beispiel #23
0
        private async void SendMessage()
        {
            if (string.IsNullOrEmpty(Message) || string.IsNullOrWhiteSpace(Message))
            {
                Message = null;
                return;
            }
            var chat = new Chat()
            {
                Sender = Settings.UsernameSettings,

                //SenderEmail = Settings.EmailSettings,
                SenderId     = Settings.KeySettings,
                SenderAvatar = Settings.AvatarSettings,
                Message      = Message.Trim(),
                Receiver     = Username,
                ReceiverId   = Id,
                //ReceiverEmail = Email,
                ReceiverAvatar = Avatar,
                Time           = DateTime.Now
            };

            Message = null;
            Chats.Add(chat);
            var send = await remoteService.SendMessage(chat);
        }
Beispiel #24
0
 public bool Connect(String channel)
 {
     try
     {
         var res = Request(String.Format("{0}channels/{1}", BaseUrl, channel));
         if (!string.IsNullOrEmpty(res))
         {
             channelId           = JsonConvert.DeserializeObject <Channel>(res);
             res                 = Request(String.Format("{0}chats/{1}", BaseUrl, channelId.id));
             chats               = JsonConvert.DeserializeObject <Chats>(res);
             ws                  = new WebSocket(chats.endpoints.LastOrDefault());
             ws.MessageReceived += Ws_MessageReceived;
             ws.Closed          += Ws_Closed;
             ws.Error           += Ws_Error;
             ws.Open();
             return(true);
         }
         else
         {
             OnError?.Invoke(new Classes.ErrorEventArgs(new Exception("Mixer Api not responding")));
         }
     }
     catch (Exception ex)
     {
         OnError?.Invoke(new Classes.ErrorEventArgs(ex));
     }
     return(false);
 }
Beispiel #25
0
        public async Task <IActionResult> PutChats(int id, Chats chats)
        {
            if (id != chats.Id)
            {
                return(BadRequest());
            }

            _context.Entry(chats).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChatsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #26
0
 public Chat CreateChat(string auctionId, string participant, IMessageListener messageListener)
 {
     CurrentChat = new Chat(auctionId, participant);
     CurrentChat.AddIMessageListener(messageListener);
     Chats.Add(CurrentChat);
     OnChatCreated(EventArgs.Empty);
     return(CurrentChat);
 }
Beispiel #27
0
        public bool DoesUserHavePermission(string userLogin, int chatId, ChatPermissionTypes permissionType)
        {
            var chatPermission             = GetChatPermission(userLogin, chatId);
            var existingChatPermissionType = (ChatPermissionTypes?)chatPermission?.PermissionType
                                             ?? ChatPermissionTypes.None;

            return(Chats.DoesUserHaveChatPermission(existingChatPermissionType, permissionType));
        }
Beispiel #28
0
        public ActionResult DeleteConfirmed(int id)
        {
            Chats chats = db.Chats.Find(id);

            db.Chats.Remove(chats);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #29
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                Categories.ToBytes(),
                Chats.ToBytes(),
                Users.ToBytes()));
 }
Beispiel #30
0
        public async Task <Chats> ReactivarChatPorConsecutivo(Chats chatParaReactivar)
        {
            Chats chatExistente = await _context.Chats.Where(x => x.Consecutivo == chatParaReactivar.Consecutivo).FirstOrDefaultAsync();

            chatExistente.EstadoChat = EstadosChat.Activo;

            return(chatExistente);
        }