Пример #1
0
 ///<summary>Also sets primary key</summary>
 public static long Insert(WebChatSurvey webChatSurvey)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         webChatSurvey.WebChatSurveyNum = Meth.GetLong(MethodBase.GetCurrentMethod(), webChatSurvey);
         return(webChatSurvey.WebChatSessionNum);
     }
     WebChatMisc.DbAction(delegate() {
         Crud.WebChatSurveyCrud.Insert(webChatSurvey);
     });
     return(webChatSurvey.WebChatSessionNum);
 }
Пример #2
0
        public static WebChatSession GetOne(long webChatSessionNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <WebChatSession>(MethodBase.GetCurrentMethod(), webChatSessionNum));
            }
            WebChatSession session = null;

            WebChatMisc.DbAction(delegate() {
                session = Crud.WebChatSessionCrud.SelectOne(webChatSessionNum);
            });
            return(session);
        }
Пример #3
0
 ///<summary>Also sets primary key and DateTcreated.</summary>
 public static long Insert(WebChatSession webChatSession)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         webChatSession.WebChatSessionNum = Meth.GetLong(MethodBase.GetCurrentMethod(), webChatSession);
         return(webChatSession.WebChatSessionNum);
     }
     WebChatMisc.DbAction(delegate() {
         Crud.WebChatSessionCrud.Insert(webChatSession);
     });
     WebChatMisc.DbAction(delegate() {
         Signalods.SetInvalid(InvalidType.WebChatSessions);                //Signal OD HQ to refresh sessions.
     }, false);
     return(webChatSession.WebChatSessionNum);
 }
Пример #4
0
        public static List <WebChatSession> GetActiveSessions()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <WebChatSession> >(MethodBase.GetCurrentMethod()));
            }
            List <WebChatSession> listWebChatSessions = new List <WebChatSession>();

            WebChatMisc.DbAction(() => {
                string command      = "SELECT * FROM webchatsession WHERE DateTend < " + POut.DateT(new DateTime(1880, 1, 1)) + " ";   //Session is ended if DateTend is set.
                command            += "ORDER BY DateTcreated";
                listWebChatSessions = Crud.WebChatSessionCrud.SelectMany(command);
            });
            return(listWebChatSessions);
        }
Пример #5
0
        public static WebChatSession GetActiveSessionsForEmployee(string techName)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <WebChatSession>(MethodBase.GetCurrentMethod(), techName));
            }
            WebChatSession webChatSession = null;

            WebChatMisc.DbAction(() => {
                string command = "SELECT * FROM webchatsession WHERE DateTend < " + POut.DateT(new DateTime(1880, 1, 1))
                                 + " AND webchatsession.TechName = '" + POut.String(techName) + "'"
                                 + " ORDER BY webchatsession.DateTcreated ";
                webChatSession = Crud.WebChatSessionCrud.SelectOne(command);
            });
            return(webChatSession);
        }
Пример #6
0
 public static void Update(WebChatSession webChatSession, WebChatSession oldWebChatSession, bool hasSignal = true)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), webChatSession, oldWebChatSession, hasSignal);
         return;
     }
     WebChatMisc.DbAction(delegate() {
         Crud.WebChatSessionCrud.Update(webChatSession, oldWebChatSession);
     });
     if (hasSignal)
     {
         WebChatMisc.DbAction(delegate() {
             Signalods.SetInvalid(InvalidType.WebChatSessions);                    //Signal OD HQ to refresh sessions.
         }, false);
     }
 }
Пример #7
0
 ///<summary>Sets PK as well as DateT.</summary>
 public static long Insert(WebChatMessage webChatMessage)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         webChatMessage.WebChatMessageNum = Meth.GetLong(MethodBase.GetCurrentMethod(), webChatMessage);
         return(webChatMessage.WebChatMessageNum);
     }
     WebChatMisc.DbAction(delegate() {
         Crud.WebChatMessageCrud.Insert(webChatMessage);
     });
     WebChatMisc.DbAction(delegate() {
         Signalod signalSession = new Signalod();
         signalSession.IType    = InvalidType.WebChatSessions;
         signalSession.FKey     = webChatMessage.WebChatSessionNum;
         Signalods.Insert(signalSession);
     }, false);
     return(webChatMessage.WebChatMessageNum);
 }
