Exemple #1
0
        private void LogEdgeNotFoundError(string msg, Edge edge)
        {
            if (s_logEdgeNotFoundError)
            {
                string       logFilePath = @"./SOM_Analytical.txt";
                Tasks.Task   task        = edge as Tasks.Task;
                StreamWriter sw          = new StreamWriter(logFilePath);
                sw.WriteLine("\r\n::::::::::::::::Message::::::::::::::::\r\n" + msg + "\r\n");
                sw.WriteLine("\r\n::::::::::::::::Call Stack::::::::::::::::\r\n");
                StackTrace st = new StackTrace(true);
                sw.WriteLine(st.ToString());
                sw.WriteLine("\r\n::::::::::::::::Requested Edge::::::::::::::::\r\n");
                sw.WriteLine("Name : " + edge.Name + "\r\nGuid : " + task.Guid + "\r\nHashCode : " + task.GetHashCode());

                sw.WriteLine("\r\n::::::::::::::::Known Edges::::::::::::::::\r\n");
                foreach (DictionaryEntry de in Edges)
                {
                    Edge       knownEdge     = (Edge)de.Key;
                    EdgeData   knownEdgeData = (EdgeData)de.Value;
                    Tasks.Task knownTask     = knownEdge as Tasks.Task;
                    if (knownTask != null)
                    {
                        sw.WriteLine("Name : " + knownTask.Name + "\r\nGuid : " + knownTask.Guid + "\r\nHashCode : " + knownTask.GetHashCode());
                    }
                    else
                    {
                        sw.WriteLine("Name : " + knownEdge.Name + "\r\nGuid : <Edge, not task, therefore no Guid>\r\nHashCode : " + knownEdge.GetHashCode());
                    }
                }
                sw.Flush();
                sw.Close();
                _Debug.WriteLine("Dumped log file to " + logFilePath);
            }
        }
Exemple #2
0
        protected override IEnumerable <ValidationResult> GetErrorsForTask(Tasks.Task task, IEnumerable <InstallParam> paramsToValidate)
        {
            foreach (InstallParam p in paramsToValidate)
            {
                WebException    error = null;
                HttpWebResponse resp  = null;
                try
                {
                    resp = this.GetResponse(p.Value);
                }
                catch (WebException ex)
                {
                    error = ex;
                }

                if (error != null)
                {
                    yield return(new ValidationResult(ValidatorState.Error, $"Unable to connect to host {p.Value}", error));

                    yield break;
                }

                if (resp.StatusCode != HttpStatusCode.OK)
                {
                    yield return(new ValidationResult(ValidatorState.Error, $"Host {p.Value} did not return 200.", null));
                }
            }
        }
Exemple #3
0
        async Tasks.Task <byte?> IByteInDevice.Read()
        {
            byte?result = null;

            Tasks.Task done;
            lock (this.peekedLock)
            {
                done = this.peeked = this.Peek().Then(p =>
                {
                    Collection.IBlock <byte> r = null;
                    if (p.NotNull() && p.Count > 0)
                    {
                        result = p[0];
                        r      = p.Count > 1 ? p.Slice(1) : null;
                    }
                    else
                    {
                        result = null;
                    }
                    return(r);
                });
            }
            await done;

            return(result);
        }
Exemple #4
0
            public async Tasks.Task <Collection.IBlock <byte> > Peek()
            {
                Tasks.Task <Collection.IBlock <byte> > task;
                bool updateCount;

                lock (this.@lock)
                {
                    if (updateCount = this.data.NotNull())
                    {
                        task = this.data;
                    }
                    else
                    {
                        this.count = null;
                        task       = this.data = this.read();
                    }
                }
                var result = await task;

                if (updateCount)
                {
                    lock (this.@lock)
                        this.count = result?.Count ?? 0;
                }
                return(result);
            }
 public TaskDetailsPage(Tasks.Task Item)
 {
     InitializeComponent();
     BindingContext = new TaskDetailsPageViewModel(Item);
     (BindingContext as TaskDetailsPageViewModel).Exit += TaskDetailsPage_Exit;
     Title = $"Задача №{Item.Id}";
 }
Exemple #6
0
        public void SetActiveTask(Tasks.Task newTask)
        {
            // first, are we active? If we aren't, there's no way
            // we ever activated a task, so there's no need to deactivate anything.
            if (IsFragmentActive == true)
            {
                // we are active, so if we have a current task, deactivate it.
                if (ActiveTask != null)
                {
                    ActiveTask.Deactivate(false);
                }

                // activate the new task
                newTask.Activate(false);

                // force the springboard to close
                if (MainActivity.IsLandscapeWide( ) == false)
                {
                    RevealSpringboard(false);
                }
            }
            else
            {
                // activate the new task
                newTask.Activate(false);
            }

            // take our active task. If we didn't activate it because we aren't
            // ready, we'll do it as soon as OnResume is called.
            ActiveTask = newTask;
        }
