Ejemplo n.º 1
0
 public void InsertTask(LoaderTask task)
 {
     currentLoaderTask = task;
     reponseData       = null;
     state             = State.Busy;
     currentTask       = new SimpleTask(request());
 }
Ejemplo n.º 2
0
        private void TasksSetup()
        {
            foreach (Task _task in gameTasks)
            {
                Debug.LogWarning("Initiallizing " + _task.name);

                // SIMPLE ----------------------------------------- //
                if (_task is SimpleTask)
                {
                    SimpleTask _simpleTask = _task as SimpleTask;

                    if (_simpleTask is ReachTask)
                    {
                        _simpleTask.Setup(tasksBlackboard.GetPlayer().gameObject);
                    }
                }
                // COMPLEX --------------------------------------- //
                else if (_task is ComplexTask)
                {
                    ComplexTask _complexTask = _task as ComplexTask;

                    foreach (Task _internalTask in _complexTask.GetTasksList())
                    {
                        // Dani esto estaria bien que el setup de los hijos los haga el padre
                        if (_internalTask is ReachTask)
                        {
                            _internalTask.Setup(tasksBlackboard.GetPlayer().gameObject);
                        }
                    }
                }

                ActivateTask(_task, true);
            }
        }
Ejemplo n.º 3
0
    public void Shot(string filename, CallBack call = null)
    {
        callback = call;
        string fold = string.Format("{0}/{1}", Application.persistentDataPath, rootFold);

        if (!Directory.Exists(fold))
        {
            Directory.CreateDirectory(fold);
        }

        string shotPath = string.Format("{0}/{1}/{2}", Application.persistentDataPath, rootFold, filename);

        if (File.Exists(shotPath))
        {
            File.Delete(shotPath);
        }

        string pngPath = shotPath;

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            shotPath = string.Format("{0}/{1}", rootFold, filename);
        }
        Application.CaptureScreenshot(shotPath);
        task = new SimpleTask(ShotComplete(pngPath));
    }
Ejemplo n.º 4
0
    IEnumerator FrameStart()
    {
        if (loop)
        {
            while (true)
            {
                for (int i = 0; i < _frame; i++)
                {
                    yield return(null);
                }

                if (callback != null)
                {
                    callback.Invoke();
                }
            }
        }
        else
        {
            for (int i = 0; i < _frame; i++)
            {
                yield return(null);
            }

            if (callback != null)
            {
                callback.Invoke();
            }
        }
        task = null;
    }
Ejemplo n.º 5
0
        public RESTStatus GetSTask(SQLLib sql, object dummy, NetworkConnectionInfo ni, Int64 id)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("select * from SimpleTasks WHERE ID=@id", new SQLParam("@id", id));
                if (dr.HasRows == false)
                {
                    dr.Close();
                    return(RESTStatus.NotFound);
                }

                SimpleTask = new SimpleTask();

                while (dr.Read())
                {
                    sql.LoadIntoClass(dr, SimpleTask);
                }
                dr.Close();
            }

            return(RESTStatus.Success);
        }
