Exemple #1
0
        public Action(ITask task, TimeSpan taskInterval, List<Notifier> notifiers)
        {
            this.task = task;
            this.taskInterval = taskInterval;

            this.notifiers = notifiers;
        }
        /// <summary>
        /// Override the default filter mechanism so that we show only
        /// completed tasks in this group.
        /// </summary>
        /// <param name="model">
        /// A <see cref="TreeModel"/>
        /// </param>
        /// <param name="iter">
        /// A <see cref="TreeIter"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        protected override bool FilterTasks(ITask task)
        {
            // Don't show any task here if showCompletedTasks is false
            if (!showCompletedTasks)
                return false;

            if (task == null || task.State != TaskState.Completed)
                return false;

            // Make sure that the task fits into the specified range depending
            // on what the user has set the range slider to be.
            if (task.CompletionDate < this.timeRangeStart)
                return false;

            if (task.CompletionDate == DateTime.MinValue)
                return true; // Just in case

            // Don't show tasks in the completed group that were completed
            // today.  Tasks completed today should still appear under their
            // original group until tomorrow.
            DateTime today = DateTime.Now;

            if (today.Year == task.CompletionDate.Year
                    && today.DayOfYear == task.CompletionDate.DayOfYear)
                return false;

            return true;
        }
        public void AddTask_startsProcessing([Values(1, 10, 100)] int repetitions, [Values(0, 1, 10)] int insertDelayMs, [Values(10)] int baseWaitTime)
        {
            Assume.That(repetitions, Is.GreaterThan(0));
            Assume.That(insertDelayMs, Is.AtLeast(0));
            Assume.That(baseWaitTime, Is.AtLeast(0));

            // create the tasks
            ITask[] tasks = new ITask[repetitions];
            for (int t=0; t<repetitions; ++t)
            {
                tasks[t] = new TestTask(true);
                Assert.That(tasks[t].TaskCompletionWaitHandle.WaitOne(0), Is.False);
            }

            // enqueue the tasks
            for (int t = 0; t < repetitions; ++t)
            {
                Processor.AddTask(tasks[t]);
                Thread.Sleep(insertDelayMs);
            }

            // wait for completion
            int maximumWaitTimeMs = insertDelayMs * repetitions + baseWaitTime;
            for (int t = 0; t < repetitions; ++t)
            {
                Assert.That(tasks[t].TaskCompletionWaitHandle.WaitOne(maximumWaitTimeMs), Is.True);
            }
        }
Exemple #4
0
        public void Add(ITask task)
        {
            if (task == null)
                throw new ArgumentNullException();

            Add(new EnumerableTask(task));
        }
        protected TaskViewModel(ILogger logger, ITask task, string name, string description, object icon)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (task == null)
                throw new ArgumentNullException("task");
            if (name == null)
                throw new ArgumentNullException("name");
            if (description == null)
                throw new ArgumentNullException("description");
            if (icon == null)
                throw new ArgumentNullException("icon");

            this.logger = logger;
            this.task = task;
            this.name = name;
            this.description = description;
            this.icon = icon;

            task.AddStoppedCallback(() => OnStopped());
            task.AddCancelledCallback(() => OnCancelled());
            task.AddCompletedCallback(() => OnCompleted());
            task.AddErrorCallback(error => OnError(error));
            task.AddFailedCallback(() => OnFailed());
            task.AddPausedCallback(() => OnPaused());
            task.AddProgressCallback(progress => OnProgressChanged(progress));
            task.AddItemChangedCallback(item => OnItemChanged(item));
            task.AddResumedCallback(() => OnResumed());
            task.AddStartedCallback(() => OnStarted());
        }
 public TaskCompleteTimerTickEventArgs(int tick, ITask task)
 {
     if (task == null)
         throw new ArgumentNullException ("task");
     Task = task;
     CountdownTick = tick;
 }
 /// <summary>
 /// public constructor
 /// </summary>
 public TaskLoggingHelperExtension(ITask taskInstance, ResourceManager primaryResources, ResourceManager sharedResources, string helpKeywordPrefix) :
     base(taskInstance)
 {
     this.TaskResources = primaryResources;
     this.TaskSharedResources = sharedResources;
     this.HelpKeywordPrefix = helpKeywordPrefix;
 }
 public TaskCompleteTimerStoppedEventArgs(ITask task, bool canceled)
 {
     if (task == null)
         throw new ArgumentNullException ("task");
     Task = task;
     Canceled = canceled;
 }
 private void FillTask(ITask task)
 {
     questionSpelling.Content = task.Question.Spelling;
     questionTranscription.Content = task.Question.Transcription;
     answers.ItemsSource = task.Answers;
     answers.ItemContainerStyleSelector = BuildStyleSelector(false);
 }
        public static ITask Else(this ITask task, Func<bool> predicate, ITask elseTask)
        {
            Contract.Requires(task != null);
            Contract.Requires(predicate != null);

            return new TaskBranched(task, elseTask, predicate);
        }
