public Entities.TaskCollection GetAll() { if (tasks == null) { tasks = new TaskCollection(); Task task; task = new Task(); task.Id = 1; task.Name = "User management"; tasks.Add(task); task = new Task(); task.Id = 2; task.Name = "Role management"; tasks.Add(task); task = new Task(); task.Id = 3; task.Name = "View daily tours"; tasks.Add(task); task = new Task(); task.Id = 4; task.Name = "View staff presence"; tasks.Add(task); } return(tasks); }
public override TaskCollection CreateTasks() { TaskCollection tasks = new TaskCollection(); // Global Tasks tasks.Add(new SyncUiTask("Demo custom global task", delegate() { MessageBox.Show("Your custom code goes here", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return(null); })); // Object Specific SyncUiTask <ListObject> taskObjectSpecific = new SyncUiTask <ListObject>("Demo Object Specific Task", delegate(ListObject computer) { // Show computer ID MessageBox.Show(computer.Id, "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return(null); }); tasks.Add(taskObjectSpecific); return(tasks); }
public static TaskCollection CreateTasks() { TaskCollection tasks = new TaskCollection(); tasks.Add(CreateCustomAction()); tasks.Add(new ProcessTask<MyBusinessObject>("Selection Task", "notepad.exe")); return tasks; }
public static TaskCollection CreateTasks() { TaskCollection tasks = new TaskCollection(); tasks.Add(CreateCustomAction()); tasks.Add(new ProcessTask <MyBusinessObject>("Selection Task", "notepad.exe")); return(tasks); }
public void GetTasksReturnsWhatWasSaved() { ITaskCollection taskCollection = new TaskCollection(); taskCollection.Add(new Task("task1")); taskCollection.Add(new Task("task2")); fileManager.SaveTasks(taskCollection); Assert.AreEqual(taskCollection, fileManager.GetTasks()); }
internal static TaskCollection CreateGlobalTasks() { if (globalTasks == null) { globalTasks = new TaskCollection(); globalTasks.Add(CreateChangeAdminAccountTask()); globalTasks.Add(CreateDisableServicesTask()); globalTasks.Add(CreateVisitMyAccountTask()); } return(globalTasks); }
private void buttonNewTask_Click(object sender, RoutedEventArgs e) { Task task = new Task(""); task.GenerateID(randomGenerator); tasks.Add(task); webClient.TaskAdd(task); taskTree.AddNode(task); taskTree.RenameTask(task.ID); e.Handled = true; }
internal static TaskCollection CreateGlobalTasks() { if (globalTasks == null) { globalTasks = new TaskCollection(); globalTasks.Add(CreateChangeAdminAccountTask()); globalTasks.Add(CreateDisableServicesTask()); globalTasks.Add(CreateVisitMyAccountTask()); } return globalTasks; }
public void TaskCollectionCleansCompletedTasksAutomaticallyMultipleEntries() { TaskCollection testCollection = new TaskCollection(); ITask testTask = new MockTask(); testCollection.Add(testTask); testCollection.Add(testTask); testCollection.Add(testTask); Assert.AreEqual(3, testCollection.Count); testTask.Exit(); Assert.AreEqual(0, testCollection.Count); }
public FashionNpcMediator() { XmlDocument modelsXmlDoc = XmlUtility.LoadXmlDocument(MODEL_TYPES_PATH); foreach (XmlNode modelInfoNode in modelsXmlDoc.SelectNodes("//Model")) { FashionModelInfo info = new FashionModelInfo(modelInfoNode); mFashionModelTypes.Add(info.Name, info); } mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler; mActiveTasks.Add(mScheduler.StartCoroutine(LoadAnimations(modelsXmlDoc))); }
public void TaskCollectionDisposeVerification() { TaskCollection testCollection = new TaskCollection(); testCollection.Add(new MockTask()); testCollection.Add(new MockTask()); testCollection.Add(new MockTask()); testCollection.Add(new MockTask()); testCollection.Add(new MockTask()); Assert.AreEqual(5, testCollection.Count); testCollection.Dispose(); Assert.AreEqual(0, testCollection.Count); }
/// <summary> /// /// </summary> /// <returns></returns> public TaskCollection Create(IDevice device) { TaskCollection tasks = new TaskCollection(); // TODO: not find // foreach (TaskDefine td in TaskDefines) { bool b = StringHelper.Equal(td.DeviceType, device.GetType().Name); if (!b) { continue; } IOpera opera = this.OperaFactory.Create(td.DeviceType, td.OperaName); Strategy strategy = td.StrategyDefine.Create(); //TimeSpan timeout = TimeSpan.FromMilliseconds(device.Station.CommuniPortConfig.TimeoutMilliSecond); Task t = new Task(device, opera, strategy, td.RetryTimes); device.TaskManager.Tasks.Enqueue(t); tasks.Add(t); } _log.Info("create '{0}' task count '{1}'", device.GetType().Name, tasks.Count); return(tasks); }
public void AddNode(UITreeViewEntity item) { List <string> paths = new List <string>(Regex.Split(@item.GetPath(), @"\\")); if (TreeNodeLevel > paths.Count - 1) { return; } string id = paths[TreeNodeLevel]; bool found = false; foreach (var p in TaskCollection) { if (p.ToString() == id) { found = true; p.AddNode(item); return; } } if (!found) { UITreeViewEntity addItem = item.GetParentItemByLevel(TreeNodeLevel + 1); //item.Parent = addItem ; TaskCollection.Add(addItem); this.OnPropertyChanged("HasChildNodes"); } }
public override void RunTaskMonitor(IEnumerable <ITaskItemContext> aTaskItem, Func <ITaskItemContext, object[], Task> aTaskExcuteDelegate, params object[] optionalParams) { if (TaskCollection == null) { TaskCollection = new ObservableCollection <ITaskItemContext>(); } TaskExcuteHandler = aTaskExcuteDelegate; aTaskItem.ToList().ForEach(x => { x.TaskId = new Random().Next(); x.TaskProgressRatio = 0; x.TaskStatus = TaskStatusEnum.Ready; if (new FileInfo(x.FilePath).Length > 104857600) { x.TaskStatus = TaskStatusEnum.Error; x.TaskMessage = "文件大小超过100M,暂不支持"; } else if (new FileInfo(x.FilePath).Length >= 1048576) { x.FileLength = System.Math.Ceiling(new FileInfo(x.FilePath).Length / 1048576.0) + "MB"; } else if (new FileInfo(x.FilePath).Length == 0) { x.TaskStatus = TaskStatusEnum.Error; x.TaskMessage = "禁止上传0KB文件"; } else { x.FileLength = System.Math.Ceiling(new FileInfo(x.FilePath).Length / 1024.0) + "KB"; } TaskCollection.Add(x); }); commonParams = optionalParams; RunTaskCollection(); }
void AddCollection() { var c = new TaskCollection(); _collection.Add(c); this.IsSaved = false; this.IsExpanded = true; }
public void Enqueue(Task task) { TaskCollection.Add(task); if (OnTaskEnqueue != null) { OnTaskEnqueue.Raise(); } }
void NewTask() { var t = new Task(); _taskCollection.Add(t); this.IsSaved = false; var tvm = new TaskViewModel(t, _dialog); base.OnRequestOpen(tvm, new WorkspaceRequestEventArgs(tvm)); }
internal void AttachTask(TaskViewModel task) { if (!_tasks.Contains(task)) { _tasks.Add(task); var sorted = _tasks.OrderBy(t => t.Reactor.ReactorNumber).ToList(); _tasks.ReplaceWithRange(sorted); UpdateProcessTimes(); } }
public void TaskCollection() { TaskCollection tasks1 = new TaskCollection(); for (int cnt = 0; cnt < 10; ++cnt) { tasks1.Add(this.CreateRandomTask()); } this.TestBusinessObject <TaskCollection, ITaskCollection>(tasks1); }
public ITaskCollection Process(ITask task, CancellationToken cancellationToken) { var tasks = new TaskCollection(); var path = task.Records.Where(m => m.Key == "path").Select(m => m.Content as string).First(); var filetype = task.Records.Where(m => m.Key == "filetype").Select(m => m.Content as string).First(); foreach (string directory in Directory.EnumerateDirectories(path)) { if (cancellationToken.IsCancellationRequested) { return(tasks); } var dirTask = new Task(); dirTask.KeyWord = "SourceFileDiscovery"; dirTask.Records.Add(new Record { Key = "path", Content = directory }); dirTask.Records.Add(new Record { Key = "filetype", Content = filetype }); tasks.Add(dirTask); } foreach (string file in Directory.EnumerateFiles(path, $"*.{filetype}")) { if (cancellationToken.IsCancellationRequested) { return(tasks); } tasks.Add(new Task("", new Record { Key = "sourcefile", Content = file })); } return(tasks); }
private void UpdateCollection() { if (TaskCollection.Count >= 1) { TaskCollection.Clear(); } foreach (var task in _dataBase.QueryItem()) { TaskCollection.Add(task); } }
public void SaveTasksSerializeTasks() { ITaskCollection taskCollection = new TaskCollection(); taskCollection.Add(new Task("task1")); fileManager.TasksFileName = "SaveTasksSerializeTasks.tmp"; File.Delete("SaveTasksSerializeTasks.tmp"); fileManager.SaveTasks(taskCollection); Assert.IsTrue(File.OpenText(fileManager.TasksFileName).ReadToEnd().Contains("task1")); }
public FashionGameGui() : base(GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>(), FASHION_GUI_PATH) { mInput = GameFacade.Instance.RetrieveMediator <FashionGameInput>(); mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler; this.MainGui.Showing = true; foreach (ITopLevel topLevel in AllGuis) { switch (topLevel.Name) { case "FashionGameGui": mMainWindow = (Window)topLevel; mMainWindow.Showing = true; break; case "FashionScoreGui": mScoreWindow = (Window)topLevel; mScoreWindow.Showing = true; break; } } mMainFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame"); mClothingButtonPrototype = mMainFrame.SelectSingleElement <PushButton>("ButtonPrototype"); // Initialize the clothing stack slots uint clothingStacks = (uint)(mMainFrame.InternalSize.x / mClothingButtonPrototype.ExternalSize.x); for (uint i = 0; i < clothingStacks; ++i) { mActiveClothes.Add(new List <Pair <ClothingItem, PushButton> >()); } mMainFrame.RemoveChildWidget(mClothingButtonPrototype); mWaveLabel = mScoreWindow.SelectSingleElement <Label>("**/WaveLabel"); mWaveString = mWaveLabel.Text; mNextWaveButton = mScoreWindow.SelectSingleElement <Button>("**/NextWaveButton"); mNextWaveButton.Enabled = false; mLevelLabel = mScoreWindow.SelectSingleElement <Label>("**/LevelLabel"); mExperienceMeter = mScoreWindow.SelectSingleElement <ProgressIndicator>("**/ExperienceMeter"); mExperienceLabel = mScoreWindow.SelectSingleElement <Label>("**/ExperienceLabel"); mProgressStyle = GetNamedStyle("Progress"); mProgressCompleteStyle = GetNamedStyle("ProgressComplete"); mEnergyLabel = mScoreWindow.SelectSingleElement <Label>("**/EnergyLabel"); mEnergyTimerLabel = mScoreWindow.SelectSingleElement <Label>("**/EnergyTimerLabel"); mEnergyMeter = mScoreWindow.SelectSingleElement <ProgressIndicator>("**/EnergyMeter"); mTasks.Add(mScheduler.StartCoroutine(UpdateEnergyDisplay())); }
public void AddTask(SingleTask task) { if (task != null) { if (TaskCollection == null) { TaskCollection = new ObservableCollection <SingleTask>(); } task.SortOrder = TaskCollection.Count; task.Name = "New Task " + task.SortOrder; TaskCollection.Add(task); } }
public TaskBacklogBuilder AddTaskCollection(params Task[] tasks) { TaskCollection taskCollection = ScriptableObject.CreateInstance <TaskCollection>(); foreach (Task task in tasks) { taskCollection.Add(task); } _taskBacklog.TaskCollection = taskCollection; return(this); }
public override TaskCollection CreateTasks() { TaskCollection tasks = new TaskCollection(); // Global Tasks tasks.Add(new SyncUiTask("Demo custom global task", delegate() { MessageBox.Show("Your custom code goes here", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return null; })); // Object Specific SyncUiTask<ListObject> taskObjectSpecific = new SyncUiTask<ListObject>("Demo Object Specific Task", delegate(ListObject computer) { // Show computer ID MessageBox.Show(computer.Id, "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return null; }); tasks.Add(taskObjectSpecific); return (tasks); }
public static ITaskCollection Deserialize(XmlNode xml) { ITaskCollection taskCollection = new TaskCollection(); foreach (XmlNode root in xml.ChildNodes) { if (root.Name == ROOT_NODE) { foreach (XmlNode taskXml in root.ChildNodes) { Task task = TaskSerializer.Deserialize(taskXml); if (task != null) taskCollection.Add(task); } } } return taskCollection; }
void IDropTarget.Drop(IDropInfo dropInfo) { if (dropInfo.Data is BookedOrderViewModel) { var order = dropInfo.Data as BookedOrderViewModel; if (order.IsPlannable) { int index = dropInfo.InsertIndex; TaskViewModel task = _factory.Create(this, order); task.Start = GetTimestamp(index); task.TaskIndex = index; if ((index < 0 || index > _tasks.Count) || (dropInfo.TargetItem == null && dropInfo.TargetCollection != null)) { _tasks.Add(task); } else { _tasks.Insert(index, task); } task.SaveChanges(); for (int idx = index + 1; idx < _tasks.Count; idx++) { var xx = _tasks[idx]; var zz = xx.TaskIndex; TimeSpan duration = TimeSpan.Zero; _tasks[idx].TaskIndex = zz + 1; if (_tasks[idx].TaskType != "O") { duration = (_tasks[idx].End - (_tasks[idx].Start < DateTime.Now ? DateTime.Now : _tasks[idx].Start)); } _tasks[idx].Start = _tasks[idx - 1].End; if (_tasks[idx].TaskType != "O") { _tasks[idx].End = _tasks[idx].Start + duration; } _tasks[idx].SaveChanges(); } RefreshLayout(); } } }
/// <summary> /// /// </summary> /// <param name="stations"></param> /// <returns></returns> private TaskCollection GetNeedExecuteTasks(StationCollection stations) { TaskCollection r = new TaskCollection(); foreach (IStation st in stations) { foreach (IDevice device in st.Devices) { //Debug.Assert(device.TaskManager.Current == null); foreach (ITask task in device.TaskManager.Tasks) { if (task.Check() == TaskStatus.Ready) { r.Add(task); } } } } return(r); }
public TaskCollection loadSubTasks(Task parent) { //DateTime dat2 = dat.Date; //TimeSpan ts = dat.TimeOfDay; TaskCollection list = new TaskCollection(); SqlCommand lcom = new SqlCommand($"SELECT * FROM Task WHERE TaskParentId='{parent.Id}'", lCon); lCon.Open(); SqlDataReader reader = lcom.ExecuteReader(); try { while (reader.Read()) { //can't be null int a = (int)reader["Id"]; string b = (string)reader["Name"]; //can be null string g = (reader["Description"].Equals(System.DBNull.Value)) ? "" : (string)reader["Description"]; string f = (reader["State"].Equals(System.DBNull.Value)) ? "" : (string)reader["State"]; double? c = (reader["Time"].Equals(System.DBNull.Value)) ? null : (double?)reader["Time"]; DateTime?e = (reader["Close"].Equals(System.DBNull.Value)) ? null : ((DateTime?)reader["Close"]); DateTime?d = (reader["Start"].Equals(System.DBNull.Value)) ? null : ((DateTime?)reader["Start"]); int? h = (reader["TaskParentId"].Equals(System.DBNull.Value)) ? null : (int?)reader["TaskParentId"]; int? i = (reader["ProgrammerId"].Equals(System.DBNull.Value)) ? null : (int?)reader["ProgrammerId"]; Task t = new Task(a, b.Trim(), c, d, e, f.Trim(), g.Trim(), h, i); list.Add(t); } } finally { // Close reader when done reading. reader.Close(); } lCon.Close();//Close connection at the end return(list); }
/// <summary> /// Creates the tasks. /// </summary> /// <returns> </returns> public override TaskCollection CreateTasks() { TaskCollection tasks = new TaskCollection(); tasks.Add(new SyncUiTask(StringResource.ConfigureWebdav, delegate { // check for remote web access if (this.Core.CheckRemoteAccess() == false) { MessageBox.Show(StringResource.Error_RemoteAccess); return(null); } // opens settings dialog FormsWebDavConfig formsWebDavConfig = new FormsWebDavConfig(this.Core); formsWebDavConfig.ShowDialog(); return(null); })); return(tasks); }
private async Task ListenAsync(CancellationToken cancellationToken) { var taskCollection = new TaskCollection(); await foreach (var(key, notification) in _fabric.GetNotifications(_delegate).WithCancellation(cancellationToken)) { taskCollection.Add(async() => { if (notification is StreamTriggerNotification) { await _fabric.ConsumeNotification(key); // Consume first, since execution might never end in this case await ExecuteAsync(notification, cancellationToken); } else { await ExecuteAsync(notification, cancellationToken); await _fabric.ConsumeNotification(key); } }); } await taskCollection.GetTask(); }
public string Render() { // Create a new string builder that contains the result json string. StringBuilder result = new StringBuilder(); foreach (ReportDefinitionVariable variable in this.ReportDefinition.LeftVariables) { LoadCombinations(variable, new List <string>(), "Report/Results"); } TaskCollection tasks = new TaskCollection(); foreach (ReportDefinitionRenderJSONCombination combination in this.Combinations) { tasks.Add(() => combination.LoadValue(this.ReportDefinition.XmlDocument)); } tasks.WaitAll(); result.Append("["); foreach (ReportDefinitionRenderJSONCombination combination in this.Combinations) { result.Append(combination.ToString()); result.Append(","); } if (this.Combinations.Count != 0) { result = result.Remove(result.Length - 1, 1); } result.Append("]"); // Return the contents of the // result string builder. return(result.ToString()); }
///// <summary> ///// ///// </summary> ///// <param name="current"></param> //private void ClearDeviceCurrentTask( ITask current ) //{ // IDevice device = current.Device; // if (current == device.TaskManager.Current) // { // device.TaskManager.Current = null; // } //} #region DoTasks queue /// <summary> /// /// </summary> /// <param name="taskCollection"></param> private void DoTasks(TaskQueue tasks) { if (tasks.Count == 0) { return; } bool find = false; ITask forExecutingTask = null; TaskCollection tempTasks = new TaskCollection(); while (tasks.Count > 0) { ITask headTask = tasks.Dequeue(); find = CanExecutingTask(headTask); if (find) { forExecutingTask = headTask; break; } else { tempTasks.Add(headTask); } } // // tasks.Enqueue(tempTasks); // // if (find) { ExecutingTask(forExecutingTask); } }
/// <summary> /// /// </summary> /// <returns></returns> public TaskCollection Create(IDevice device) { TaskCollection tasks = new TaskCollection(); // TODO: not find // foreach (TaskDefine td in TaskDefines) { bool b = StringHelper.Equal(td.DeviceType, device.GetType().Name); if (!b) { continue; } IOpera opera = this.OperaFactory.Create(td.DeviceType, td.OperaName); Strategy strategy = td.StrategyDefine.Create(); TimeSpan timeout = TimeSpan.FromMilliseconds(device.Station.CommuniPortConfig.TimeoutMilliSecond); Task t = new Task(device, opera, strategy, timeout, td.RetryTimes); device.TaskManager.Tasks.Enqueue(t); tasks.Add(t); } _log.Info("create '{0}' task count '{1}'", device.GetType().Name, tasks.Count); return tasks; }
/// <summary> /// /// </summary> /// <param name="stationCollection"></param> /// <returns></returns> public TaskCollection Create(StationCollection stationCollection) { if (stationCollection == null) { throw new ArgumentNullException("stationCollection"); } TaskCollection taskCollection = new TaskCollection(); foreach( Station st in stationCollection ) { foreach (Device device in st.Devices) { if (StringHelper.Equal(device.DeviceDefine.DeviceType, this.DeviceType)) { Opera opera = device.DeviceDefine.CreateOpera(this.OperaName); Strategy strategy = this.StrategyDefine.Create(); Task task = new Task(device, opera, strategy, TimeOut); taskCollection.Add(task); } } } return taskCollection; }
/// <summary> /// /// </summary> /// <param name="taskCollection"></param> private void DoTasks(TaskQueue tasks) { if (tasks.Count == 0) { return; } TaskCollection tempTasks = new TaskCollection(); while (tasks.Count > 0) { ITask headTask = tasks.Dequeue(); bool b = DoNotExecutingTask(headTask); if (b) { break; } else { tempTasks.Add(headTask); } } // // tasks.Enqueue(tempTasks); }
/// <summary> /// /// </summary> private void CheckSendedCollection() { TaskCollection temp = new TaskCollection(); for (Task t = this.ExecutingTasks.Pick(); t != null; t = this.ExecutingTasks.Pick()) { TimeSpan ts = DateTime.Now - t.LastExecute; if (ts >= this.Timeout) { DoitReceive(t); } else { temp.Add(t); } } this._executingTasks = temp; }
public void GetTasksReturnsWhatWasSaved() { ITaskCollection taskCollection = new TaskCollection(); taskCollection.Add(new Task("task1")); taskCollection.Add(new Task("task2")); fileManager.SaveTasks(taskCollection); Assert.AreEqual(taskCollection, fileManager.GetTasks()); }
/// <summary> /// /// </summary> /// <param name="stations"></param> /// <returns></returns> private TaskCollection GetNeedExecuteTasks(StationCollection stations) { TaskCollection r = new TaskCollection(); foreach (IStation st in stations) { foreach (IDevice device in st.Devices) { //Debug.Assert(device.TaskManager.Current == null); foreach (ITask task in device.TaskManager.Tasks) { if (task.Check() == TaskStatus.Ready) { r.Add(task); } } } } return r; }
/// <summary> /// �������� CheckedTasks �� ExecutingTasks /// </summary> /// <param name="checkedTasks"></param> /// <param name="task"></param> /// <param name="executeSuccess"></param> private void AAA(TaskCollection checkedTasks, Task task, bool canExecute, bool executed, bool executeSuccess) { if (canExecute && executed && executeSuccess) { this.ExecutingTasks.Add(task); return; } if (task.CanRemove) { // 2010-06-10 // fix remove not connected immedia task // //if (canExecute && !executed) // checkedTasks.Add(task); if (!executed) { checkedTasks.Add(task); } } else { checkedTasks.Add(task); } //if( !canExecute && task.CanRemove ) //if (canExecute) //{ // if (executeSuccess) // { // this.ExecutingTasks.Add(task); // } // else // { // if (!task.CanRemove) // checkedTasks.Add(task); // } //} //else //{ // checkedTasks.Add(task); //} }
public void SaveTasksSerializeTasks() { ITaskCollection taskCollection = new TaskCollection(); taskCollection.Add(new Task("task1")); fileManager.TasksFileName = "SaveTasksSerializeTasks.tmp"; File.Delete("SaveTasksSerializeTasks.tmp"); fileManager.SaveTasks(taskCollection); Assert.IsTrue(File.OpenText(fileManager.TasksFileName).ReadToEnd().Contains("task1")); }