Exemple #7
0
 public Tasks.Task <Collection.IBlock <byte> > Read()
 {
     lock (this.peekedLock)
     {
         var result = this.peeked ?? this.RawRead();
         this.peeked = null;
         return(result);
     }
 }
Exemple #8
0
 protected override IEnumerable <ValidationResult> GetErrorsForTask(Tasks.Task task, IEnumerable <InstallParam> paramsToValidate)
 {
     foreach (InstallParam p in paramsToValidate)
     {
         if (!this.PathExists(p.Value))
         {
             yield return(new ValidationResult(ValidatorState.Error, $"Path {p.Value} does not exist.", null));
         }
     }
 }
Exemple #9
0
 public override void AssignActivity(TaskDictionary task, User u)
 {
     Tasks.Task t = new Tasks.Task(u.ID, task.ID);
     using (var DbContext = new HomeOfficeContext())
     {
         DbContext.Database.EnsureCreated();
         DbContext.Tasks.Add(t);
         DbContext.SaveChanges();
     }
 }
Exemple #10
0
 public Tasks.Task <Collection.IBlock <byte> > Read()
 {
     Tasks.Task <Collection.IBlock <byte> > result;
     lock (this.@lock)
     {
         result     = this.data;
         this.data  = null;
         this.count = 0;
     }
     return(result ?? this.read());
 }
Exemple #11
0
 public void AddTask(Tasks.Task Task)
 {
     Task.Core = Core;
     lock ( m_TaskQueue )
     {
         m_TaskQueue.Add(Task);
     }
     if (!m_BackgroundWorker.IsBusy)
     {
         m_BackgroundWorker.RunWorkerAsync();
     }
 }
Exemple #12
0
 public override void UnassignActivity(Tasks.Task t)
 {
     using (var DbContext = new HomeOfficeContext())
     {
         var result = DbContext.Tasks.SingleOrDefault(b => b.Users_ID == t.Users_ID && b.TaskDictionary_ID == t.TaskDictionary_ID);
         if (result != null)
         {
             result.Status = true;
             DbContext.SaveChanges();
         }
     }
 }
Exemple #13
0
            public int Reset()
            {
                int result;

                lock (this.@lock)
                {
                    this.data  = null;
                    result     = this.count ?? 0;
                    this.count = 0;
                }
                return(result);
            }
Exemple #14
0
 /// <summary>
 /// Creates a new instance of the <see cref="T:ValidationService"/> class.
 /// </summary>
 /// <param name="root">The root task of the directed acyclic graph.</param>
 public ValidationService(Tasks.Task root)
 {
     m_root                    = root.PreVertex;
     m_suspensions             = 0;
     m_dirty                   = true;
     m_structureChangeListener = new StructureChangeHandler(OnStructureChange);
     if (s_diagnostics)
     {
         m_suspendResumeStack = new Stack();
     }
     _knownServices.Add(this);
     Refresh();
 }
Exemple #15
0
 void m_BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     while (!Core.ShuttingDown)
     {
         Tasks.Task newTask = null;
         lock ( m_TaskQueue )
         {
             if (m_TaskQueue.Count == 0)
             {
                 return;
             }
             newTask = m_TaskQueue[0];
             m_TaskQueue.RemoveAt(0);
         }
         newTask.RunTask();
     }
 }
Exemple #16
0
        public void CreateTask(CreateTaskInput input)
        {
            //我们可以使用Logger,它在应用服务基类中定义
            Logger.Info("Creating a task for input:" + input);

            //使用给定的input的属性创建一个新的Task
            var task = new Tasks.Task {
                Description = input.Description
            };

            if (input.AssignedPersonId.HasValue)
            {
                task.AssignedPersonId = input.AssignedPersonId.Value;
            }

            //使用仓储标准Insert方法保存实体
            _taskRepository.Insert(task);
        }
