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
Hi,
I tried reading the AllProperties Column in SQL Server, and all I got when converted back to character, I used the following C# Code to convert it back to string as follows:
byte[] bt = (byte[])row["AllProperties"]; string s = System.Text.UTF8Encoding.ASCII.GetString(bt);
And the result is as follows:
"\0\0\0\0????\0\0\0\0\0\0\0\f\0\0\0sInfragistics4.Win.UltraWinSchedule.v12.2, Version=12.2.20122.1006, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb\0\0\0&Infragistics.Win.UltraWinSchedule.Task\b\0\0\0Id\nConstraintConstraintDateTime\bDurationDurationFormatName\rStartDateTime\fParentTaskId\0\0\0\0\0\vSystem.Guid\b\r\f\b\r\vSystem.Guid\0\0\0????\vSystem.Guid\v\0\0\0_a_b_c_d_e_f_g_h_i_j_k\0\0\0\0\0\0\0\0\0\0\0\b\a\a6?H?GsH???{??\0\0\0\0??k????\0?i*?\0\0\0\0\0\0\0\0\0New sub-task 2\0??k????????????k???_?O?2??F?@\v"
Can you please give me some idea on how to it properly?
Thanks in advance.
I have converted it properly using Task.ReadFromBytes, now my problem is how am I going to access the custom column from the task class?
Thank you.
When I run and debug the application that reads the binary column, there is a non-public member that has CustomProperties that contains the custom columns and their values, but my question, how to access those fields when they are not public members.
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
ultraCalendarInfo1.Tasks.Add(MyTask);
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.
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?
OK. Let me know if you have any questions.
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:
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.