search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Asp Net MVC5

Asked by Luiz Forçan
8 years ago.

I'm testing the TutorialMvc5Gantt project to make the purchase.
But I have a problem. I could not change the PercentComplete.
How can I insert the Percent on the gantt chart.

Answer posted by Dan Letecky [DayPilot]
8 years ago.

It's a propery of the Task class. You can set the value like this:

Tasks = new TaskCollection();

Task task = new Task("Task 1", "1", DateTime.Today, DateTime.Today.AddDays(5));
task.Complete = 50; // 50%

Tasks.Add(task);
Comment posted by Luiz Forçan
8 years ago.

Hello!
It did not work for me. I put the above code in the GanttController.cs class inside the OnBeforeTaskRender(BeforeTaskRenderArgs e) as below:
                
Task task = new Task ( "Create Web Service", "574");
Task.Complete = 50; // 50%

The Task 574 is a task I created in my process. It started on 10/2/2014 and ended on 10/6/2014.

Thank you reply

Comment posted by Luiz Forçan
8 years ago.

The complete code:
protected override void OnBeforeTaskRender(BeforeTaskRenderArgs e)
{
// (e.Row.Columns.Count == 3)
if (e.Row.Columns.Count == 6)
{
e.Row.Columns[2].Html = (e.End - e.Start).ToString();
e.Row.Columns[3].Html = e.Start.ToString();
e.Row.Columns[4].Html = e.End.ToString();
e.Row.Columns[5].Html = "20%".ToString();

}

switch (e.Type)
{

case TaskType.Milestone:
e.Row.ContextMenuClientName = "ContextMenuMilestone";
e.Row.Areas.Add(new Area().Width(14).Height(14).Right(2).Top(2).ContextMenu("ContextMenuMilestone").Style("cursor: pointer; box-sizing: border-box; background: white; border: 1px solid #ccc; background-repeat: no-repeat; background-position: center center; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVChTYxg4wAjE0kC8AoiFQAJYwFcgjocwGRiMgPgdEP9HwyBFDkCMAtAVY1UEAzDFeBXBAEgxQUWUAgYGAEurD5Y3/iOAAAAAAElFTkSuQmCC);"));
break;
case TaskType.Group:
e.Row.ContextMenuClientName = "ContextMenuGroup";
e.Row.Areas.Add(new Area().Width(14).Height(14).Right(2).Top(2).ContextMenu("ContextMenuGroup").Style("cursor: pointer; box-sizing: border-box; background: white; border: 1px solid #ccc; background-repeat: no-repeat; background-position: center center; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVChTYxg4wAjE0kC8AoiFQAJYwFcgjocwGRiMgPgdEP9HwyBFDkCMAtAVY1UEAzDFeBXBAEgxQUWUAgYGAEurD5Y3/iOAAAAAAElFTkSuQmCC);"));
break;
case TaskType.Task:
e.Row.Areas.Add(new Area().Width(14).Height(14).Right(2).Top(2).ContextMenu("ContextMenuTask").Style("cursor: pointer; box-sizing: border-box; background: white; border: 1px solid #ccc; background-repeat: no-repeat; background-position: center center; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVChTYxg4wAjE0kC8AoiFQAJYwFcgjocwGRiMgPgdEP9HwyBFDkCMAtAVY1UEAzDFeBXBAEgxQUWUAgYGAEurD5Y3/iOAAAAAAElFTkSuQmCC);"));
break;

}

Tasks = new TaskCollection();

Task task = new Task("Create Web Service", "574");
task.Complete = 50; // 50%

Tasks.Add(task);
e.Box.BubbleHtml = "Complete: " + task.Complete + "%";
e.Row.BubbleHtml = "Task Name: " + task.Text;

}

Thank you

Comment posted by Dan Letecky [DayPilot]
8 years ago.

In OnBeforeTaskRender event hadler you can set it using e.PercentComplete:

protected override void OnBeforeTaskRender(BeforeTaskRenderArgs e) 
{ 
  // ...
  e.PercentComplete = 50;
}

The previous sample should go into OnInit() or OnFinish() - wherever you load the tasks.

class Gantt : DayPilotGantt
{
  protected override void OnInit(InitArgs e)
  {
    Tasks = new TaskCollection();

    Task task = new Task("Task 1", "1", DateTime.Today, DateTime.Today.AddDays(5));
    task.Complete = 50; // 50%

    Tasks.Add(task);
    UpdateWithMessage("Welcome!");
  }
  //...
}
Comment posted by Luiz Forçan
8 years ago.

Hello
I put the code above in the OnInit method and it erased in the view all the other tasks that were registered.

In my first process, I register the tasks and then as the tasks are accomplish. I have to go changing the percentage of each task. In this case the tasks are already registered in the task table.

How can I do this?

regards

Comment posted by Dan Letecky [DayPilot]
8 years ago.

Luiz,

Can you post the piece of code which you use to load tasks from the database?

Comment posted by Luiz Forçan
8 years ago.

Hello!
I do not use any code.
Your program daypilot automatically loads what is in the task table.
I just register my tasks in the task table.
As the tasks are being performed I need to update the percentage for each task.
Thank you for your valuable time.

Comment posted by Dan Letecky [DayPilot]
8 years ago.

Hi Luiz,

Sorry for the delay. It looks like you are using TasksFromEnumerable() method - is that correct?

There are two options:

1. With the latest build (8.3.5848), you can use an extended version of TaskFieldMappings which includes support for direct loading of the "complete" field using CompleteField property.

You can get the latest build in the sandbox:
http://mvc.daypilot.org/sandbox/

2. You can use OnBeforeTaskRender to load the value from the data source item:

protected override void OnBeforeTaskRender(BeforeTaskRenderArgs e) 
{ 
  // ...
  e.PercentComplete = e.DataItem["Complete"];
}

This assumes the data source includes "Complete" property or field (in case of DataRow).

Let me know if it didn't help.

Comment posted by Luiz Forçan
8 years ago.

Hi,
I'm using Asp Net MVC5. Look at your website: https://code.daypilot.org/73633/asp-net-mvc-5-gantt-chart. File TutorialMvc5Gantt.20141130.zip 2150 kB. Tutorial CS.

The version you indicated to me "DayPilotProMvcTrial-8.3.5848.zip" was developed using the asp net mvc architecture and not asp net mvc5 as above.

They are different architectures.

Can you help me?

Comment posted by Luiz Forçan
8 years ago.

Note: The "DayPilotProMvcTrial-8.3.5848.zip" version has the following assembly error:

Error 1 The assembly 'DayPilot.Web.Mvc, Version = 8.3.5848.0, Culture = neutral, PublicKeyToken = b8d928e6588028e4' uses 'System.Web.Mvc, Version = 4.0.0.1, Culture = neutral, PublicKeyToken = 31bf3856ad364e35', which owns A newer version than the assembly 'System.Web.Mvc, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' used as reference

Comment posted by Luiz Forçan
8 years ago.

Hi,

However, the percent field in the gantt chart does not show the value we reported inside the OnBeforeTaskRender method for the PercentComplete property. However, for the ToolTip property, it displays the Look This message on the chart for the ToolTip property. See the code snippet:

        //e.PercentComplete = (int) e.DataItem [ "id"];
                 E.PercentComplete = 5;
                 E.ToolTip = "Look this";

Comment posted by Dan Letecky [DayPilot]
8 years ago.

> The version you indicated to me "DayPilotProMvcTrial-8.3.5848.zip" was developed using the asp net mvc architecture and not asp net mvc5 as above.

The download package includes binaries for MVC 3, MVC 4 and MVC 5. It looks like you used the version for MVC4 by accident. You'll find the MVC 5 version in "Binary/Mvc5" folder.

> However, the percent field in the gantt chart does not show the value we reported inside the OnBeforeTaskRender method for the PercentComplete property.

You are right. This should be fixed now in build 5849:
http://mvc.daypilot.org/sandbox/

> Error 1 The assembly 'DayPilot.Web.Mvc, Version = 8.3.5848.0, Culture = neutral, PublicKeyToken = b8d928e6588028e4' uses 'System.Web.Mvc, Version = 4.0.0.1, Culture = neutral, PublicKeyToken = 31bf3856ad364e35', which owns A newer version than the assembly 'System.Web.Mvc, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' used as reference

This happens because your system has MVC 4 version installed and it's an older version which has security bugs. Microsoft released a fix and in order to force users to upgrade it they changed the reference version from 4.0.0.0 to 4.0.0.1. It needs to be updated to the latest version. See also:
https://blogs.msdn.microsoft.com/webdev/2014/10/16/microsoft-asp-net-mvc-security-update-ms14-059-broke-my-build/

Comment posted by Luiz Forçan
7 years ago.

Hello
I made MV5 update but now it is generating the error:
Incompatible DayPilot client script version. Expected 2537 (you are using 1368).

Comment posted by Dan Letecky [DayPilot]
7 years ago.

You need to use daypilot-all.min.js (the client script) from the same package - just replace it in your project. The versions have to match.

Comment posted by Luiz Forçan
7 years ago.

Hello
Don't work for me.

I replaced the file "daypilot-all.min.js" from "DayPilotProMvcTrial-8.3.5849\Scripts" to folder TutorialMvc5Gantt\TutorialCS\Scripts\DayPilot. In header the file is:
/*
DayPilot Pro
Copyright (c) 2005 - 2016 Annpoint s.r.o.
http://www.daypilot.org/
Use of this software is subject to license terms.
Version: 2537
*/

I replaced the files "DayPilot.Web.Mvc.dll" and "DayPilot.Web.Mvc.xml" from "DayPilotProMvcTrial-8.3.5849\Binary\Mvc5" to "TutorialMvc5Gantt\TutorialCS\bin".

But when I run the project it returns the following message:

Incompatible DayPilot client script version. Expected 2537 (you are using 1368).

Please let me know the thing which i am missing.

regards

Comment posted by Dan Letecky [DayPilot]
7 years ago.

It looks like the old script might be cached in the browser.

Try adding a dummy query string to the script reference in TutorialCS/Views/Shared/_Layout.cshtml:

<script src="@Url.Content("~/Scripts/DayPilot/daypilot-all.min.js?v=2537")" type="text/javascript"></script>

You also can replace "v=2537" with any other string when you need to force a refresh.

Comment posted by Luiz Forçan
7 years ago.

Dan,

Thank you very much.

Now it worked perfectly.

I'm tracking the percentage per task performed.

I'm going to integrate the gantt chart into my hour controls project.

So I'll submit for approval from my company's board.

When they approve I will then make the purchase of their software.

regards.

Comment posted by Dan Letecky [DayPilot]
7 years ago.

Great - thanks for the update, Luiz.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.