Exemple #17
0
        public void AddTask(Tasks.Task Task)
        {
            Task.Core = Core;
            lock ( m_TaskQueue )
            {
                var tasksToRemove = new List <Task>();

                /*
                 * if ( Task is TaskUpdateKeywords )
                 * {
                 * Debug.Log( "Add TaskUpdateKeywords for " + ( (TaskUpdateKeywords)Task ).Doc.DocumentFilename );
                 * }*/

                // remove duplicate update keyword tasks!
                foreach (var task in m_TaskQueue)
                {
                    if ((task is TaskUpdateKeywords) &&
                        (Task is TaskUpdateKeywords))
                    {
                        var oldTask = task as TaskUpdateKeywords;
                        var newTask = Task as TaskUpdateKeywords;

                        if (oldTask.Doc == newTask.Doc)
                        {
                            //Debug.Log( "remove previous TaskUpdateKeywords as duplicate" );
                            tasksToRemove.Add(oldTask);
                        }
                    }
                }
                foreach (var taskToRemove in tasksToRemove)
                {
                    m_TaskQueue.Remove(taskToRemove);
                }

                m_TaskQueue.Add(Task);
            }
            if (!m_BackgroundWorker.IsBusy)
            {
                m_BackgroundWorker.RunWorkerAsync();
            }
        }
Exemple #18
0
        public static Tasks.Task Iterate(IEnumerable <Tasks.Task> asyncIterator, CancellationToken cancellationToken = default(CancellationToken), bool disposeEnumerator = true)
        {
            if (asyncIterator == null)
            {
                throw new ArgumentNullException("asyncIterator");
            }


            IEnumerator <Tasks.Task> enumerator = null;

            try
            {
                enumerator = asyncIterator.GetEnumerator();
                Tasks.Task task = IterateImpl(enumerator, cancellationToken);
                return((disposeEnumerator && enumerator != null) ? task.Finally(enumerator.Dispose, runSynchronously: true) : task);
            }
            catch (Exception ex)
            {
                return(TaskHelpers.FromError(ex));
            }
        }
Exemple #19
0
        internal static Tasks.Task IterateImpl(IEnumerator <Tasks.Task> enumerator, CancellationToken cancellationToken)
        {
            try
            {
                while (true)
                {
                    // short-circuit: iteration canceled
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(TaskHelpers.Canceled());
                    }

                    // short-circuit: iteration complete
                    if (!enumerator.MoveNext())
                    {
                        return(TaskHelpers.Completed());
                    }

                    // fast case: Task completed synchronously & successfully
                    Tasks.Task currentTask = enumerator.Current;
                    if (currentTask.Status == TaskStatus.RanToCompletion)
                    {
                        continue;
                    }

                    // fast case: Task completed synchronously & unsuccessfully
                    if (currentTask.IsCanceled || currentTask.IsFaulted)
                    {
                        return(currentTask);
                    }

                    // slow case: Task isn't yet complete
                    return(IterateImplIncompleteTask(enumerator, currentTask, cancellationToken));
                }
            }
            catch (Exception ex)
            {
                return(TaskHelpers.FromError(ex));
            }
        }
Exemple #20
0
 public void task(Tasks.Task task)
 {
     player.task = task;
 }
Exemple #21
0
 public Tasks.Task <Collection.IBlock <byte> > Peek()
 {
     lock (this.peekedLock)
         return(this.peeked ?? (this.peeked = this.RawRead()));
 }
Exemple #22
0
 public virtual void UnassignActivity(Tasks.Task t)
 {
 }
Exemple #23
0
        internal static bool TrySetFromTask <TResult>(this TaskCompletionSource <Task <TResult> > tcs, Tasks.Task source)
        {
            if (source.Status == TaskStatus.Canceled)
            {
                return(tcs.TrySetCanceled());
            }

            if (source.Status == TaskStatus.Faulted)
            {
                return(tcs.TrySetException(source.Exception.InnerExceptions));
            }

            if (source.Status == TaskStatus.RanToCompletion)
            {
                // Sometimes the source task is Task<Task<TResult>>, and sometimes it's Task<TResult>.
                // The latter usually happens when we're in the middle of a sync-block postback where
                // the continuation is a function which returns Task<TResult> rather than just TResult,
                // but the originating task was itself just Task<TResult>. An example of this can be
                // found in TaskExtensions.CatchImpl().
                Task <Task <TResult> > taskOfTaskOfResult = source as Task <Task <TResult> >;
                if (taskOfTaskOfResult != null)
                {
                    return(tcs.TrySetResult(taskOfTaskOfResult.Result));
                }

                Task <TResult> taskOfResult = source as Task <TResult>;
                if (taskOfResult != null)
                {
                    return(tcs.TrySetResult(taskOfResult));
                }

                return(tcs.TrySetResult(TaskHelpers.FromResult(default(TResult))));
            }

            return(false);
        }
Exemple #24
0
 public void End()
 {
     this.reader.OnRead -= this.Read;             // Stop receiving new Read events, already started once will styll arrive.
     this.end            = reader.Position;
 }
