Skip to content

Instantly share code, notes, and snippets.

@ShilGen
Created September 7, 2023 08:27
Show Gist options
  • Save ShilGen/ca9e6692f0e1639090f19e0467147a5c to your computer and use it in GitHub Desktop.
Save ShilGen/ca9e6692f0e1639090f19e0467147a5c to your computer and use it in GitHub Desktop.
Карта синхронизации приборов учёта.
var worksheet = WorkbookNonExcel.Worksheets.FirstOrDefault();
var mps=new HashSet<MeterPoint>();
mps=MeterPoint.GetInstances().ToHashSet();
int i=0;
int mpN =0;
foreach(var mp in mps)
{
var el=mp.AttributeElectricityMeter;
if(el!=null)
{
var gts=el.GetTimeStatus();
if(gts!=null)
{
var lsr=gts.LastSucceedReadInfo;
if(lsr!=null)
{
worksheet.Cells[i,0].Value=mp.Caption;
worksheet.Cells[i,1].Value=el.AttributeSerialNumber;
worksheet.Cells[i,2].SetValue(lsr.ServerDt.AddSeconds(lsr.DeltaValueSec));
worksheet.Cells[i,2].Style.NumberFormat="dd.mm.yyyy hh:mm:ss";
worksheet.Cells[i,3].SetValue(lsr.ServerDt);
worksheet.Cells[i,3].Style.NumberFormat="dd.mm.yyyy hh:mm:ss";
worksheet.Cells[i,4].SetValue(lsr.DeltaValueSec);
i++;
}
}
}
mpN++;
}
worksheet.Cells.GetSubrangeAbsolute(0,0, mpN, 4).Sort(false).By(4, true).Apply();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment