Exemplo n.º 1
0
    public int Logout()
    {
        try
        {
            HttpContext.Current.Session["LoggedIntoChat"] = false;
            HttpContext.Current.Session["ChatMode"]       = -1;

            HttpContext.Current.Session["AutoLoadChatMode"] = -1;

            Member member = (Member)HttpContext.Current.Session["Member"];

            try
            {
                ChatLogic.Logoff(member.WebMemberID);
            }
            catch { }

            MemberSettings ms = member.MemberSettings[0];
            ms.AutoLoadChatMode = -1;
            ms.Save();
        }
        catch { }

        return(0);
    }
Exemplo n.º 2
0
    public AjaxChat GetUpdate(string token)
    {
        Member   member = (Member)HttpContext.Current.Session["Member"];
        AjaxChat ret    = null;

        bool force = false;

        if (HttpContext.Current.Session["fr"] == null)
        {
            HttpContext.Current.Session["fr"] = DateTime.Now;
        }

        int mod = (((int)(DateTime.Now - (DateTime)HttpContext.Current.Session["fr"]).TotalSeconds) % 30);

        force = mod >= 0 && mod <= 2;

        ret = ChatLogic.GetUpdate(member.WebMemberID, token, force);

        InitLast10Messages();
        foreach (AjaxChatMessage ajaxMsg in ret.Messages)
        {
            AddMessageToLast10Message(ajaxMsg);
        }
        PersistLast10Messages();

        return(ret);
    }
Exemplo n.º 3
0
 public MessagesReaderFromServiceJob()
 {
     _chatBL     = new ChatLogic();
     _securityBL = new SecurityLogic();
     _userList   = new List <string>();
     _userList.AddRange(_chatBL.GetUsers().Where(p => p.Name != CurrentUserName).Select(p => p.Name));
 }
 public VolunteerController(QuestionLogic questionLogic, UserLogic userLogic, ReactionLogic reactionLogic, ChatLogic chatLogic, AppointmentLogic appointmentLogic)
 {
     _questionLogic    = questionLogic;
     _userLogic        = userLogic;
     _reactionLogic    = reactionLogic;
     _chatLogic        = chatLogic;
     _appointmentLogic = appointmentLogic;
 }
Exemplo n.º 5
0
 public CareRecipientController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, AppointmentLogic appointmentLogic)
 {
     _questionLogic    = questionLogic;
     _categoryLogic    = categoryLogic;
     _reactionLogic    = reactionLogic;
     _userLogic        = userLogic;
     _chatLogic        = chatLogic;
     _appointmentLogic = appointmentLogic;
 }
Exemplo n.º 6
0
 public AdminController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, LogLogic logLogic)
 {
     _questionLogic = questionLogic;
     _categoryLogic = categoryLogic;
     _reactionLogic = reactionLogic;
     _userLogic     = userLogic;
     _chatLogic     = chatLogic;
     _logLogic      = logLogic;
 }
Exemplo n.º 7
0
 public ReviewController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, ReviewLogic reviewLogic)
 {
     _questionLogic = questionLogic;
     _categoryLogic = categoryLogic;
     _reactionLogic = reactionLogic;
     _userLogic     = userLogic;
     _chatLogic     = chatLogic;
     _reviewLogic   = reviewLogic;
 }
Exemplo n.º 8
0
    public int SendMessage(string messages)
    {
        string[] msgArray = messages.Split(new char[] { ';' });
        List <AjaxChatMessage> ajaxChtMsgs = new List <AjaxChatMessage>();

        foreach (string msg in msgArray)
        {
            string [] singleMsg = msg.Split(new char[] { ',' });

            if (singleMsg.Length < 2)
            {
                continue;
            }

            string WebMemberIDTo = singleMsg[0];
            string Message       = singleMsg[1];
            Member member        = (Member)HttpContext.Current.Session["Member"];
            int    MemberID      = member.MemberID;

            Member memberTo = Member.GetMemberViaWebMemberID(WebMemberIDTo);

            AjaxChatMessage ajaxMsg = new AjaxChatMessage();

            ajaxMsg.ChatMessageWebID = Next2Friends.Misc.UniqueID.NewWebID();
            ajaxMsg.Delivered        = false;
            ajaxMsg.DTCreated        = DateTime.Now;
            ajaxMsg.Message          = Message;
            ajaxMsg.MemberIDFrom     = MemberID;
            ajaxMsg.WebMemberIDFrom  = member.WebMemberID;
            ajaxMsg.Retrieved        = false;
            ajaxMsg.WebMemberIDTo    = WebMemberIDTo;
            ajaxMsg.MemberIDTo       = memberTo.MemberID;
            ajaxMsg.Outbound         = 1;

            try
            {
                ChatLogic.SendMessage(ajaxMsg);
            }
            catch { }

            ajaxChtMsgs.Add(ajaxMsg);

            InitLast10Messages();
            AddMessageToLast10Message(ajaxMsg);

            PersistLast10Messages();
        }

        ParameterizedThreadStart ts = new ParameterizedThreadStart(SaveMessageDB);
        Thread t = new Thread(SaveMessageDB);

        t.Priority = ThreadPriority.BelowNormal;
        t.Start(ajaxChtMsgs);

        return(0);
    }