Exemple #25
0
 /// <summary>
 /// Fallback for IterateImpl when the antecedent Task isn't yet complete.
 /// </summary>
 internal static Tasks.Task IterateImplIncompleteTask(IEnumerator <Tasks.Task> enumerator, Tasks.Task currentTask, CancellationToken cancellationToken)
 {
     // There's a race condition here, the antecedent Task could complete between
     // the check in Iterate and the call to Then below. If this happens, we could
     // end up growing the stack indefinitely. But the chances of (a) even having
     // enough Tasks in the enumerator in the first place and of (b) *every* one
     // of them hitting this race condition are so extremely remote that it's not
     // worth worrying about.
     return(currentTask.Then(() => IterateImpl(enumerator, cancellationToken)));
 }
Exemple #26
0
        /// <summary>
        /// Update the completion source if the task failed (cancelled or faulted). No change to completion source if the task succeeded.
        /// </summary>
        /// <typeparam name="TResult">result type of completion source</typeparam>
        /// <param name="tcs">completion source to update</param>
        /// <param name="source">task to update from.</param>
        /// <returns>true on success</returns>
        internal static bool SetIfTaskFailed <TResult>(this TaskCompletionSource <TResult> tcs, Tasks.Task source)
        {
            switch (source.Status)
            {
            case TaskStatus.Canceled:
            case TaskStatus.Faulted:
                return(tcs.TrySetFromTask(source));
            }

            return(false);
        }
 public ITaskDialog TaskDialog(Tasks.Task task)
 {
     return(new TaskDialog(task));
 }
Exemple #28
0
        internal static bool TrySetFromTask <TResult>(this TaskCompletionSource <TResult> tcs, Tasks.Task source)
        {
            if (source.Status == TaskStatus.Canceled)
            {
                return(tcs.TrySetCanceled());
            }

            if (source.Status == TaskStatus.Faulted)
            {
                return(tcs.TrySetException(source.Exception.InnerExceptions));
            }

            if (source.Status == TaskStatus.RanToCompletion)
            {
                Task <TResult> taskOfResult = source as Task <TResult>;
                return(tcs.TrySetResult(taskOfResult == null ? default(TResult) : taskOfResult.Result));
            }

            return(false);
        }
Exemple #29
0
        public Interface(Tasks.Task task)
        {
            // if (!File.Exists("config.ini"))
            // {
            //     File.Create("config.ini").Close();
            //     Console.WriteLine("Enter origin path");
            //     Origin = Console.ReadLine();
            //     File.WriteAllText("config.ini", Origin);
            // }
            // else
            // {
            //     Origin = File.ReadAllText("config.ini");
            // }

            string    originBackup;
            string    remoteIp;
            ClientTcp clientTcp;

            switch (task)
            {
            case Tasks.Task.Original:
                Console.WriteLine("Server mode activated! Enter the path to work on please: ");
                var origin = Console.ReadLine();
                if (!Directory.Exists(origin))
                {
                    //break;
                }
                //begin server
                var s = new ServerTcp(origin);
                //start backup for both
                s.StartBackupCommand();
                break;

            case Tasks.Task.Backup:
                //begin client
                Console.WriteLine("Client mode activated! Enter the path to work on please: ");
                originBackup = Console.ReadLine();
                if (!Directory.Exists(originBackup))
                {
                    //break;
                }
                Console.WriteLine("Enter an ip to connect to (default is localhost) :");
                remoteIp  = Console.ReadLine();
                clientTcp = new ClientTcp(originBackup, remoteIp);
                clientTcp.ReceiveBackupCommand();
                break;

            case Tasks.Task.CompareFileList:
                Console.WriteLine("Server mode activated! Enter the path to work on please: ");
                originBackup = Console.ReadLine();
                if (!Directory.Exists(originBackup))
                {
                    //break;
                }
                var server = new ServerTcp(originBackup);
                server.GenerateFileList();
                break;

            case Tasks.Task.FileList:
                //begin client
                Console.WriteLine("Client mode activated! Enter the path to work on please: ");
                originBackup = Console.ReadLine();
                if (!Directory.Exists(originBackup))
                {
                    //break;
                }
                Console.WriteLine("Enter an ip to connect to (default is localhost) :");
                remoteIp  = Console.ReadLine();
                clientTcp = new ClientTcp(originBackup, remoteIp);
                clientTcp.GenerateFileList();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(task), task, null);
            }
        }
Exemple #30
0
 public TextMark(ITextReader reader)
 {
     this.reader    = reader;
     this.start     = reader.Position;
     reader.OnRead += this.Read;
 }