Exemple #11
0
 internal static string GetV1Path(ITask v1Task)
 {
     var ppszFileName = string.Empty;
     try { ((IPersistFile)v1Task).GetCurFile(out ppszFileName); }
     catch (Exception ex) { throw ex; }
     return ppszFileName;
 }
 public void Process(ResultItems resultItems, ITask task)
 {
     foreach (DictionaryEntry entry in resultItems.GetAll())
     {
         System.Console.WriteLine(entry.Key + ":\t" + entry.Value);
     }
 }
Exemple #13
0
 public bool ContainsTask(ITask task)
 {
     if(task.Category is RtmCategory)
         return ((task.Category as RtmCategory).ID.CompareTo(ID) == 0);
     else
         return false;
 }
 public PeriodicalTaskRunner(ITask task, int frequency, DateTime lastRun)
 {
     Task = task;
     _frequency = frequency;
     _lastRun = lastRun;
     _nextRun = _lastRun.AddSeconds(_frequency);
 }
Exemple #15
0
 public bool ContainsTask(ITask task)
 {
     if(task.Category is DummyCategory)
         return (task.Category.Name.CompareTo(name) == 0);
     else
         return false;
 }
 	public void Setup()
 	{
 		_mocks = new MockRepository();
     _task = _mocks.DynamicMock<ITask>();
     _engine = _mocks.DynamicMock<IBuildEngine>();
     _logger = new MsBuildLogger(new TaskLoggingHelper(_task));
 	}
 public void Process(object o, ITask task)
 {
     string path = BasePath + "/" + task.Identify + "/";
     try
     {
         string filename;
         var key = o as IHasKey;
         if (key != null)
         {
             filename = path + key.Key + ".json";
         }
         else
         {
             //check
             filename = path + Encrypt.Md5Encrypt(o.ToString()) + ".json";
         }
         FileInfo file = GetFile(filename);
         using (StreamWriter printWriter = new StreamWriter(file.OpenWrite(), Encoding.UTF8))
         {
             printWriter.WriteLine(JsonConvert.SerializeObject(o));
         }
     }
     catch (Exception e)
     {
         _logger.Warn("write file error", e);
         throw;
     }
 }
Exemple #18
0
 public void Execute(ITask task)
 {
     foreach (Hashtable data in task.Datas)
     {
         this.Post(task, data);
     }
 }
		public	BotStepReport(
			ITask TravelTask,
			ITask MineTask)
		{
			this.TravelTask = TravelTask;
			this.MineTask = MineTask;
		}
