Пример #1
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();
            }
        }
        public static List <SynAppsIntentModel> FindAllByDeviceId(string _deviceId)
        {
            List <SynAppsIntentModel> list = new List <SynAppsIntentModel>();

            var dc      = new SynAppsIntentDataContext(SqlConnectionString);
            var intents =
                from n in dc.SynAppsIntents
                where n.SynAppsDeviceId == _deviceId
                select n;

            foreach (var intent in intents)
            {
                var model = SynAppsIntentModel.New();
                model.SynAppsDeviceId = intent.SynAppsDeviceId;
                model.Name            = intent.Name;
                model.ReactionBody    = intent.ReactionBody;
                model.Entity          = intent.Entity ?? "";

                list.Add(model);
            }

            return(list);
        }