Exemplo n.º 9
0
        public ActionResult SendWebPushnotification(string Token, string Message, int ChannelId)
        {
            List <string> receiverTokens = new List <string>();

            receiverTokens.Add(Token);
            ChatLogic cl = new ChatLogic();

            cl.SendNotification(receiverTokens, Message, "Push Notification", "Push Notification", ChannelId, null, null, null, null);
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
        public void SendMessage_Called_Exactly_Once()
        {
            Mock <IChatContext> mockContext = new Mock <IChatContext>();

            mockContext.Setup(x => x.SendMessage(0, 1, 2, "hoi"));

            ChatLogic chatLogic = new ChatLogic(mockContext.Object);

            chatLogic.SendMessage(0, 1, 2, "hoi");
            mockContext.Verify((x => x.SendMessage(0, 1, 2, "hoi")), Times.Exactly(1));
        }
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            TRS_Domain.GROUP.Data selectedGroup = GroupControl_Logic.GetGroupInformation(groupId);
            ChatLogic             chatlogic     = new ChatLogic();

            DisplayImage(selectedGroup.Img);

            TB_GroupName.Text      = selectedGroup.Name;
            CB_Region.ItemsSource  = Enum.GetNames(typeof(GroupControl_Logic.Regions));
            CB_Region.SelectedItem = selectedGroup._region;
            RTB_Description.Text   = selectedGroup.Description;
        }
Exemplo n.º 12
0
 public ChatViewModel()
 {
     SendCommand = new DelegateCommand(ExecuteSendCommand);
     _chatBL     = new ChatLogic();
     _securityBL = new SecurityLogic();
     _listUser   = new ObservableCollection <string>();
     _listUser.AddRange(_chatBL.GetUsers().Where(p => p.Name != CurrentUserName).Select(p => p.Name).ToList());
     JobScheduler.Start();
     _timer          = new Timer();
     _timer.Interval = 2000;
     _timer.Elapsed += (sender, args) => ChatText = _chatBL.GenerateChatText(_selectedUserName);
     _timer.Start();
 }
Exemplo n.º 13
0
        public void GetAllOpenChatsWithCareRecipientID_IsValid()
        {
            using (AutoMock mock = AutoMock.GetLoose())
            {
                mock.Mock <IChatContext>()
                .Setup(x => x.GetAllOpenChatsWithCareRecipientId(1))
                .Returns(GetSampleChats());

                ChatLogic      cls      = mock.Create <ChatLogic>();
                List <ChatLog> expected = GetSampleChats();

                List <ChatLog> actual = cls.GetAllOpenChatsWithCareRecipientId(1);

                Assert.AreEqual(expected.Count, actual.Count);
            }
        }
