/// <summary> /// Update a record /// </summary> public bool Update(TasksEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Tasks set "); strSql.Append("ProjectID=@ProjectID,"); strSql.Append("TicketID=@TicketID,"); strSql.Append("Title=@Title,"); strSql.Append("Description=@Description,"); strSql.Append("IsCompleted=@IsCompleted"); strSql.Append(" where TaskID=@TaskID "); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "TaskID", DbType.Int32, model.TaskID); db.AddInParameter(dbCommand, "ProjectID", DbType.Int32, model.ProjectID); db.AddInParameter(dbCommand, "TicketID", DbType.Int32, model.TicketID); db.AddInParameter(dbCommand, "Title", DbType.String, model.Title); db.AddInParameter(dbCommand, "Description", DbType.String, model.Description); db.AddInParameter(dbCommand, "IsCompleted", DbType.Boolean, model.IsCompleted); int rows = db.ExecuteNonQuery(dbCommand); if (rows > 0) { return(true); } else { return(false); } } } /// <summary>
// Post api/tasks public HttpResponseMessage Post([FromBody] string description) { if (description.Replace(" ", "") == String.Empty) { return(Request.CreateResponse(HttpStatusCode.NoContent, "WebApi: Task has no description")); } TasksEntity newTask = new TasksEntity { Description = description, CreateTime = DateTime.Now }; try { messageQueueProvider.SendMessage(newTask); } catch (Exception ex) { HttpResponseMessage badResponse = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(badResponse); } HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, $"WebApi: Task {newTask.Description} {newTask.CreateTime} added to queue succesfully"); return(response); }
public async Task TaskActions(int taskId, string action) { TasksEntity tasksEntity = await this.GetSingleAsync <TasksEntity>(taskId); if (tasksEntity != null) { if (action == "Star") { tasksEntity.Starred = !tasksEntity.Starred; } else if (action == "Important") { tasksEntity.Important = !tasksEntity.Important; } else if (action == "Completed") { tasksEntity.Completed = !tasksEntity.Completed; } else if (action == "Deleted") { tasksEntity.Deleted = true; tasksEntity.DeletedInd = true; } await UpdateEntityWithoutModel <TasksEntity>(tasksEntity); } }
public TasksEntity ReceiveMessage() { if (!this.isInitialized) { this.InitializeQueue(); } TasksEntity taskEntity = new TasksEntity(); try { messageQueue.Formatter = new XmlMessageFormatter (new Type[] { typeof(TasksEntity) }); Message myMessage = messageQueue.Receive(new TimeSpan(0, 0, 2)); taskEntity = (TasksEntity)myMessage.Body; } catch (MessageQueueException msgEx) { if (msgEx.MessageQueueErrorCode != MessageQueueErrorCode.IOTimeout) { Console.WriteLine(msgEx.Message); } } catch (InvalidOperationException e) { Console.WriteLine(e.Message); } return(taskEntity); }
protected void Page_Load(object sender, EventArgs e) { int taskid = QS("taskid", 0); int ticketid = QS("tid", 0); if (!IsPostBack) { if (taskid == 0 && ticketid == 0) { this.ShowArgumentErrorMessageToClient(); return; } if (taskid > 0) { Page.Title = "View Task Detail"; TasksEntity ta = ticketApp.GetTaskEntity(taskid); if (CheckSecurity(ta, 0)) { BindData(ta); EnableControl(ta.IsCompleted); } } else { Page.Title = "Add New Task"; if (CheckSecurity(null, ticketid)) { this.btnClear.Visible = true; this.btnSave.Visible = true; } } } }
/// <summary> /// Add a record /// </summary> public int Insert(TasksEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Tasks("); strSql.Append("ProjectID,TicketID,Title,Description,IsCompleted,CompletedDate)"); strSql.Append(" values ("); strSql.Append("@ProjectID,@TicketID,@Title,@Description,@IsCompleted,@CompletedDate)"); strSql.Append(";select ISNULL( SCOPE_IDENTITY(),0);"); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "ProjectID", DbType.Int32, model.ProjectID); db.AddInParameter(dbCommand, "TicketID", DbType.Int32, model.TicketID); db.AddInParameter(dbCommand, "Title", DbType.String, model.Title); db.AddInParameter(dbCommand, "Description", DbType.String, model.Description); db.AddInParameter(dbCommand, "IsCompleted", DbType.Boolean, model.IsCompleted); db.AddInParameter(dbCommand, "CompletedDate", DbType.Date, model.CompletedDate); int result; object obj = db.ExecuteScalar(dbCommand); if (!int.TryParse(obj.ToString(), out result)) { return(0); } return(result); } }
public int Insert(TasksEntity tasks) { string sql = @"INSERT INTO T_JobLog (JobName, JobGroup, AssemblyName, ClassName, CronExpression, Priority, IsNeedStart, State, Remark, UpdateTime, UpdateMan, CreateMan) VALUES (@JobName, @JobGroup, @AssemblyName, @ClassName, @CronExpression, @Priority, @IsNeedStart, @State, @Remark, @UpdateTime, @UpdateMan, @CreateMan))"; int result = db.Execute(sql, tasks); return(result); }
public void SendMessage(TasksEntity taskEntity) { if (!this.isInitialized) { this.InitializeQueue(); } messageQueue.Send(taskEntity); }
async Task <bool> StartupJob(TasksEntity task) { bool result = false; if (string.IsNullOrEmpty(task.GroupName)) { task.GroupName = "DEFAULT"; } try { if (!dictCount.ContainsKey(task.JobName)) { dictCount.Add(task.JobName, 0); } AppDomain appDomain = null; if (!AppDomainDict.ContainsKey(task.AssemblyName)) { appDomain = AppDomain.CreateDomain(task.AssemblyName); AppDomainDict.Add(task.AssemblyName, appDomain); } else { appDomain = AppDomainDict[task.AssemblyName]; } var instance = appDomain.CreateInstanceFromAndUnwrap(Path.GetFullPath(task.AssemblyName), task.ClassName); Type t = instance.GetType(); //Assembly assembly = Assembly.LoadFile(Path.GetFullPath(task.AssemblyName)); //Type t = assembly.GetType(task.ClassName); IJobDetail job = JobBuilder.Create(t) .WithIdentity(task.JobName) .Build(); ITrigger trigger = TriggerBuilder.Create() .WithIdentity("trigger_" + task.JobName, task.GroupName) //.WithSimpleSchedule(x => x.WithIntervalInSeconds(1)) //.WithCronSchedule("*/5 * * * * ? *") //.WithCronSchedule("*/5 25-26 14 * * ?") //.WithSimpleSchedule(x => x.WithIntervalInSeconds(1).RepeatForever()) .WithCronSchedule(task.CronExpression) .Build(); await sched.ScheduleJob(job, trigger); sched.ListenerManager.AddJobListener(new JobListener()); //sched.ListenerManager.AddTriggerListener(new TriggerListener()); result = true; } catch (Exception ex) { WriteLog($"{task.JobName},{ex.Message}", ConsoleColor.Red); } return(result); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; try { if (IdentityContext.UserID <= 0) { return; } #region get value int tid = Convert.ToInt32(context.Request["tid"]); String title = context.Request["title"]; String descr = context.Request["descr"]; #endregion #region declare TasksEntity ta = new TasksEntity(); int result = 0; #endregion GetProjectIdAndUserIDResponse response = ticketApp.GetProjectIdAndUserID(tid); int pid = response.ProjectId; ta.TicketID = tid; ta.ProjectID = pid; ta.Title = title.NoHTML(); ta.Description = descr.NoHTML(); ta.IsCompleted = false; ta.CompletedDate = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate(); result = ticketApp.AddTaskEntity(ta); if (result > 0) { context.Response.Write("Add Successful!"); } else { context.Response.Write("Add Fail!"); } } catch (Exception ex) { context.Response.Write("para error!"); WebLogAgent.Write(string.Format("Error Ashx:DoAddTaskHandler.ashx Messages:\r\n{0}", ex)); return; } }
private void BindData(TasksEntity ta) { this.txtTitle.Value = ta.Title; this.txtDesc.Value = ta.Description; if (ta.IsCompleted) { this.IsComplete.Visible = true; this.Complete.Visible = true; this.IsCompleteCK.Checked = true; } this.txtComplete.Text = ta.CompletedDate.ToString("MM/dd/yyyy"); }
public int AddNewTask(TasksEntity task) { var entityToAdd = new TasksEntity() { Description = task.Description, CreateTime = task.CreateTime }; if (taskTableRepository.Contains(entityToAdd)) { throw new ArgumentException($"Attention. This task \"{entityToAdd.Description}\" has been registered"); } taskTableRepository.Add(entityToAdd); taskTableRepository.SaveChanges(); return(entityToAdd.TaskId); }
/// <summary> /// Get an object entity /// </summary> public TasksEntity Get(int TaskID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from Tasks "); strSql.Append(" where TaskID=@TaskID "); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "TaskID", DbType.Int32, TaskID); TasksEntity model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = TasksEntity.ReaderBind(dataReader); } } return(model); } }
private bool CheckSecurity(TasksEntity ta, int tid) { GetTicketCreateByAndStatusResponse response = new GetTicketCreateByAndStatusResponse(); if (ta == null) { response = ticketApp.GetTicketCreateByAndStatus(tid); } else { response = ticketApp.GetTicketCreateByAndStatus(ta.TicketID); } if ((response.CreateUserId == UserInfo.UserID || allowAddTaskUser.Contains(UserInfo.RoleID)) && response.status >= (int)TicketsState.Submitted && response.status != (int)TicketsState.Estimation_Fail && response.status != (int)TicketsState.Completed && response.status != (int)TicketsState.Cancelled) { return(true); } return(false); }
public TasksEntity GetTaskById(int id) { var resultTask = new TasksEntity(); return(this.dbContext.Tasks.First(t => t.TaskId == id)); }
public bool Contains(TasksEntity entityToAdd) { return(this.dbContext.Tasks.Any(t => t.Description == entityToAdd.Description)); }
public void Add(TasksEntity entity) { this.dbContext.Tasks.Add(entity); }
public int UpdateState(TasksEntity task) { return(db.Execute("UPDATE T_Tasks SET State = @State WHERE JobName = @JobName", new { State = task.State, JobName = task.JobName })); }