コード例 #1
0
		/// <summary>
		/// Execute the Task
		/// </summary>
		public void StartTask(AppTask t)
		{
			Log.Debug(this._LogTag, "StartTask");
			var id = t.JobID;
			t.task
				.ContinueWith (x => {
					Log.Debug(this._LogTag, "After service execute");
					var b = this._binder as TaskBinder;
					if (x.Exception != null)
					{
						t.Error(x.Exception);
					}
					else if (x.IsCanceled)
					{
						t.Error(new System.Threading.Tasks.TaskCanceledException());
					}
					else
					{
						t.Complete(x.Result);
					}

					var jobstop = new Intent (TaskBinder.JobEnded); 
					jobstop.PutExtra("id", t.JobID);
					jobstop.PutExtra("ok", x.Exception == null && x.IsCanceled == false);
					SendOrderedBroadcast (jobstop, null);

					// dispose of the task
					t.task.Dispose();
			});
		}
コード例 #2
0
		public TaskConnection(TaskBinder binder, AppTask task)
		{
			if (binder != null) {
				this._Binder = binder;
			}

			this.Task = task;
		}
コード例 #3
0
        private void ResultClicked(AppTask task, string resFile, int resIndex)
        {
            string fullPath = Path.Combine(GetCacheFolder(), resFile);

            ResultMediaViewerController imageViewer = Storyboard.InstantiateViewController("MediaViewerController") as ResultMediaViewerController;

            imageViewer.FilePath     = fullPath;
            imageViewer.Task         = task;
            imageViewer.ResultIndex  = resIndex;
            imageViewer.DeleteResult = DeleteFile;
            NavigationController.PushViewController(imageViewer, true);
        }
コード例 #4
0
        public async Task <AppTask> AddTaskAsync(AppTask task, CancellationToken token)
        {
            if (task == null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            _taskRepository.AddTask(task);
            await _unitOfWork.SaveAsync(token);

            return(task);
        }
コード例 #5
0
        internal void EnsureTaskHandleCreated(TaskRunEntity run)
        {
            if (run.Task != null)
            {
                return;
            }

            // Re-create the task from the run entity
            AppTask task = AppTaskBuilder.BuildTaskFromRun(run);

            run.Task = task;
        }
コード例 #6
0
        public async Task <ActionResult> UpdateAsync([Range(1, int.MaxValue)] int id, [FromBody] TaskDto taskDto, CancellationToken token)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            AppTask task = _mapper.MapToEntity(taskDto);
            await _taskService.UpdateTaskAsync(id, task, token);

            return(NoContent());
        }
コード例 #7
0
        public async Task <IActionResult> PutEmployee([FromBody] AppTask appTask)
        {
            if (null == appTask)
            {
                return(BadRequest());
            }

            _context.Task.Update(appTask);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTask", new { id = appTask.AppTaskId }, appTask));
        }
コード例 #8
0
        public async Task <IActionResult> PostAppTask([FromBody] AppTask appTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Tasks.Add(appTask);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAppTask", new { id = appTask.ID }, appTask));
        }
コード例 #9
0
        public async Task <ActionResult <Task> > PostEmployee([FromBody] AppTask appTask)
        {
            if (appTask == null)
            {
                return(BadRequest());
            }

            _context.Task.Add(appTask);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTask", new { id = appTask.AppTaskId }, appTask));
        }
