Thanks, it's working. But I'm trying to integrate with razor page and I would like to have this information in the object generated by the page. Is there a way to get through it? ? Below is the code for the page
@using Lider.Sigma.ValueObject.ViewModel.PCP
@model ProjetoPCPVM
@{
ViewBag.Title = "Projeto";
Layout = "~/Views/Shared/_Layout.cshtml";
var jss = new System.Web.Script.Serialization.JavaScriptSerializer();
var projeto = jss.Serialize(Model);
}
<div class="panel panel-default margin-10">
<div class="panel-heading row" style="margin:unset">
<div class="col-md-10" style="margin-top: 10px">
<h3 class="panel-title">@ViewBag.PCPTitle</h3>
</div>
<div class="pull-right col-md-2">
<input class="form-control" type="text" id="taskSearch" placeholder="Pesquisar">
</div>
</div>
<div class="panel-body" style="padding-bottom: 0px; padding-top: 0px">
<div class="row">
<div class="row">
<div class="pull-right">
<div class="col-md-3">
<button type="button" style="margin: 4px" class="btn btn-default" id="btnCriarAlterar"><i class="fa fa-save"></i> SALVAR</button>
</div>
</div>
</div>
@if (!Model.Tarefas.Any())
{
<div class="text-center" style="margin: 15px">
Não foram encontradas tarefas para o projeto.
</div>
}
else
{
<div style="position:relative;" id="reactdiv"></div>
}
</div>
</div>
</div>
<script src="~/Scripts/react/react.min.js"></script>
<script src="~/Scripts/react/gantt.umd.js"></script>
<link rel="stylesheet" href="~/Scripts/react/gantt.classic-light.css" id="bryntum-theme">
<link rel="stylesheet" href="~/Scripts/react/gantt.material.css">
<link rel="stylesheet" href="~/Scripts/react/gantt.stockholm.css" id="data-bryntum-theme">
<link rel="stylesheet" href="~/Scripts/react/gantt.classic.css" id="bryntum-theme">
<script type="text/javascript">
function getData() {
//Projeto - Project data
var projeto = @(Html.Raw(projeto));
//tarefas - Tasks data
var tarefas = projeto.Tarefas;
var filhos = [];
var total = 0;
tarefas.forEach((tarefa, i) => {
//Iterating children array to display children data
var filho = {
IdPCP: tarefa.IdPCP,
IdPCPLInha: tarefa.IdPCPLinha,
Ordem: tarefa.Ordem,
WoNum: tarefa.WoNum,
IdProjetoServico: tarefa.IdProjetoServico,
Parent: tarefa.parentId,
Status: tarefa.status,
StatusDate: moment(tarefa.statusDate).format("DD/MM/YYYY HH:mm"),
Worktype: tarefa.worktype,
Descricao: tarefa.Descricao,
DTP: moment(tarefa.DTP).format("DD/MM/YYYY HH:mm"),
DTPS: moment(tarefa.DTPS).format("DD/MM/YYYY HH:mm"),
ETA: moment(tarefa.ETA).format("DD/MM/YYYY HH:mm"),
HorasPlanejadas: tarefa.HorasPlanejadas,
HorasTrabalhadas: tarefa.effort,
Percentual: tarefa.percentDone,
duration: tarefa.HorasTrabalhadas,
startDate: moment(tarefa.DTP).format(),
endDate: moment(tarefa.DTPS).format(),
automaticPercent: 10,
WOEQ5: tarefa.WOEQ5,
parentId: "_generatedv4",
//Predecessor:
}
total = total + filho.HorasPlanejadas;
filhos.push(filho);
});
//Updated Project data
var novoProjeto = {
IdProjetoServico: projeto.id,
Descricao: projeto.DescricaoProjeto,
startDate: projeto.DtPrevisaoEntrada,
HorasPlanejadas: total,
expanded: true,
children: [...filhos]
}
return novoProjeto
}
var data = getData();
console.log("data", data.startDate);
//var salvar = saveData();
$('#btnCriarAlterar').click(function () {
var projeto = @(Html.Raw(projeto));
var date = new Date(projeto.DataCriacao);
date.setFullYear(2022);
var DtPrevisaoEntradaFormat = new Date(parseInt(projeto.DtPrevisaoEntrada.substr(6)));
var dataCriacaoFormat = new Date(parseInt(projeto.DataCriacao.substr(6)));
const projetoLista = [];
projeto.DtPrevisaoEntrada = moment(DtPrevisaoEntradaFormat).format("DD/MM/YYYY HH:mm");
projeto.DataCriacao = moment(dataCriacaoFormat).format("DD/MM/YYYY HH:mm");
projeto.Tarefas.forEach((tarefa, index) => {
//var DTPformat = new Date(parseInt(tarefa.DTP.substr(6)));
//var DTPSformat = new Date(parseInt(tarefa.DTPS.substr(6)));
//var ETAformat = new Date(parseInt(tarefa.ETA.substr(6)));
var StatusDateformat = new Date(parseInt(tarefa.StatusDate.substr(6)));
var projetoAtual = {
IdPCP: tarefa.IdPCP || null,
IdPCPLinha: tarefa.IdPCPLinha || null,
WoNum: tarefa.WoNum || null,
IdProjetoServico: tarefa.IdProjetoServico || null,
Parent: tarefa.parentId || null,
Ordem: index +1,
Status: tarefa.Status || null,
StatusDate: moment(StatusDateformat).format("DD/MM/YYYY HH:mm"),
WorkType: tarefa.WorkType || null,
Descricao: tarefa.Descricao || null,
FailureDesc: tarefa.FailureDesc || null,
WORK8: tarefa.WOEQ8 || null,
HorasPlanejadas: tarefa.HorasPlanejadas,
HorasTrabalhadas: tarefa.HorasTrabalhadas || null,
DTP: tarefa.DTP,
DTPS: tarefa.DTPS,
ETA: tarefa.ETA,
Percentual: tarefa.Percentual,
Nivel: tarefa.Nivel || null,
Versao: tarefa.Versao || null,
DataInicioPlan: moment(tarefa.startDate).format("DD/MM/YYYY HH:mm"),
Predecessor:
}
projetoLista.push(projetoAtual);
});
projeto.Tarefas = projetoLista;
if (!data.children) {
data.children = projeto.Tarefas;
console.log("Projeto tarefas botao", projeto.Tarefas);
} else {
const listaTarefas = [];
data.children.forEach((tarefa, index) => {
var novaTarefa = {
IdPCP: tarefa.IdPCP || null,
IdPCPLinha: tarefa.IdPCPLinha || null,
WoNum: tarefa.WoNum || null,
IdProjetoServico: tarefa.IdProjetoServico || null,
Parent: tarefa.parentId || null,
Ordem: index +1,
//trazer internalId do objeto record
//NumeroTarefa: obj._internalId,
//trazer internalId do objeto record _data fromEvent _internalId
//Predecessor: ,
Status: tarefa.Status || null,
StatusDate: moment(tarefa.statusDate).format("DD/MM/YYYY HH:mm"),
WorkType: tarefa.WorkType || null,
Descricao: tarefa.Descricao || null,
FailureDesc: tarefa.FailureDesc || null,
WORK8: tarefa.WOEQ8 || null,
HorasPlanejadas: tarefa.HorasPlanejadas,
HorasTrabalhadas: tarefa.HorasTrabalhadas || null,
DTP: moment(tarefa.startDate).format("DD/MM/YYYY HH:mm"),
DTPS: moment(tarefa.endDate).format("DD/MM/YYYY HH:mm"),
ETA: moment(tarefa.ETA).format("DD/MM/YYYY HH:mm"),
Percentual: tarefa.Percentual,
Nivel: tarefa.Nivel || null,
Versao: tarefa.Versao || null,
DataInicioPlan: moment(tarefa.DTP).format("DD/MM/YYYY HH:mm"),
Predecessor:
}
listaTarefas.push(novaTarefa);
});
projeto.Tarefas = listaTarefas;
console.log("Lista", listaTarefas);
}
console.log("Projeto Final", projeto);
//$.ajax({
// async: true,
// type: 'POST',
// url: '/PCP/CriarAlterar',
// data: projeto
//});
});
</script>
<script src="@Url.Content("~/Scripts/jsx/App.jsx")"></script>