예제 #1
0
        internal static DateTime GetLastMessage(string conversationId)
        {
            var filter = Builders <ConversationObject> .Filter.Eq(s => s.ConversationId, conversationId);

            ConversationObject results = UserCollection.Find(filter).FirstOrDefault();

            return(results.Date != null ? results.Date : DateTime.Now);
        }
예제 #2
0
        //Get language stored in conversation object using conversation id, if null default to English
        internal static string GetLanguage(string conversationId)
        {
            var filter = Builders <ConversationObject> .Filter.Eq(s => s.ConversationId, conversationId);

            ConversationObject results = UserCollection.Find(filter).FirstOrDefault();

            return(results.Language != null && results.Language != "" ? results.Language : "En");
        }
예제 #3
0
        //Updates the language stored in the conversation object with user selection
        //Should eventually be changed to take/ update from database instead
        internal static async Task UpdateLanguage(string conversationId, string language)
        {
            var filter = Builders <ConversationObject> .Filter.Eq(s => s.ConversationId, conversationId);

            ConversationObject results = UserCollection.Find(filter).FirstOrDefault();

            results.Language = language;

            var x = await UserCollection.ReplaceOneAsync(filter, results);
        }
예제 #4
0
        /* Keep track of the time since the last message the user sent*/
        internal async static Task UpdateConvTime(string conversationId)
        {
            var filter = Builders <ConversationObject> .Filter.Eq(s => s.ConversationId, conversationId);

            ConversationObject results      = UserCollection.Find(filter).FirstOrDefault();
            DateTime           previousDate = results.Date;

            results.Date = DateTime.Now;

            var result = await UserCollection.ReplaceOneAsync(filter, results);
        }
예제 #5
0
        internal static async Task <bool> SaveConversationAsync(string fromName, string toId, string toName, string serviceUrl, string channelId, string conversationId)
        {
            if (channelId != "directline") // updating the time of already existing attribute
            {
                var filter = Builders <ConversationObject> .Filter.Eq(s => s.ConversationId, conversationId);

                ConversationObject results = UserCollection.Find(filter).FirstOrDefault();
                results.FromName  = fromName;
                results.ToId      = toId;
                results.ToName    = toName;
                results.ChannelId = channelId;

                var x = await UserCollection.ReplaceOneAsync(filter, results);

                return(true);
            }
            return(false);
        }
예제 #6
0
        /* Called by root dialog to save new conversation IDs*/
        internal static async Task <bool> SaveBasicConversationAsync(string fromId, string serviceUrl, string channelId, string conversationId, bool status)
        {
            var exists = UserCollection.AsQueryable().FirstOrDefault(x => x.ConversationId == conversationId) != null;

            if (!exists)
            {
                await UserCollection.InsertOneAsync(
                    new ConversationObject
                {
                    FromId         = fromId,
                    ServiceUrl     = serviceUrl,
                    ConversationId = conversationId,
                    Date           = DateTime.Now,
                    Status         = status,
                    FromName       = "",
                    ToId           = "",
                    ToName         = "",
                    ChannelId      = "",
                    Language       = ""
                });

                return(true);
            }
            else // updating the time of already existing attribute
            {
                var filter = Builders <ConversationObject> .Filter.Eq(s => s.ConversationId, conversationId);

                ConversationObject results      = UserCollection.Find(filter).FirstOrDefault();
                DateTime           previousDate = results.Date;
                results.Date = DateTime.Now;


                var result = await UserCollection.ReplaceOneAsync(filter, results);
            }
            return(false);
        }