public void UpdateTask(IManagerEntity taskEntity) { Task task = (Task)taskEntity; IStorageCommand updateTaskCommand = fRepository.CommandFactory.GetUpdateCommand("Task"); Hashtable values = new Hashtable(); if (task.ActorPresent) { values.Add("ActorID", task.ActorID); } values.Add("Description", task.Description); values.Add("StartTime", task.StartTime); values.Add("EndTime", task.EndTime); values.Add("Priority", task.Priority); if (task.StatePresent) { values.Add("StateID", task.StateID); } updateTaskCommand.SetParam("Values", values); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + task.Id); updateTaskCommand.SetParam("Rules", rules); fRepository.ExecuteNonQuery(updateTaskCommand); }
/* * public void BindTaskComment(IManagerEntity parent) * { * IStorageCommand commentCommand = fDealer.CommandFactory.CreateSelectCommand(fDealer); * * commentCommand.SetParam("EntityName","Comment"); * * Hashtable rules = new Hashtable(); * rules.Add("TaskID","ID = " + parent.ID); * * commentCommand.SetParam("Rules",rules); * * DataTable commentTable = fDealer.ExecuteDataSet(commentCommand).Tables[0]; * if (commentTable.Rows.Count > 1) * { * throw new ValidationException("more when one comment for task id " + parent.ID); * } * * if (commentTable.Rows.Count == 0) * { * //todo create comment on the fly * } * else * { * //todo: fill comment * DataRow commentRow = commentTable.Rows[0]; * Comment comment = new Comment * { * Description = (string)commentRow["Description"], * Date = (DateTime)commentRow["Description"], * ID = commentRow["ID"], * * }; * } * * } */ public void UpdateTaskState(IManagerEntity stateEntity) { State state = (State)stateEntity; IStorageCommand updateStateCommand = fRepository.CommandFactory.GetUpdateCommand("TaskState"); Hashtable values = new Hashtable(); values.Add("Name", state.Name); values.Add("ColorRed", state.ColorRed); values.Add("ColorGreen", state.ColorGreen); values.Add("ColorBlue", state.ColorBlue); try { values.Add("MappingID", state.MappingID); } catch (ManagementException) { values.Add("MappingID", DBNull.Value); } updateStateCommand.SetParam("Values", values); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + state.Id); updateStateCommand.SetParam("Rules", rules); fRepository.ExecuteNonQuery(updateStateCommand); //store fConnections }
public void BindTaskStateConnection(IManagerEntity stateConnectionEntity) { Connection connection = (Connection)stateConnectionEntity; IStorageCommand connectionCommand = fRepository.CommandFactory.GetSelectCommand("TaskStateConnection"); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + connection.Id); connectionCommand.SetParam("Rules", rules); DataTable connectionTable = fRepository.ExecuteDataSet(connectionCommand).Tables[0]; if (connectionTable.Rows.Count > 1) { throw new ManagementException(ExceptionType.ValidationFailed, "more when one task state connection for id " + connection.Id); } if (connectionTable.Rows.Count == 0) { throw new ManagementException(ExceptionType.ValidationFailed, "Task state Connection not found for id " + connection.Id); } DataRow connectionRow = connectionTable.Rows[0]; connection.Name = (string)connectionRow["Name"]; connection.MappingID = (int)connectionRow["MappingID"]; connection.StateID = (int)connectionRow["StateID"]; }
public IManagerEntity CreateTaskState() { IStorageCommand createTaskStateCommand = fRepository.CommandFactory.GetInsertCommand("TaskState"); Hashtable values = new Hashtable(); values.Add("Name", ""); values.Add("ColorRed", 0); values.Add("ColorGreen", 0); values.Add("ColorBlue", 0); int mappintID = -1; foreach (DataRow row in TaskStateSource.Tables["TaskState"].Rows) { if (!(row["MappingID"] is DBNull) && (int)row["MappingID"] > mappintID) { mappintID = (int)row["MappingID"]; } } mappintID++; values.Add("MappingID", mappintID); createTaskStateCommand.SetParam("Values", values); int id = (int)fRepository.ExecuteScalar(createTaskStateCommand); Console.WriteLine(id); State state = new State(this, id); BindTaskState(state); return(state); }
public void BindActor(IManagerEntity actorEntity) { Actor actor = (Actor)actorEntity; IStorageCommand actorCommand = fRepository.CommandFactory.GetSelectCommand("Actor"); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + actor.Id); actorCommand.SetParam("Rules", rules); DataTable actorTable = fRepository.ExecuteDataSet(actorCommand).Tables[0]; if (actorTable.Rows.Count > 1) { throw new ManagementException(ExceptionType.ValidationFailed, "more when one actor for id " + actor.Id); } if (actorTable.Rows.Count == 0) { throw new ManagementException(ExceptionType.ValidationFailed, "Actor not found for id " + actor.Id); } DataRow actorRow = actorTable.Rows[0]; actor.Name = actorRow["Name"].ToString(); actor.Email = actorRow["Email"].ToString(); }
/* * public IManagerEntity GetComment(int id) * { * Comment comment = new Comment(this, id); * BindComment(comment); * return comment; * }*/ public IManagerEntity CreateComment(IManagerEntity commentedEntity) { IStorageCommand createCommentCommand = fRepository.CommandFactory.GetInsertCommand("Comment"); Hashtable values = new Hashtable(); values.Add("Description", ""); values.Add("Date", DateTime.Now); if (commentedEntity != null) { if (commentedEntity is Task) { values.Add("EntryID", commentedEntity.Id); } } else { values.Add("EntryID", DBNull.Value); } createCommentCommand.SetParam("Values", values); //int id = (int)fDealer.ExecuteScalar(createCommentCommand); //Comment comment = new Comment(this, id); //BindComment(comment); return(null); }
public void DeleteTaskStateConnection(int id) { IStorageCommand deleteStateConnectionCommand = fRepository.CommandFactory.GetDeleteCommand("TaskStateConnection"); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + id); deleteStateConnectionCommand.SetParam("Rules", rules); fRepository.ExecuteNonQuery(deleteStateConnectionCommand); }
public void UpdateActor(IManagerEntity actorEntity) { Actor actor = (Actor)actorEntity; IStorageCommand updateActorCommand = fRepository.CommandFactory.GetUpdateCommand("Actor"); Hashtable values = new Hashtable(); values.Add("Name", actor.Name); values.Add("Email", actor.Email); updateActorCommand.SetParam("Values", values); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + actor.Id); updateActorCommand.SetParam("Rules", rules); fRepository.ExecuteNonQuery(updateActorCommand); }
public void UpdateTaskStateConnection(IManagerEntity stateConnectionEntity) { Connection connection = (Connection)stateConnectionEntity; IStorageCommand updateStateConnectionCommand = fRepository.CommandFactory.GetUpdateCommand("TaskStateConnection"); Hashtable values = new Hashtable(); values.Add("Name", connection.Name); values.Add("MappingID", connection.MappingID); values.Add("StateID", connection.StateID); updateStateConnectionCommand.SetParam("Values", values); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + connection.Id); updateStateConnectionCommand.SetParam("Rules", rules); fRepository.ExecuteNonQuery(updateStateConnectionCommand); //store fConnections }
public IManagerEntity CreateActor() { IStorageCommand createActorCommand = fRepository.CommandFactory.GetInsertCommand("Actor"); Hashtable values = new Hashtable(); values.Add("Name", ""); values.Add("Email", ""); createActorCommand.SetParam("Values", values); int id = (int)fRepository.ExecuteScalar(createActorCommand); Actor actor = new Actor(this, id); BindActor(actor); return(actor); }
public IManagerEntity CreateTask() { IStorageCommand createTaskCommand = fRepository.CommandFactory.GetInsertCommand("Task"); Hashtable values = new Hashtable(); values.Add("ActorID", DBNull.Value); values.Add("Description", string.Empty); values.Add("StartTime", DateTime.Now); values.Add("EndTime", DateTime.Now); values.Add("StateID", DBNull.Value); values.Add("Priority", 10); createTaskCommand.SetParam("Values", values); int id = (int)fRepository.ExecuteScalar(createTaskCommand); Task task = new Task(this, id); BindTask(task); return(task); }
public IManagerEntity CreateTaskStateConnection(IManagerEntity stateEntity, IManagerEntity connectedStateEntity) { IStorageCommand createTaskStateConnectionCommand = fRepository.CommandFactory.GetInsertCommand("TaskStateConnection"); Hashtable values = new Hashtable(); State state = (State)stateEntity; State connectedState = (State)connectedStateEntity; values.Add("Name", ""); if (!state.IsMapped) { // create mappintID int mappintID = -1; foreach (DataRow row in TaskStateSource.Tables["TaskState"].Rows) { if (!(row["MappingID"] is DBNull) && (int)row["MappingID"] > mappintID) { mappintID = (int)row["MappingID"]; } } mappintID++; state.MappingID = mappintID; state.Save(); } values.Add("MappingID", state.MappingID); values.Add("StateID", connectedState.Id); createTaskStateConnectionCommand.SetParam("Values", values); int id = (int)fRepository.ExecuteScalar(createTaskStateConnectionCommand); Connection connection = new Connection(this, id); BindTaskStateConnection(connection); return(connection); }
public void BindTask(IManagerEntity taskEntity) { Task task = (Task)taskEntity; IStorageCommand taskCommand = fRepository.CommandFactory.GetSelectCommand("Task"); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + task.Id); taskCommand.SetParam("Rules", rules); DataTable taskTable = fRepository.ExecuteDataSet(taskCommand).Tables[0]; if (taskTable.Rows.Count > 1) { throw new ManagementException(ExceptionType.ValidationFailed, "more when one task for id " + task.Id); } if (taskTable.Rows.Count == 0) { throw new ManagementException(ExceptionType.ValidationFailed, "task not found for id " + task.Id); } DataRow taskRow = taskTable.Rows[0]; if (!(taskRow["ActorID"] is DBNull)) { task.ActorID = (int)taskRow["ActorID"]; } else { task.ActorPresent = false; } task.Description = taskRow["Description"] as string; if (task.Description == null) { task.Description = string.Empty; } task.StartTime = (DateTime)taskRow["StartTime"]; task.EndTime = (DateTime)taskRow["EndTime"]; if (taskRow["Priority"] is DBNull) { task.Priority = 10; } else { task.Priority = (int)taskRow["Priority"]; } if (!(taskRow["StateID"] is DBNull)) { task.StateID = (int)taskRow["StateID"]; } else { task.StatePresent = false; } task.EstimatedTime = task.EndTime.Subtract(task.StartTime); }
public void BindTaskState(IManagerEntity stateEntity) { State state = (State)stateEntity; IStorageCommand stateCommand = fRepository.CommandFactory.GetSelectCommand("TaskState"); Hashtable rules = new Hashtable(); rules.Add("UniqueID", "ID = " + state.Id); stateCommand.SetParam("Rules", rules); DataTable stateTable = fRepository.ExecuteDataSet(stateCommand).Tables[0]; if (stateTable.Rows.Count > 1) { throw new ManagementException(ExceptionType.ValidationFailed, "more when one task state for id " + state.Id); } if (stateTable.Rows.Count == 0) { throw new ManagementException(ExceptionType.ValidationFailed, "Task state not found for id " + state.Id); } DataRow stateRow = stateTable.Rows[0]; state.Name = (string)stateRow["Name"]; state.ColorRed = (byte)stateRow["ColorRed"]; state.ColorGreen = (byte)stateRow["ColorGreen"]; state.ColorBlue = (byte)stateRow["ColorBlue"]; bool connectionsPresent = true; try { state.MappingID = (int)stateRow["MappingID"]; state.IsMapped = true; } catch (InvalidCastException) { connectionsPresent = false; state.IsMapped = false; } if (connectionsPresent) { IStorageCommand stateConnectionCommand = fRepository.CommandFactory.GetSelectCommand("TaskStateConnection"); Hashtable connectionRules = new Hashtable(); rules.Add("ReferenceID", "ID = " + state.MappingID); stateConnectionCommand.SetParam("Rules", connectionRules); DataTable stateConnectionTable = fRepository.ExecuteDataSet(stateConnectionCommand).Tables[0]; foreach (DataRow row in stateConnectionTable.Rows) { State connectedState = (State)GetTaskStateConnection((int)row["ID"]); state.Connect(connectedState, connectedState.Name); } } }