Exemple #20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="task"></param>
        /// <param name="pr"></param>
        public override void OnProcess(ITask task, IParseResult pr)
        {
            if (pr.IsSuccess)
            {
                string opera = task.Opera.Name;
                if (StringHelper.Equal(opera, XD1100OperaNames.ReadReal))
                {
                    ProcessReadReal(task, pr);
                }
                else if( StringHelper.Equal ( opera, XD1100OperaNames.ReadStatus ))
                {
                    ProcessReadStatus(task, pr);
                }
                else if (
                    (StringHelper.Equal(opera, XD1100OperaNames.WriteOT)) ||
                    (StringHelper.Equal(opera, XD1100OperaNames.WriteOTMode)) ||
                    (StringHelper.Equal(opera, XD1100OperaNames.OPERA_READ)) ||
                    (StringHelper.Equal(opera, XD1100OperaNames.OPERA_WRITE))
                    )
                {

                }
                else
                {
                    string s = string.Format("not process xd1100 opera '{0}'", opera);
                    throw new NotImplementedException(s);
                }
            }
        }
Exemple #21
0
        public bool ContainsTask(ITask task)
        {
            if(task.Category is SqliteCategory)
                return ((task.Category as SqliteCategory).ID == id);

            return false;
        }
 public void QueueTask(ITask task)
 {
     Task newTask = new Task(delegate () {
         task.Execute();
     });
     newTask.RunSynchronously(this);
 }
Exemple #23
0
        public void LogTaskState(ITaskExecuteClient client, ITask task, TaskMessage message)
        {
            //��������Լ�¼��־

            if (this.Storage != null)
                this.Storage.SaveTaskChangedState(task, message);
        }
Exemple #24
0
        public TaskContext Execute(ITask task, object associatedData = null)
        {
            var context = new TaskContext(task, associatedData);

            _dispatcher.BeginInvoke(() =>
            {
                _all.Add(task);
                _contexts.Add(context);
                UpdateBusy();
            });


            task.Execute(context).ContinueWith((p, d) =>
            {
                _dispatcher.BeginInvoke(() =>
                {
                    _all.Remove(task);
                    _contexts.Remove(context);
                    UpdateBusy();
                });
            }).Failed((p, d) =>
            {

            });

            return context;
        }
 public TaskRepository()
 {
     if (_repos == null)
     {
         _repos = new RcMobileService();
     }
 }
        public TaskDefinitionAssertions AssertExecutableIs(ITask<object> task)
        {
            AssertDefined();
            Assert.That(TaskWithBehaviors.Task, Is.EqualTo(task));

            return this;
        }
        /// <summary>
        /// This is the same as CompareTo above but should use completion date
        /// instead of due date.  This is used to sort items in the
        /// CompletedTaskGroup.
        /// </summary>
        /// <returns>
        /// whether the task has lower, equal or higher sort order.
        /// </returns>
        public override int Compare(ITask x, ITask y)
        {
            bool isSameDate = true;
            if (x.CompletionDate.Year != y.CompletionDate.Year
                || x.CompletionDate.DayOfYear != y.CompletionDate.DayOfYear)
                isSameDate = false;

            if (!isSameDate) {
                if (x.CompletionDate == DateTime.MinValue) {
                    // No completion date set for some reason.  Since we already
                    // tested to see if the dates were the same above, we know
                    // that the passed-in task has a CompletionDate set, so the
                    // passed-in task should be "higher" in the sort.
                    return 1;
                } else if (y.CompletionDate == DateTime.MinValue) {
                    // "this" task has a completion date and should evaluate
                    // higher than the passed-in task which doesn't have a
                    // completion date.
                    return -1;
                }

                return x.CompletionDate.CompareTo (y.CompletionDate);
            }

            // The completion dates are the same, so no sort based on other
            // things.
            return CompareByPriorityAndName (x, y);
        }
        public IResponse Execute(ITask task)
        {
            Debug.WriteLine(string.Format("{0}: Received task", DateTime.Now));

            bool successful = true;
            Exception exception = null;
            IResult result = null;
            try
            {
                ITaskExecutor taskExecutor = taskExecuterFactory.CreateExecuterFor(task);
                Debug.WriteLine(string.Format("{0}: Executing {1}", DateTime.Now, task.GetType().Name));
                result = taskExecutor.Execute(task);
            }
            catch(Exception e)
            {
                Debug.WriteLine(string.Format("{0}: Error in {1}, {2} ({3})", DateTime.Now, task.GetType().Name, e.GetType().Name, e.Message));
                successful = false;
                exception = e;
                logger.LogException(LogLevel.Debug, "Exception when executing task: " + task.GetType().Name, e);
            }

            var resultType = task.GetType().GetInterfaces().Single(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof (ITask<>)).GetGenericArguments()[0];

            return CreateResponse(resultType, result, successful, exception);
        }