コード例 #10
0
        public void AppTask_CRUD_Test()
        {
            foreach (CultureInfo culture in AllowableCulture)
            {
                ChangeCulture(culture);

                using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                {
                    AppTaskService appTaskService = new AppTaskService(new Query()
                    {
                        Lang = culture.TwoLetterISOLanguageName
                    }, dbTestDB, ContactID);

                    int count = 0;
                    if (count == 1)
                    {
                        // just so we don't get a warning during compile [The variable 'count' is assigned but its value is never used]
                    }

                    AppTask appTask = GetFilledRandomAppTask("");

                    // -------------------------------
                    // -------------------------------
                    // CRUD testing
                    // -------------------------------
                    // -------------------------------

                    count = appTaskService.GetAppTaskList().Count();

                    Assert.AreEqual(count, (from c in dbTestDB.AppTasks select c).Count());

                    appTaskService.Add(appTask);
                    if (appTask.HasErrors)
                    {
                        Assert.AreEqual("", appTask.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(true, appTaskService.GetAppTaskList().Where(c => c == appTask).Any());
                    appTaskService.Update(appTask);
                    if (appTask.HasErrors)
                    {
                        Assert.AreEqual("", appTask.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(count + 1, appTaskService.GetAppTaskList().Count());
                    appTaskService.Delete(appTask);
                    if (appTask.HasErrors)
                    {
                        Assert.AreEqual("", appTask.ValidationResults.FirstOrDefault().ErrorMessage);
                    }
                    Assert.AreEqual(count, appTaskService.GetAppTaskList().Count());
                }
            }
        }
コード例 #11
0
        public void InvokeTest()
        {
            var invoker = new InterceptorsInvoker();
            var mf      = new MockRepository(MockBehavior.Strict);


            var i1 = mf.Create <IInterceptor>();
            var i2 = mf.Create <IInterceptor>();
            var i3 = mf.Create <IInterceptor>();

            var ctx      = new RibEfTestContext();
            var appTask1 = new AppTask {
                Id = 1
            };
            var appTask2 = new AppTask {
                Id = 2
            };

            ctx.Set <AppTask>().Attach(appTask1);
            ctx.Set <AppTask>().Attach(appTask2);

            var e1 = ctx.Entry(appTask1);
            var e2 = ctx.Entry(appTask2);

            var callOrder = 0;

            i3.Setup(x => x.IsApplicable(e1)).Returns(false).Verifiable();
            i3.Setup(x => x.IsApplicable(e2)).Returns(false).Verifiable();

            i1.Setup(x => x.IsApplicable(e1)).Returns(true).Verifiable();
            i2.Setup(x => x.IsApplicable(e1)).Returns(true).Verifiable();

            i1.Setup(x => x.Order(e1)).Returns(1).Verifiable();
            i2.Setup(x => x.Order(e1)).Returns(2).Verifiable();

            i1.Setup(x => x.BeforeSave(e1)).Callback(() => Assert.AreEqual(0, callOrder++)).Verifiable();
            i2.Setup(x => x.BeforeSave(e1)).Callback(() => Assert.AreEqual(1, callOrder++)).Verifiable();

            i1.Setup(x => x.IsApplicable(e2)).Returns(true).Verifiable();
            i2.Setup(x => x.IsApplicable(e2)).Returns(true).Verifiable();

            i1.Setup(x => x.Order(e2)).Returns(2).Verifiable();
            i2.Setup(x => x.Order(e2)).Returns(1).Verifiable();

            i1.Setup(x => x.BeforeSave(e2)).Callback(() => Assert.AreEqual(3, callOrder++)).Verifiable();
            i2.Setup(x => x.BeforeSave(e2)).Callback(() => Assert.AreEqual(2, callOrder++)).Verifiable();

            invoker.InvokeBeforeSave(new[] { i1.Object, i2.Object, i3.Object }, new DbEntityEntry[] { e1, e2 });

            Assert.AreEqual(4, callOrder);
            mf.VerifyAll();
        }
コード例 #12
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.CameraActivity);

            string jsonData = Intent.GetStringExtra("JSON") ?? "";

            learningTask = JsonConvert.DeserializeObject <AppTask>(jsonData, new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Auto
            });
            activityId = Intent.GetIntExtra("ACTID", -1);

            if (bundle == null)
            {
                if (learningTask.TaskType.IdName == "TAKE_VIDEO")
                {
                    RequestedOrientation = ScreenOrientation.Landscape;
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                    {
                        FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera2VideoFragment.NewInstance()).Commit();
                    }
                    else
                    {
                        FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera1VideoFragment.NewInstance()).Commit();
                    }
                }
                else
                {
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                    {
                        FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera2Fragment.NewInstance()).Commit();
                    }
                    else
                    {
                        FragmentManager.BeginTransaction().Replace(Resource.Id.container, Camera1Fragment.NewInstance()).Commit();
                    }
                }
            }

            if (!AndroidUtils.IsGooglePlayServicesInstalled(this) || googleApiClient != null)
            {
                return;
            }

            googleApiClient = new GoogleApiClient.Builder(this)
                              .AddConnectionCallbacks(this)
                              .AddOnConnectionFailedListener(this)
                              .AddApi(LocationServices.API)
                              .Build();

            locRequest = new LocationRequest();
        }
