예제 #1
0
        public async Task <IActionResult> EditTask(Guid id, Guid assignmentId, EditTaskViewModel model)
        {
            if (ModelState.IsValid)
            {
                ATask task = await _taskService.GetTaskById(id);

                AppUser currentUser = _userManager.GetUserAsync(User).Result;

                task.Title       = model.Title;
                task.Description = model.Description;
                task.ATaskStatus = model.ATaskStatus;
                if (model.ATaskStatus == CompletionStatus.Done)
                {
                    task.CompleteTime = DateTime.Now;
                }
                await _taskService.EditTask(task);

                if (await _userManager.IsInRoleAsync(currentUser, "Manager"))
                {
                    if (assignmentId != null && assignmentId != Guid.Empty)
                    {
                        return(RedirectToAction("CreateAssignmentTask", "ATask", new { assignmentId }));
                    }
                    return(RedirectToAction("GetCompanyTasks", "ATask"));
                }
                else if (await _userManager.IsInRoleAsync(currentUser, "Member"))
                {
                    return(RedirectToAction("GetMemberAssignmentsTasks", "Member"));
                }
                return(RedirectToAction("GetAllTasks", "ATask"));
            }
            return(View(model));
        }
예제 #2
0
        public void ShouldReturnDependenciesMarkedWithAttribute()
        {
            ITask dep = new Mock<ITask>().Object;
            var task = new ATask {A = dep};

            Assert.That(task.Dependencies.Select(d => d.Task), Is.EquivalentTo(new[] {dep}));
        }
        public async Task <IHttpActionResult> PutATask(int id, ATask aTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != aTask.Id)
            {
                return(BadRequest());
            }

            db.Entry(aTask).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ATaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #4
0
        public async Task <IActionResult> CreateTask(CreateTaskViewModel model)
        {
            AppUser user      = _userManager.GetUserAsync(User).Result;
            Guid    companyId = user.CompanyId;

            ViewBag.companyAssignments = new SelectList(await _assignmentService.GetCompanyAssignments(companyId), "AssignmentId", "AssignmentName");

            if (ModelState.IsValid)
            {
                Guid guidAssignmentId = Guid.Parse(model.AssignmentId);

                ATask atask = new ATask
                {
                    Company      = await _companyService.GetCompanyById(companyId),
                    Title        = model.Title,
                    Description  = model.Description,
                    AssignmentId = guidAssignmentId,
                    Assignment   = await _assignmentService.GetAssignmentById(guidAssignmentId),
                    AppUser      = _userManager.GetUserAsync(User).Result,
                    AppUserId    = user.Id,
                    ATaskStatus  = model.ATaskStatus,
                    WrittenBy    = user.UserName,
                    CreateTime   = DateTime.Now,
                };

                await _taskService.NewATask(atask);

                return(RedirectToAction("CreateAssignmentTask", new { guidAssignmentId }));
            }
            return(View(model));
        }
예제 #5
0
        public void Remove()
        {
            ATask t = new ATask(view.Date, view.FirstName, view.Description);

            model.CurrenNotebook.RemoveRevenge(t);

            if (model.CurrenNotebook.CountTask < 1)
            {
                model.CurrenIndex = -1;

                view.Date        = string.Empty;
                view.FirstName   = string.Empty;
                view.Description = string.Empty;
            }
            else
            {
                model.CurrenIndex--;
                if (model.CurrenIndex < 0)
                {
                    model.CurrenIndex = 0;
                }

                view.Date        = model.CurrentTask.Date;
                view.FirstName   = model.CurrentTask.Name;
                view.Description = model.CurrentTask.Description;
            }
        }
예제 #6
0
파일: TaskTest.cs 프로젝트: t3hc13h/bounce
        public void ShouldReturnDependenciesMarkedWithAttribute()
        {
            IObsoleteTask dep  = new Mock <IObsoleteTask>().Object;
            var           task = new ATask {
                A = dep
            };

            Assert.That(task.Dependencies.Select(d => d.Task), Is.EquivalentTo(new[] { dep }));
        }
예제 #7
0
파일: Run.cs 프로젝트: alexfordc/Au
 public RunningTasks()
 {
     _a     = new List <RunningTask>();
     _q     = new List <_WaitingTask>();
     _wMain = (AWnd)Program.MainForm;
     Program.Timer1sOr025s += _TimerUpdateUI;
     ATask.Init_(ATRole.EditorExtension);
     Au.Util.Log_.Run.Start();
 }