Exemple #29
0
        public void Send(ITask task)
        {
            if (!this.running)
                this.Start();

            this.queue.Enqueue(task);
        }
        private static TaskMainDTO TaskMainToTaskMainDTO(ITask param)
        {
            TaskMainDTO target = new TaskMainDTO();

            target.TaskID = param.TaskID;
            target.TargetVersion = param.TargetVersion;
            target.Summary = param.Summary;
            target.SubtaskType = param.SubtaskType;
            target.Status = param.Status;
            target.Project = param.Project;
            target.Product = param.Product;
            target.Priority = param.Priority;
            target.Source = param.Source;
            target.Estimation = param.Estimation;
            target.Description = param.Description;
            target.CreatedDate = param.CreatedDate;
            target.CreatedBy = param.CreatedBy;
            target.Comments = param.Comments;
            target.TokenID = param.TokenID;
            target.LinkToTracker = param.LinkToTracker;

            if (param.TaskParent != null)
            {
                target.TaskParent = TaskMainToTaskMainDTO(param.TaskParent);
            }

            if (param.Assigned != null)
            {
                target.Assigned = UserToUserDTO(param.Assigned);
            }

            return target;
        }
 private void MoveNext()
 {
     bool flag;
     int num = this.int_0;
     try
     {
         if (num != 0)
         {
             this.bool_0 = this.string_0.EndsWith("_event");
             this.bool_1 = false;
             this.list_0 = this.taskManager_0.list_0.ToList<ITask>();
             this.enumerator_0 = this.list_0.GetEnumerator();
         }
         try
         {
             if (num != 0)
             {
                 goto Label_0077;
             }
             TaskAwaiter<bool> awaiter = this.taskAwaiter_0;
             this.taskAwaiter_0 = new TaskAwaiter<bool>();
             num = -1;
             this.int_0 = -1;
             goto Label_00D4;
         Label_0070:
             this.itask_0 = null;
         Label_0077:
             if (!this.enumerator_0.MoveNext())
             {
                 goto Label_01A8;
             }
             this.itask_0 = this.enumerator_0.Current;
             awaiter = this.itask_0.Logic(this.string_0, this.object_0).GetAwaiter();
             if (awaiter.IsCompleted)
             {
                 goto Label_00D4;
             }
             goto Label_0172;
         Label_00C3:
             if (!this.bool_0)
             {
                 goto Label_00E7;
             }
             this.bool_1 = true;
             goto Label_0070;
         Label_00D4:
             bool introduced7 = awaiter.GetResult();
             awaiter = new TaskAwaiter<bool>();
             if (!introduced7)
             {
                 goto Label_0070;
             }
             goto Label_00C3;
         Label_00E7:
             if (!GlobalSettings.Instance.DebugLastTask)
             {
                 goto Label_016C;
             }
             StringBuilder builder = new StringBuilder();
             List<ITask>.Enumerator enumerator = this.list_0.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     ITask current = enumerator.Current;
                     if (current == this.itask_0)
                     {
                         goto Label_014C;
                     }
                     builder.AppendFormat("[{0}] -> ", current.Name);
                 }
             }
             finally
             {
                 if (num < 0)
                 {
                     enumerator.Dispose();
                 }
             }
         Label_014C:
             TaskManager.ilog_0.InfoFormat("[Execute] {1} {0}.", this.itask_0.Name, builder.ToString());
         Label_016C:
             flag = true;
             goto Label_01D6;
         Label_0172:
             num = 0;
             this.int_0 = 0;
             this.taskAwaiter_0 = awaiter;
             this.asyncTaskMethodBuilder_0.AwaitUnsafeOnCompleted<TaskAwaiter<bool>, TaskManager.Struct35>(ref awaiter, ref this);
             return;
         }
         finally
         {
             if (num < 0)
             {
                 this.enumerator_0.Dispose();
             }
         }
     Label_01A8:
         this.enumerator_0 = new List<ITask>.Enumerator();
         flag = this.bool_1;
     }
     catch (Exception exception)
     {
         this.int_0 = -2;
         this.asyncTaskMethodBuilder_0.SetException(exception);
         return;
     }
 Label_01D6:
     this.int_0 = -2;
     this.asyncTaskMethodBuilder_0.SetResult(flag);
 }