コード例 #13
0
ファイル: Selection.cs プロジェクト: sahilagnihotri/Chess
        void selectTaskOnSetup_TaskSetup(AppTask task, EventArgs e)
        {
            Debug.Assert(task is ITaskDefinesARun, "Shouldn't have been able to register this handler unless the task implemented ITaskDefinesARun.");

            // remove the handler
            task.TaskSetup -= new AppTaskEventHandler(selectTaskOnSetup_TaskSetup);

            // Ok then, select the run
            if (task == _selectTaskOnSetup)
            {
                Update(task, ((ITaskDefinesARun)task).Run);
            }
        }
コード例 #14
0
 public TaskDto MapToDto(AppTask task)
 {
     return(new TaskDto
     {
         Id = task.Id,
         Name = task.Name,
         Priority = task.Priority,
         Status = task.Status,
         TaskListId = task.TaskListId,
         Date = task.Date,
         Description = task.Description
     });
 }
コード例 #15
0
        private void AddJob(AppTask task)
		{
			if (_Jobs == null) {
				_Jobs = new ConcurrentDictionary<string, JobResult> ();
				var intentFilter = new IntentFilter (TaskBinder.JobEnded){Priority = (int)IntentFilterPriority.HighPriority};
				Xamarin.Forms.Forms.Context.RegisterReceiver (this, intentFilter);
			}				

			var temp = new JobResult { IsRunning = true };

			_Jobs.AddOrUpdate(task.JobID,  temp,  (z, x) => {
				return temp;
			});
		}
コード例 #16
0
        public void Put(int id, [FromBody] AppTaskViewModel model)
        {
            var userId = _caller.Claims.Single(c => c.Type == "id");

            var newAppTask = new AppTask
            {
                Title       = model.Title,
                UserId      = Guid.Parse(userId.Value),
                Description = model.Description,
                IsCompleted = model.IsCompleted
            };

            _appTaskRepository.Update(id, newAppTask);
        }
コード例 #17
0
        public void RunTask(AppTask task)
        {
            AddJob(task);

            // fire the task
            Console.WriteLine("long task");

            Android.App.Application.Context.StartService(new Intent(Android.App.Application.Context, typeof(TaskService)));
            var TaskServiceConnection = new TaskConnection(null, task);

            Intent TaskServiceIntent = new Intent(Android.App.Application.Context, typeof(TaskService));

            Android.App.Application.Context.BindService(TaskServiceIntent, TaskServiceConnection, Bind.AutoCreate);
        }
コード例 #18
0
		private void AddJob(DeviceTask.AppTask task)
		{
			if (_Jobs == null) {
				_Jobs = new ConcurrentDictionary<string, JobResult> ();
			}				

			var temp = new JobResult { IsRunning = true };

			_Jobs.AddOrUpdate(task.JobID,  temp,  (z, x) => {
				return temp;
			});

			this._Task = task;
		}
コード例 #19
0
        public IHttpActionResult GetAppTaskWithID([FromUri] int AppTaskID, [FromUri] string lang = "en", [FromUri] string extra = "")
        {
            using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
            {
                AppTaskService appTaskService = new AppTaskService(new Query()
                {
                    Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en)
                }, db, ContactID);

                appTaskService.Query = appTaskService.FillQuery(typeof(AppTask), lang, 0, 1, "", "", extra);

                if (appTaskService.Query.Extra == "A")
                {
                    AppTaskExtraA appTaskExtraA = new AppTaskExtraA();
                    appTaskExtraA = appTaskService.GetAppTaskExtraAWithAppTaskID(AppTaskID);

                    if (appTaskExtraA == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(appTaskExtraA));
                }
                else if (appTaskService.Query.Extra == "B")
                {
                    AppTaskExtraB appTaskExtraB = new AppTaskExtraB();
                    appTaskExtraB = appTaskService.GetAppTaskExtraBWithAppTaskID(AppTaskID);

                    if (appTaskExtraB == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(appTaskExtraB));
                }
                else
                {
                    AppTask appTask = new AppTask();
                    appTask = appTaskService.GetAppTaskWithAppTaskID(AppTaskID);

                    if (appTask == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(appTask));
                }
            }
        }
コード例 #20
0
        public async Task <IActionResult> PostAppTask([FromBody] AppTask appTask)
        {
            var user = _context.AppUser.SingleOrDefault(u => u.UserName == User.Identity.Name);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            appTask.AppUserId = user.Id;
            _context.AppTask.Add(appTask);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAppTask", new { id = appTask.AppTaskId }));
        }