Ejemplo n.º 6
0
        private static void TestTaskmanager()
        {
            var tm = new TaskManager();
            var brContextFactory    = new BrowsingContextFactory();
            var link                = "https://www.olx.ua/nedvizhimost/arenda-kvartir/dolgosrochnaya-arenda-kvartir/dnepr/";
            var getPagesCountTask   = new GetPagesCountActivity(link, brContextFactory.GetNew()).AsSimpleTask(tm);
            var printPagesCountTask = new SimpleTask(() => System.Console.WriteLine("PagesCount: {0}", getPagesCountTask.Result));

            printPagesCountTask.ContinueWith(() =>
            {
                var linkPage = "?page={0}";
                var tasks    = new ITask <IEnumerable <PreviewAdModel> > [getPagesCountTask.Result];
                for (int i = 1; i <= getPagesCountTask.Result; i++)
                {
                    var procLink = i == 1 ? link : link + string.Format(linkPage, i);
                    tasks[i - 1] = new GetPreviewModelsActivity(procLink, brContextFactory).AsSimpleTask(tm);
                }
                tasks.ForEach(s => s.ContinueWith(() => { return(new SimpleTask(() => { s.Result.ForEach(k => System.Console.WriteLine(k.Price)); })); }));

                /*   tasks.ContinueWith(new SimpleTask(() =>
                 * {
                 *     System.Console.WriteLine("Completed");
                 * }));*/
                return(tasks);
            }).ContinueWith(() => { return(new SimpleTask(() => System.Console.WriteLine("Completed"))); });
            getPagesCountTask.ContinueWith(printPagesCountTask);
            tm.AddTask(getPagesCountTask);
            tm.Start();
        }
        public void Test_執行簡單備份_應會產生三個檔案()
        {
            // arrange
            // 產生測試用檔案
            string filePath = "D:\\Projects\\oop-homework\\storage\\app\\SimpleTaskTest.txt5";

            File.WriteAllText(filePath, "123");
            // 測試執行時預期產生的檔案
            string byteArrayToFile = "D:\\Projects\\oop-homework\\storage\\app\\SimpleTaskTest.txt5.backup";
            // 測試完預期產生的檔案
            string copyToNewFile = "D:\\Projects\\oop-homework\\storage\\app\\backup\\SimpleTaskTest.txt5.backup";

            // act
            JObject    inputStub  = JObject.Parse(@"{'configs':[{'connectionString':'','destination':'directory','dir':'D:\\Projects\\oop-homework\\storage\\app\\backup','ext':'txt5','handlers':['zip', 'encode'],'location':'D:\\Projects\\oop-homework\\storage\\app','remove':false,'subDirectory':false,'unit':'file'}]}");
            Config     configStub = new Config(inputStub["configs"][0]);
            SimpleTask simpleTask = new SimpleTask();

            simpleTask.Execute(configStub, null);

            // assert
            // 查看是否有檔案產生
            Assert.True(File.Exists(filePath));
            Assert.True(File.Exists(byteArrayToFile));
            Assert.True(File.Exists(copyToNewFile));

            // 測試結束刪除檔案
            File.Delete(filePath);
            File.Delete(byteArrayToFile);
            File.Delete(copyToNewFile);
            Assert.False(File.Exists(filePath));
            Assert.False(File.Exists(byteArrayToFile));
            Assert.False(File.Exists(copyToNewFile));
        }
        public async Task <ProcessingResponse> ProcessRequest(RequestData requestData)
        {
            var inputTransmitter  = new InputTransmitterAsync(requestData.ThingNames);
            var outputTransmitter = new OutputTransmitterAsync();

            var simpleTask = new SimpleTask(
                id:               Guid.NewGuid(),
                executionsNumber: 1,
                delayTime:        TimeSpan.Zero
                );

            ServiceStatus status = (
                await simpleTask.ExecuteAsync(requestData, inputTransmitter, outputTransmitter)
                ).Single();

            IReadOnlyList <IReadOnlyList <RatingDataContainer> > results =
                outputTransmitter.GetResults();

            var response = new ProcessingResponse
            {
                Metadata = new ResponseMetadata
                {
                    CommonResultsNumber           = results.Sum(rating => rating.Count),
                    CommonResultCollectionsNumber = results.Count,
                    ResultStatus = status,
                    OptionalData = CreateOptionalData()
                },
                RatingDataContainers = results
            };

            return(response);
        }
        public SimpleTaskShould(ITestOutputHelper output)
        {
            _output = output;
            _task   = new SimpleTask("Sample Task");
            _output.WriteLine(string.Format("Created a simple task called : \"{0}\"", _task.Name));

            _output.WriteLine("Leaving constructor - starting test");
        }
Ejemplo n.º 10
0
 public void Stop()
 {
     if (task != null)
     {
         task.Stop();
         task = null;
     }
 }
Ejemplo n.º 11
0
        public void NewTask(PTTimePair start, PTTimePair end)
        {
            var task = new SimpleTask(start, end);

            ParallelTasker.AddTask(start, end, task.OnInitialize, task.Execute, task.OnFinalize, m_period);
            PTLogger.Warning($"Added {task}");
            m_tasks.Add(task);
        }
        public void Add_InvalidTask()
        {
            repo = new TaskRepository <ITask>();
            repo.InsertTask(task_1);

            SimpleTask invalidTask = new SimpleTask(task_1.Id, 9);

            Assert.IsFalse(repo.InsertTask(invalidTask));
        }
