Example #1
0
        public static void Main()
        {
            // create your profile
            DefaultProfile profile = new DefaultProfile("cn-shanghai", "<your access key id>", "<your access key secret>");
            AliYunClient   client  = new AliYunClient(profile);

            ClientInfo clientInfo = new ClientInfo();

            clientInfo.ip = "127.0.0.1";

            // text scan task
            string content  = "测试";
            Task   textTask = new TextTask(content);

            textTask.dataId = Guid.NewGuid().ToString();
            textTask.time   = DateTime.Now.Millisecond;
            BizData textBizData = new BizData("Text", new String[] { "antispam" }, new Task[] { textTask });


            string  algoPath = "/green/text/scan";
            Request req      = new Request(textBizData, algoPath);

            req.addQueryParameter("clientInfo", JSON.stringify(clientInfo));

            string response = client.getResponse(req);

            // your biz code
            Console.WriteLine(response);

            Console.ReadKey();
        }
 private void SaveUserLvl(TextTask text)
 {
     if (text.Name.StartsWith("Текст на рівень знань: "))
     {
         var       identity = User.Identity.GetUserId();
         var       user     = db.User.Where(x => x.IdentityId == identity).First();
         string    result   = user.ObjLvlReading;
         Difficult userLvl  = (Difficult)Enum.Parse(typeof(Difficult), user.ObjLvlReading.Replace('-', '_'));
         foreach (Difficult el in Enum.GetValues(typeof(Difficult)))
         {
             string name  = Enum.Format(typeof(Difficult), el, "G");
             int    value = (int)el;
             if (text.Name == "Текст на рівень знань: " + name)
             {
                 if (value > (int)userLvl)
                 {
                     result = name;
                 }
             }
         }
         result             = result.Replace('_', '-');
         user.ObjLvlReading = result;
         db.SaveChanges();
     }
 }
Example #3
0
 public EditExamenViewModel(ObservableCollection <Examen> examens)
 {
     loader        = new Loader();
     indexExamen   = examens.Count;
     Examens       = examens;
     CurrentExamen = new Examen();
     CurrentTask   = new TextTask();
 }
Example #4
0
 public EditExamenViewModel(Examen examen, ObservableCollection <Examen> examens)
 {
     editFlag      = true;
     indexExamen   = examens.IndexOf(examen);
     loader        = new Loader();
     Examens       = examens;
     CurrentExamen = (Examen)examen.Clone();
     CurrentTask   = new TextTask();
 }
 public ActionResult Edit([Bind(Include = "TextId,AuthorId,Name,Text,Words,Difficult")] TextTask textTask)
 {
     if (ModelState.IsValid)
     {
         db.Entry(textTask).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(textTask));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            TextTask textTask = db.TextTask.Find(id);
            var      task     = db.ELTask.Where(x => x.TextId == textTask.TextId && x.AuthorId == 1);

            if (task.Count() > 0)
            {
                db.ELTask.Remove(task.First());
            }
            db.TextTask.Remove(textTask);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: Moderator/ManageTextTasks/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TextTask textTask = db.TextTask.Find(id);

            if (textTask == null)
            {
                return(HttpNotFound());
            }
            return(View(textTask));
        }
Example #8
0
        public void UpdateCurrentTask(TextTask task)
        {
            var currentTask = (TextTask)task.Clone();

            CurrentTask = currentTask;
            OnPropertyChanged("CurrentTask");
            OnPropertyChanged("Answer_1");
            OnPropertyChanged("Answer_2");
            OnPropertyChanged("Answer_3");
            OnPropertyChanged("Answer_4");
            OnPropertyChanged("CheckBox_1");
            OnPropertyChanged("CheckBox_2");
            OnPropertyChanged("CheckBox_3");
            OnPropertyChanged("CheckBox_4");
        }
        public ActionResult Create([Bind(Include = "TextId,Name,Text,Words,Difficult")] TextTask textTask)
        {
            if (ModelState.IsValid)
            {
                if (textTask.Words.EndsWith(";"))
                {
                    textTask.Words = textTask.Words.TrimEnd(';');
                }
                textTask.AuthorId = 1;
                ELTask task = new ELTask()
                {
                    AuthorId = 1, Difficult = textTask.Difficult, Group = "TextTask", TextTask = textTask, Name = textTask.Name, Description = "Прочитайте текст та вставте в проміжки слова"
                };
                db.ELTask.Add(task);
                db.TextTask.Add(textTask);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(textTask));
        }
