Ejemplo n.º 1
0
        public int GetLatestWatercoolerCount()
        {
            User            user = TSAuthentication.GetUser(TSAuthentication.GetLoginUser());
            WaterCoolerView wcv  = new WaterCoolerView(TSAuthentication.GetLoginUser());

            return(wcv.GetLatestWatercoolerCount(user.LastLoginUtc.ToString()));
        }
        override protected void LoadData()
        {
            WaterCoolerView waterCoolerMessages = new WaterCoolerView(_loginUser);

            waterCoolerMessages.LoadForIndexing(_organizationID, _maxCount, _isRebuilding);
            foreach (WaterCoolerViewItem waterCoolerMessage in waterCoolerMessages)
            {
                _itemIDList.Add(waterCoolerMessage.MessageID);
            }
        }
        public WaterCoolerThread[] GetMoreThreads(int pageType, int pageID, int msgcount)
        {
            List <WaterCoolerThread> result = new List <WaterCoolerThread>();

            //This reads the WaterCoolerView because it has UserNames and Groups.  This is readonly

            WaterCoolerView wc = new WaterCoolerView(TSAuthentication.GetLoginUser());

            wc.LoadMoreThreads(pageType, pageID, msgcount);

            foreach (WaterCoolerViewItem item in wc)
            {
                WaterCoolerThread thread = new WaterCoolerThread();

                WaterCoolerView replies = new WaterCoolerView(wc.LoginUser);
                replies.LoadReplies(item.MessageID);

                WatercoolerAttachments wcgroups = new WatercoolerAttachments(TSAuthentication.GetLoginUser());
                wcgroups.LoadByType(item.MessageID, WaterCoolerAttachmentType.Group);

                WatercoolerAttachments wctickets = new WatercoolerAttachments(TSAuthentication.GetLoginUser());
                wctickets.LoadByType(item.MessageID, WaterCoolerAttachmentType.Ticket);

                WatercoolerAttachments wcprods = new WatercoolerAttachments(TSAuthentication.GetLoginUser());
                wcprods.LoadByType(item.MessageID, WaterCoolerAttachmentType.Product);

                WatercoolerAttachments wccompany = new WatercoolerAttachments(TSAuthentication.GetLoginUser());
                wccompany.LoadByType(item.MessageID, WaterCoolerAttachmentType.Company);

                WatercoolerAttachments wcuseratt = new WatercoolerAttachments(TSAuthentication.GetLoginUser());
                wcuseratt.LoadByType(item.MessageID, WaterCoolerAttachmentType.User);

                WatercoolerAttachments wcactivitiesatt = new WatercoolerAttachments(TSAuthentication.GetLoginUser());
                wcactivitiesatt.LoadByType(item.MessageID, WaterCoolerAttachmentType.Activities);

                thread.Message    = item.GetProxy();
                thread.Replies    = replies.GetWaterCoolerViewItemProxies();
                thread.Groups     = wcgroups.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Group);
                thread.Tickets    = wctickets.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Ticket);
                thread.Products   = wcprods.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Product);
                thread.Company    = wccompany.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Company);
                thread.User       = wcuseratt.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.User);
                thread.Activities = wcactivitiesatt.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Activities);

                result.Add(thread);
            }

            return(result.ToArray());
        }
        public bool IsValid(int pageID, int itemID, int messageID)
        {
            WaterCoolerView wcv = new WaterCoolerView(TSAuthentication.GetLoginUser());

            wcv.CheckMessage(pageID, itemID, messageID);

            if (wcv.IsEmpty)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public WaterCoolerViewItemProxy AddMessage(int?messageID, string message)
        {
            // DON'T user the view to save to the DB.  User the WaterCooler table.  The views are read only
            WaterCoolerItem wc = (new WaterCooler(TSAuthentication.GetLoginUser())).AddNewWaterCoolerItem();

            wc.GroupFor       = null;
            wc.Message        = message;
            wc.MessageType    = messageID == null ? "Comment" : "Reply";
            wc.OrganizationID = TSAuthentication.OrganizationID;
            wc.ReplyTo        = messageID;
            wc.TimeStamp      = DateTime.UtcNow;
            wc.UserID         = TSAuthentication.UserID;
            wc.Collection.Save();

            return(WaterCoolerView.GetWaterCoolerViewItem(wc.Collection.LoginUser, wc.MessageID).GetProxy());
        }
        public WaterCoolerThread GetMessage(int messageID)
        {
            WaterCoolerThread thread = new WaterCoolerThread();

            WaterCoolerView wcv = new WaterCoolerView(TSAuthentication.GetLoginUser());

            wcv.LoadByMessageID(messageID);

            WaterCoolerView replies = new WaterCoolerView(TSAuthentication.GetLoginUser());

            replies.LoadReplies(messageID);

            WatercoolerAttachments wcgroups = new WatercoolerAttachments(TSAuthentication.GetLoginUser());

            wcgroups.LoadByType(messageID, WaterCoolerAttachmentType.Group);

            WatercoolerAttachments wctickets = new WatercoolerAttachments(TSAuthentication.GetLoginUser());

            wctickets.LoadByType(messageID, WaterCoolerAttachmentType.Ticket);

            WatercoolerAttachments wcprods = new WatercoolerAttachments(TSAuthentication.GetLoginUser());

            wcprods.LoadByType(messageID, WaterCoolerAttachmentType.Product);

            WatercoolerAttachments wccompany = new WatercoolerAttachments(TSAuthentication.GetLoginUser());

            wccompany.LoadByType(messageID, WaterCoolerAttachmentType.Company);

            WatercoolerAttachments wcuseratt = new WatercoolerAttachments(TSAuthentication.GetLoginUser());

            wcuseratt.LoadByType(messageID, WaterCoolerAttachmentType.User);

            WatercoolerAttachments wcactivitiesatt = new WatercoolerAttachments(TSAuthentication.GetLoginUser());

            wcactivitiesatt.LoadByType(messageID, WaterCoolerAttachmentType.Activities);

            thread.Message    = wcv.GetWaterCoolerViewItemProxies()[0];
            thread.Replies    = replies.GetWaterCoolerViewItemProxies();
            thread.Groups     = wcgroups.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Group);
            thread.Tickets    = wctickets.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Ticket);
            thread.Products   = wcprods.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Product);
            thread.Company    = wccompany.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Company);
            thread.User       = wcuseratt.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.User);
            thread.Activities = wcactivitiesatt.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Activities);

            return(thread);
        }
        public void Del(int messageID)
        {
            LoginUser loginUser = new LoginUser(connString, -1, -1, null);

            try
            {
                loginUser = new LoginUser(connString, TSAuthentication.GetLoginUser().UserID, TSAuthentication.GetLoginUser().OrganizationID, null);
                WaterCoolerView wcv = new WaterCoolerView(loginUser);
                wcv.LoadByMessageID(messageID);

                var result = pusher.Trigger("ticket-dispatch-" + TSAuthentication.GetLoginUser().OrganizationID, "deleteMessage", new { msgID = messageID, parentID = wcv[0].MessageParent });
                //Clients.All.deleteMessage(messageID, wcv[0].MessageParent);
            }
            catch (Exception ex)
            {
                ExceptionLogs.LogException(loginUser, ex, "Socket.Del");
            }
        }
        public WaterCoolerThread[] GetThreads(int pageType, int pageID, int messageID)
        {
            List <WaterCoolerThread> result = new List <WaterCoolerThread>();

            // Main page [group, user]
            // Ticket page
            // Product page
            // Company page

            WaterCoolerView wc = new WaterCoolerView(TSAuthentication.GetLoginUser());

            if (messageID == -1)
            {
                wc.LoadTop10Threads(pageType, pageID);
            }
            else
            {
                wc.SearchLoadByMessageID(pageType, pageID, messageID);
            }


            foreach (WaterCoolerViewItem item in wc)
            {
                WaterCoolerThread thread = new WaterCoolerThread();

                WaterCoolerView replies = new WaterCoolerView(wc.LoginUser);
                replies.LoadReplies(item.MessageID);

                WatercoolerAttachments threadAttachments = new WatercoolerAttachments(TSAuthentication.GetLoginUser());
                threadAttachments.LoadByMessageID(item.MessageID);

                thread.Message    = item.GetProxy();
                thread.Replies    = replies.GetWaterCoolerViewItemProxies();
                thread.Groups     = threadAttachments.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Group);
                thread.Tickets    = threadAttachments.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Ticket);
                thread.Products   = threadAttachments.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Product);
                thread.Company    = threadAttachments.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Company);
                thread.User       = threadAttachments.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.User);
                thread.Activities = threadAttachments.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Activities);
                result.Add(thread);
            }

            return(result.ToArray());
        }
        public WaterCoolerThread[] GetUpdatedThreads(int msgcount, int pausetime)
        {
            List <WaterCoolerThread> result = new List <WaterCoolerThread>();

            //This reads the WaterCoolerView because it has UserNames and Groups.  This is readonly

            WaterCoolerView wc = new WaterCoolerView(TSAuthentication.GetLoginUser());

            //wc.LoadUpdatedThreads(msgcount, pausetime);


            foreach (WaterCoolerViewItem item in wc)
            {
                WaterCoolerThread thread = new WaterCoolerThread();

                WaterCoolerView replies = new WaterCoolerView(wc.LoginUser);
                replies.LoadReplies(item.MessageID);

                //WatercoolerGroupAtt wcgroups = new WatercoolerGroupAtt(TSAuthentication.GetLoginUser());
                //wcgroups.LoadByMessageID(item.MessageID);
                //WatercoolerTicketAtt wctickets = new WatercoolerTicketAtt(TSAuthentication.GetLoginUser());
                //wctickets.LoadByMessageID(item.MessageID);
                //WatercoolerProductAtt wcprods = new WatercoolerProductAtt(TSAuthentication.GetLoginUser());
                //wcprods.LoadByMessageID(item.MessageID);

                //WatercoolerCompanyAtt wccompany = new WatercoolerCompanyAtt(TSAuthentication.GetLoginUser());
                //wccompany.LoadByMessageID(item.MessageID);

                //WatercoolerUserAtt wcuseratt = new WatercoolerUserAtt(TSAuthentication.GetLoginUser());
                //wcuseratt.LoadByMessageID(item.MessageID);

                thread.Message = item.GetProxy();
                thread.Replies = replies.GetWaterCoolerViewItemProxies();
                //thread.Groups = wcgroups.GetWatercoolerGroupAttItemProxies();
                //thread.Tickets = wctickets.GetWatercoolerTicketAttItemProxies();
                //thread.Products = wcprods.GetWatercoolerProductAttItemProxies();
                //thread.Company = wccompany.GetWatercoolerCompanyAttItemProxies();
                //thread.User = wcuseratt.GetWatercoolerUserAttItemProxies();
                result.Add(thread);
            }

            return(result.ToArray());
        }
        override protected void GetNextRecord()
        {
            WaterCoolerViewItem waterCooler = WaterCoolerView.GetWaterCoolerViewItem(_loginUser, _itemIDList[_rowIndex]);

            _lastItemID = waterCooler.MessageID;
            UpdatedItems.Add((int)_lastItemID);

            DocText = HtmlToText.ConvertHtml(waterCooler.Message);

            _docFields.Clear();
            foreach (DataColumn column in waterCooler.Collection.Table.Columns)
            {
                object value = waterCooler.Row[column];
                string s     = value == null || value == DBNull.Value ? "" : value.ToString();
                AddDocField(column.ColumnName, s);
            }

            DocFields       = _docFields.ToString();
            DocIsFile       = false;
            DocName         = waterCooler.MessageID.ToString();
            DocCreatedDate  = waterCooler.TimeStampUtc;
            DocModifiedDate = DateTime.UtcNow;
        }