Ejemplo n.º 13
0
 public void AddTask(SimpleTask form)
 {
     if (form.DueDate < System.DateTime.Now)
     {
         throw new Exception("Due Date can not be in the past for new tasks");
     }
     _context.Add(form);
     _context.SaveChanges(); //if this was real application, I'd push this down to a separate Db Repository class.
 }
 private void AddSimpleTaskIfNotExists(SimpleTask simpleTask)
 {
     if (_context.Tasks.IgnoreQueryFilters().Any(task => task.Id == simpleTask.Id && task.Title == simpleTask.Title))
     {
         return;
     }
     _context.Tasks.Add(simpleTask);
     _context.SaveChanges();
 }
Ejemplo n.º 15
0
 public void Stop()
 {
     lpindex = 0;
     if (task != null)
     {
         task.Stop();
         task = null;
     }
 }
Ejemplo n.º 16
0
        public IActionResult Delete([Bind] SimpleTask task)
        {
            var request = Common.SecureRequest.RequestClient.Request($"{this.MyAPIUrl}/api/task/{task.Id}", Method.DELETE);

            if (!request.Success && !string.IsNullOrEmpty(request.Message))
            {
                ModelState.AddModelError(string.Empty, request.Message); return(View(task));
            }
            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 17
0
        public async Task <ActionResult> Put(string name, [FromBody] SimpleTaskDto value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool isTaskInProgress = true;

            do
            {
                isTaskInProgress = _tasksInProgress.Any(x => x == value.Name);
                if (isTaskInProgress)
                {
                    Thread.Sleep(1000);
                }
                else
                {
                    _tasksInProgress.Add(value.Name);
                }
            } while (!isTaskInProgress);

            var        task         = _iMapper.Map <SimpleTaskDto, SimpleTask>(value);
            SimpleTask existingTask = null;

            existingTask = _simpleTaskRepository.Get(name);
            if (existingTask == null)
            {
                return(NotFound($"Task with name {name} does not exist."));
            }

            // check for uniqness of name
            bool isValid = await Validate(existingTask);

            if (!isValid)
            {
                _tasksInProgress.Remove(value.Name);
                return(BadRequest($"Task name {name} already exists in database."));
            }

            // Actually, this should not be used at all - PUT is just to take whole object and "put" it somewhere else. That's the theory at least :)
            // No fields should be changed, including last update time and number of updates.
            // For updating task please use "PATCH".

            existingTask.LastUpdateDateTime = DateTime.Now;
            existingTask.LastUpdateBy       = "Mikk";
            existingTask.NumberOfUpdates++;

            existingTask.Update(task);
            _simpleTaskRepository.Update(task);
            IncrementNumberOfTotalOperations();
            _tasksInProgress.Remove(value.Name);

            return(Ok(existingTask));
        }
Ejemplo n.º 18
0
        static void CompleteTask(Network net, SimpleTask st, int Code, string Text)
        {
            SimpleTaskResult res = new SimpleTaskResult();

            res.ID        = st.ID;
            res.MachineID = SystemInfos.SysInfo.MachineID;
            res.Name      = st.Name;
            res.Result    = Code;
            res.Text      = Text;
            net.CompleteSimpleTask(res);
        }
Ejemplo n.º 19
0
    public void Dispose()
    {
        if (currentTask != null)
        {
            currentTask.Stop();
            currentTask = null;
        }

        currentLoaderTask = null;
        DisposeLoader();
        state = State.Idle;
    }
Ejemplo n.º 20
0
        public async Task <ActionResult> Patch(string name, [FromBody] SimpleTaskDto value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool isTaskInProgress = true;

            do
            {
                isTaskInProgress = _tasksInProgress.Any(x => x == value.Name);
                if (isTaskInProgress)
                {
                    Thread.Sleep(1000);
                }
                else
                {
                    _tasksInProgress.Add(value.Name);
                }
            } while (!isTaskInProgress);

            var        task         = _iMapper.Map <SimpleTaskDto, SimpleTask>(value);
            SimpleTask existingTask = null;

            existingTask = _simpleTaskRepository.Get(name);
            if (existingTask == null)
            {
                _tasksInProgress.Remove(value.Name);
                return(NotFound($"Task with name {name} does not exist."));
            }


            bool isValid = await Validate(existingTask);

            if (!isValid)
            {
                _tasksInProgress.Remove(value.Name);
                return(BadRequest($"Task with name {name} already exists in database."));
            }


            existingTask.LastUpdateDateTime = DateTime.Now;
            existingTask.LastUpdateBy       = "Mikk";
            existingTask.NumberOfUpdates++;

            existingTask.Patch(task);
            _simpleTaskRepository.Update(task);
            IncrementNumberOfTotalOperations();
            _tasksInProgress.Remove(value.Name);

            return(Ok(existingTask));
        }
Ejemplo n.º 21
0
 void LoadTasks()
 {
     tasks = new List <SimpleTask>();
     if (File.Exists(savePath))
     {
         string[] lines = File.ReadAllLines(savePath);
         foreach (var l in lines)
         {
             tasks.Add(SimpleTask.Deserialize(l));
         }
     }
 }
Ejemplo n.º 22
0
 IEnumerator ShotComplete(string path)
 {
     while (!File.Exists(path))
     {
         yield return(1);
     }
     task = null;
     if (callback != null)
     {
         callback();
     }
 }
Ejemplo n.º 23
0
        public async Task <ActionResult <SimpleTask> > CreateTask(SimpleTask task)
        {
            if (task == null)
            {
                return(BadRequest());
            }

            _db.todos.Add(task);
            await _db.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetSpecTask), new { task.id }, task));
        }