Example #10
0
 /// <summary>
 /// Показать текст
 /// </summary>
 public static void ShowMsg(
     string pText
     , float pWaitBefore      = 0
     , float pSymPause        = 0.005f
     , float pWaitAfter       = 0
     , System.Action WhenDone = null)
 {
     if (pText == "<")
     {
         DelLast();
     }
     else
     {
         TextTask task = new TextTask();
         task.beforePause = pWaitBefore;
         task.symPause    = pSymPause;
         task.afterPause  = pWaitAfter;
         task.text        = pText;
         task.WhenDone    = WhenDone;
         tasks.Enqueue(task);
     }
 }
Example #11
0
    void Update()
    {
        _carTimer -= Time.deltaTime;
        if (_carTimer < -carSpeed)
        {
            _carTimer = carSpeed;
        }
        showCar(_carTimer > 0);

        if (task == null && tasks.Count > 0)
        {
            task  = tasks.Dequeue();
            ready = false;
        }

        if (task != null)
        {
            task.curTimer -= Time.deltaTime;
            if (task.curTimer > 0)
            {
                return;
            }

            switch (task.phase)
            {
            case Phase.None:                     // Стартуем
                task.phase    = Phase.Pre;
                task.curTimer = task.beforePause;
                break;

            case Phase.Pre:
                task.phase    = Phase.Sym;
                task.curTimer = task.symPause;
                task.symNo    = 0;
                break;

            case Phase.Sym:
                showCar(false);
                _carTimer = 0;
                while (task.curTimer < 0)
                {
                    if (task.text.Length <= task.symNo)
                    {
                        task.phase    = Phase.After;
                        task.curTimer = task.afterPause;
                        //text.text += "\n";
                    }
                    else
                    {
                        char c = task.text[task.symNo];
                        text.text += c;
                        if (largeLine)                                 // Перенос на новую строку
                        {
                            c          = '\n';
                            text.text += c;
                        }

                        task.symNo++;
                        if (c == '\n')
                        {
                            CheckLines();
                        }
                    }
                    task.curTimer += task.symPause;
                }
                break;

            default:
                if (task.WhenDone != null)
                {
                    task.WhenDone.Invoke();
                }
                task = null;
                if (tasks.Count < 1)
                {
                    ready = true;
                }
                break;
            }
        }
    }
Example #12
0
        public ITask Create(IAction action)
        {
            ITask task = null;

            if (taskDic.TryGetValue(action.ActionType, out task))
            {
                return(task);
            }

            if (action.ActionType == ActionType.PageAction)
            {
                task = new PageTask(manager);
            }
            else if (action.ActionType == ActionType.BrowserAction)
            {
                task = new BrowserTask(manager);
            }
            else if (action.ActionType == ActionType.FindAction)
            {
                task = new FindTask(manager);
            }
            else if (action.ActionType == ActionType.MouseAction)
            {
                task = new MouseTask(manager);
            }
            else if (action.ActionType == ActionType.AttributeAction)
            {
                task = new AttributeTask(manager);
            }
            else if (action.ActionType == ActionType.ScrollAction)
            {
                task = new ScrollTask(manager);
            }
            else if (action.ActionType == ActionType.ClearDataAction)
            {
                task = new ClearDataTask(manager);
            }
            else if (action.ActionType == ActionType.WaitAction)
            {
                task = new WaitTask(manager);
            }
            else if (action.ActionType == ActionType.ClickAction)
            {
                task = new ClickTask(manager);
            }
            else if (action.ActionType == ActionType.KeyboardAction)
            {
                task = new KeyboardTask(manager);
            }
            else if (action.ActionType == ActionType.SendKeyAction)
            {
                task = new SendKeyTask(manager);
            }
            else if (action.ActionType == ActionType.ConditionAction)
            {
                task = new ConditionTask(manager);
            }
            else if (action.ActionType == ActionType.ClearHistoryAction)
            {
                task = new ClearHistoryTask(manager);
            }
            else if (action.ActionType == ActionType.TextAction)
            {
                task = new TextTask(manager);
            }
            else if (action.ActionType == ActionType.ScriptAction)
            {
                task = new ScriptTask(manager);
            }
            else if (action.ActionType == ActionType.PackageAction)
            {
                task = new PackageTask(manager);
            }

            taskDic.Add(action.ActionType, task);

            return(task);
        }
        private void Seed()
        {
            using (var context = new TaskDbContext(contextOptions, configuration, DataBaseFlags.Test))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                #region InitTextTask
                var oneTextTask = new TextTask()
                {
                    Id               = new Guid(),
                    StartTime        = DateTime.Now.AddDays(-1),
                    EndTime          = DateTime.Now.AddHours(4),
                    CountOfRepeating = 30
                };
                var twoTextTask = new TextTask()
                {
                    Id               = new Guid(),
                    StartTime        = DateTime.Now,
                    EndTime          = DateTime.Now.AddDays(1),
                    CountOfRepeating = 40
                };
                _textTask = new List <TextTask>()
                {
                    oneTextTask, twoTextTask
                };
                context.TextTask.AddRange(oneTextTask, twoTextTask);
                #endregion

                #region InitSearxhWords
                var oneSearchWords = new SearchWords()
                {
                    Id     = new Guid(),
                    IdTask = _textTask[0].Id,
                    Word   = "a"
                };
                var twoSearchWords = new SearchWords()
                {
                    Id     = new Guid(),
                    IdTask = _textTask[0].Id,
                    Word   = "b"
                };
                var threeSearchWords = new SearchWords()
                {
                    Id     = new Guid(),
                    IdTask = _textTask[1].Id,
                    Word   = "а"
                };
                var fourSearchWords = new SearchWords()
                {
                    Id     = new Guid(),
                    IdTask = _textTask[1].Id,
                    Word   = "б"
                };
                _searchWords = new List <SearchWords>()
                {
                    oneSearchWords, twoSearchWords, threeSearchWords, fourSearchWords
                };
                context.SearchWords.AddRange(oneSearchWords, twoSearchWords, threeSearchWords, fourSearchWords);
                #endregion

                #region InitTextTaskResult
                var oneTextTaskResult_1 = new TextTaskResult()
                {
                    Id     = new Guid(),
                    IdTask = _textTask[0].Id,
                    IdText = new Guid("65BC3B85-806F-493B-ADBA-E13E3C935A60"),
                    IdWord = _searchWords[0].Id,
                    Count  = 1
                };
                var oneTextTaskResult_2 = new TextTaskResult()
                {
                    Id     = new Guid(),
                    IdTask = _textTask[0].Id,
                    IdText = new Guid("65BC3B85-806F-493B-ADBA-E13E3C935A60"),
                    IdWord = _searchWords[1].Id,
                    Count  = 21
                };
                var twoTextTaskResult_1 = new TextTaskResult()
                {
                    Id     = new Guid(),
                    IdTask = _textTask[1].Id,
                    IdText = new Guid("65BC3B85-806F-493B-ADBA-E13E3C935A60"),
                    IdWord = _searchWords[2].Id,
                    Count  = 7
                };
                var twoTextTaskResult_2 = new TextTaskResult()
                {
                    Id     = new Guid(),
                    IdTask = _textTask[1].Id,
                    IdText = new Guid("65BC3B85-806F-493B-ADBA-E13E3C935A60"),
                    IdWord = _searchWords[3].Id,
                    Count  = 8
                };
                _textTaskResult = new List <TextTaskResult>()
                {
                    oneTextTaskResult_1, oneTextTaskResult_2, twoTextTaskResult_1, twoTextTaskResult_2
                };
                context.TextTaskResult.AddRange(oneTextTaskResult_1, oneTextTaskResult_2, twoTextTaskResult_1, twoTextTaskResult_2);
                #endregion

                context.SaveChanges();
            }
        }