Exemple #1
0
        public void Save()
        {
            var dc = new RobotBehaviorsDataContext(SqlConnectionString);

            if (this.Id == 0)
            {
                var robotBehaviorKeyphrase = new RobotBehaviorKeyphrase();
                robotBehaviorKeyphrase.SynAppsId       = this.SynAppsId;
                robotBehaviorKeyphrase.SynAppsDeviceId = this.SynAppsDeviceId;
                robotBehaviorKeyphrase.Keyphrase       = this.Keyphrase;
                robotBehaviorKeyphrase.KeyphraseReply  = this.KeyphraseReply;
                robotBehaviorKeyphrase.Status          = this.Status;
                robotBehaviorKeyphrase.IsSynAppsLinked = this.IsSynAppsLinked;
                robotBehaviorKeyphrase.IsDeleted       = this.IsDeleted;
                robotBehaviorKeyphrase.CreatedAt       = DateTime.Now;

                dc.RobotBehaviorKeyphrases.InsertOnSubmit(robotBehaviorKeyphrase);
                dc.SubmitChanges();

                this.Id        = robotBehaviorKeyphrase.Id;
                this.CreatedAt = robotBehaviorKeyphrase.CreatedAt;
            }
            else
            {
                var records =
                    from n in dc.RobotBehaviorKeyphrases
                    where n.Id == this.Id
                    select n;

                foreach (var r in records)
                {
                    r.SynAppsId       = this.SynAppsId;
                    r.SynAppsDeviceId = this.SynAppsDeviceId;
                    r.Keyphrase       = this.Keyphrase;
                    r.KeyphraseReply  = this.KeyphraseReply;
                    r.Status          = this.Status;
                    r.IsSynAppsLinked = this.IsSynAppsLinked;
                    r.IsDeleted       = this.IsDeleted;
                    r.UpdatedAt       = DateTime.Now;
                }
                dc.SubmitChanges();
            }
        }
        public void Save()
        {
            var dc = new RobotBehaviorsDataContext(SqlConnectionString);

            if (this.Id == 0)
            {
                var robotBehaviorTalkLog = new RobotBehaviorTalkLog();
                robotBehaviorTalkLog.DeviceId            = this.DeviceId;
                robotBehaviorTalkLog.PersonId            = this.PersonId;
                robotBehaviorTalkLog.RobotTalk           = this.RobotTalk;
                robotBehaviorTalkLog.PersonTalk          = this.PersonTalk;
                robotBehaviorTalkLog.PersonTalkKeyphrase = this.PersonTalkKeyphrase;
                robotBehaviorTalkLog.Status    = this.Status;
                robotBehaviorTalkLog.IsDeleted = this.IsDeleted;
                robotBehaviorTalkLog.CreatedAt = DateTime.Now;

                dc.RobotBehaviorTalkLogs.InsertOnSubmit(robotBehaviorTalkLog);
                dc.SubmitChanges();

                this.Id        = robotBehaviorTalkLog.Id;
                this.CreatedAt = robotBehaviorTalkLog.CreatedAt;
            }
            else
            {
                var records =
                    from n in dc.RobotBehaviorTalkLogs
                    where n.Id == this.Id
                    select n;

                foreach (var r in records)
                {
                    r.PersonId            = this.PersonId;
                    r.RobotTalk           = this.RobotTalk;
                    r.PersonTalk          = this.PersonTalk;
                    r.PersonTalkKeyphrase = this.PersonTalkKeyphrase;
                    r.Status    = this.Status;
                    r.IsDeleted = this.IsDeleted;
                    r.UpdatedAt = DateTime.Now;
                }
                dc.SubmitChanges();
            }
        }
Exemple #3
0
        public void Save()
        {
            var dc = new RobotBehaviorsDataContext(SqlConnectionString);

            if (this.Id == 0)
            {
                var robotBehaviorToPerson = new RobotBehaviorToPerson();
                robotBehaviorToPerson.DeviceId        = this.DeviceId;
                robotBehaviorToPerson.PersonId        = this.PersonId;
                robotBehaviorToPerson.RobotBehaviorId = this.RobotBehaviorId;
                robotBehaviorToPerson.Status          = this.Status;
                robotBehaviorToPerson.Weather         = this.Weather;
                robotBehaviorToPerson.IsDeleted       = this.IsDeleted;
                robotBehaviorToPerson.CreatedAt       = DateTime.Now;

                dc.RobotBehaviorToPersons.InsertOnSubmit(robotBehaviorToPerson);
                dc.SubmitChanges();

                this.Id        = robotBehaviorToPerson.Id;
                this.CreatedAt = robotBehaviorToPerson.CreatedAt;
            }
            else
            {
                var records =
                    from n in dc.RobotBehaviorToPersons
                    where n.Id == this.Id
                    select n;

                foreach (var r in records)
                {
                    r.PersonId        = this.PersonId;
                    r.RobotBehaviorId = this.RobotBehaviorId;
                    r.Status          = this.Status;
                    r.Weather         = this.Weather;
                    r.IsDeleted       = this.IsDeleted;
                    r.UpdatedAt       = DateTime.Now;
                }
                dc.SubmitChanges();
            }
        }
