private void OnTaskProgress(string progressText) { TaskProgress?.Invoke(this, new TaskProgressEventArgs() { ProgressText = progressText }); }
public async Task <CrawlResults> Crawl( CancellationToken token, IProgress <TaskProgress> progress = null) { _linkTracker.Clear(); _seedUris.Select(x => new Link(x, "")).ForEach(FoundLink); while (_linkTracker.TryNextUnvisited(out StandardizedUri unvisited)) { Debug.WriteLine($"Parsing {unvisited.Standardized.AbsoluteUri}"); if (token.IsCancellationRequested) { throw new TaskCanceledException(); } var currentProgress = new TaskProgress( _linkTracker.Count(u => u.Status != SpiderPageStatus.Unvisited), _linkTracker.Count(), unvisited.Standardized.ToString()); progress?.Report(currentProgress); await Visit(unvisited); } TaskProgress completionProgress = new TaskProgress(_linkTracker.Count(), _linkTracker.Count(), "Complete"); progress?.Report(completionProgress); return(_linkTracker.ToCrawlResults()); }
private void lZBDeCompressorToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "LZB File (*.LZB)|*.LZB|OUT File (*.OUT)|*.OUT|Other Files|*.*"; openFileDialog.FilterIndex = 0; if (openFileDialog.ShowDialog() == DialogResult.OK) { string extension = Path.GetExtension(openFileDialog.FileName).ToUpper(); if (extension == ".LZB") { LZBFile lzbFile = new LZBFile(openFileDialog.FileName); TaskProgress progress = new TaskProgress(); progress.TaskDone += ProgressOnTaskDone; Enabled = false; lzbFile.Decompress(); Enabled = true; } else if (extension == ".OUT") { LZBFile lzbFile = new LZBFile(); lzbFile.DecompressedFile = new BaseFile(openFileDialog.FileName); lzbFile.HeaderFile = new BaseFile(Path.GetDirectoryName(openFileDialog.FileName) + "\\" + Path.GetFileNameWithoutExtension(openFileDialog.FileName) + ".HEADER"); lzbFile.FilePath = Path.GetDirectoryName(openFileDialog.FileName) + "\\" + Path.GetFileNameWithoutExtension(openFileDialog.FileName); TaskProgress progress = new TaskProgress(); progress.TaskDone += ProgressOnTaskDone; Enabled = false; lzbFile.Compress(); Enabled = true; } else { LZBFile lzbFile = new LZBFile(); SelectModeWindow selectModeWindow = new SelectModeWindow(); if (selectModeWindow.ShowDialog() == DialogResult.OK) { string headerPath = openFileDialog.FileName + ".HEADER"; using (BinaryWriter writer = new BinaryWriter(new FileStream(headerPath, FileMode.Create))) { writer.Write(LZSSHeader.Empty(selectModeWindow.Mode).GetBytes()); } string outputPath = openFileDialog.FileName + ".OUT"; File.Copy(openFileDialog.FileName, outputPath); lzbFile.HeaderFile = new BaseFile(headerPath); lzbFile.DecompressedFile = new BaseFile(outputPath); lzbFile.FilePath = openFileDialog.FileName + ".LZB"; TaskProgress progress = new TaskProgress(); progress.TaskDone += ProgressOnTaskDone; Enabled = false; lzbFile.Compress(); Enabled = true; } } } }
public RawConverter() { // initialize the log list; LogList = new List <string>(); // initialize the predefined charge state set for DDA data; // charge 2+ and 3+ are the default ones; DDADataChargeStates = new HashSet <int>(); DDADataChargeStates.Add(2); DDADataChargeStates.Add(3); // initialize the temporary file folder; UsingTempFiles = false; TempFileFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\temp_msd"; Directory.CreateDirectory(TempFileFolder); // initialize the terminating code; terminateCode = 1; // 1: not finished yet; 0: finished successfully; -1: finished unsuccessfully. isCentroided = true; // initialze the decimal places; MzDecimalPlace = 4; IntensityDecimalPlace = 1; ExtractProgress = new TaskProgress(); CurrentFileLabel = "File 0 / 0"; showPeakChargeStates = true; showPeakResolution = true; exportChargeState = false; }
public TaskDTO PatchTask(int id, JsonPatchDocument <TaskDTO> taskPatchDocument) { var task = Database.Tasks.Get(id); if (task == null) { throw new ValidationException("Task not found", ""); } // Map var taskDTO = taskFactory.CreateTask(task); // Applying patch document to dto taskPatchDocument.ApplyTo(taskDTO); // Convertion patched dto to entity Task resTask = taskFactory.CreateTask(taskDTO); task.Progress = TaskProgress.GetTaskProgress(resTask); Database.Tasks.Update(resTask); Database.Save(); return(taskDTO); }
public TaskManager( Player player ) { this.player = player; taskProgress = Deserialize(player.Client.Character.TaskStats); }
public static TaskProgress RunBackground(Action <TaskProgress> work) { var prog = new TaskProgress(); ThreadPool.QueueUserWorkItem(state => { try { work(prog); } #if UNITY_EDITOR catch (ThreadAbortException e) { // 此处吃掉异常,因为线程经常在UnityEditor内被杀掉 } #endif catch (Exception e) { if (GLog.IsLogErrorEnabled) { GLog.LogException(e); } prog.Error = e.Message; } finally { prog.Done = true; } }); return(prog); }
List <string> GetTaskStatus() { List <TaskItem> taskItemList = TaskManager._instance.TaskItemList; List <string> talk = new List <string>(); foreach (TaskItem ti in taskItemList) { if (ti._TaskType == TaskType.Main) { this.taskId = ti._Task._Id; this.progress = ti._TaskProgress; } } if (taskId == 0) { talk[0] = "欢迎你,新手!"; } else { switch (this.progress) { //case TaskProgress.NoStart: break; case TaskProgress.Accept: talk[0] = "你不去做任务,看我干什么!"; break; case TaskProgress.Complete: talk[0] = "干什么呢,快领取奖励!"; break; case TaskProgress.Reward: talk = GetTaskTalk(this.taskId); break; } } return(talk); }
private void FireProgress(TaskProgress progress) { if (this.Progress != null) { this.Progress(this, new TaskProgressEventArgs(progress)); } }
public async Task TakeScreenshotsAsync(CancellationToken?token = null, IProgress <TaskProgress> progress = null) { CreateEmptyDir(); var results = new ScreenshotResults(_creationTimestamp); using (var ss = new Screenshotter(_project)) { int i = 0; foreach (var uri in PageUris) { if (token?.IsCancellationRequested == true) { throw new TaskCanceledException("The screenshotting task was canceled."); } var currentProgress = new TaskProgress(++i, PageUris.Count, uri.AbsoluteUri); progress?.Report(currentProgress); var result = new DeviceScreenshots(uri); await ScreenshotPageAsAllDevices(ss, uri, result); results.Screenshots.Add(result); } } string sessionLabel = Path.GetFileName(_screenshotDir); Store.SaveScreenshotManifest(sessionLabel, results); var completedProgress = new TaskProgress(PageUris.Count, PageUris.Count, "Completed"); progress?.Report(completedProgress); }
//设置当前NPC任务显示状态 当前只有可接 可完成 两种状态 public void SetTaskState(TaskProgress taskProgress) { string taskstatesprite; switch (taskProgress) { case TaskProgress.NoAccept: taskstatesprite = "tanhao-jin"; break; case TaskProgress.Complete: taskstatesprite = "wenhao-jin"; break; case TaskProgress.Accept: case TaskProgress.CantAccept: case TaskProgress.Reward: taskstatesprite = ""; break; default: taskstatesprite = ""; break; } //if (statesprite == null) //{ // statesprite = GameObject.Instantiate(CharacterManager.instance.stateobj).GetComponent<UISprite>(); // statesprite.name = name + "_State"; // statesprite.transform.parent = CharacterManager.instance.UIControl; //} //stateActive = !string.IsNullOrEmpty(taskstatesprite); //statesprite.gameObject.SetActive(stateActive); //statesprite.spriteName = taskstatesprite; //statesprite.MakePixelPerfect(); if (taskProgress == TaskProgress.NoAccept) { transform.Find("toudjstb").gameObject.SetActive(true); transform.Find("toudwctb").gameObject.SetActive(false); Vector3 tempV = transform.position; tempV.y += 1f; transform.Find("toudjstb").position = tempV; } else if (taskProgress == TaskProgress.Complete) { transform.Find("toudwctb").gameObject.SetActive(true); transform.Find("toudjstb").gameObject.SetActive(false); Vector3 tempV = transform.position; tempV.y += 1f; transform.Find("toudwctb").position = tempV; } else { transform.Find("toudjstb").gameObject.SetActive(false); transform.Find("toudwctb").gameObject.SetActive(false); } SetNpcStateEffectRotation(); }
private void setProgress(TaskProgress progress) { this.progressBarLoading.InvokeIfRequired(() => { this.progressBarLoading.Style = progress.ProgressBarStyle(); this.progressBarLoading.Value = progress.Percentage; }); }
/// <remarks>OnDone is called from ThreadPool thread, NOT the main thread.</remarks> //public static TaskProgress DownloadLargeFile(string uri, Stream dst, Action<TaskProgress> OnDone) //{ // // TODO: 断点续传 // var prog = new TaskProgress(); // UnityFramework.HttpRequest req = new UnityFramework.HttpRequest(uri); // req.DestStream = dst; // req.StartRequest(); // prog.OnCancel = () => req.StopRequest(); // ThreadPool.QueueUserWorkItem(state => //{ // int unreachStartTime = Environment.TickCount; // ulong lastLen = 0; // bool timedout = false; // while (!req.IsDone) // { // prog.Total = (int)req.Total; // prog.Length = (int)req.Length; // if (GLog.IsLogInfoEnabled) GLog.LogInfo(req.Length + "\n" + req.Total + "\n" + req.IsDone); // if (req.Length > lastLen) // { // lastLen = req.Length; // unreachStartTime = Environment.TickCount; // } // else // { // int deltatime = Environment.TickCount - unreachStartTime; // if (deltatime > 15000) // { // timedout = true; // break; // } // } // } // if (timedout) // { // req.StopRequest(); // prog.Error = "timedout"; // prog.Done = true; // } // else // { // prog.Error = req.Error; // prog.Done = true; // } // if (OnDone != null) // { // OnDone(prog); // } //}); // return prog; //} /// <remarks>OnDone is called from ThreadPool thread, NOT the main thread.</remarks> public static TaskProgress DownloadLargeFile(string uri, System.IO.Stream dst, bool rangeEnabled, Action <TaskProgress> OnDone) { // TODO: 断点续传 var prog = new TaskProgress(); UnityFramework.HttpRequest req = new UnityFramework.HttpRequest(uri); req.DestStream = dst; req.RangeEnabled = rangeEnabled; req.StartRequest(); prog.OnCancel = () => req.StopRequest(); System.Threading.ThreadPool.QueueUserWorkItem(state => { int unreachStartTime = Environment.TickCount; ulong lastLen = 0; bool timedout = false; while (!req.IsDone) { prog.Total = (int)req.Total; prog.Length = (int)req.Length; //LogInfo(req.Length); //LogInfo(req.Total); //LogInfo(req.IsDone); if (req.Length > lastLen) { lastLen = req.Length; unreachStartTime = Environment.TickCount; } else { int deltatime = Environment.TickCount - unreachStartTime; if (deltatime > 15000) { timedout = true; break; } } } if (timedout) { req.StopRequest(); prog.Error = "timedout"; prog.Done = true; } else { prog.Error = req.Error; prog.Done = true; } if (OnDone != null) { OnDone(prog); } }); //#endif return(prog); }
private void UpdateProgressForTasks(TaskProgress progress) { foreach (var task in TaskManager.instance.activeTasks) { // Debug.Log("Update progress for task"); Debug.Log(task.description); task.updateProgress(progress); } }
internal void Update(OperationTask task, TaskProgress progress, OperationEvent sourceEvent, OperationEvent destinationEvent) { operations[task.OperationID] = new OperationInfo { Progress = progress, LastSourceEvent = sourceEvent, LastDestinationEvent = destinationEvent, }; }
public void Reset() { if (status == TaskStatus.Cancelled || status == TaskStatus.Completed || status == TaskStatus.Failed) { status = TaskStatus.Ready; progress = default(TaskProgress); error = default(TaskError); } }
public override void updateProgress(TaskProgress progress) { if (progress.Type == TaskProgress.TaskType.Knockable && numDestroyed != numGoal) { numDestroyed++; description = "Knock over " + numDestroyed + "/" + numGoal + " items"; //Debug.Log("progress: " + description); } }
private bool onTaskProgressRecieved(TaskNetworkServiceEvents.DailyTaskProgressRecieved evt) { serverTaskProgress = evt.DailyTaskProgress; for (int i = 0; i < evt.DailyTaskProgress.Count; i++) { TaskProgress taskProgress = evt.DailyTaskProgress[i]; taskService.SetTaskProgress(taskProgress.taskId, taskProgress.counter, taskProgress.claimed); } return(false); }
public void Update(TaskProgress progress) { // Only when progress changed, flows might be updated by more than one message if (progress != flow.Task.Progress) { flow.Update(progress); cancelSource.Cancel(); } }
/// <summary> /// Progress_s the progress changed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> void progress_ProgressChanged(object sender, double e) { e = Math.Min(e, 100); CurrentProgress = e; TaskProgress?.Invoke(this, new GenericEventArgs <double> { Argument = e }); }
private void OnProgress(TaskProgress progressMessage) { Task.Run(() => { lock (_db) { var progressEvents = _db.GetCollection <TaskProgress>(); progressEvents.Insert(progressMessage); } }); }
/// <summary> /// Progress update /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mp_onProgress(object sender, HDCallBackEventArgs e) { this.Dispatcher.BeginInvoke(delegate() { if (e != null) { TaskProgress tp = e.Result as TaskProgress; this.UpdateProgress(tp.percentage, tp.TaskDescription); } }); }
private void UpdateCache(Guid taskId, TaskProgress progress) { if (progress is null) { throw new ArgumentNullException(nameof(progress)); } _cache.Set(taskId.ToString(), progress, new CacheItemPolicy { SlidingExpiration = TimeSpan.FromHours(1) }); }
public void AddProgressDetail(TaskProgress progress) { var viewModel = new TaskProgressDetailViewModel(progress); Action action = () => { LimitTotalSize(); viewModels.Add(viewModel); }; Dispatcher.Invoke(action, DispatcherPriority.DataBind); }
internal static void Update(string operationID, TaskProgress progress) { if (pending.TryGetValue(operationID, out OperationMonitor flow)) { if (progress.IsFinal()) { pending.Remove(operationID); } flow.Update(progress); } }
private void OnProgressChanged(TaskProgress progress) { try { ProgressCount = progress.Count; ProgressMaximum = progress.Maximum; } catch (Exception ex) { logger.Error(" OnProgressChanged", ex); } }
void ChangeTaskList(TaskProgress taskProgress, TaskItem taskItem) { RemoveOtherProgressType(taskItem); if ((TaskClass)taskItem.tasknode.Type == TaskClass.Main) { TaskList[taskProgress].Insert(0, taskItem); } else { TaskList[taskProgress].Add(taskItem); } }
private string MyTask(int maximum, out TaskProgress progress) { for (var i = 0; i < maximum; i++) { progress = new TaskProgress( $"Counted to {i + 1} of {maximum}", (i + 1f) / maximum); } progress = TaskProgress.Done; return($"Counted to {countTo}!"); }
public static bool IsFinal(this TaskProgress progress) { switch (progress) { case TaskProgress.Confirmed: case TaskProgress.Timeout: case TaskProgress.Failed: return(true); default: return(false); } }
public TaskDTO AddTask(TaskDTO taskDTO) { Task task = taskFactory.CreateTask(taskDTO); task.Progress = TaskProgress.GetTaskProgress(task); var result = Database.Tasks.Create(task); if (result.Status == DAL.RepositoryActionStatus.Created) { var newTask = taskFactory.CreateTask(result.Entity); return(newTask); } throw new DatabaseException("Something wrong with data", ""); }
protected virtual void UpdateProgress(int count, int maximum, string description) { this.progress = new TaskProgress(count, maximum, description); OnProgressUpdated(); }
//用来同步任务信息的 public void SyncTask(TaskDB taskDb) { TaskDB = taskDb; taskProgress = (TaskProgress) taskDb.State; }
public TaskProgressDetailViewModel(TaskProgress progress) { this.progress = progress; }
public void AsyncTask(TaskDB taskdb) { this.taskDB = taskdb; switch(taskdb.TaskState) { case TaskState.Accept: taskProgress = TaskProgress.Accept; break; case TaskState.NotStart: taskProgress = TaskProgress.NoStart; break; case TaskState.Complete: taskProgress = TaskProgress.Complete; break; case TaskState.Reward: taskProgress = TaskProgress.Reward; break; } }