Ejemplo n.º 24
0
        public ActionResult EditTask(int id, SimpleTask task)
        {
            if (id != task.id)
            {
                return(BadRequest());
            }

            _db.Entry(task).State = EntityState.Modified;
            _db.SaveChanges();

            return(NoContent());
        }
Ejemplo n.º 25
0
        public IActionResult Edit(string id)
        {
            SimpleTask model = GetTask(id);

            if (model != null)
            {
                return(View(model));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 26
0
        public async Task <OperationResult> SaveTaskAsync(SimpleTask record)
        {
            var validation = record.Validate();

            if (!validation.IsValid)
            {
                return(new OperationResult(false, validation.ResultsToHtml()));
            }
            var endpoint = UriFactory.CreateDocumentCollectionUri(_db.DatabaseName, _db.TaskCollectionName);

            using (var client = _db.NewClient())
            {
                ResourceResponse <Microsoft.Azure.Documents.Document> response;

                if (!string.IsNullOrEmpty(record.Id) && _db.DoesDocumentExists(_db.TaskCollectionName, record.Id))
                {
                    var task = _db.QueryTask(client).Where(t => t.Id == record.Id).AsEnumerable().FirstOrDefault();
                    if (task != null)
                    {
                        task.Title       = record.Title;
                        task.Description = record.Description;
                        response         = await client.UpsertDocumentAsync(endpoint, task, new RequestOptions());

                        return(new OperationResult(true)
                        {
                            RecordId = record.Id, Tag = response
                        });
                    }
                }

                record.Id = string.IsNullOrEmpty(record.Id) ? Guid.NewGuid().ToString() : record.Id;
                record.RegistrationDateTime = DateTime.Now;
                record.State = new List <SimpleTaskStatus>()
                {
                    new SimpleTaskStatus()
                    {
                        Id               = Guid.NewGuid().ToString(),
                        TaskId           = record.Id,
                        Status           = TaskStatusType.New,
                        RegistrationUser = record.User,
                        RegistrationDate = DateTime.Now
                    }
                };
                response = await client.CreateDocumentAsync(endpoint, record);

                return(new OperationResult(true)
                {
                    RecordId = record.Id
                });
            }
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> Uncomplete([FromBody] CompleteUncomplete dto)
        {
            if (dto == null)
            {
                return(BadRequest());
            }

            try
            {
                dto.UserId = IdentityHelper.GetUserId(User);
            }
            catch (UnauthorizedAccessException)
            {
                return(Unauthorized());
            }

            SimpleTask task = await _taskService.UncompleteAsync(dto);

            // Notify
            var usersToBeNotified = await _userService.GetToBeNotifiedOfListChangeAsync(task.ListId, dto.UserId, task.Id);

            if (usersToBeNotified.Any())
            {
                var currentUser = await _userService.GetAsync(dto.UserId);

                SimpleList list = await _listService.GetAsync(task.ListId);

                foreach (var user in usersToBeNotified)
                {
                    CultureInfo.CurrentCulture = new CultureInfo(user.Language, false);
                    string message = _localizer["UncompletedTaskNotification", IdentityHelper.GetUserName(User), task.Name, list.Name];

                    var updateNotificationDto = new CreateOrUpdateNotification(user.Id, dto.UserId, list.Id, task.Id, message);
                    var notificationId        = await _notificationService.CreateOrUpdateAsync(updateNotificationDto);

                    var pushNotification = new PushNotification
                    {
                        SenderImageUri = currentUser.ImageUri,
                        UserId         = user.Id,
                        Application    = "To Do Assistant",
                        Message        = message,
                        OpenUrl        = GetNotificationsPageUrl(notificationId)
                    };

                    _senderService.Enqueue(pushNotification);
                }
            }

            return(NoContent());
        }
Ejemplo n.º 28
0
        private static string DoNewTaskArrived()
        {
            UserTask task = GetLastUserTaskQuery.GetLatestUserTask(DeluxeIdentity.CurrentUser.ID);

            string result = string.Empty;

            if (task != null)
            {
                SimpleTask st = new SimpleTask(task);

                result = JSONSerializerExecute.Serialize(st);
            }

            return(result);
        }
Ejemplo n.º 29
0
 public IActionResult Create([Bind("Id,Name,DueDate,Completed")] SimpleTask simpleTask)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _businessLogic.AddTask(simpleTask);
             return(RedirectToAction(nameof(Index)));
         }
         catch (Exception ex)
         {
             HandleException(ex);
         }
     }
     return(View(simpleTask));
 }