Exemple #32
0
 public TasksController(ITask db)
 {
     this.db = db;
 }
Exemple #33
0
        /// <summary>
        /// 异步获取AB包
        /// </summary>
        /// <param name="path"></param>
        private IProgress GetAssetBundleAsync(string path, System.Action <AssetBundle> callBack)
        {
            path = Path2Key(path);
            path = path.Replace('\\', '/');
            if (!m_ABDic.TryGetValue(path, out AssetBundle ab))
            {
                string abName = path;
                //string abName = string.IsNullOrEmpty(path) ? "" : "/" + path;

                AssetBundleCreateRequest mainRequest = AssetBundle.LoadFromFileAsync(m_ABPath + "/" + abName + m_Variant);
                m_LoadingAB.Add(abName, mainRequest);

                // 添加任务列表
                List <AssetBundleCreateRequest> requests = new List <AssetBundleCreateRequest>
                {
                    mainRequest
                };

                //string[] dependencies = m_Mainfest.GetAllDependencies(path + ".ab");
                string[] dependencies = m_DependenceInfo.GetAllDependencies(path + m_Variant);
                foreach (var name in dependencies)
                {
                    if (m_ABDic.ContainsKey(Name2Key(name)))
                    {
                        continue;
                    }
                    var request = AssetBundle.LoadFromFileAsync(m_ABPath + "/" + name);
                    requests.Add(request);
                    m_LoadingAB.Add(Name2Key(name), request);
                }

                ITask[] tasks = new ITask[requests.Count];

                for (int i = 0; i < tasks.Length; i++)
                {
                    int index = i;
                    tasks[index] = new SingleTask(() =>
                    {
                        return(requests[index].isDone);
                    });
                    tasks[index].Then(new SingleTask(() =>
                    {
                        string key = Name2Key(requests[index].assetBundle.name);
                        m_ABDic.Add(key, requests[index].assetBundle);
                        m_LoadingAB.Remove(key);
                        return(true);
                    }));
                }

                AllTask abTask = new AllTask(tasks);
                abTask.Then(new SingleTask(() =>
                {
                    callBack.Invoke(mainRequest.assetBundle);
                    return(true);
                }));
                TaskManager.Instance.StartTask(abTask);

                return(new ResProgress(requests.ToArray()));
            }
            else
            {
                callBack(ab);
                return(new DefaultProgress());
            }
        }
Exemple #34
0
 /// <summary>
 /// Adds a task and updates description.
 /// </summary>
 /// <param name="task">Given task to add.</param>
 public void AddTask(ITask task)
 {
     task.SetPackage(this);
     activeTasks.Add(task);
     manager.UpdateDescription();
 }
