using System; using System.Collections.Generic; using System.Linq; using System.Text; using DataClients; namespace Mailing { public class SZOWork { public TechCycle tc = new TechCycle(); public DateTime tStart = DateTime.Now; public DateTime tEnd = DateTime.Now; public TimeSpan workTime { get { return tEnd - tStart; } } } public static class SZOEveryday { public static List GetSZOWorks(DateTime timeStart, DateTime timeEnd, ushort vdp) { var result = new List(); var a = new STPClient(); int[] chk1 = { (int)TechCycle.Operation.cooling_ingot, (int)TechCycle.Operation.cooling_reflow, (int)TechCycle.Operation.cooling_welding }; int[] chk2 = { (int)TechCycle.Operation.end_tech_cycle, (int)TechCycle.Operation.unloading_loading, (int)TechCycle.Operation.looking_welding, (int)TechCycle.Operation.unloading_kit }; var tc = a.GetTechCycle(timeStart, timeEnd, vdp); var ad = a.GetAnalogDiscret(timeStart, timeEnd, vdp); foreach(var cycle in tc) { if (!chk1.Contains((int)cycle.index) && !chk2.Contains((int)cycle.index)) continue; if (chk1.Contains((int)cycle.index)) { var test = (from l in ad.an[13] where l.Item1 >= cycle.start && l.Item1 <= cycle.end && l.Item2 >= 30 select l).ToArray(); if (test.Length == 0) continue; } for(var i = 0; i < ad.di[22].Length; i++) { var ts = ad.di[22][i].Item1; var te = (i == ad.di[22].Length) ? (ad.di[22][i].Item1 < timeEnd) ? timeEnd : ad.di[22][i].Item1 : ad.di[22][i + 1].Item1; var v = ad.di[22][i].Item2; if ( ts <= cycle.end && te >= cycle.start && v.HasValue && v.Value ) { var t1 = ts > cycle.start ? ts : cycle.start; var t2 = te > cycle.end ? cycle.end : te; var res = t2 - t1; if (res.TotalMinutes < 15) continue; result.Add(new SZOWork() { tc = cycle, tStart = t1, tEnd = t2 }); } } } return result; } public static void GetPDF(DateTime time) { timeStart = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0); timeEnd = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0).AddDays(1); GetData(); PDFGenSZO.AddHeader("Контроль работы водокольцевых насосов SZO ", timeStart, timeEnd); foreach (var e in resFull) PDFGenSZO.AddSZOTable(e.Key, e.Value); PDFGenSZO.AddTotalTime(); PDFGenSZO.Print(time); } } }