Ejemplo n.º 11
0
        public void NewThread(int messageID, string organizationID)
        {
            LoginUser loginUser = new LoginUser(connString, -1, -1, null);

            try
            {
                loginUser = new LoginUser(connString, TSAuthentication.GetLoginUser().UserID, TSAuthentication.GetLoginUser().OrganizationID, null);
                WaterCoolerThread thread = new WaterCoolerThread();

                WaterCoolerView wcv = new WaterCoolerView(loginUser);
                wcv.LoadByMessageID(messageID);

                WaterCoolerView replies = new WaterCoolerView(loginUser);
                replies.LoadReplies(messageID);

                WatercoolerAttachments wcgroups = new WatercoolerAttachments(loginUser);
                wcgroups.LoadByType(messageID, WaterCoolerAttachmentType.Group);

                WatercoolerAttachments wctickets = new WatercoolerAttachments(loginUser);
                wctickets.LoadByType(messageID, WaterCoolerAttachmentType.Ticket);

                WatercoolerAttachments wcprods = new WatercoolerAttachments(loginUser);
                wcprods.LoadByType(messageID, WaterCoolerAttachmentType.Product);

                WatercoolerAttachments wccompany = new WatercoolerAttachments(loginUser);
                wccompany.LoadByType(messageID, WaterCoolerAttachmentType.Company);

                WatercoolerAttachments wcuseratt = new WatercoolerAttachments(loginUser);
                wcuseratt.LoadByType(messageID, WaterCoolerAttachmentType.User);

                WatercoolerAttachments wcactivitiesatt = new WatercoolerAttachments(loginUser);
                wcactivitiesatt.LoadByType(messageID, WaterCoolerAttachmentType.Activities);

                thread.Message    = wcv.GetWaterCoolerViewItemProxies()[0];
                thread.Replies    = replies.GetWaterCoolerViewItemProxies();
                thread.Groups     = wcgroups.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Group);
                thread.Tickets    = wctickets.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Ticket);
                thread.Products   = wcprods.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Product);
                thread.Company    = wccompany.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Company);
                thread.User       = wcuseratt.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.User);
                thread.Activities = wcactivitiesatt.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Activities);

                //If this is a new thread
                if (thread.Message.MessageParent == -1)
                {
                    var result = pusher.Trigger("ticket-dispatch-" + organizationID, "addThread", thread);
                    //return JsonConvert.SerializeObject(true);
                    //Clients.Group().addThread(thread);
                }
                else
                {
                    var result = pusher.Trigger("ticket-dispatch-" + organizationID, "addComment", thread);
                    //Clients.Group(organizationID).addComment(thread);
                    int parentThreadID = (int)thread.Message.MessageParent;

                    WaterCoolerThread parentThread    = new WaterCoolerThread();
                    WaterCoolerView   parentThreadwcv = new WaterCoolerView(loginUser);
                    parentThreadwcv.LoadByMessageID(parentThreadID);

                    WatercoolerAttachments parentThreadwcgroups = new WatercoolerAttachments(loginUser);
                    parentThreadwcgroups.LoadByType(parentThreadID, WaterCoolerAttachmentType.Group);

                    WatercoolerAttachments parentThreadwctickets = new WatercoolerAttachments(loginUser);
                    parentThreadwctickets.LoadByType(parentThreadID, WaterCoolerAttachmentType.Ticket);

                    WatercoolerAttachments parentThreadwcprods = new WatercoolerAttachments(loginUser);
                    parentThreadwcprods.LoadByType(parentThreadID, WaterCoolerAttachmentType.Product);

                    WatercoolerAttachments parentThreadwccompany = new WatercoolerAttachments(loginUser);
                    parentThreadwccompany.LoadByType(parentThreadID, WaterCoolerAttachmentType.Company);

                    WatercoolerAttachments parentThreadwcuseratt = new WatercoolerAttachments(loginUser);
                    parentThreadwcuseratt.LoadByType(parentThreadID, WaterCoolerAttachmentType.User);

                    WatercoolerAttachments parentThreadactivitiesatt = new WatercoolerAttachments(TSAuthentication.GetLoginUser());
                    parentThreadactivitiesatt.LoadByType(parentThreadID, WaterCoolerAttachmentType.Activities);

                    parentThread.Message    = parentThreadwcv.GetWaterCoolerViewItemProxies()[0];
                    parentThread.Groups     = parentThreadwcgroups.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Group);
                    parentThread.Tickets    = parentThreadwctickets.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Ticket);
                    parentThread.Products   = parentThreadwcprods.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Product);
                    parentThread.Company    = parentThreadwccompany.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Company);
                    parentThread.User       = parentThreadwcuseratt.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.User);
                    parentThread.Activities = parentThreadactivitiesatt.GetWatercoolerAttachmentProxies(WaterCoolerAttachmentType.Activities);

                    result = pusher.Trigger("ticket-dispatch-" + organizationID, "updateattachments", parentThread);
                    //Clients.Group(organizationID).updateattachments(parentThread);
                }
            }
            catch (Exception ex)
            {
                ExceptionLogs.LogException(loginUser, ex, "Socket.NewThread");
            }
        }