Ejemplo n.º 30
0
 /// <summary>
 /// get
 /// </summary>
 /// <returns></returns>
 public override SimpleTask Load()
 {
     if (loadType == LoadType.Get)
     {
         task = new SimpleTask(request());
     }
     else if (loadType == LoadType.Post)
     {
         task = new SimpleTask(request(form));
     }
     else if (loadType == LoadType.PostHeader)
     {
         task = new SimpleTask(request(postdata, header));
     }
     return(task);
 }
Ejemplo n.º 31
0
 public override void BeforeExecute(SimpleTask simpleTask)
 {
     ((MockSimpleTaskWithAttributes)simpleTask).CallbackQueue.Enqueue("First.Before");
 }
Ejemplo n.º 32
0
        private static string DoNewTaskArrived()
        {
            UserTask task = GetLastUserTaskQuery.GetLatestUserTask(DeluxeIdentity.CurrentUser.ID);

            string result = string.Empty;

            if (task != null)
            {
                SimpleTask st = new SimpleTask(task);

                result = JSONSerializerExecute.Serialize(st);
            }

            return result;
        }
Ejemplo n.º 33
0
        private void TaskList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var list = sender as ListBox;
            if (list == null) return;
            var item = list.SelectedItem;
            Task task = null;
            if (item == null) // 選択されていない場合は新規
            {
                task = new SimpleTask();
            }
            else
            {
                task = item as Task;
            }

            var detailWindow = new TaskDetailWindow();
            detailWindow.DataContext = task;
            detailWindow.Show();
        }
Ejemplo n.º 34
0
 private void Page_Drop(object sender, DragEventArgs e)
 {
     if (FileGroupDescriptor.CanDecode(e.Data))
     {
         foreach (FileGroupDescriptor.File file in FileGroupDescriptor.Decode(e.Data))
         {
             Task newTask = new SimpleTask();
             newTask.Name = file.Name;
             newTask.AttachmentName = file.Name;
             byte[] buffer = new byte[file.Content.Length];
             file.Content.Position = 0;
             file.Content.Read(buffer, 0, Convert.ToInt32(file.Content.Length));
             newTask.AttachmentContent = buffer;
             Tasks.Add(newTask);
         }
     }
     // View をリフレッシュ
     RefreshViews();
 }
Ejemplo n.º 35
0
 public override void OnError(SimpleTask simpleTask, Exception exception)
 {
     ((MockSimpleTaskWithAttributes)simpleTask).CallbackQueue.Enqueue("Second.OnError");
 }
Ejemplo n.º 36
0
 public override void AfterExecute(SimpleTask simpleTask)
 {
     ((MockSimpleTaskWithAttributes)simpleTask).CallbackQueue.Enqueue("Second.After");
 }
Ejemplo n.º 37
0
 public abstract void BeforeExecute(SimpleTask simpleTask);
Ejemplo n.º 38
0
 public abstract void OnError(SimpleTask simpleTask, Exception exception);
Ejemplo n.º 39
0
 public abstract void AfterExecute(SimpleTask simpleTask);