Exemple #35
0
 /// <summary>
 /// Moves task from ProgressManager before given task
 /// </summary>
 /// <param name="type">Given type of task to move.</param>
 /// <param name="previousTask">Task point where given task will be moved</param>
 public void MoveTaskFromManagerBeforeTask(TaskType type, ITask previousTask)
 {
     manager.MoveToPackageBeforeTask(this, type, previousTask);
 }
        public async System.Threading.Tasks.Task RunAsync(ITask currentTask, IServiceProvider scopeServiceProvider, CancellationToken cancellationToken)
        {
            //var URL = "http://hapi.fhir.org/baseDstu3";

            /*
             *
             *
             * var obs= new Observation();
             * obs.Status = ObservationStatus.Preliminary;
             * obs.Code = new CodeableConcept("http://example.org","my-example-code");
             *
             * var result = client.Create<Observation>(obs);
             */



            //ServiceReference1.Service1Client proxy = new ServiceReference1.Service1Client();
            //ServiceReference1.Student newStudent =

            //   new ServiceReference1.Student()

            //   {

            //       StudentId = 0,

            //       FirstName = "Mark",

            //       LastName = "Dallas",

            //       RegisterNo = "278589243579432",

            //       Department = "DEPT"

            //   };


            // await proxy.AddStudentsAsync(newStudent);
            //hapi fhir starts here
            //var client = new FhirClient("http://vonk.fire.ly");
            //client.PreferredFormat = ResourceFormat.Json;
            //Debug.WriteLine("LINE WRITE");
            //var q = new SearchParams().LimitTo(10);
            //Bundle result = client.Search<Claim>();

            //FhirJsonSerializer sr = new FhirJsonSerializer();



            //while (result != null)
            //{
            //    foreach (var e in result.Entry)
            //    {
            //        Claim p = (Claim)e.Resource;
            //        var bundlexml = sr.SerializeToString(p);

            //        Debug.WriteLine(bundlexml);
            //    }

            //    result = client.Continue(result, PageDirection.Next);
            //}

            //currentTask.Interval = currentTask.Interval.Add(TimeSpan.FromSeconds(20));
            //await System.Threading.Tasks.Task.CompletedTask;

            //ends here
        }
Exemple #37
0
 public void DeleteTask(ITask task)
 {
 }
 internal bool method_0(ITask itask_1)
 {
     return (itask_1.Name == this.itask_0.Name);
 }
Exemple #39
0
 public void AddWorkflow(ITask task)
 {
     _task.Add(task);
 }
 internal bool method_0(ITask itask_0)
 {
     return (itask_0.Name == this.string_0);
 }
Exemple #41
0
 public bool IsPredecessorOf(ITask task) => _successors.Contains(task);
Exemple #42
0
 public void RemoveWorkflow(ITask task)
 {
     _task.Remove(task);
 }
 public void AddNode(ITaskParent parent, ITask child)
 {
     parent.AddChild(child);
     child.ParentTree = this;
     child.Owner      = _owner;
 }
Exemple #44
0
 void Auto()
 {
     while (true)
     {
         ITask task = TaskQueue.GetTask();
         if (task == null)
         {
             Thread.Sleep(1000);
             continue;
         }
         if (task.handle_info.type == ITask.HALDLE_TYPE.ALL_WITHOUT)
         {
             foreach (KeyValuePair <string, Character> character in characters)
             {
                 if (!task.handle_info.without_id.Contains(character.Value.character_id))
                 {
                     character.Value.AddTask(task);
                 }
             }
         }
         else if (task.handle_info.type == ITask.HALDLE_TYPE.ALL)
         {
             foreach (KeyValuePair <string, Character> character in characters)
             {
                 character.Value.AddTask(task);
             }
         }
         else if (task.handle_info.type == ITask.HALDLE_TYPE.RANDOM)
         {
             KeyValuePair <string, Character>[] character_list = characters.ToArray();
             character_list[random.Next(0, character_list.Length)].Value.AddTask(task);
         }
         else if (task.handle_info.type == ITask.HALDLE_TYPE.RANDOM_MUL)
         {
             KeyValuePair <string, Character>[] character_list = characters.ToArray();
             if (character_list.Length > 0)
             {
                 for (int i = 0; i < task.handle_info.count; i++)
                 {
                     character_list[random.Next(0, character_list.Length)].Value.AddTask(task);
                 }
             }
         }
         else if (task.handle_info.type == ITask.HALDLE_TYPE.RANDOM_WITHOUT)
         {
             List <KeyValuePair <string, Character> > trash          = new List <KeyValuePair <string, Character> >();
             List <KeyValuePair <string, Character> > character_list = characters.ToList();
             for (int i = 0; i < character_list.Count; i++)
             {
                 if (task.handle_info.without_id.Contains(character_list[i].Value.character_id))
                 {
                     trash.Add(character_list[i]);
                 }
             }
             foreach (KeyValuePair <string, Character> i in trash)
             {
                 character_list.Remove(i);
             }
             if (character_list.Count > 0)
             {
                 character_list[random.Next(0, character_list.Count)].Value.AddTask(task);
             }
         }
         else if (task.handle_info.type == ITask.HALDLE_TYPE.RANDOM_MUL_WITHOUT)
         {
             List <KeyValuePair <string, Character> > trash          = new List <KeyValuePair <string, Character> >();
             List <KeyValuePair <string, Character> > character_list = characters.ToList();
             for (int i = 0; i < character_list.Count; i++)
             {
                 if (task.handle_info.without_id.Contains(character_list[i].Value.character_id))
                 {
                     trash.Add(character_list[i]);
                 }
             }
             foreach (KeyValuePair <string, Character> i in trash)
             {
                 character_list.Remove(i);
             }
             if (character_list.Count > 0)
             {
                 for (int i = 0; i < task.handle_info.count; i++)
                 {
                     character_list[random.Next(0, character_list.Count)].Value.AddTask(task);
                 }
             }
         }
         else if (task.handle_info.type == ITask.HALDLE_TYPE.TARGET)
         {
             characters[task.handle_info.id].AddTask(task);
         }
     }
 }