Exemple #4
0
        public static void Refresh(string _synappsDeviceId, List <RobotBehaviorModel> list)
        {
            var dc         = new RobotBehaviorsDataContext(SqlConnectionString);
            var synAppsIds = (from l in list select l.SynAppsId).ToList <int>();
            var forDelete  =
                from n in dc.RobotBehaviors
                where n.SynAppsDeviceId == _synappsDeviceId
                where n.IsSynAppsLinked == true
                where !synAppsIds.Contains(n.SynAppsId)
                select n;

            Delete(forDelete);

            var newBehaviors = new List <RobotBehavior>();

            foreach (var l in list)
            {
                var behaviors =
                    from n in dc.RobotBehaviors
                    where n.SynAppsDeviceId == _synappsDeviceId
                    where n.IsSynAppsLinked == true
                    where n.SynAppsId == l.SynAppsId
                    select n;

                if (behaviors.Count() > 0)
                {
                    behaviors.First <RobotBehavior>().IsDeleted  = false;
                    behaviors.First <RobotBehavior>().Status     = l.Status;
                    behaviors.First <RobotBehavior>().ActionType = l.ActionType;
                    behaviors.First <RobotBehavior>().ActionBody = l.ActionBody;
                    behaviors.First <RobotBehavior>().UpdatedAt  = DateTime.Now;
                }
                else
                {
                    newBehaviors.Add(new RobotBehavior
                    {
                        SynAppsId       = l.SynAppsId,
                        SynAppsDeviceId = l.SynAppsDeviceId,
                        Status          = l.Status,
                        ActionType      = l.ActionType,
                        ActionBody      = l.ActionBody,
                        IsSynAppsLinked = l.IsSynAppsLinked,
                        IsDeleted       = l.IsDeleted,
                        CreatedAt       = DateTime.Now
                    });
                }
            }
            dc.RobotBehaviors.InsertAllOnSubmit(newBehaviors);
            dc.SubmitChanges();
        }
Exemple #5
0
        public static void Refresh(string _synappsDeviceId, List <RobotBehaviorKeyphraseModel> list)
        {
            var dc         = new RobotBehaviorsDataContext(SqlConnectionString);
            var synAppsIds = (from l in list select l.SynAppsId).ToList <int>();
            var forDelete  =
                from n in dc.RobotBehaviorKeyphrases
                where n.SynAppsDeviceId == _synappsDeviceId
                where n.IsSynAppsLinked == true
                where !synAppsIds.Contains(n.SynAppsId)
                select n;

            Delete(forDelete);

            var newKeyphrases = new List <RobotBehaviorKeyphrase>();

            foreach (var l in list)
            {
                var keyphrases =
                    from n in dc.RobotBehaviorKeyphrases
                    where n.SynAppsDeviceId == _synappsDeviceId
                    where n.IsSynAppsLinked == true
                    where n.SynAppsId == l.SynAppsId
                    select n;

                if (keyphrases.Count() > 0)
                {
                    keyphrases.First <RobotBehaviorKeyphrase>().Keyphrase      = l.Keyphrase;
                    keyphrases.First <RobotBehaviorKeyphrase>().KeyphraseReply = l.KeyphraseReply;
                    keyphrases.First <RobotBehaviorKeyphrase>().Status         = l.Status;
                    keyphrases.First <RobotBehaviorKeyphrase>().UpdatedAt      = DateTime.Now;
                }
                else
                {
                    newKeyphrases.Add(new RobotBehaviorKeyphrase
                    {
                        SynAppsId       = l.SynAppsId,
                        SynAppsDeviceId = l.SynAppsDeviceId,
                        Keyphrase       = l.Keyphrase,
                        KeyphraseReply  = l.KeyphraseReply,
                        Status          = l.Status,
                        IsSynAppsLinked = l.IsSynAppsLinked,
                        IsDeleted       = l.IsDeleted,
                        CreatedAt       = DateTime.Now
                    });
                }
            }
            dc.RobotBehaviorKeyphrases.InsertAllOnSubmit(newKeyphrases);
            dc.SubmitChanges();
        }