예제 #8
0
        private void _SucceedTask(ATask task, string completedByID)
        {
            string   incoming;
            DateTime start;

            _GetIncomingIDAndStart(task.id, out start, out incoming);
            _addPathEntry(task.id, incoming, task.Outgoing, StepStatuses.Succeeded, start, DateTime.Now, (task is UserTask ? completedByID : null));
            _Complete(task.id, (task.Outgoing == null ? null : task.Outgoing[0]));
        }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Start"></param>
        /// <param name="End"></param>
        public void Build(DateTime Start, DateTime End)
        {
            ClearGeneratedData();

            // Normalize Start
            Start = Components.Utils.GetNormalizedDateTime(Start);

            // Current time begins at Start
            DateTime CurrentTime = Start;

            // Pre-process every task
            foreach (Project AProject in _Projects)
            {
                foreach (ProjectTask ATask in AProject.Tasks)
                {
                    ATask.PreBuild(this, AProject);
                }
            }

            while (CurrentTime < End)
            {
                // Process every task that contains effective work
                foreach (Project AProject in _Projects)
                {
                    List <ProjectTask> EffectiveTasks = new List <ProjectTask>();

                    foreach (ProjectTask ATask in AProject.Tasks)
                    {
                        AggregateEffectiveTasks(AProject, EffectiveTasks, ATask);
                    }

                    ProcessTasks(AProject, EffectiveTasks, CurrentTime);
                }

                // Process every task that acts as a container
                foreach (Project AProject in _Projects)
                {
                    List <ProjectTask> ContainerTasks = new List <ProjectTask>();

                    foreach (ProjectTask ATask in AProject.Tasks)
                    {
                        AggregateNonEffectiveTasks(AProject, ContainerTasks, ATask);
                    }

                    ProcessTasks(AProject, ContainerTasks, CurrentTime);
                }

                CurrentTime = CurrentTime.AddDays(1.0);
            }

            // Compute project times
            foreach (Project AProject in _Projects)
            {
                AProject.ComputeStartEnd();
            }
        }
예제 #10
0
        internal void FailTask(ATask task, Exception ex)
        {
            _WriteLogLine(task.id, LogLevels.Debug, "Failing Task in Process Path");
            string   incoming;
            DateTime start;

            _GetIncomingIDAndStart(task.id, out start, out incoming);
            _addPathEntry(task.id, incoming, StepStatuses.Failed, start, DateTime.Now);
            _Error(task, ex);
        }
예제 #11
0
        internal void FailTask(ATask task, Exception ex)
        {
            Log.Debug("Failing Task {0} in Process Path", new object[] { task.id });
            string   incoming;
            DateTime start;

            _GetIncomingIDAndStart(task.id, out start, out incoming);
            _addPathEntry(task.id, incoming, StepStatuses.Failed, start, DateTime.Now);
            _Error(task, ex);
        }
예제 #12
0
        public bool AddRevenge(ATask NewTask)
        {
            bool flag = false;

            if (!notebook.Contains(NewTask))
            {
                notebook.Add(NewTask);
                flag = true;
            }
            return(flag);
        }
예제 #13
0
        public bool RemoveRevenge(ATask RemoveTask)
        {
            bool flag = false;

            if (notebook.IndexOf(RemoveTask) != -1)
            {
                notebook.Remove(RemoveTask);
                flag = true;
            }
            return(flag);
        }
예제 #14
0
        public void PrintTree(ATask task)
        {
            if (task is IComposite compositeNode)
            {
                for (int i = 0; i < compositeNode.Children.Count; i++)
                {
                    ATask taskNode = (ATask)compositeNode;
                    PrintTree(compositeNode.Children[i]);
                }
            }

            Debug.Log(task);
        }
예제 #15
0
    public static void AutoTask(int taskID)
    {
        ATask task = TaskSys.GetInstance().GetTask(taskID);

        if (null == task)
        {
            return;
        }

        if (task.Type == ATask.TaskType.Fight)
        {
            AutoFightTask(task as FightTask);
        }
    }
예제 #16
0
        public async Task <IActionResult> TaskDetails(Guid id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ATask aTask = await _taskService.GetTaskById(id);

            if (aTask == null)
            {
                return(NotFound());
            }
            return(View(aTask));
        }