Exemplo n.º 14
0
        public void CreateNewChatLog_IsValid()
        {
            Mock <IChatContext> mockContext = new Mock <IChatContext>();

            int newChatLogId = 3;

            mockContext.Setup(x => x.CreateNewChatLog(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(newChatLogId);

            ChatLogic chatLogic = new ChatLogic(mockContext.Object);
            int       result    = chatLogic.CreateNewChatLog(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>());

            mockContext.Verify(x => x.CreateNewChatLog(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()));
            Assert.IsInstanceOfType(result, typeof(int));
            Assert.AreEqual(newChatLogId, result);
        }
Exemplo n.º 15
0
    public int Login(int x, bool rem)
    {
        Member member = (Member)HttpContext.Current.Session["Member"];

        HttpContext.Current.Session["fr"] = DateTime.Now;

        try
        {
            ChatLogic.Login(member);
        }
        catch { }

        if (member != null)
        {
            try
            {
                HttpContext.Current.Session["LoggedIntoChat"] = true;
                HttpContext.Current.Session["ChatMode"]       = x;

                // persist autoload settings
                if (rem)
                {
                    HttpContext.Current.Session["AutoLoadChatMode"] = x;
                    MemberSettings ms = member.MemberSettings[0];
                    ms.AutoLoadChatMode = x;
                    ms.Save();
                }
            }
            catch
            {
                try
                {
                    ChatLogic.Logoff(member.WebMemberID);
                }
                catch { }
            }

            return(0);
        }

        else
        {
            return(-1);
        }
    }
Exemplo n.º 16
0
        private void btnCreateChatlog_Click(object sender, EventArgs e)
        {
            if (lvQuestionReaction.SelectedItems.Count == 1)
            {
                int selectedRow = lvQuestionReaction.SelectedItems[0].Index;
                int selectedId  = Convert.ToInt32(lvQuestionReaction.Items[selectedRow].SubItems[3].Text);
                int reactionID  = Convert.ToInt32(lvQuestionReaction.Items[selectedRow].SubItems[4].Text);
                int senderID    = Convert.ToInt32(lvQuestionReaction.Items[selectedRow].SubItems[5].Text);

                ChatLogic cl = new ChatLogic();
                cl.CreateNewChatLog(reactionID, senderID, FormLogin.currentUser.UserId);
                MessageBox.Show("Chat aangemaakt");
                ((FormMain)this.Parent.Parent).ReplaceForm(new FormCareChatOverview());
            }
            else
            {
                MessageBox.Show("Error");
            }
        }
Exemplo n.º 17
0
        public void LoadMessageAsListUsingChatLogID_IsValid()
        {
            Mock <IChatContext> mockContext = new Mock <IChatContext>();
            List <ChatMessage>  stub        = new List <ChatMessage>();

            User user = new Mock <User>(1, "Jesse", "Oosterwijk", "Kleidonk 1", "Beuningen", "6641LM", "*****@*****.**", DateTime.Today, User.Gender.Man, true, User.AccountType.CareRecipient, "1111").Object;

            mockContext.Setup(x => x.LoadMessage(user.UserId))
            .Returns(stub);

            ChatLogic chatLogic = new ChatLogic(mockContext.Object);

            List <ChatMessage> result   = chatLogic.LoadMessageListWithChatId(user.UserId);
            List <ChatMessage> expected = stub;


            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(List <ChatMessage>));
            Assert.AreEqual(result, expected);
        }
Exemplo n.º 18
0
        public void SetUp()
        {
            _repo = new Mock <IChatRepository>();

            _logic = new ChatLogic(_repo.Object);
        }
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            //Console.WriteLine("STUB DID NOT INSERT ANY CHAT LINES STUB");
            //return;

            try
            {
                Console.WriteLine("Inserting data from in-game chat logs.  This will take a long time...  be patient and don't exit early!");
            }
            catch { }

            var context   = new TunnelQuestContext();
            var chatLogic = new ChatLogic(context);
            var authToken = context.AuthTokens.FirstOrDefault(token => token.Name == "default").Value;

            var assembly = typeof(InsertChatLogData).GetTypeInfo().Assembly;

            int  i      = 1;
            bool isDone = false;

            do
            {
                var allFileLines = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Migrations\Data\EcTunnelChatLogs\eqlog_project1999_" + i.ToString() + ".txt");

                try
                {
                    int      fileLineCount  = 0;
                    DateTime lastLoggedTime = DateTime.Now;

                    foreach (string logLineText in allFileLines)
                    {
                        string   chatLineText  = logLineText.Substring(27);
                        string[] chatLineWords = chatLineText.Split(' ');

                        if (chatLineWords.Length > 2 && chatLineWords[1] == "auctions,")
                        {
                            string   timeStampString = logLineText.Substring(1, 24);
                            string[] timeStampParts  = timeStampString.Split(' ');

                            int month;
                            switch (timeStampParts[1])
                            {
                            case "Jan":
                                month = 1;
                                break;

                            case "Feb":
                                month = 2;
                                break;

                            case "Mar":
                                month = 3;
                                break;

                            case "Apr":
                                month = 4;
                                break;

                            case "May":
                                month = 5;
                                break;

                            case "Jun":
                                month = 6;
                                break;

                            case "Jul":
                                month = 7;
                                break;

                            case "Aug":
                                month = 8;
                                break;

                            case "Sep":
                                month = 9;
                                break;

                            case "Oct":
                                month = 10;
                                break;

                            case "Nov":
                                month = 11;
                                break;

                            case "Dec":
                                month = 12;
                                break;

                            default:
                                throw new Exception("Unknown month '" + timeStampParts[1] + "'");
                            }

                            int day  = Int32.Parse(timeStampParts[2]);
                            int year = Int32.Parse(timeStampParts[4]);

                            string[] timeParts = timeStampParts[3].Split(':');
                            int      hour      = Int32.Parse(timeParts[0]);
                            int      minute    = Int32.Parse(timeParts[1]);
                            int      second    = Int32.Parse(timeParts[2]);

                            DateTime chatLineTimestamp = new DateTime(year, month, day, hour, minute, second).AddHours(6); // +6 hours to convert the log file times from Central Standard Time to UTC

                            var result = chatLogic.ProcessLogLine(authToken, ServerCodes.Blue, chatLineText, chatLineTimestamp);

                            fileLineCount++;
                            if (fileLineCount % 100 == 0)
                            {
                                Console.WriteLine("[" + DateTime.Now.ToString() + ", took " + (DateTime.Now - lastLoggedTime).TotalSeconds.ToString() + " seconds] " + fileLineCount.ToString());
                                lastLoggedTime = DateTime.Now;

                                // create a new context every so often, or else the inserts will get slower and slower
                                // until you're processing 1 chat line per second
                                context.Dispose();
                                context   = new TunnelQuestContext();
                                chatLogic = new ChatLogic(context);
                            }

                            // STUB
                            if (fileLineCount > 5000)
                            {
                                Console.WriteLine("STUB ended chat log import early for debugging purposes STUB");
                                isDone = true;
                                break;
                            }
                            // END STUB
                        }
                    }

                    i++;
                }
                catch (ArgumentNullException)
                {
                    isDone = true;
                }
            }while (!isDone);

            try
            {
                Console.WriteLine("Finished inserting data from in-game chat logs.");
            }
            catch { }
        } // end function Up()
