コード例 #1
0
        public TaskClass getTask()
        {
            TaskClass task = new TaskClass();

            task.serviceVisitID          = this.serviceVisitID;
            task.lastService             = this.lastService;
            task.thisResult              = (TaskResultStatus)Enum.Parse(typeof(TaskResultStatus), this.thisResult);
            task.lastResult              = (TaskResultStatus)Enum.Parse(typeof(TaskResultStatus), this.lastResult);
            task.taskType                = this.taskType;
            task.serviceVisitItemNumber  = this.serviceVisitItemNumber;
            task.taskName                = this.taskName;
            task.siteEquipmentLineNumber = this.siteEquipmentLineNumber;
            task.siteID = this.siteID;
            TaskInformation taskInfo = new TaskInformation();

            taskInfo.contractor           = this.contractor;
            taskInfo.taskTypeDescription  = this.taskTypeDescription;
            taskInfo.location             = this.location;
            taskInfo.barcode              = this.barcode;
            taskInfo.opNumber             = this.opNumber;
            taskInfo.isMoving2012Standard = this.isMoving2012Standard;
            taskInfo.maintainedStandard   = this.maintainedStandard;
            taskInfo.lastServicedBy       = this.lastServicedBy;
            task.taskInformation          = taskInfo;
            return(task);
        }
コード例 #2
0
ファイル: TaskCrud.cs プロジェクト: Manojkumarupm/Apisample
 /// <summary>
 /// Remove Task from the database
 /// </summary>
 /// <param name="TaskId">TaskId</param>
 /// <returns>Status of the Operation</returns>
 public string RemoveTask(int TaskId)
 {
     try
     {
         using (CapsuleEntities PE = new CapsuleEntities())
         {
             PE.Configuration.ProxyCreationEnabled = false;
             TaskInformation I = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault();
             if (I == null)
             {
                 return("Task with Id " + TaskId + " Not found");
             }
             else
             {
                 PE.Entry(I).State = System.Data.Entity.EntityState.Deleted;
                 PE.SaveChanges();
                 return("Success");
             }
         }
     }
     catch (Exception ex)
     {
         return("Failed : " + ex.Message);
     }
 }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: Manojkumarupm/Apisample
        public void PosTaskTest()
        {
            //Arrange
            TaskCrud taskcrud = new TaskCrud();
            //Act
            TaskInformation task = new TaskInformation();

            task.IsTaskCompleted = 0;
            task.Priority        = 4;
            task.ProjectId       = 1;
            task.TaskId          = 0;
            task.TaskDescription = "Test Child";
            task.UserId          = 1;
            task.StartDate       = DateTime.Parse("02/01/2018");
            task.EndDate         = DateTime.Parse("02/01/2018");
            TaskInformation value = taskcrud.AddTask(task);

            //Assert
            if (value != null)
            {
                Assert.AreEqual(value.TaskDescription, task.TaskDescription);
            }
            else
            {
                Assert.IsNotNull(value);//Arrange
            }
        }