예제 #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="SomeTasks"></param>
        /// <param name="CurrentTime"></param>
        public void ProcessTasks(Project AProject, List <ProjectTask> SomeTasks, DateTime CurrentTime)
        {
            // Sort the task list using the ProjectTask compare method
            SomeTasks.Sort(
                delegate(ProjectTask a, ProjectTask b)
            {
                return(a.QualifyVersus(b));
            }
                );

            // Build every task
            foreach (ProjectTask ATask in SomeTasks)
            {
                ATask.Build(this, AProject, CurrentTime);
            }
        }
예제 #18
0
    void _Toolbar_Common1()
    {
        var t = new AToolbar("_Toolbar_Common1");

        if (!t.SettingsModified)
        {
            //first time set initial properties that are in the right-click menu. Later use saved values.
            t.AutoSize = true;
        }
        //set other properties
        t.BorderColor = System.Drawing.Color.Olive;

        //add buttons
        t["A"] = o => {  };
        t["B"] = o => {  };
        t.MenuButton("C", m => { //drop-down menu
            m["X"] = o => {  };
            m["Y"] = o => {  };
        });
        t.Group("Examples"); //horizontal separator, optionally with text
        t.NoText         = true;
        t["Run program"] = o => AExec.Run(AFolders.System + @"notepad.exe");
        t["Run script"]  = o => ATask.Run("Script example1.cs");
        t["Copy-paste"]  = o => {
            string s = AClipboard.Copy();     //note: to test it, at first select some text somewhere, else it will fail
            s = s.Upper();
            AClipboard.Paste(s);
        };

        bool autoHide = false; //or true

        if (autoHide)
        {
            //An "auto-hide" toolbar actually consists of 2 toolbars:
            //	t - toolbar with many buttons. Hidden when mouse pointer isn't in toolbar t2.
            //	t2 - small toolbar with zero or few buttons. It is the owner of toolbar t.
            var t2 = new AToolbar(t.Name + "^")
            {
                Satellite = t
            };
            t2.Show();
        }
        else
        {
            t.Show();
        }
    }
예제 #19
0
        /// <summary>
        ///
        /// </summary>
        public void Process()
        {
            DateTime Current = Utils.GetNormalizedDateTime(DateTime.Now);

            if (Current > _LastProcessDate)
            {
                foreach (Project AProject in _Projects)
                {
                    foreach (ProjectTask ATask in AProject.Tasks)
                    {
                        ATask.Process(this, AProject, _LastProcessDate, Current);
                    }
                }

                _LastProcessDate = Current;
            }
        }
예제 #20
0
        public async Task <IActionResult> DeleteTask(Guid id, Guid?assignmentId)
        {
            AppUser currentUser = _userManager.GetUserAsync(User).Result;
            ATask   aTask       = await _taskService.GetTaskById(id);

            await _taskService.DeleteTask(aTask);

            if (await _userManager.IsInRoleAsync(currentUser, "Manager"))
            {
                if (assignmentId != null)
                {
                    return(RedirectToAction("CreateAssignmentTask", "ATask", new { assignmentId }));
                }
                return(RedirectToAction("GetCompanyTasks", "ATask"));
            }
            return(RedirectToAction("GetAllTasks", "ATask"));
        }
예제 #21
0
        public async Task <IActionResult> EditTask(Guid id, Guid?assignmentId)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ATask task = await _taskService.GetTaskById(id);

            EditTaskViewModel model = new EditTaskViewModel()
            {
                AssignmentId = assignmentId,
                Title        = task.Title,
                Description  = task.Description,
                ATaskStatus  = task.ATaskStatus
            };

            return(View(model));
        }
예제 #22
0
        public static void MultiThreadAuCarre()
        {
            string  adr = Properties.Api.Default.Adresse;
            ATask   a   = new ATask();
            Program p   = new Program();

            p.httpClient = new HttpClient();
            p.requestUri = new Uri(adr);

            a.Action = p.CallDate;
            var tasks = a.RunPoolOfTasks(true);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Minutes : " + (a.Start - a.End).Minutes);
            Console.WriteLine("Secondes : " + (a.Start - a.End).Seconds);
            Console.WriteLine("Millisecondes : " + (a.Start - a.End).Milliseconds);
            Console.ReadLine();
        }
