示例#1
0
        public async Task CreateAutobotAsync(Autobot autobot, TaskContext context)
        {
            var authentication = context.Authentication;
            var autobotService = autobot.Service;

            if (context.AllowException == false)
            {
                if (autobot.IsOnline == false)
                {
                    return;
                }
                if (authentication.Authority != Authority.Admin)
                {
                    return;
                }
            }
            var info                   = autobotService.GetRandomUserInfo();
            var userCollection         = autobot.GetService(typeof(IUserCollection)) as IUserCollection;
            var userCategoryCollection = autobot.GetService(typeof(IUserCategoryCollection)) as IUserCategoryCollection;

            if (await userCollection.ContainsAsync(info.ID) == false)
            {
                var category = await userCategoryCollection.GetRandomUserCategoryAsync();

                await category.AddNewUserAsync(authentication, info.ID, info.Password, info.Name, info.Authority);
            }
            await autobotService.CreateAutobotAsync(authentication, info.ID, info.Password);
        }
        public static object ActionInTake(string intakeContent)
        {
            IndexesObj _indexesObj = new IndexesObj();
            var        obj         = new { status = 400, message = string.Empty, value = new IndexesObj() };


            Autobot _autobot = new Autobot();

            _autobot.Indexes = intakeContent;
            // check in the database for the user input:
            // If no result gets then insert it as new action/
            // Else fetch the action for the indexes and then return.
            _autobot = _service.GetActionByAction(_autobot);
            if (_autobot != null && !string.IsNullOrEmpty(_autobot.Action))
            {
                _indexesObj.Indexes     = string.Empty;
                _indexesObj.returnValue = _autobot.Action;

                // If there is a action to return then call the speech return function.
                obj = new { status = 200, message = "valid", value = _indexesObj };
            }
            else
            {
                _indexesObj.Indexes     = intakeContent;
                _indexesObj.returnValue = "Sorry ! I don't know what you say. Can you tell me, what should i say for it.";

                // If no action is to return then insert the indexes with proper action.
                obj = new { status = 400, message = "fails", value = _indexesObj };
            }
            return(obj);
        }
示例#3
0
        public void UpdateAction(Autobot action)
        {
            Data1 actionData = _dataContext.Data1s.Where(u => u.Id == action.Id).SingleOrDefault();

            actionData.Id         = action.Id;
            actionData.Action     = action.Action;
            actionData.ActionDate = DateTime.Now;
            actionData.Indexes    = action.Indexes;
            _dataContext.SubmitChanges();
        }
示例#4
0
 public void AddNewAutoBot(Autobot autobot, TaskContext context)
 {
     this.Dispatcher.Invoke(() =>
     {
         if (autobot.IsOnline == true)
         {
             autobot.Service.AddAutobot(context.Authentication);
         }
     });
 }
示例#5
0
        public void InsertAction(Autobot action)
        {
            var actionData = new Data1()
            {
                Id         = action.Id,
                Action     = action.Action,
                Indexes    = action.Indexes,
                ActionDate = DateTime.Now
            };

            _dataContext.Data1s.InsertOnSubmit(actionData);
            _dataContext.SubmitChanges();
        }
示例#6
0
        public Autobot GetActionByAction(string action)
        {
            var query = from u in _dataContext.Data1s
                        where u.Action == action
                        select u;
            var actionData = query.FirstOrDefault();
            var model      = new Autobot()
            {
                Id         = actionData.Id,
                Indexes    = actionData.Indexes,
                Action     = actionData.Action,
                ActionDate = actionData.ActionDate
            };

            return(model);
        }
示例#7
0
        public Autobot InsertAction(Autobot autobot)
        {
            Autobot _autobot = new Autobot();

            try
            {
                _repo.saveIndexesAction(autobot);
            }
            catch (Exception ex)
            {
                _autobot.Except = ex.Message;
                return(_autobot);
            }

            return(_autobot);
        }
示例#8
0
        public Autobot GetActionByAction(Autobot action)
        {
            Autobot _autobot = new Autobot();

            try
            {
                _autobot = _repo.fetchIndexes(action);
            }
            catch (Exception ex)
            {
                _autobot.Except = ex.Message;
                return(_autobot);
            }

            return(_autobot);
        }
示例#9
0
        // Get All the data
        public Autobot fetchIndexes(Autobot entities)
        {
            Autobot actionRst = new Autobot();

            try
            {
                actionRst = (from c in _context.AutobotDataSources
                             where c.Indexes.Equals(entities.Indexes)
                             select new Autobot {
                    Action = c.Action
                }).SingleOrDefault();
            }
            catch (Exception ex)
            {
            }
            return(actionRst);
        }
示例#10
0
        public void saveIndexesAction(Autobot entities)
        {
            try
            {
                AutobotDataSource _ds = new AutobotDataSource()
                {
                    Action      = entities.Action,
                    Indexes     = entities.Indexes,
                    ActionDates = DateTime.Now
                };

                _context.AutobotDataSources.InsertOnSubmit(_ds);
                _context.SubmitChanges();
            }
            catch (Exception ex)
            {
            }
        }
示例#11
0
        public static object UserActionSave(IndexesObj response)
        {
            var obj = new { status = 400, message = string.Empty, value = new IndexesObj() };

            try
            {
                Autobot _autobot = new Autobot();
                _autobot.Indexes = response.Indexes;
                _autobot.Action  = response.ActionResponse;
                _service.InsertAction(_autobot);

                response.returnValue = "Sure Buddy...";

                obj = new { status = 200, message = "valid", value = response };
            }
            catch (Exception ex)
            {
            }
            return(obj);
        }