Exemplo n.º 20
0
        public async Task <ActionResult> Create(Attende appUser, AdminInfo adminInfo, List <int> events)
        {
            try
            {
                ChatLogic chatLogic = new ChatLogic();
                if (appUser.ID > 0)
                {
                    var update = await db.Attendes.FindAsync(appUser.ID);

                    update.FirstName             = appUser.FirstName;
                    update.Lastname              = appUser.Lastname;
                    update.Email                 = appUser.Email.Trim();
                    update.AdminInfo.UserRole    = adminInfo.UserRole;
                    update.AdminInfo.Password    = adminInfo.Password;
                    update.AdminInfo.PhoneNumber = adminInfo.PhoneNumber;

                    if (events == null)
                    {
                        var removeAll = db.AttendesEvents.Where(x => x.AttendesID == appUser.ID).ToList();
                        db.AttendesEvents.RemoveRange(removeAll);
                        await db.SaveChangesAsync();
                    }
                    else
                    {
                        var removeEvent = db.AttendesEvents.Where(x => x.AttendesID == appUser.ID && !events.Contains(x.EventID));
                        if (removeEvent.Any())
                        {
                            db.AttendesEvents.RemoveRange(removeEvent);
                            await db.SaveChangesAsync();
                        }
                        foreach (var item in events)
                        {
                            if (!db.AttendesEvents.Any(x => x.EventID == item && x.AttendesID == appUser.ID))
                            {
                                db.AttendesEvents.Add(new AttendesEvent
                                {
                                    EventID    = item,
                                    AttendesID = appUser.ID
                                });
                                chatLogic.AddNewAdminToEventChannels(appUser, item);
                            }
                        }
                    }
                    await db.SaveChangesAsync();
                }
                else
                {
                    if (db.Attendes.Any(x => string.Equals(x.Email.Trim(), appUser.Email.Trim(), StringComparison.CurrentCultureIgnoreCase)))
                    {
                        EventLogic eventLogic = new EventLogic();
                        ViewBag.Events = await eventLogic.GetAllEvents();

                        ModelState.AddModelError("Email", "Email already exists. Please try any other Email");
                        ModelState.AddModelError(String.Empty, "Failed");
                        return(View(appUser));
                    }
                    appUser.AdminInfo = adminInfo;
                    appUser.Email     = appUser.Email.Trim();
                    appUser.IsAdmin   = true;
                    if (events != null && events.Count > 0)
                    {
                        appUser.AttendesEvents = events.Select(x => new AttendesEvent {
                            EventID = x
                        }).ToList();
                    }

                    if (chatLogic.getAdminGroupID() != null)
                    {
                        appUser.AttendeeGroups.Add(new AttendeeGroup()
                        {
                            GroupID = chatLogic.getAdminGroupID()
                        });
                    }
                    db.Attendes.Add(appUser);
                    await db.SaveChangesAsync();

                    if (events != null)
                    {
                        foreach (var eventID in events)
                        {
                            chatLogic.AddNewAdminToEventChannels(appUser, eventID);
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException ex)
            {
                Helpers.LogError("AppUser Error", ex);
                ModelState.AddModelError(String.Empty, ex.EntityValidationErrors.ElementAt(0).ValidationErrors.ElementAt(0).ErrorMessage);
                EventLogic eventLogic = new EventLogic();
                ViewBag.Events = await eventLogic.GetAllEvents();

                ViewBag.error = Literals.ErrorMessage;
                return(View(appUser));
            }
        }