예제 #23
0
        public IActionResult AddTask(AddTaskViewModel addTaskViewModel)
        {
            if (ModelState.IsValid)
            {
                ATask newTask = new ATask
                {
                    Name = addTaskViewModel.Name,
                    Id   = addTaskViewModel.TaskId
                };

                context.Tasks.Add(newTask);
                context.SaveChanges();

                return(Redirect("/Tasks"));
            }

            return(View(addTaskViewModel));
        }
예제 #24
0
        public static void MultiTaskMultiThreadTen(int nbThread, int nbQuery, int leftPos)
        {
            MainQuery.Results = new List <TaskResult>();
            string adr = Properties.Api.Default.Adresse;

            Program p = new Program();

            p.httpClient = new HttpClient();
            p.requestUri = new Uri(adr);
            p.Mode       = ProgramMode.NoAnswer;

            ATask a = new ATask(nbQuery);

            a.LeftPosition      = leftPos;
            a.ProcessCompleted += A_ProcessCompleted;
            a.Action            = p.CallDate;

            var tasks = a.RunPoolOfTasks(nbQuery / nbThread, true);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.CursorLeft      = leftPos;
            Console.WriteLine("NB THREAD : " + nbThread);
            Console.CursorLeft = leftPos;

            Console.WriteLine("NB CALLS : " + nbQuery);
            Console.CursorLeft = leftPos;

            Console.WriteLine("Minutes : " + (a.Start - a.End).Minutes);
            Console.CursorLeft = leftPos;

            Console.WriteLine("Secondes : " + (a.Start - a.End).Seconds);
            Console.CursorLeft = leftPos;

            Console.WriteLine("Millisecondes : " + (a.Start - a.End).Milliseconds);
            Console.CursorLeft = leftPos;

            for (int i = 0; i < Results.Count; i++)
            {
                var res = Results[i];
                Console.WriteLine("Thread N° : " + i + "            Durée :" + (res.End - res.Start));
            }

            Console.ReadLine();
        }
        public static ATask MakeTask(string taskName, string taskInfo, string category = null, bool favourite = false, bool done = false, Person person = null, ATask aTask = null)
        {
            ATask task = new ATask {
                TaskName = taskName, TaskInfo = taskInfo, Category = category, Favourite = favourite, Done = done
            };

            task.SubTasks = new List <ATask>();
            if (person != null)
            {
                person.Tasks.Add(task);
            }
            ;
            if (aTask != null)
            {
                aTask.SubTasks.Add(task);
            }
            ;
            return(task);
        }
예제 #26
0
    void HotkeyTriggers()
    {
        var hk = Triggers.Hotkey;

        //examples of hotkey triggers

        hk["Ctrl+Alt+K"]     = o => AOutput.Write(o.Trigger); //it means: when I press Ctrl+Alt+K, execute action "AOutput.Write(o.Trigger)"
        hk["Ctrl+Shift+F11"] = o => {                         //action can have multiple statements
            var w1 = AWnd.FindOrRun("* Notepad", run: () => AExec.Run(AFolders.System + "notepad.exe"));
            AKeys.Text("text");
            500.ms();
            w1.Close();
        };
        hk["Ctrl+Shift+1"] = o => TriggerActionExample();          //action code can be in other function. To find it quickly, Ctrl+click the function name here.
        hk["Ctrl+Shift+2"] = o => TriggerActionExample2(o.Window); //the function can be in any class or partial file of this project folder
        hk["Ctrl+Shift+3"] = o => ATask.Run("Script example1.cs"); //run script in separate process. Then don't need to restart triggers when editing the script.

        //triggers that work only with some windows (when the window is active)

        Triggers.Of.Window("* WordPad", "WordPadClass");

        hk["Ctrl+F5"] = o => AOutput.Write("action 1", o.Trigger, o.Window);
        //hk[""] = o => {  };
        //...

        Triggers.Of.Windows(",,notepad.exe"); //all windows of notepad.exe process

        hk["Ctrl+F5"] = o => AOutput.Write("action 2", o.Trigger, o.Window);
        //hk[""] = o => {  };
        //...

        //...

        //disable/enable triggers
        Triggers.Of.AllWindows();
        hk["Ctrl+Alt+Win+D"]  = o => ActionTriggers.DisabledEverywhere ^= true;
        hk.Last.EnabledAlways = true;

        //To add triggers can be used snippets. Start typing "trig" and you will see snippets in the completion list.
        //For more info click word ActionTriggers above and press F1.
    }
        public Person InitialiseData()
        {
            Person admin = MakePerson("Admin", "Simpson", "Homer", "*****@*****.**");

            ATask t1 = MakeTask("Fix computer", "Computer fked.", "IT", person: admin);
            ATask t2 = MakeTask("Get Parts", "Buy Power supply", aTask: t1);
            ATask t3 = MakeTask("Install software", "Install needed software", aTask: t1);
            ATask t4 = MakeTask("Windows", "Windows 7", aTask: t3);
            ATask t5 = MakeTask("Office", "Office 2013", aTask: t3);
            ATask t6 = MakeTask("UMLet", "Tool for fast UML diagrams", aTask: t3);

            ATask t7  = MakeTask("clean house", "clean the house", "Chores", person: admin);
            ATask t8  = MakeTask("Clean bathroom", "Bathroom is dirty", aTask: t7);
            ATask t9  = MakeTask("Toilette", "Scrub the toilette", aTask: t8);
            ATask t10 = MakeTask("Shower", "Scrub the shower", aTask: t8);
            ATask t11 = MakeTask("Clean bedroom", "Bedroom is dirty", aTask: t7);
            ATask t12 = MakeTask("Bed", "Make the bed", aTask: t11);
            ATask t13 = MakeTask("Closet", "Organise the closet", aTask: t11);

            return(admin);
        }
        public async Task <IHttpActionResult> PostATask(ATask aTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ATasks.Add(aTask);
            await db.SaveChangesAsync();

            //db.Entry(aTask).Reference(x => x.SubTasks).Load();

            var sto = new TaskDTO()
            {
                Id       = aTask.Id,
                TaskName = aTask.TaskName,
                Category = aTask.Category,
            };

            return(CreatedAtRoute("DefaultApi", new { id = aTask.Id }, aTask));
        }