Exemple #45
0
 public TaskLogger(ITask task)
 {
     this.logger = new TaskLoggingHelper(task);
 }
Exemple #46
0
 public void CompletePredecessor(ITask task)
 {
     lock (_lockPredecessors)
         _predecessors.Remove(task);
 }
Exemple #47
0
        private async Task TaskSync()
        {
            // add new local tasks in ToodleDo
            int count      = this.Metadata.AddedTasks.Count;
            var addedTasks = new List <ITask>(count);

            foreach (var addedTaskId in this.Metadata.AddedTasks.ToList())
            {
                var task = this.Workbook.Tasks.FirstOrDefault(t => t.Id == addedTaskId);
                if (task != null)
                {
                    addedTasks.Add(task);
                }
                this.Metadata.AddedTasks.Remove(addedTaskId);
            }

            foreach (var task in addedTasks)
            {
                this.OnSynchronizationProgressChanged(string.Format(StringResources.SyncProgress_AddingTaskFormat, task.Title));

                string taskId = await this.service.AddTask(new ToodleDoTask(task));

                if (!string.IsNullOrEmpty(taskId))
                {
                    this.PrepareTaskUpdate(task);

                    task.SyncId = taskId;
                    this.Changes.WebAdd++;
                }
            }

            // remove deleted local tasks from ToodleDo
            if (this.Metadata.DeletedTasks.Count > 0)
            {
                var message = StringResources.SyncProgress_DeletingTaskFormat.Replace(" {0}...", string.Empty);
                this.OnSynchronizationProgressChanged(message);

                var tasks = this.Metadata.DeletedTasks
                            .Where(d => !string.IsNullOrEmpty(d.SyncId))
                            .Select(deletedEntry => deletedEntry.SyncId)
                            .ToList();

                if (tasks.Count > 0)
                {
                    await this.service.DeleteTasks(tasks);

                    this.Changes.WebDelete += tasks.Count;
                    this.Metadata.DeletedTasks.Clear();
                }
            }

            // if TaskEditTimestamp newer than the last sync
            // it means we have edited task in ToodleDo since the last sync
            if (this.account.TaskEditTimestamp > this.taskEditTimestamp)
            {
                this.OnSynchronizationProgressChanged(StringResources.SyncProgress_GettingTasks);

                // there are probably changed in ToodleDo we must do locally... start by fetching tasks
                // ask the server to give us all the task that have changed since the last sync
                var toodleTasks = await this.service.GetTasks(false, this.taskEditTimestamp);

                // does the server have tasks we don't have ?
                this.EnsureWorkbookHasTasks(toodleTasks, true);

                // does tasks exist in both place, resolve conflicts and update
                await this.UpdateWorkbookTasks(toodleTasks);
            }

            // is TaskDeleteTimestamp newer than the last sync
            if (this.account.TaskDeleteTimestamp > this.taskDeleteTimestamp)
            {
                this.OnSynchronizationProgressChanged(StringResources.SyncProgress_UpdatingTasks);

                var deletedTasks = await this.service.GetDeletedTasks(this.taskDeleteTimestamp);

                foreach (string syncId in deletedTasks)
                {
                    var task = this.Workbook.Tasks.FirstOrDefault(t => t.SyncId == syncId);
                    if (task != null)
                    {
                        this.DeleteTask(task);
                        this.Changes.LocalDelete++;
                    }
                }
            }

            // do we need to edit tasks
            foreach (var kvp in this.Metadata.EditedTasks.ToList())
            {
                ITask task = this.Workbook.Tasks.FirstOrDefault(t => t.Id == kvp.Key);

                if (task != null)
                {
                    TaskProperties changes = kvp.Value;

                    this.OnSynchronizationProgressChanged(string.Format(StringResources.SyncProgress_UpdatingTaskFormat, task.Title));

                    var result = await this.service.UpdateTask(task.SyncId, new ToodleDoTask(task), changes);

                    if (result)
                    {
                        this.Changes.WebEdit++;
                        this.Metadata.EditedTasks.Remove(kvp.Key);
                    }
                }
            }

            this.RemoveDefaultFolderIfNeeded();
        }