コード例 #21
0
		public void RunTask(AppTask task)
		{
			AddJob (task);

			// fire the task
			Console.WriteLine ("long task");

			Android.App.Application.Context.StartService (new Intent (Android.App.Application.Context, typeof(TaskService)));
			var TaskServiceConnection = new TaskConnection (null, task);

			Intent TaskServiceIntent = new Intent (Android.App.Application.Context, typeof(TaskService));

			Android.App.Application.Context.BindService (TaskServiceIntent, TaskServiceConnection, Bind.AutoCreate);

		}
コード例 #22
0
 private void RunScriptsForTask(Project project, AppTask task, CommandOptions options)
 {
     if (project.Scripts?.Count > 0 && project.Scripts.TryGetValue(task, out ICollection <object> beforeScripts))
     {
         foreach (var script in beforeScripts)
         {
             if (script is string simpleScript)
             {
                 _platformService.RunAnonymousScript(simpleScript, options);
             }
             else if (script is AppScript appScript)
             {
                 _platformService.RunAnonymousScript(appScript.Run, options, appScript.Path);
             }
         }
     }
 }
コード例 #23
0
        private bool TryToSave(AppTask appTask)
        {
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                appTask.ValidationResults = new List <ValidationResult>()
                {
                    new ValidationResult(ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : ""))
                }.AsEnumerable();
                return(false);
            }

            return(true);
        }
コード例 #24
0
        public bool Update(AppTask appTask)
        {
            appTask.ValidationResults = Validate(new ValidationContext(appTask), ActionDBTypeEnum.Update);
            if (appTask.ValidationResults.Count() > 0)
            {
                return(false);
            }

            db.AppTasks.Update(appTask);

            if (!TryToSave(appTask))
            {
                return(false);
            }

            return(true);
        }
コード例 #25
0
        public async System.Threading.Tasks.Task DeleteAsync(int id, CancellationToken token)
        {
            if (id <= 0)
            {
                throw new ArgumentException("Id must be >= 0", nameof(id));
            }

            AppTask task = await _taskRepository.FindByIdAsync(id, token);

            if (task == null)
            {
                throw new ArgumentException("not fount", nameof(id));
            }

            _taskRepository.Delete(task);
            await _unitOfWork.SaveAsync(token);
        }
コード例 #26
0
        public async Task <ActionResult> Create([Bind(Include = "Name,Note,MaxStep,ParentId,AcceptId,Level")] AppTask appTask, string[] TagTaskId)
        {
            var helper = new DBHelper();

            appTask.Id = helper.GetAppCategoryId(db);
            if (TagTaskId != null)
            {
                foreach (var item in TagTaskId)
                {
                    var tag = await db.TagTasks.FindAsync(item);

                    if (tag == null)
                    {
                        tag = await db.TagTasks.SingleOrDefaultAsync(x => x.Name == item);

                        if (tag == null)
                        {
                            db.TagTasks.Add(new TagTask
                            {
                                Id   = helper.GetTagTaskId(db),
                                Name = item,
                            });
                            await db.SaveAsync();
                        }
                    }
                    if (tag != null)
                    {
                        db.TaskTags.Add(new TaskTag
                        {
                            AppTask = appTask,
                            TagTask = tag,
                        });
                    }
                }
            }
            appTask.Created = DateTime.UtcNow;
            appTask.UserId  = User.Identity.GetUserId();
            db.AppTasks.Add(appTask);
            var str = await db.SaveMessageAsync();

            if (str != null)
            {
                return(Json(str.GetError()));
            }
            return(Json(LanguageDB.AppTaskAdded, "/admin/apptasks/edit/" + appTask.Id));
        }
コード例 #27
0
        public async Task <ActionResult> Delete(string id)
        {
            if (id == null)
            {
                return(Json(LanguageDB.NotFound.GetError()));
            }
            AppTask appTask = await db.AppTasks.FindAsync(id);

            db.AppTasks.Remove(appTask);
            var str = await db.SaveMessageAsync();

            if (str != null)
            {
                return(Json(str.GetError()));
            }
            return(Json(Js.SuccessRedirect(LanguageDB.AppTaskRemoved, "/admin/apptasks")));
        }
コード例 #28
0
        private void AddJob(DeviceTask.AppTask task)
        {
            if (_Jobs == null)
            {
                _Jobs = new ConcurrentDictionary <string, JobResult> ();
            }

            var temp = new JobResult {
                IsRunning = true
            };

            _Jobs.AddOrUpdate(task.JobID, temp, (z, x) => {
                return(temp);
            });

            this._Task = task;
        }
