Good day,
I have a ganttview bound to a database, from the table where I saved the data, there are columns for taskname, duration, taskstarttime, etc. and the binary column for all fields. Now I have a process wherein I need to increase the taskduration directly from the database, I was able to increase it since the format of the data stored in database is 1.00:00:00, so what I did, I strip the 1 from the left and increment it by whatever number the user wants to, but my problem is, during reloading in the ganttview, the old value prevails, even if the taskduration is already 4.00:00:00, in ganttview it is still 1.
How to do it properly without using the ganttview to increase the taskduration?
Thanks
Hello LSG,
For that scenario the mentioed issue is expected, because when you make changes direct into database ( for example in the TaskDuration column) these changes are not apply to the AllProperties column in the database. So we have inconsistent data between TaskDuration column and AllProperties column in the database, that`s why when you re-laod your UltraGanttView, you still see your old data (from AllProperties column) instead the new data from TaskDuration column.
So if you make a changes direct into database for example in the TaskDuration column, you should make the same changes in the AllProperties column, but this is difficult task, because your data is in Binary format in the AllProperties column. So another possible option could be to set AllProprties = NULL or exclude AllProperties from the DataBinding. It means to remove :
this.ultraCalendarInfo1.DataBindingsForTasks.DurationMember = "TaskDuration";
Please take a look at the attached video file where I reproduce your issue and how to use my suggestion to solve your task.
Let me know if you have any questions.
Regards
part 2
part 3
Removing the AllProperties column is not an option in my case, since I have a lot of custom columns and the only place they can be saved in the database is through AllProperties.
So, in this case you could try to read and write data from/in your binary column in database. More details you could find in MSDN http://msdn.microsoft.com/en-us/library/29kt2zfk
OK. Let me know if you have any questions.
Hi,
I am sorry I missed that part, I will do test it and will post the result as soon as possible.
LSG said:I first assumed that I can read it by using GetCustomProperty, but unfortunately, it caused an error of object not set .....
For example:
ultraCalendarInfo1.Tasks.Add(MyTask);
var a = MyTask.GetCustomProperty("MyCustomColumn");
If you take a look at the attached code in my previous response, you will see that I`m using the same approach to set a new value in the custom column.
Please try this approach and let me know if you have any questions.
My scenario is like this, I have custom columns saved in AllProperties column in sql server, I want to access this from outside the ganttview control, what happened, I tried the readfrombytes in task column, I first assumed that I can read it by using GetCustomProperty, but unfortunately, it caused an error of object not set, so I tried to run in debug mode, and found out that there is a CustomProperties found in task variable, but the problem is, it is not public so it is hard to read it directly, so what I did I used reflection and I was able to read the CustomProperties and converted it to Dictionary.
But my question, isn't there any easier way of reading custom columns?
Please take a look at the answers of your questions:
LSG said: I tried reading the AllProperties Column in SQL Server, and all I got when converted back to character.Can you please give me some idea on how to it properly?
One possible approach could be if you are using the code below:
private void ultraButton3_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=IGBGSOFDS22;Initial Catalog=Test;Integrated Security=True");
SqlCommand command = new SqlCommand("SELECT AllProperties FROM [dbTasks] WHERE [TaskID] = '2d43b92c-9f7e-474b-88dc-87d54649fcdf'", conn);
conn.Open();
SqlDataReader myReader = command.ExecuteReader();
byte[] BinaryTaskData = null;
while (myReader.Read())
// Deserialize the Task from Binary data using AllProperties column
Task MyTask = Task.FromBytes((byte[])myReader[0]);
// Make changes in the Task
MyTask.Name ="New Name Task";
MyTask.SetDuration(new TimeSpan(5, 35, 0), Infragistics.Win.TimeSpanFormat.Hours);
// Set a value in the Custom column
MyTask.SetCustomProperty("MyCustomColumn", "This is test");
// By this way you could get a value from your custom column
//var a = MyTask.GetCustomProperty("MyCustomColumn");
//Save chages in the Task in Binary format;
BinaryTaskData = MyTask.Save();
}
myReader.Close();
// Save changes in the database usign Binary data and AllProperties column
SqlCommand command2 = new SqlCommand("UPDATE [dbTasks] set AllProperties = @AllProperties WHERE [TaskID] = '2d43b92c-9f7e-474b-88dc-87d54649fcdf'", conn);
command2.Parameters.Add("@AllProperties", SqlDbType.Binary);
command2.Parameters["@AllProperties"].SqlValue = BinaryTaskData;
command2.ExecuteNonQuery();
conn.Close();
LSG said:now my problem is how am I going to access the custom column from the task class?
Maybe you could use MyTask.SetCustomProperty() and MyTask.GetCustomProperty() method to get and set values from your custom columns.