Exemple #48
0
 public void AddSubTask(ITask task)
 {
     SubTasks.Add(new TaskViewModel(task.Title, task.DueDate));
 }
Exemple #49
0
 private void AddTask(ITask task)
 {
     Tasks.Add(new TaskViewModel(task, WindowMessenger));
     _taskList.Add(task);
     SaveToXml();
 }
 /// <summary>
 ///  Cleans up a task that is finished.
 /// </summary>
 public void CleanupTask(ITask task)
 {
 }
Exemple #51
0
 private static void AddTask(ITask handler)
 {
     list.Add(handler);
 }
Exemple #52
0
 public LikeController(ILike ilike, IShare ishare, IBady ibady, ILog ilog, IUserSetting iusersetting, ISetting isetting, IUser iuser, IMoney imoney, ITask itask)
 {
     this.ilike        = ilike;
     this.ishare       = ishare;
     this.imoney       = imoney;
     this.ibady        = ibady;
     this.ilog         = ilog;
     this.iuser        = iuser;
     this.iusersetting = iusersetting;
     this.isetting     = isetting;
     this.itask        = itask;
 }
 public static ITask <T> FinallyInUI <T>(this ITask <T> task, Func <bool, Exception, T, T> continuation)
 {
     return(task.Finally(continuation, TaskAffinity.UI));
 }
 public TaskInfo(ITask task, double weight)
     : this()
 {
     this.Task   = task;
     this.Weight = weight;
 }
 public static ITask <TRet> ThenInUI <T, TRet>(this ITask <T> task, Func <bool, T, TRet> continuation, bool always = false)
 {
     return(task.Then(continuation, TaskAffinity.UI, always));
 }
 public static void Forget(this ITask task)
 {
     task.Task.Forget();
 }
 public static ITask <T> Then <T>(this ITask task, Func <Task <T> > continuation, TaskAffinity affinity = TaskAffinity.Concurrent, bool always = false)
 {
     return(task.Then(continuation(), affinity, always));
 }
 public static ITask <T> FinallyInUI <T>(this ITask <T> task, Func <T> continuation)
 {
     return(task.Finally((s, e, r) => continuation(), TaskAffinity.UI));
 }
Exemple #59
0
 public void AddTask(ITask task)
 {
     tasks.Add(task);
 }
 public static ITask ThenInUI <T>(this ITask <T> task, Action <bool, T> continuation, bool always = false)
 {
     return(task.Then(continuation, TaskAffinity.UI, always));
 }