コード例 #29
0
        public static string GetCommand(this AppTask task)
        {
            switch (task)
            {
            case AppTask.Test:
                return("test");

            case AppTask.Start:
                return("start");

            case AppTask.Install:
                return("install");

            default:
                throw new ArgumentException("Task must be valid AppTask value", nameof(task));
            }
        }
コード例 #30
0
        // GET: Admin/AppTasks/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(View());
            }
            AppTask appTask = await db.AppTasks.FindAsync(id);

            if (appTask == null)
            {
                return(View());
            }
            ViewBag.AcceptId = new SelectList(db.Users, "Id", "UserName", appTask.AcceptId);
            ViewBag.ParentId = new SelectList(db.AppTasks, "Id", "Name", appTask.ParentId);

            ViewBag.TagTaskId = new MultiSelectList(db.TagTasks, "Id", "Name", appTask.TaskTags.Select(x => x.TagTaskId));
            return(PartialView(appTask));
        }
コード例 #31
0
        public async Task <ActionResult <TaskDto> > GetByIdAsync(int id, CancellationToken token)
        {
            if (id <= 0)
            {
                return(BadRequest());
            }

            AppTask task = await _taskService.GetByIdAsync(id, token);

            if (task == null)
            {
                return(NotFound());
            }

            TaskDto taskDto = _mapper.MapToDto(task);

            return(Ok(taskDto));
        }
コード例 #32
0
        public void Update(int taskId, AppTask updatedTask)
        {
            var oldTask = _dbContext.AppTasks.Where(p => p.Id == taskId).FirstOrDefault();

            oldTask.Title       = updatedTask.Title;
            oldTask.Description = updatedTask.Description;
            oldTask.UpdatedAt   = DateTime.Now;
            oldTask.CreatedAt   = oldTask.CreatedAt;
            oldTask.IsCompleted = updatedTask.IsCompleted;

            if (updatedTask.IsCompleted)
            {
                oldTask.CompletedAt = DateTime.Now;
            }

            _dbContext.Entry(oldTask).State = EntityState.Modified;
            _dbContext.SaveChanges();
        }
コード例 #33
0
        public void AppTask_Controller_GetAppTaskWithID_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    AppTaskController appTaskController = new AppTaskController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(appTaskController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, appTaskController.DatabaseType);

                    AppTask appTaskFirst = new AppTask();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        AppTaskService appTaskService = new AppTaskService(new Query(), db, ContactID);
                        appTaskFirst = (from c in db.AppTasks select c).FirstOrDefault();
                    }

                    // ok with AppTask info
                    IHttpActionResult jsonRet = appTaskController.GetAppTaskWithID(appTaskFirst.AppTaskID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <AppTask> Ret = jsonRet as OkNegotiatedContentResult <AppTask>;
                    AppTask appTaskRet = Ret.Content;
                    Assert.AreEqual(appTaskFirst.AppTaskID, appTaskRet.AppTaskID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Not Found
                    IHttpActionResult jsonRet2 = appTaskController.GetAppTaskWithID(0);
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <AppTask> appTaskRet2 = jsonRet2 as OkNegotiatedContentResult <AppTask>;
                    Assert.IsNull(appTaskRet2);

                    NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult;
                    Assert.IsNotNull(notFoundRequest);
                }
            }
        }
コード例 #34
0
        public void DeleteFile(int taskId, int fileIndex)
        {
            try
            {
                AppTask thisTask  = GetTaskWithId(taskId);
                int     taskIndex = GetIndexWithId(taskId);

                List <string> paths      = JsonConvert.DeserializeObject <List <string> >(thisTask.CompletionData.JsonData);
                string        deletePath = paths[fileIndex];

                FileInfo info = new FileInfo(deletePath);

                if (!info.Exists)
                {
                    throw new Exception("File doesn't exist");
                }

                Dictionary <string, string> properties = new Dictionary <string, string>
                {
                    { "TaskId", taskId.ToString() }
                };
                Analytics.TrackEvent("TaskAdapter_DeleteFile", properties);

                info.Delete();
                paths.RemoveAt(fileIndex);
                Items[taskIndex].CompletionData.JsonData = JsonConvert.SerializeObject(paths);

                if (!paths.Any())
                {
                    Items[taskIndex].IsCompleted = false;
                    CheckForChildren(taskIndex);
                }

                info.Refresh();
                Console.WriteLine("Deletion success = " + !info.Exists);

                NotifyItemChanged(taskIndex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #35
0
        public void CheckForChildren(int position)
        {
            AppTask parent      = Items[position];
            bool    hasChildren = parent.ChildTasks != null && parent.ChildTasks.Any();

            if (hasChildren && !parent.IsCompleted)
            {
                if (hiddenChildren.ContainsKey(parent.Id))
                {
                    return;
                }

                // Parent task is no longer complete, hide children
                hiddenChildren[parent.Id] = new List <AppTask>();
                foreach (LearningTask child in parent.ChildTasks)
                {
                    AppTask childProgress = GetTaskWithId(child.Id);
                    if (childProgress == null)
                    {
                        continue;
                    }

                    hiddenChildren[parent.Id].Add(childProgress);
                    Items.Remove(childProgress);
                }
            }
            else if (hasChildren && Items[position].IsCompleted && hiddenChildren.ContainsKey(Items[position].Id))
            {
                // Show the child tasks if they're hidden
                var children = hiddenChildren[Items[position].Id];
                int nextPos  = position + 1;
                foreach (AppTask child in children)
                {
                    if (!Items.Exists(t => t?.Id == child.Id))
                    {
                        Items.Insert(nextPos++, child);
                    }
                }
                hiddenChildren.Remove(Items[position].Id);
            }

            context.RunOnUiThread(NotifyDataSetChanged);
        }
コード例 #36
0
        public void GetRingTonePicker(AppTask task = null)
        {
            Core core = Core.GetCore();
            AppConfig config = core.GetConfig();
            string notificationSound;

            if (task != null && task.RingTone != "")
            {
                notificationSound = task.RingTone;
            }
            else
            {
                notificationSound = m_selectedRingTone;
            }

            Android.Net.Uri rURI = Android.Net.Uri.Parse(notificationSound);

            Intent intent = new Intent(RingtoneManager.ActionRingtonePicker);
            intent.PutExtra(RingtoneManager.ExtraRingtoneTitle, "Notification Ringtone");
            intent.PutExtra(RingtoneManager.ExtraRingtoneShowSilent, true);
            //intent.PutExtra(RingtoneManager.ExtraRingtoneShowDefault, true);
            intent.PutExtra(RingtoneManager.ExtraRingtoneType, "TYPE_ALL");
            //Need condition to see if default Noti. actually exists, else dont send anything
            //look below. for possible solution.
            //http://stackoverflow.com/questions/7645951/how-to-check-if-resource-pointed-by-uri-is-available

            //check existence, then set to EXTRA_RINGTONE_DEFAULT_URI if not found
            //try
            //{
            //    openInputStream
            //}
            //catch (System.Exception ex)
            //{
            //    rURI = Android.Net.Uri.Parse(RingtoneManager.ExtraRingtoneDefaultUri);
            //}

            intent.PutExtra(RingtoneManager.ExtraRingtoneExistingUri, rURI);
            intent.PutExtra("ScheduleApp.Droid.ID", (task != null) ? (int)task.TaskID : (int)-1);

            ((Activity)Forms.Context).StartActivityForResult(intent, 1);
        }
コード例 #37
0
        public void FiniteLengthTask(AppTask task)
        {
			task.IsRunning = true;
            this._FiniteTaskID = UIApplication.SharedApplication.BeginBackgroundTask(FiniteTaskEnd);
            try
            {
				task.task
					.ContinueWith( t => {

						Console.WriteLine("ContinueWith:=" + TimeRemaining);
						if (t.Exception != null)
						{
							Console.WriteLine("ContinueWith/Exception:=" + TimeRemaining);
							UpdateJob (true);
							this._Task.Error(t.Exception.Flatten());
						}
						else if (t.IsCanceled || t.IsFaulted)
						{
							UpdateJob (true);
							this._Task.Error(new TaskCanceledException());
						}
						else
						{
							Console.WriteLine("ContinueWith/ok:=" + TimeRemaining);
							UpdateJob (false);
							this._Task.Complete(t.Result);
						}
						task.task.Dispose();
						task.IsRunning = false;
						UIApplication.SharedApplication.EndBackgroundTask(this._FiniteTaskID);
						this._FiniteTaskID = -1;
					});
            }
			catch (OperationCanceledException cancel)
            {
				UpdateJob (true);
				this._Task.Error (cancel);
            }
			catch (Exception ex) {
				UpdateJob (true);
				this._Task.Error (ex);
			}
        }
コード例 #38
0
		public void RunTask (AppTask task)
		{			
			AddJob (task);
			FiniteLengthTask (task);
		}