private static List <ConversationHistoryModel> Build(IQueryable <ConversationHistory> records)
        {
            var list = new List <ConversationHistoryModel>();

            foreach (var r in records)
            {
                var model = ConversationHistoryModel.New();
                model.Id                 = r.Id;
                model.DeviceId           = r.DeviceId;
                model.FromUserId         = r.FromUserId;
                model.FromMessage        = r.FromMessage;
                model.ToMessage          = r.ToMessage;
                model.Intent             = r.Intent;
                model.Score              = r.Score;
                model.SynAppsAccountId   = r.SynAppsAccountId;
                model.SynAppsAccountName = r.SynAppsAccountName;
                model.SynAppAssetId      = r.SynAppAssetId;
                model.Status             = ConversationStatusExt.ToEnum <ConversationStatus>(r.Status);
                model.IsSynAppsLinked    = r.IsSynAppsLinked;
                model.CreatedAt          = r.CreatedAt;
                model.UpdatedAt          = r.UpdatedAt;

                list.Add(model);
            }

            return(list);
        }
Example #2
0
        public void SaveReaction(LuisExample example, string action, long _exampleTextId)
        {
            string entity_values = "";

            foreach (var label in example.EntityLabels)
            {
                var value = example.Text.Substring(label.StartCharIndex, (label.EndCharIndex - label.StartCharIndex + 1)) + ",";
                entity_values += value;
            }
            entity_values = entity_values.Trim(',');

            var model = SynAppsIntentModel.New();

            model.SynAppsDeviceId = this.DeviceId;
            model.Name            = example.IntentName;
            model.Entity          = entity_values;
            model.ReactionBody    = "{\"Talk\": \"" + action + "\"}";
            model.IsSynAppsLinked = false;
            model.Save();

            if (_exampleTextId > 0)
            {
                var m = ConversationHistoryModel.FindById(_exampleTextId);
                m.ToMessage       = action;
                m.IsSynAppsLinked = false;
                m.Save();
            }
        }
Example #3
0
        public void Train(long exampleTextId)
        {
            this.Train();

            var model = ConversationHistoryModel.FindById(exampleTextId);

            model.Learned();
        }
Example #4
0
        public void ResetLearning(long _conversationHistoryId)
        {
            var model = ConversationHistoryModel.FindById(_conversationHistoryId);

            if (model != null && model.Status != ConversationStatus.None)
            {
                model.Status = ConversationStatus.None;
                model.Save();
            }
        }
Example #5
0
 public ApiResult AddMessageText(MessageTextDto dto)
 {
     return(ConversationHistoryModel.AddMessageText(
                this.DeviceId,
                dto.FromUserId,
                dto.FromMessage,
                dto.ToMessage,
                dto.Intent,
                dto.Score,
                dto.SynAppsAccountId,
                dto.SynAppsAccountName,
                dto.SynAppsAssetId,
                dto.Status
                ));
 }
Example #6
0
        public LuisService(string _deviceId, string _luisAppId, string _luisSubscriptionKey, string _luisProgrammaticAPIKey, string _luisVersionId, string _connectionString)
        {
            this.DeviceId            = _deviceId;
            this.luisAppId           = _luisAppId;
            this.luisSubscriptionKey = _luisSubscriptionKey;
            this.luisVersionId       = _luisVersionId;

            this.httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", _luisProgrammaticAPIKey);

            SynAppsIntentModel.Connection(_connectionString);
            ConversationHistoryModel.Connection(_connectionString);
            PredictionIntentModel.Connection(_connectionString);
            PredictionEntityModel.Connection(_connectionString);
            SynAppsSyncStatusModel.Connection(_connectionString);
        }
Example #7
0
        public ApiResult BatchLearning(string _learningJson)
        {
            var learningObject = JsonConvert.DeserializeObject <JObject>(_learningJson);
            var exampleText    = (learningObject["text"] ?? "").ToString();

            if (exampleText == "")
            {
                throw new Exception("text(utterance) must have some value.");
            }

            var result = AdvancedLearning(_learningJson, exampleText, 0);

            if (result.StatusCode == StatusCode.Success)
            {
                var messages = ConversationHistoryModel.FindAllOfUnknownMessageByDeviceIdAndFromMessage(this.DeviceId, exampleText);
                foreach (var message in messages)
                {
                    message.ToMessage = (learningObject["action"] ?? "").ToString();
                    message.Learned();
                }
            }

            return(result);
        }
Example #8
0
        public void DenyTeach(long exampleTextId)
        {
            var model = ConversationHistoryModel.FindById(exampleTextId);

            model.DenyTeach();
        }
Example #9
0
 public void NotificationFinished(ConversationHistoryModel model)
 {
     model.Status = ConversationStatus.Notified;
     model.Save();
 }
Example #10
0
 public ConversationHistoryModel GetLearningMessage()
 {
     return(ConversationHistoryModel.FindByDeviceId(this.DeviceId, ConversationStatus.Learning));
 }
Example #11
0
 public List <ConversationHistoryModel> GetSynAppsUnlinks()
 {
     return(ConversationHistoryModel.FindAllByDeviceIdAndSynAppsUnlink(this.DeviceId));
 }
Example #12
0
 public List <ConversationHistoryModel> GetDenyTeachMessage()
 {
     return(ConversationHistoryModel.FindAllByDeviceId(this.DeviceId, ConversationStatus.DenyTeach));
 }
Example #13
0
 public List <ConversationHistoryModel> GetLearnedMessage()
 {
     return(ConversationHistoryModel.FindAllByDeviceId(this.DeviceId, ConversationStatus.Learned));
 }
Example #14
0
 public void StartLearning(ConversationHistoryModel model)
 {
     model.Status = ConversationStatus.Learning;
     model.Save();
 }
Example #15
0
 public void StartLearning(long exampleTextId)
 {
     StartLearning(ConversationHistoryModel.FindById(exampleTextId));
 }
Example #16
0
 public void NotificationFinished(long exampleTextId)
 {
     NotificationFinished(ConversationHistoryModel.FindById(exampleTextId));
 }
Example #17
0
 public ConversationHistoryModel GetUnKnownMessage()
 {
     return(ConversationHistoryModel.FindOneOfUnknownMessageByDeviceId(this.DeviceId));
 }