/// <summary> /// Froms the db reader. /// </summary> /// <param name="reader">The reader.</param> /// <returns></returns> private TaskActivity ReadFromDatabase(SqlDataReader reader) { //Id DescriptionId Remarks StartDate EndDate Duration CrossTabDescriptionId CustomFlags UserId SourceMachine OriginalDate TaskActivity ta = new TaskActivity { Id = reader.GetGuid(0) }; Debug.Assert(ta.Id != null, "The TaskActivity Guid cannot be null."); ta.TaskDescription = Engine.TaskDescriptionsProvider.FindDescription(reader.GetGuid(1)); if (!reader.IsDBNull(2)) { ta.Remarks = reader.GetString(2); } ta.StartDate = reader.GetDateTime(3); if (!reader.IsDBNull(4)) { ta.EndDate = reader.GetDateTime(4); } if (!reader.IsDBNull(6)) { ta.CrosstabTaskDescription = Engine.TaskDescriptionsProvider.FindDescription(reader.GetGuid(6)); } ta.CustomFlags = reader.GetInt32(7); ta.UserId = reader.GetString(8); ta.OriginalDate = reader.GetDateTime(9); return(ta); }
public async Task <TResult> ExecuteTask <TResult>(string name, string version, params object[] parameters) { string serializedInput = dataConverter.Serialize(parameters); TaskActivity activity = objectManager.GetObject(name, version); Interlocked.Increment(ref pendingExecutions); string serializedResult = await Task.Factory.StartNew(() => { try { string result = activity.RunAsync(null, serializedInput).Result; return(result); } catch (AggregateException e) { e = e.Flatten(); if (e.InnerException is TaskFailureException) { var taskFailureException = e.InnerException as TaskFailureException; Exception cause = Utils.RetrieveCause(taskFailureException.Details, dataConverter); throw new TaskFailedException(0, 0, name, version, taskFailureException.Message, cause); } throw new TaskFailedException(0, 0, name, version, e.Message, e); } finally { Interlocked.Decrement(ref pendingExecutions); } }); var r = dataConverter.Deserialize <TResult>(serializedResult); return(r); }
/// <summary> /// Saves the activity to the SqlConnection /// </summary> /// <param name="connection">The connection.</param> /// <param name="activity">The activity.</param> private void WriteToDatabase(SqlConnection connection, TaskActivity activity) { using (SqlCommand command = new SqlCommand(saveActivityStatement, connection) { CommandType = System.Data.CommandType.StoredProcedure }) { command.Parameters.AddWithValue("@Id", activity.Id); command.Parameters.AddWithValue("@DescriptionId", activity.TaskDescription.Id); command.Parameters.AddWithValue("@Remarks", activity.Remarks); command.Parameters.AddWithValue("@StartDate", activity.StartDate); if (activity.EndDate != DateTime.MinValue) { command.Parameters.AddWithValue("@EndDate", activity.EndDate); } command.Parameters.AddWithValue("@Duration", activity.Duration); if (activity.CrosstabTaskDescription != null) { command.Parameters.AddWithValue("@CrossTabDescriptionId", activity.CrosstabTaskDescription.Id); } command.Parameters.AddWithValue("@CustomFlags", activity.CustomFlags); command.Parameters.AddWithValue("@UserId", activity.UserId); command.Parameters.AddWithValue("@SourceMachine", _machineName); command.ExecuteNonQuery(); } }
public ActionResult Index() { var today = DateTime.UtcNow.Date; var expiredTasks = _taskRepository.GetAllBy(t => (t.TaskStatus != ProjectTaskStatus.Completed && t.TaskStatus != ProjectTaskStatus.Cancelled) && t.DueDate < today).ToList(); foreach (var expiredTask in expiredTasks) { var taskId = expiredTask.Id; var selectedTask = _taskRepository.Get(taskId); var dueDate = selectedTask.DueDate?.ToString("d") ?? "No due date"; var activity = new TaskActivity { TaskId = selectedTask.Id, Title = "Missed DueDate", Comment = $"Missed the due date of {dueDate} as of {DateTime.UtcNow:d}, Sent the reminder", CreatedByUserId = 1 }; _taskActivityRepository.Create(activity); _unitOfWork.Commit(); #if !DEBUG _emailComposerService.TaskMissed(taskId); #endif } return(Json(true, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Appends the task descriptions to node. /// </summary> /// <param name="parent">The parent.</param> /// <param name="descriptions">The descriptions.</param> private void AppendTaskDescriptionsToNode(TreeNode parent, IEnumerable descriptions) { TaskActivity currentActivity = AppContext.Current.CurrentActivity; TaskDescription currentDescription = (currentActivity != null) ? currentActivity.TaskDescription : null; parent.Nodes.Clear(); foreach (TaskDescription description in descriptions) { TreeNode node = new TreeNode(description.Name); parent.Nodes.Add(node); node.Tag = description; node.ToolTipText = description.Description; if (description.IsEvent) { node.NodeFont = new Font(this.Font, FontStyle.Italic); } if (description.Name == currentDescription.Name) { node.NodeFont = new Font(this.Font, FontStyle.Strikeout); node.ForeColor = SystemColors.InactiveCaptionText; } } }
public void Initialize(IServiceProvider serviceProvider) { if (Instance == null) { Instance = Factory(serviceProvider); } }
/// <summary> /// Creates the inner activity, setting <see cref="InnerActivity" />. /// </summary> /// <param name="serviceProvider">The service provider. Not null.</param> public void Initialize(IServiceProvider serviceProvider) { Check.NotNull(serviceProvider, nameof(serviceProvider)); // Reflection activity if (Descriptor.Method is object) { // The "DeclaringType" must be an interface so that DTFx can emit a dynamic wrapper in an orchestration. // As such, we expect the implementation to be registered in the service provider. object obj = serviceProvider.GetRequiredService(Descriptor.Method.DeclaringType); InnerActivity = new ReflectionBasedTaskActivity(obj, Descriptor.Method); return; } // Service activity if (!s_factories.TryGetValue(Descriptor, out Func <IServiceProvider, TaskActivity> factory)) { if (serviceProvider.GetService(Descriptor.Type) is TaskActivity activity) { InnerActivity = activity; s_factories.TryAdd(Descriptor, sp => (TaskActivity)sp.GetRequiredService(Descriptor.Type)); return; // already created it this time, so return now. } else { ObjectFactory objectFactory = ActivatorUtilities.CreateFactory( Descriptor.Type, Array.Empty <Type>()); factory = s_factories.GetOrAdd( Descriptor, sp => (TaskActivity)objectFactory.Invoke(sp, Array.Empty <object>())); } } InnerActivity = factory.Invoke(serviceProvider); return; }
private void TaskDescriptionsExplorer_Load(object sender, EventArgs e) { treeView.Font = (Font)AppContext.Current.SettingsProvider.Get("GeneralFont", Font); propertyGrid.Font = (Font)AppContext.Current.SettingsProvider.Get("GeneralFont", Font); //clear the context variable AppContext.Current.SettingsProvider.Set( "SelectedTaskDescription", TaskDescription.Empty, PersistHint.AcrossSessions); TaskActivity currentTaskactivity = (TaskActivity)AppContext.Current.SettingsProvider.Get("CurrentActivity", TaskActivity.Empty); if (currentTaskactivity.IsNotEmpty()) { _currentTaskDescription = currentTaskactivity.TaskDescription; } // Set Owner Draw Mode to Text if ((null == Site) || (!Site.DesignMode)) { if ((bool)AppContext.Current.SettingsProvider.Get("Advanced Draw on Descriptions Tree", true)) { treeView.DrawMode = TreeViewDrawMode.OwnerDrawText; } } ReBuildTree(AppContext.Current.TaskDescriptionsProvider.TaskDescriptions); buttonUse.Visible = !(bool)AppContext.Current.SettingsProvider.Get("HideUseButton", false); Activate(); }
private static DispatchMiddlewareContext CreateContext(TaskActivity activity) { var context = (DispatchMiddlewareContext)Activator.CreateInstance(typeof(DispatchMiddlewareContext), true); context.SetProperty(activity); return(context); }
public async Task <IActionResult> PutTaskActivity(int id, TaskActivity taskActivity) { if (id != taskActivity.TaskActivityId) { return(BadRequest()); } _context.Entry(taskActivity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskActivityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task LongRunningActivity() { this.testService.OrchestrationServiceOptions.WorkItemLockTimeout = TimeSpan.FromSeconds(10); int activityExecutions = 0; TaskActivity longRunningActivity = TestService.MakeActivity((TaskContext ctx, string input) => { Interlocked.Increment(ref activityExecutions); // Sleeping for 15 seconds should cause work-item renewal to trigger at least twice. Thread.Sleep(TimeSpan.FromSeconds(15)); return(input); }); string input = $"[{DateTime.UtcNow:o}]"; TestInstance <string> instance = await this.testService.RunOrchestration( input, orchestrationName : nameof(LongRunningActivity), implementation : (ctx, input) => ctx.ScheduleTask <string>("LongRunning", "", input), activities : ("LongRunning", longRunningActivity)); OrchestrationState state = await instance.WaitForCompletion( timeout : TimeSpan.FromSeconds(30), expectedOutput : input); // Make sure the activity didn't get scheduled multiple times. Assert.Equal(1, activityExecutions); // Verify that the task renewal method was called at least once. this.testService.OrchestrationServiceMock.Verify( s => s.RenewTaskActivityWorkItemLockAsync(It.IsAny <TaskActivityWorkItem>()), Times.AtLeastOnce()); }
public async Task <ActionResult <TaskActivity> > PostTaskActivity(TaskActivity taskActivity) { _context.TaskActivities.Add(taskActivity); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTaskActivity", new { id = taskActivity.TaskActivityId }, taskActivity)); }
public void Create_NotExists_Null() { var manager = new GenericObjectManager <TaskActivity>(); TaskActivity activity = manager.GetObject("DNE", ""); activity.Should().BeNull(); }
public async Task TaskReturnsVoid_OrchestratorFails() { using (TestOrchestrationHost host = TestHelpers.GetTestOrchestrationHost(false)) { await host.StartAsync(); TaskActivity activity = TestOrchestrationHost.MakeActivity <int, Task>( delegate(TaskContext ctx, int input) { return(null); }); TestInstance <int> instance = await host.StartInlineOrchestration( input : 123, orchestrationName : "TestOrchestration", implementation : (ctx, input) => ctx.ScheduleTask <int>("Activity", "", input), activities : ("Activity", activity)); // The expectedOutput value is the string that's passed into the InvalidOperationException await Task.WhenAll(instance.WaitForCompletion( expectedStatus: OrchestrationStatus.Completed, expectedOutput: 0)); await host.StopAsync(); } }
/// <summary> /// When overridden in a provider, it completes an activity. /// </summary> /// <param name="activity">The activity.</param> protected override void ProviderCompleteActivity(TaskActivity activity) { using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); WriteToDatabase(connection, activity); } }
public virtual void Notify(string processInstanceId, string executionId, TaskActivity task, IDictionary <string, object> executionVariables, IDictionary <string, object> customPropertiesMap) { if (transactionDependentTaskListenerInstance == null) { transactionDependentTaskListenerInstance = TransactionDependentTaskListenerInstance; } transactionDependentTaskListenerInstance.Notify(processInstanceId, executionId, task, executionVariables, customPropertiesMap); }
public TransactionDependentTaskListenerExecutionScope(string processInstanceId, string executionId, TaskActivity task, IDictionary <string, object> executionVariables, IDictionary <string, object> customPropertiesMap) { this.processInstanceId = processInstanceId; this.executionId = executionId; this.task = task; this.executionVariables = executionVariables; this.customPropertiesMap = customPropertiesMap; }
/// <summary> /// When overridden in a provider, it adds an activity. /// </summary> /// <param name="activity">The activity.</param> protected override void ProviderBeginActivity(TaskActivity activity) { using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); WriteToDatabase(connection, activity); } }
/// <summary> /// Completes the activity. /// </summary> /// <param name="activity">The activity.</param> public void CompleteActivity(TaskActivity activity) { if (activity == null) { throw new ArgumentNullException("activity"); } CompleteActivity(activity, activity.StartDate); }
public static EventActivityBinder <TInstance, TData> ThenAsync <TInstance, TData>( this EventActivityBinder <TInstance, TData> source, Func <TInstance, TData, Task <TInstance> > action) where TInstance : class { var activity = new TaskActivity <TInstance, TData>(action); var adapter = new DataConverterActivity <TInstance, TData>(activity); return(source.Add(adapter)); }
/// <summary> /// This method get handed the start and end date selected by the exporter user /// and a copy of all the TaskActivities that fit into the users export selection /// and a copy of all the TaskDescriptions the export user selected /// </summary> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="taskActivities"></param> /// <param name="taskDescriptions"></param> public void AcceptData(DateTime startDate, DateTime endDate, TaskActivity[] taskActivities, TaskDescription[] taskDescriptions) { _startDate = startDate; _endDate = endDate; _taskActivities = taskActivities; _taskDescriptions = taskDescriptions; }
public ActionResult ChangeTaskStatus(ChangeTaskStatusViewModel vm) { if (ModelState.IsValid) { var selectedTask = _taskRepository.Get(vm.Id, "Assignee.User.Person"); if (selectedTask != null) { selectedTask.TaskStatus = vm.TaskStatus; selectedTask.UpdatedByUserId = WebUser.Id; _taskRepository.Update(selectedTask); _unitOfWork.Commit(); #if !DEBUG _emailComposerService.TaskUpdated(selectedTask.Id); #endif // Add Task Effort var effort = new TaskEffort { TaskId = selectedTask.Id, Effort = vm.Effort, Comments = vm.Comments, CreatedByUserId = WebUser.Id }; _taskEffortRepository.Create(effort); _unitOfWork.Commit(); // Log as a Task Activity var activity = new TaskActivity { TaskId = selectedTask.Id, Title = "Changed Status", Comment = $"{WebUser.Name} changed status of the Task at {DateTime.UtcNow.ToString("G")} to state {selectedTask.TaskStatus}, with comments - {vm.Comments}", CreatedByUserId = WebUser.Id }; _taskActivityRepository.Create(activity); _unitOfWork.Commit(); // Notify Creator of the Task var createdByUser = _userRepository.Get(selectedTask.CreatedByUserId); if (createdByUser != null) { var message = $"{selectedTask.Title} has been changed to {selectedTask.TaskStatus}"; _notificationService.NotifyUser("Task Status Changed", message, createdByUser.Code); } return(RedirectToAction("Details", "Tasks", new { selectedTask.Id })); } } return(View(vm)); }
public void Create_WrapperCreated() { var descriptor = TaskActivityDescriptor.Create <TestActivity>(); var creator = new ActivityObjectCreator(descriptor); TaskActivity activity = creator.Create(); activity.Should().NotBeNull(); activity.Should().BeOfType <WrapperActivity>() .Which.Descriptor.Should().Be(descriptor); }
public void Create_OpenGeneric_NotNull(Type type) { var manager = new GenericObjectManager <TaskActivity>(); manager.Add(new ActivityObjectCreator(new TaskActivityDescriptor(typeof(TestActivity <>)))); TaskActivity activity = manager.GetObject(TypeShortName.ToString(type, false), string.Empty); activity.Should().NotBeNull(); activity.As <WrapperActivity>().Descriptor.Type.Should().Be(type); }
/// <summary> /// When overridden in a provider, it completes an activity. /// </summary> /// <param name="activity">The activity.</param> protected override void ProviderCompleteActivity(TaskActivity activity) { Collection<TaskActivity> activities = LoadActivities(activity.StartDate); if (activities.Contains(activity)) { activities.Remove(activity); } activities.Add(activity); SaveActivities(activities); }
public void Create_Exists_NotNull() { var manager = new GenericObjectManager <TaskActivity>(); manager.Add(new ActivityObjectCreator(s_descriptor)); TaskActivity activity = manager.GetObject(s_descriptor.Name, s_descriptor.Version); activity.Should().NotBeNull(); activity.As <WrapperActivity>().Descriptor.Type.Should().Be(s_descriptor.Type); }
private void buttonOk_Click(object sender, EventArgs e) { TaskActivity currentActivity = AppContext.Current.CurrentActivity; if (currentActivity.IsNotEmpty()) { currentActivity.Remarks = textBoxRemark.Text; } this.Close(); }
/// <summary> /// When overridden in a provider, it completes an activity. /// </summary> /// <param name="activity">The activity.</param> protected override void ProviderCompleteActivity(TaskActivity activity) { Collection <TaskActivity> activities = LoadActivities(activity.StartDate); if (activities.Contains(activity)) { activities.Remove(activity); } activities.Add(activity); SaveActivities(activities); }
public ActionResult Edit(EditTaskViewModel vm) { if (ModelState.IsValid) { var selectedTask = _taskRepository.Get(vm.Id, "Assignee.User.Person"); if (selectedTask != null) { selectedTask.ProjectId = vm.ProjectId; selectedTask.Title = vm.Title; selectedTask.Description = vm.Description; selectedTask.ExpectedTime = vm.ExpectedTime; selectedTask.TaskStatus = vm.TaskStatus; selectedTask.Priority = vm.Priority; selectedTask.AssigneeId = vm.AssigneeId; selectedTask.StartDate = vm.StartDate; selectedTask.DueDate = vm.DueDate; selectedTask.UpdatedByUserId = WebUser.Id; _taskRepository.Update(selectedTask); _unitOfWork.Commit(); #if !DEBUG _emailComposerService.TaskUpdated(selectedTask.Id); #endif // Log as a Task Activity var dueDate = selectedTask.DueDate?.ToString("d") ?? "No due date"; var assignedTo = selectedTask.AssigneeId.HasValue ? selectedTask.Assignee.User.Person.Name : "No Assignee"; var activity = new TaskActivity { TaskId = selectedTask.Id, Title = "Updated", Comment = $"{WebUser.Name} updated the Task at {DateTime.UtcNow.ToString("G")} with state {selectedTask.TaskStatus}, expected hours {selectedTask.ExpectedTime}, due date as {dueDate} and assigned to {assignedTo}", CreatedByUserId = WebUser.Id }; _taskActivityRepository.Create(activity); _unitOfWork.Commit(); return(RedirectToAction("Index")); } } var myProjects = GetAllProjectsForMe(); var userList = GetAllMyReportees(); ViewBag.AssigneeId = new SelectList(userList, "Id", "Person.Name", vm.AssigneeId); ViewBag.ProjectId = new SelectList(myProjects, "Id", "Title", vm.ProjectId); return(View(vm)); }
private void UpdateStatusBarText() { TaskActivity current = _engine.SettingsProvider.Get("CurrentActivity", TaskActivity.Empty) as TaskActivity; if (current.IsNotEmpty()) { toolStripStatusLabel.Text = current.ToSummaryString().Replace("\r\n", " "); } else { toolStripStatusLabel.Text = "There is no activity running."; } }
/// <summary> /// Removes an activity. /// </summary> /// <param name="activity"></param> public void RemoveActivity(TaskActivity activity) { TaskActivityEventArgs taea = new TaskActivityEventArgs(activity); OnRemovingActivityEvent(taea); if (taea.Cancel == false) { DateTime timerStart = DateTime.Now; ProviderRemoveActivity(activity); RaiseTimingEvent(MethodInfo.GetCurrentMethod(), timerStart); OnTaskActivitiesChangedEvent(new TaskActivityEventArgs(activity)); } }
public void Create_ClosedGeneric_NotNull() { var descriptor = TaskActivityDescriptor.Create <TestActivity <object> >(); var manager = new GenericObjectManager <TaskActivity>(); manager.Add(new ActivityObjectCreator(descriptor)); TaskActivity activity = manager.GetObject(descriptor.Name, descriptor.Version); activity.Should().NotBeNull(); activity.As <WrapperActivity>().Descriptor.Type.Should().Be(descriptor.Type); TaskActivity activity2 = manager.GetObject(typeof(TestActivity <int>).FullName, descriptor.Version); activity2.Should().BeNull(); }
/// <summary> /// When overridden in a provider, it removes an activity. /// </summary> /// <param name="activity">The activity.</param> protected override void ProviderRemoveActivity(TaskActivity activity) { using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand(removeActivityStatement, connection) { CommandType = System.Data.CommandType.StoredProcedure }) { command.Parameters.AddWithValue("@Id", activity.Id); command.Parameters.AddWithValue("@UserId", activity.UserId); command.ExecuteNonQuery(); } } }
private void AddNewTaskActivity(object sender, EventArgs e) { if (treeView.SelectedNode.Tag.GetType() == typeof (DateTime)) { DateTime workingWithDate = (DateTime) treeView.SelectedNode.Tag; TaskDescription taskDescription = _engine.TaskDescriptionsProvider.TaskDescriptions[0]; TaskActivity pastTaskActivity = new TaskActivity( taskDescription, _engine.IdentityProvider.Principal.Identity.Name); pastTaskActivity.StartDate = workingWithDate; pastTaskActivity.EndDate = workingWithDate; pastTaskActivity.Remarks = "Inserted"; _engine.TaskActivitiesProvider.CompleteActivity(pastTaskActivity); RefreshViews(workingWithDate); } }
public void SaveActivities() { Random rnd = new Random(DateTime.Now.Millisecond); Collection<TaskActivity> activities = new Collection<TaskActivity>(); for (int n = 0; n < 10; n++) { TaskActivity ta = new TaskActivity(TaskDescription.Empty, "test user"); ta.StartDate = DateTime.Now.AddMinutes(-(n * rnd.Next(20))); ta.EndDate = DateTime.Now.AddMinutes(n * rnd.Next(20)); ta.Remarks = "Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition".Substring(0, rnd.Next(50)); ta.CrosstabTaskDescription = TaskDescription.Empty; activities.Add(ta); } SqlTaskActivitiesProvider s = new SqlTaskActivitiesProvider(); s.SaveActivities(activities); Console.WriteLine("10 records written to the Activities table."); }
public ActivityPanel(TaskActivity activity, Rectangle clientRectangle, float step) { InitializeComponent(); //Visible = false; TabStop = false; Activity = activity; Location = new Point(clientRectangle.X, clientRectangle.Y); Size = new Size(clientRectangle.Width, clientRectangle.Height); _step = step; BackColor = Color.FromArgb(177, Activity.TaskDescription.Color); if (Activity.TaskDescription.IsEvent) { panelRight.Visible = false; } Anchor = AnchorStyles.Left & AnchorStyles.Right; SetToolTip(); InMoveMode = false; }
/// <summary> /// When overridden in a provider, it removes an activity. /// </summary> /// <param name="activity">The activity.</param> protected override void ProviderRemoveActivity(TaskActivity activity) { Collection<TaskActivity> activities = LoadActivities(activity.StartDate); if (activities.Contains(activity)) { // If we are deleting the last activity in the file // just delete the file if (activities.Count <= 1) { FileInfoFromDate(activity.StartDate).Delete(); } else { activities.Remove(activity); SaveActivities(activities); } } }
/// <summary> /// Saves the activity to the SqlConnection /// </summary> /// <param name="connection">The connection.</param> /// <param name="activity">The activity.</param> private void WriteToDatabase(SqlConnection connection, TaskActivity activity) { SqlCommand command = new SqlCommand(saveActivityStatement, connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@Id", activity.Id); command.Parameters.AddWithValue("@DescriptionId", activity.TaskDescription.Id); command.Parameters.AddWithValue("@Remarks", activity.Remarks); command.Parameters.AddWithValue("@StartDate", activity.StartDate); if (activity.EndDate != DateTime.MinValue) { command.Parameters.AddWithValue("@EndDate", activity.EndDate); } command.Parameters.AddWithValue("@Duration", activity.Duration); if (activity.CrosstabTaskDescription != null) { command.Parameters.AddWithValue("@CrossTabDescriptionId", activity.CrosstabTaskDescription.Id); } command.Parameters.AddWithValue("@CustomFlags", activity.CustomFlags); command.Parameters.AddWithValue("@UserId", activity.UserId); command.Parameters.AddWithValue("@SourceMachine", _machineName); command.ExecuteNonQuery(); }
/// <summary> /// When overridden in a provider, it adds an activity. /// </summary> /// <param name="activity">The activity.</param> protected override void ProviderBeginActivity(TaskActivity activity) { }
/// <summary> /// When overridden in a provider, it removes an activity. /// </summary> /// <param name="activity">The activity.</param> protected override void ProviderRemoveActivity(TaskActivity activity) { using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(removeActivityStatement, connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@Id", activity.Id); command.Parameters.AddWithValue("@UserId", activity.UserId); command.ExecuteNonQuery(); } }
/// <summary> /// Froms the db reader. /// </summary> /// <param name="reader">The reader.</param> /// <returns></returns> private TaskActivity ReadFromDatabase(SqlDataReader reader) { //Id DescriptionId Remarks StartDate EndDate Duration CrossTabDescriptionId CustomFlags UserId SourceMachine OriginalDate TaskActivity ta = new TaskActivity(); ta.Id = reader.GetGuid(0); Debug.Assert(ta.Id != null, "The TaskActivity Guid cannot be null."); ta.TaskDescription = Engine.TaskDescriptionsProvider.FindDescription(reader.GetGuid(1)); if (!reader.IsDBNull(2)) { ta.Remarks = reader.GetString(2); } ta.StartDate = reader.GetDateTime(3); if (!reader.IsDBNull(4)) { ta.EndDate = reader.GetDateTime(4); } if (!reader.IsDBNull(6)) { ta.CrosstabTaskDescription = Engine.TaskDescriptionsProvider.FindDescription(reader.GetGuid(6)); } ta.CustomFlags = reader.GetInt32(7); ta.UserId = reader.GetString(8); ta.OriginalDate = reader.GetDateTime(9); return ta; }
private void addToolStripMenuItem_Click(object sender, EventArgs e) { DateTime selectedRowTime; if ((this.dataGridView.SelectedRows[0] != null) && (this.dataGridView.SelectedRows[0].Cells[1] != null)) { selectedRowTime = Convert.ToDateTime(this.dataGridView.SelectedRows[0].Cells[1].Value); selectedRowTime = selectedRowTime.AddSeconds(-10); TaskDescription taskDescription = AppContext.Current.TaskDescriptionsProvider.TaskDescriptions[0]; TaskActivity pastTaskActivity = new TaskActivity(taskDescription, AppContext.Current.IdentityProvider.Principal.Identity.Name); pastTaskActivity.StartDate = selectedRowTime; pastTaskActivity.EndDate = selectedRowTime.AddSeconds(1); pastTaskActivity.Remarks = "Inserted"; AppContext.Current.TaskActivitiesProvider.CompleteActivity(pastTaskActivity); SelectRow(pastTaskActivity); } else if (_effectiveDate > DateTime.MinValue) { _effectiveDate = _effectiveDate.AddSeconds(-10); TaskDescription taskDescription = AppContext.Current.TaskDescriptionsProvider.TaskDescriptions[0]; TaskActivity pastTaskActivity = new TaskActivity(taskDescription, AppContext.Current.IdentityProvider.Principal.Identity.Name); pastTaskActivity.StartDate = _effectiveDate; pastTaskActivity.EndDate = _effectiveDate.AddSeconds(1); pastTaskActivity.Remarks = "Inserted"; AppContext.Current.TaskActivitiesProvider.CompleteActivity(pastTaskActivity); SelectRow(pastTaskActivity); } }
private void DrawTaskActivity(TaskActivity taskActivity) { if (taskActivity.TaskDescription.Equals(TaskDescription.Empty)) { return; } float width = (float) ClientRectangle.Width; float step = width/(24*60); float startPosX = ((taskActivity.StartDate.Hour*60) + taskActivity.StartDate.Minute)*step; float endPosX = ((taskActivity.EndDate.Hour*60) + taskActivity.EndDate.Minute)*step; float startPosY = ClientRectangle.Height; float endPosY = ClientRectangle.Height; if (taskActivity.TaskDescription.IsEvent) { startPosY = startPosY/4; endPosY = (endPosY/3)*2; endPosX += 1; } else { startPosY = startPosY/3; endPosY = (endPosY/3)*2; } Rectangle rect = new Rectangle( (int) startPosX, (int) startPosY, (int) endPosX - (int) startPosX, (int) endPosY - (int) startPosY); ActivityPanel ap = new ActivityPanel(taskActivity, rect, step); ap.Name = taskActivity.Id.ToString(); ap.Parent = this; ap.Anchor = AnchorStyles.Top | AnchorStyles.Left; Controls.Add(ap); }
/// <summary> /// When overridden in a provider, it removes an activity. /// </summary> /// <param name="activity">The activity.</param> protected abstract void ProviderRemoveActivity(TaskActivity activity);
public void SelectRow(TaskActivity taskActivity) { if (taskActivity != null) { dataGridView.Focus(); foreach (DataGridViewRow dgvr in dataGridView.Rows) { if (((TaskActivity) dgvr.DataBoundItem).Id == taskActivity.Id) { dgvr.Selected = true; dataGridView.CurrentCell = dataGridView[1, dgvr.Index]; } else { dgvr.Selected = false; } } } }
/// <summary> /// When overridden in a provider, it completes an activity. /// </summary> /// <param name="activity">The activity.</param> protected abstract void ProviderCompleteActivity(TaskActivity activity);
/// <summary> /// When overridden in a provider, it adds an activity. /// </summary> /// <param name="activity">The activity.</param> protected abstract void ProviderBeginActivity(TaskActivity activity);
/// <summary> /// Completes the activity. /// </summary> /// <param name="activity">The activity.</param> /// <param name="effectiveDate">The effective date.</param> public void CompleteActivity(TaskActivity activity, DateTime effectiveDate) { if (activity == null) { throw new ArgumentNullException("activity"); } TaskActivityEventArgs taea = new TaskActivityEventArgs(activity, effectiveDate); OnCompletingActivityEvent(taea); if (taea.Cancel == false) { DateTime timerStart = DateTime.Now; ProviderCompleteActivity(taea.TaskActivity); RaiseTimingEvent(MethodInfo.GetCurrentMethod(), timerStart); OnTaskActivitiesChangedEvent(new TaskActivityEventArgs(activity)); } }
public void store(TaskActivity task) { }