AnsweredAssumed Answered

AFElement.GetElements obsolete

Question asked by PIAdminEnelGP on Oct 25, 2018
Latest reply on Oct 30, 2018 by rdavin

Hi guys,

 

I have a script on VB that help me create an automatic report of various variables from AF. What would be the best way to change my code as now I'm getting a warning that the action I try to do is now obsolete (AFElement.GetElements) .

 

I'm not an expert on coding but the guy responsible for the code changed of company not a long ago. So now I need to fix this as my report is not being updated as before and I don't know if its because of this warning. I tried using the AFElementSearch but so far I cannot do the same logic as before with it.

 

This is what the report does.

 

And this is that part of the code.

 

html.Append("<table width=\"100%\" class=\"tabla\" cellspacing=\"0\"><tr class=\"trOculta\"><th colspan=\"11\"><h1></h1></th></tr><tr><td class=\"cabecera2\">WTG</td><td class=\"cabecera2\">Fallas</td><td class=\"cabecera2\">Vel. Viento</td><td class=\"cabecera2\">Producción Real</td><td class=\"cabecera2\">Producción Esperada</td><td class=\"cabecera2\">Diferencias</td><td class=\"cabecera2\">E. Falla (kWh)</td><td class=\"cabecera2\">Ineficiencia (kWh)</td><td class=\"cabecera2\">Código Alarma</td><td class=\"cabecera2\">Descripción Alarma</td><td class=\"cabecera2\">Disponibilidad</td></tr>");
int count = 0;
int rowIndex = 0;
foreach (var child in element.GetElements(AFSortField.Name, AFSortOrder.Ascending, 0, 50, out count))
    {
    double wind = 0.0;
    double.TryParse(child.Attributes["Average_wind_speed_previous_day"].GetValue().Value.ToString(), out wind);
    double power = 0.0;
    double.TryParse(child.Attributes["Energy_previous_day"].GetValue().Value.ToString(), out power);
    double expected = 0.0;
    double.TryParse(child.Attributes["Previous_day_estimated_energy"].GetValue().Value.ToString(), out expected);
    double difference = power - expected;
    double availability = difference < 0 ? (power * 100) / expected : 100;


double ineficiency = 0.0;
    double.TryParse(child.Attributes["Previous_day_inefficiency"].GetValue().Value.ToString(), out ineficiency);
    //double.TryParse(child.Attributes["Disponibilidad Día Anterior"].GetValue().Value.ToString(), out availability);


html.Append(string.Format("<tr class=\"{8}\"><td class=\"tdPunteado\">{0}</td><td class=\"tdPunteado\"> </td><td class=\"tdPunteado\">{1:N2}</td><td class=\"tdPunteado\">{2:N2}</td><td class=\"tdPunteado\">{3:N2}</td><td class=\"tdPunteado\">{4:N2}</td><td class=\"tdPunteado\">{5:N2}</td><td class=\"tdPunteado\">{6:N2}</td><td class=\"tdPunteado\"> </td><td class=\"tdPunteado\"> </td><td>{7:N2} %</td></tr>", child.Name, wind, power, expected, difference, 0, ineficiency, availability, IsOdd(rowIndex) ? "trGris" : "trBlanco"));
rowIndex++;
}

 

Could you help me with this request?

Thank you very much for your help.

Outcomes