예제 #29
0
        public ATask GetATask(SubjectTheme theme, int num)
        {
            string fileName = subject.ToString() + "/" + theme.Num.ToString() + @"/a/" + num.ToString() + "/" + "task.txt";
            var    assets   = MRApplication.GetAssetManager();

            try
            {
                using (StreamReader reader = new  StreamReader(assets.Open(fileName))) {
                    string content = reader.ReadToEnd();

                    var        json     = JsonObject.Parse(content);
                    JsonObject jsonTask = json ["task"] as JsonObject;

                    var aTask = new ATask(num, theme, subject);
                    SetCommonTaskParams(jsonTask, aTask);

                    List <AVariant> variants     = new List <AVariant> ();
                    JsonArray       variantsJSON = jsonTask ["vs"] as JsonArray;
                    foreach (var variant in variantsJSON)
                    {
                        string   text       = variant ["txt"];
                        string   png        = variant ["png"];
                        bool     isRight    = Boolean.Parse(variant ["right"]);
                        AVariant newVariant = new AVariant()
                        {
                            ImageLink = png, IsRight = isRight, Text = text
                        };
                        variants.Add(newVariant);
                    }

                    aTask.Variants = variants;
                    return(aTask);
                }
            }
            catch (Exception e) {
                return(null);
            }
        }
예제 #30
0
        /// <summary>
        ///
        /// </summary>
        public void ClearGeneratedData(Workspace AWorkspace)
        {
            // Use to assign task indices
            int Index = 0;

            // For every task...
            foreach (ProjectTask ATask in _Tasks)
            {
                // If the task's delivery limit time exceeds the project's delivery time,
                // assign the project's delivery time to the task's delivery time
                if (_Delivery < ATask.DeliveryLimit)
                {
                    ATask.DeliveryLimit = _Delivery;
                }

                // Set the task's index
                ATask.Index = Index;

                // Clear the task's generated data
                ATask.ClearGeneratedData();

                Index++;
            }
        }
예제 #31
0
    /// <summary>
    /// adds a task to be run on the main thread
    /// </summary>
    public void AddTask(ATask task, params ATask[] otherTasks) {
        _taskList.Add(task);

        foreach (var t in otherTasks)
            _taskList.Add(t);

        // if our update loop isnt running start it up
        if (!_isRunningTasks)
            StartCoroutine(ProcessTasks());
    }
예제 #32
0
 internal void SucceedTask(ATask task)
 {
     Log.Debug("Succeeding Task {0} in Process Path", new object[] { task.id });
     _SucceedTask(task, null);
 }
예제 #33
0
	public static void Main ()
	{
		var a = new ATask ();
		var res = a.OnDoWorkAsync ().Result;
	}