Пример #8
0
        public static List <WebChatMessage> GetAllForSessions(params long[] arrayWebChatSessionNums)
        {
            if (arrayWebChatSessionNums.Length == 0)
            {
                return(new List <WebChatMessage>());
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <WebChatMessage> >(MethodBase.GetCurrentMethod(), arrayWebChatSessionNums));
            }
            List <WebChatMessage> listWebChatMessages = null;

            WebChatMisc.DbAction(delegate() {
                string command      = "SELECT * FROM webchatmessage WHERE WebChatSessionNum IN (" + String.Join(",", arrayWebChatSessionNums.Select(x => POut.Long(x))) + ")";
                listWebChatMessages = Crud.WebChatMessageCrud.SelectMany(command);
            });
            return(listWebChatMessages);
        }
Пример #9
0
        public static string GetString(WebChatPrefName prefName)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetString(MethodBase.GetCurrentMethod(), prefName));
            }
            WebChatPref pref = null;

            WebChatMisc.DbAction(delegate() {
                string command = "SELECT * FROM webchatpref WHERE PrefName='" + POut.String(prefName.ToString()) + "'";
                pref           = Crud.WebChatPrefCrud.SelectOne(command);
            });
            if (pref == null)
            {
                return("");
            }
            return(pref.ValueString);
        }
Пример #10
0
        public static List <WebChatSurvey> GetSurveysForSessions(List <long> listWebChatSessionNums)
        {
            if (listWebChatSessionNums.Count == 0)
            {
                return(new List <WebChatSurvey>());
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <WebChatSurvey> >(MethodBase.GetCurrentMethod(), listWebChatSessionNums));
            }
            List <WebChatSurvey> listWebChatSurveys = null;

            WebChatMisc.DbAction(delegate() {
                string command     = "SELECT * FROM webchatsurvey WHERE WebChatSessionNum IN (" + String.Join(",", listWebChatSessionNums) + ")";
                listWebChatSurveys = Crud.WebChatSurveyCrud.SelectMany(command);
            });
            return(listWebChatSurveys);
        }
Пример #11
0
        public static List <WebChatSession> GetSessions(bool hasEndedSessionsIncluded, DateTime dateCreatedFrom, DateTime dateCreatedTo)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <WebChatSession> >(MethodBase.GetCurrentMethod(), hasEndedSessionsIncluded, dateCreatedFrom, dateCreatedTo));
            }
            List <WebChatSession> listWebChatSessions = null;

            WebChatMisc.DbAction(delegate() {
                string command = "SELECT * FROM webchatsession "
                                 + "WHERE DateTcreated >= " + POut.DateT(dateCreatedFrom) + " AND DateTcreated <= " + POut.DateT(dateCreatedTo) + " ";
                if (!hasEndedSessionsIncluded)                                                 //Do not show ended sessions?
                {
                    command += "AND DateTend < " + POut.DateT(new DateTime(1880, 1, 1)) + " "; //Session is ended if DateTend is set.
                }
                command            += "ORDER BY DateTend,DateTcreated";                        //By DateTend first, so that currently active sessions show at the top of the list.
                listWebChatSessions = Crud.WebChatSessionCrud.SelectMany(command);
            });
            return(listWebChatSessions);
        }
Пример #12
0
 ///<summary>Sets the DateTend field to now and inserts a message into the chat so all users can see the session has ended.</summary>
 public static void EndSession(long webChatSessionNum)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), webChatSessionNum);
         return;
     }
     WebChatMisc.DbAction(delegate() {
         string command = "UPDATE webchatsession SET DateTend=NOW() WHERE WebChatSessionNum=" + POut.Long(webChatSessionNum);
         DataCore.NonQ(command);
         //Last message just after session ended, in case someone types another message into the thread just as the thread is ending.
         //This way the end session message is guaranteed to be last, since the timestamp on it is after the session technically ended.
         WebChatMessage endSessionMessage    = new WebChatMessage();
         endSessionMessage.WebChatSessionNum = webChatSessionNum;
         endSessionMessage.UserName          = WebChatPrefs.GetString(WebChatPrefName.SystemName);
         endSessionMessage.MessageText       = WebChatPrefs.GetString(WebChatPrefName.SystemSessionEndMessage);
         endSessionMessage.MessageType       = WebChatMessageType.EndSession;
         WebChatMessages.Insert(endSessionMessage);
     });
 }