Hi I am trying to do _dms.SendMessages in loop to the value of parameters of elements it takes lot of time and goes into timeout, what is the workaround for this?
Scenario:
I am iterating over services in a view, then on each element of that followed by PIDs for which I want value and do _dms.SendMEssages call, but it takes lot of time.
If I try to do in one go, then later it becomes difficult to identify based on primary key.
Can anyone please suggest the best way or approach
try
{
foreach (var service in serviceList)
{
var childInfos = service.Children?.ToList();
if (childInfos.Count > 0)
{
var reqParam = new List<DMSMessage>();
foreach (var childInfo in childInfos)
{
var paramsNeeded = childInfo.Parameters
.Where(x => _resources.Any(y => y.ParamterId == x.ParameterID))
.ToList();
foreach (var parameter in paramsNeeded)
{
var msg = new GetParameterMessage(childInfo.DataMinerID, childInfo.ElementID,
parameter.ParameterID, parameter.FilterValue, true);
reqParam.Add(msg);
}
}
try
{
var responseMsg = _dms.SendMessages(reqParam.ToArray());
var response = responseMsg.OfType<GetParameterResponseMessage>().ToList();
paramInfo = response.FindAll(x => !string.IsNullOrEmpty(x.Value.ToString()) && !x.Value.ToString().Equals("EMPTY", StringComparison.CurrentCultureIgnoreCase)).ToList();
}
catch (Exception e)
{
_logger.Error($"Error fetching parameters: {e.Message}");
continue;
}
if (paramInfo.Any())
{
foreach (var childInfo in childInfos)
{
var cells = InitializeTableCells();
CreateElementRow(ref rows, childInfo, cells, paramInfo, service.Name);
}
}
}
}
return new GQIPage(rows.ToArray()) { HasNextPage = false };
}
catch (Exception e)
{
_logger.Error($"Error fetching elements: {e.Message}");
return new GQIPage(rows.ToArray()) { HasNextPage = false };
}
Hi Apurva,
I’m not sure I fully understood your question. Could you please provide more details about your scenario and share the code you’re trying to execute? This will help us better understand your issue and assist you more effectively.
Thanks in advance,
Kind regards