コード例 #4
0
        private void RefreshRead(TaskInformation task)
        {
            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Button("名称:", GUILayout.Width(WIDTH));

                    GUILayout.Label(task.name, GUILayout.Width(150));

                    GUILayout.Button("进度:", GUILayout.Width(WIDTH));

                    GUILayout.Label(string.Format("{0}%", task.progress));
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Button("描述:", GUILayout.Width(WIDTH));

                    GUILayout.Label(task.description, GUILayout.ExpandHeight(true));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
コード例 #5
0
        public IHttpActionResult Put(int TaskId, TaskInformation t)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (TaskId != t.TaskId)
            {
                return(BadRequest());
            }
            try
            {
                TaskDetailsGetter.UpdateTask(t);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TaskDetailsGetter.IsTaskExist(TaskId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #6
0
    public static void PopulateTaskInformation(TaskInformation information)
    {
        if (information.Status == TaskStatus.Completed)
        {
            return;
        }
        else
        {
            TaskConfigData taskData = ConfigInterface.Instance.TaskConfigHelper.GetTaskData(information.TaskID);

            foreach (KeyValuePair <int, TaskConditionConfigData> condition in taskData.Conditions)
            {
                if (information.ConditionProgresses == null)
                {
                    information.ConditionProgresses = new Dictionary <int, TaskProgressInformation>();
                }
                if (!information.ConditionProgresses.ContainsKey(condition.Key))
                {
                    information.ConditionProgresses.Add(condition.Key, new TaskProgressInformation()
                    {
                        StartValue = 0, CurrentValue = GetCurrentValueFromConfig(condition.Value)
                    });
                }
                else
                {
                    information.ConditionProgresses[condition.Key].CurrentValue = GetCurrentValueFromConfig(condition.Value);
                }
            }
        }
    }
コード例 #7
0
        void GetANewTask()
        {
            System.Random Random     = new System.Random();
            int           NewTaskInt = Random.Next(0, Tasks.Length);

            if (TaskInt != NewTaskInt)
            {
                TaskInt     = NewTaskInt;
                CurrentTask = Tasks[TaskInt];
            }
            else
            {
                while (TaskInt == NewTaskInt)
                {
                    NewTaskInt = Random.Next(0, Tasks.Length);

                    if (TaskInt != NewTaskInt)
                    {
                        TaskInt     = NewTaskInt;
                        CurrentTask = Tasks[TaskInt];

                        Config.Clear();

                        break;
                    }
                }
            }
        }
コード例 #8
0
        private void RefreshWrite(TaskInformation task)
        {
            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Button("名称:", GUILayout.Width(WIDTH));

                    task.name = GUILayout.TextField(task.name);

                    switch (task.status)
                    {
                    case Status.Editor:
                    {
                        GUILayout.Button("进度:", GUILayout.Width(WIDTH));

                        GUILayout.Label(string.Format("{0}%", task.progress), GUILayout.Width(100));

                        task.progress = GUILayout.HorizontalSlider(task.progress, 0, 100, GUILayout.Width(150));
                    }
                    break;
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Button("描述:", GUILayout.Width(WIDTH));

                    task.description = GUILayout.TextField(task.description, GUILayout.ExpandHeight(true));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
コード例 #9
0
        public static async Task <BackgroundTaskRegistration> RegisterBackgroundTask(TaskInformation info)
        {
            if (info.background)
            {
                await BackgroundExecutionManager.RequestAccessAsync();
            }

            var builder = new BackgroundTaskBuilder();

            builder.Name           = info.name;
            builder.TaskEntryPoint = info.taskEntryPoint;
            builder.SetTrigger(info.trigger);

            if (info.condition != null)
            {
                builder.AddCondition(info.condition);

                builder.CancelOnConditionLoss = true;
            }


            BackgroundTaskRegistration task = builder.Register();

            /*if (info.callback != null)
             * {
             *  task.Completed +=
             * }*/

            return(task);
        }
コード例 #10
0
ファイル: Task.cs プロジェクト: KangLLL/century_war
 public void OpenChildrenTask()
 {
     foreach (int childID in this.TaskConfigData.Children)
     {
         TaskInformation info = new TaskInformation();
         info.Status = TaskStatus.Opened;
         info.TaskID = childID;
         info.ConditionProgresses = new Dictionary <int, TaskProgressInformation>();
         TaskConfigData configData = ConfigInterface.Instance.TaskConfigHelper.GetTaskData(childID);
         if (configData.ValidSeconds > 0)
         {
             info.RemainingSeconds = configData.ValidSeconds;
         }
         foreach (KeyValuePair <int, TaskConditionConfigData> condition in configData.Conditions)
         {
             if (!condition.Value.IsGlobal)
             {
                 info.ConditionProgresses.Add(condition.Key, new TaskProgressInformation()
                 {
                     StartValue = TaskProgressFactory.GetCurrentValueFromConfig(condition.Value)
                 });
             }
         }
         TaskProgressFactory.PopulateTaskInformation(info);
         Task childTask = new Task(info, this.m_Manager);
         LogicController.Instance.TaskManager.AddTask(childTask);
     }
 }
コード例 #11
0
ファイル: TaskCrud.cs プロジェクト: Manojkumarupm/Apisample
 /// <summary>
 /// Getting the specific Task from the database
 /// </summary>
 /// <param name="TaskId">TaskId</param>
 /// <returns>TaskInformation</returns>
 public TaskInformation GetTask(int TaskId)
 {
     using (CapsuleEntities PE = new CapsuleEntities())
     {
         PE.Configuration.ProxyCreationEnabled = false;
         TaskInformation i = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault();
         return(i);
     }
 }
コード例 #12
0
 public IHttpActionResult Post(TaskInformation t)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     TaskDetailsGetter.AddTask(t);
     return(CreatedAtRoute("DefaultApi", new { id = t.TaskId }, t));
 }
コード例 #13
0
        public ActionResult DeleteTaskInfo(string id)
        {
            TaskInformationDBContext db     = new TaskInformationDBContext();
            int             ID              = Convert.ToInt32(id);
            TaskInformation taskinformation = db.taskInformations.Find(ID);

            db.taskInformations.Remove(taskinformation);
            db.SaveChanges();
            return(RedirectToAction("TaskListInfo"));
        }
コード例 #14
0
 public ActionResult EditTaskInfo([Bind(Include = "taskId,taskName,taskStartTime,taskEndTime,taskMaxSubmitTime,taskPercent,taskRequire,taskSubmitter,courseId")] TaskInformation task)
 {
     if (ModelState.IsValid)
     {
         TaskInformationDBContext db = new TaskInformationDBContext();
         db.Entry(task).State = EntityState.Modified;
         db.SaveChanges();
     }
     return(RedirectToAction("TaskListInfo"));
 }
コード例 #15
0
        public IHttpActionResult Delete(int TaskId)
        {
            TaskInformation task = TaskDetailsGetter.GetTask(TaskId);

            if (task == null)
            {
                return(NotFound());
            }
            TaskDetailsGetter.RemoveTask(TaskId);
            return(Ok(task));
        }
コード例 #16
0
        private void RefreshTask(TaskInformation task)
        {
            switch (task.status)
            {
            case Status.Create:
            {
                RefreshWrite(task);

                if (GUILayout.Button("新加", GUILayout.Width(100), GUILayout.ExpandHeight(true)))
                {
                    task.status = Status.None;

                    this.task.Add(task); Save();

                    create = new TaskInformation()
                    {
                        status = Status.Create,
                    };
                }
            }
            break;

            case Status.Editor:
            {
                RefreshWrite(task);

                GUILayout.BeginVertical(GUILayout.Width(100));
                {
                    if (GUILayout.Button("保存"))
                    {
                        task.status = Status.None; Save();
                    }
                    if (GUILayout.Button("删除"))
                    {
                        this.task.Remove(task.name); Save();
                    }
                }
                GUILayout.EndVertical();
            }
            break;

            case Status.None:
            {
                RefreshRead(task);

                if (GUILayout.Button("修改"))
                {
                    task.status = Status.Editor;
                }
            }
            break;
            }
        }
コード例 #17
0
        public IHttpActionResult Get(int TaskId)
        {
            TaskInformation i = TaskDetailsGetter.GetTask(TaskId);

            if (i != null)
            {
                return(Ok(i));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #18
0
    public void UpdateTask(TaskInformation _task)
    {
        var AllTasks = QuestManager.Instance.TaskContainer.GetComponentsInChildren <Tasks> ();

        foreach (var taskGameObject in AllTasks)
        {
            if (_task == taskGameObject.task)
            {
                taskGameObject.DoneImageSprite.SetActive(_task.TaskCompleted);
                taskGameObject.GoButton.SetActive(!_task.TaskCompleted);
            }
        }
    }
コード例 #19
0
        public HttpResponseMessage Get(int TaskId)
        {
            TaskInformation i = TaskDetailsGetter.GetTask(TaskId);

            if (i != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, i));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Task Id : " + TaskId + " Not Found"));
            }
        }
コード例 #20
0
 public Boolean AddTaskInformation(TaskInformation tinfo)
 {
     try
     {
         _context.TaskInformations.Add(tinfo);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        protected void OnButton1Clicked(object sender, EventArgs e)
        {
            // start a new task with Task.Factory
            // this is a very common method to work on something in the background
            // use TaskInformation to observe this new task

            CancellationTokenSource cancelTokenSource = new CancellationTokenSource();

            lock (cancelTokenList)
                cancelTokenList.Add(cancelTokenSource);

            Task.Factory.StartNew(() =>
            {
                myTaskId++;
                String name        = String.Format("{0}:{1}", myThreadHeader, myTaskId);
                String description = "Example how to use a Task";
                Message(String.Format("Task {0} started", name));

                Gtk.Application.Invoke(delegate
                {
                    labelTaskCount.Text = String.Format("Running count: {0}", ++countTasks);
                });
                TaskInformation ti = TaskInformation.Create(cancelTokenSource, name, description);

                int duration  = rnd.Next() % 5000 + 5000;
                int steps     = 100;
                int onesleep  = duration / steps;
                int proceeded = 0;
                while (proceeded < duration)
                {
                    proceeded += onesleep;
                    Thread.Sleep(onesleep);
                    ti.Progress = proceeded * 100 / duration;
                    if (cancelTokenSource.IsCancellationRequested)
                    {
                        break;
                    }
                }
                Message(String.Format("Task {0} {1}", name,
                                      cancelTokenSource.IsCancellationRequested ? "cancelled" : "finished"));
                ti.Destroy();
                Gtk.Application.Invoke(delegate
                {
                    labelTaskCount.Text = String.Format("Running count: {0}", --countTasks);
                });
                lock (cancelTokenList)
                    cancelTokenList.Remove(cancelTokenSource);
            }, cancelTokenSource.Token);
        }
コード例 #22
0
        public async Task Register(TaskInformation info)
        {
            bool found = false;
            foreach (var task in BackgroundTaskRegistration.AllTasks)
            {
                if (task.Value.Name == info.name) found = true;
            }

            if (!found)
            {
                var reg =
                    await
                        RegisterBackgroundTask(info);
            }
        }
コード例 #23
0
ファイル: UnitTest1.cs プロジェクト: Manojkumarupm/Apisample
        public void GetTaskTest()
        {    //Arrange
            TaskCrud taskcrud = new TaskCrud();
            //Act
            TaskInformation task = taskcrud.GetTask(1);

            //Assert
            if (task != null)
            {
                Assert.AreEqual(1, task.TaskId);
            }
            else
            {
                Assert.IsNotNull(task);
            }
        }
コード例 #24
0
        public ActionResult CreateTaskInfo([Bind(Include = "taskName,taskStartTime,taskEndTime,taskMaxSubmitTime,taskRequire")] TaskInformation task)
        {
            DBHelper dbHelper = DBHelper.getMyHelper();

            if (ModelState.IsValid)
            {
                //1.获取Cookie,从中提取课程id
                HttpCookie cookie   = Request.Cookies["course"];
                string     courseId = null;
                if (cookie != null)
                {
                    courseId = cookie["courseid"];
                }
                if (courseId == null)
                {
                    return(RedirectToAction("CourseInfo"));
                }
                //2.赋值给task
                task.courseId = courseId;

                //3.获取cookie,提取用户id,获得用户姓名
                cookie = Request.Cookies["Account"];
                string userId = null;
                if (cookie != null)
                {
                    userId = cookie["userName"];
                }
                if (userId == null)
                {
                    return(RedirectToAction("Index", "SecurityController"));
                }
                List <User> users = dbHelper.getUsers();
                foreach (User u in users)
                {
                    if (u.userId == userId)
                    {
                        task.taskSubmitter = u.userName;
                        break;
                    }
                }
                TaskInformationDBContext db = new TaskInformationDBContext();
                db.taskInformations.Add(task);
                db.SaveChanges();
                db = null;
            }
            return(RedirectToAction("TaskListInfo"));
        }
コード例 #25
0
        public ActionResult TaskInfoDetails(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TaskInformationDBContext db     = new TaskInformationDBContext();
            int             ID              = Convert.ToInt32(id);
            TaskInformation taskinformation = db.taskInformations.Find(ID);

            if (taskinformation == null)
            {
                return(HttpNotFound());
            }

            return(View(taskinformation));
        }
コード例 #26
0
 public TaskDetailsViewModel(TaskViewModel targetTast)
 {
     TargetTask = targetTast;
     //DuplicateTaskInfo = new TaskInformation
     DuplicateTaskInfo = new TaskInformation()
     {
         Contractor           = _taskViewModel.TaskInfo.Contractor,
         TaskTypeDescription  = _taskViewModel.TaskInfo.TaskTypeDescription,
         Barcode              = _taskViewModel.TaskInfo.Barcode,
         IsMoving2012Standard = _taskViewModel.TaskInfo.IsMoving2012Standard,
         LastServicedBy       = _taskViewModel.TaskInfo.LastServicedBy,
         Location             = _taskViewModel.TaskInfo.Location,
         MaintainedStandard   = _taskViewModel.TaskInfo.MaintainedStandard,
         OPNumber             = _taskViewModel.TaskInfo.OPNumber
     };
     SaveTaskInfoCommand = new Command(async() => await SaveTaskInfoCommandAct());
 }
コード例 #27
0
        protected override void Init()
        {
            string content = UnityEngine.PlayerPrefs.GetString(KEY);

            if (string.IsNullOrEmpty(content))
            {
                task = new TaskData();
            }
            else
            {
                task = JsonUtility.FromJson <TaskData>(content);
            }

            create = new TaskInformation()
            {
                status = Status.Create,
            };
        }
コード例 #28
0
ファイル: TaskCrud.cs プロジェクト: Manojkumarupm/Apisample
        /// <summary>
        /// Add a particular task to database
        /// </summary>
        /// <param name="i">TaskInformation</param>
        /// <returns>Status of the Operation</returns>
        public TaskInformation AddTask(TaskInformation i)
        {
            try
            {
                using (CapsuleEntities PE = new CapsuleEntities())
                {
                    PE.Configuration.ProxyCreationEnabled = false;
                    PE.TaskInformations.Add(i);
                    PE.SaveChanges();

                    return(i);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #29
0
ファイル: TaskCrud.cs プロジェクト: Manojkumarupm/Apisample
        /// <summary>
        /// Add a particular task to database
        /// </summary>
        /// <param name="i">TaskInformation</param>
        /// <returns>Status of the Operation</returns>
        public string AddTask(TaskInformation i)
        {
            try
            {
                using (CapsuleEntities PE = new CapsuleEntities())
                {
                    PE.Configuration.ProxyCreationEnabled = false;
                    PE.TaskInformations.Add(i);
                    PE.SaveChanges();

                    return("Success");
                }
            }
            catch (Exception ex)
            {
                return("Failed" + ex.Message);
            }
        }
コード例 #30
0
ファイル: TaskCrud.cs プロジェクト: Manojkumarupm/Apisample
        /// <summary>
        /// Remove Task from the database
        /// </summary>
        /// <param name="TaskId">TaskId</param>
        /// <returns>Status of the Operation</returns>
        public TaskInformation RemoveTask(int TaskId)
        {
            try
            {
                using (CapsuleEntities PE = new CapsuleEntities())
                {
                    PE.Configuration.ProxyCreationEnabled = false;
                    TaskInformation I = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault();

                    PE.Entry(I).State = System.Data.Entity.EntityState.Deleted;
                    PE.SaveChanges();
                    return(I);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #31
0
        public async Task Register(TaskInformation info)
        {
            bool found = false;

            foreach (var task in BackgroundTaskRegistration.AllTasks)
            {
                if (task.Value.Name == info.name)
                {
                    found = true;
                }
            }

            if (!found)
            {
                var reg =
                    await
                    RegisterBackgroundTask(info);
            }
        }
コード例 #32
0
        public static async Task<BackgroundTaskRegistration> RegisterBackgroundTask(TaskInformation info)
        {
            if (info.background)
            {
                await BackgroundExecutionManager.RequestAccessAsync();
            }

            var builder = new BackgroundTaskBuilder();

            builder.Name = info.name;
            builder.TaskEntryPoint = info.taskEntryPoint;
            builder.SetTrigger(info.trigger);

            if (info.condition != null)
            {
                builder.AddCondition(info.condition);

                builder.CancelOnConditionLoss = true;
            }


            BackgroundTaskRegistration task = builder.Register();

            /*if (info.callback != null)
            {
                task.Completed +=
            }*/

            return task;
        }