Beispiel #1
0
        private void LoadLog(int pos, int count, bool print = false)
        {
            if (pos < 0)
            {
                return;
            }
            var dateBefore = DateTime.Now.AddYears(-1);

            CalcRowsCount(lvLogView);
            int linescount;
            var results = Data.GetFillLogRecords(pos, count, dateBefore, out linescount, true);

            if (count <= 0)
            {
                return;
            }
            _reportrows.Clear();
            var row = 0;

            foreach (string[] rec in results)
            {
                if (rec.Length != 13)
                {
                    continue;
                }
                var item = new ListViewItem();
                if (row % 2 != 0)
                {
                    item.BackColor = Color.FromKnownColor(KnownColor.WhiteSmoke);
                }
                var startdatetime = rec[0];
                var enddatetime   = rec[1];
                item.Text = GetDateStr(enddatetime);
                var overpass = rec[3];
                var way      = rec[4];
                var product  = Data.GetFineProductName(rec[5]);
                var riser    = rec[6];
                var addr     = string.Join("", rec, 1, 5).Trim().Length > 0
                               ? string.Format("Эстакада {0}. Путь {1}. {2}. Стояк {3}",
                                               overpass, way, product, riser) : "";
                item.SubItems.Add(addr);
                var waggon = rec[7];
                item.SubItems.Add(waggon);
                var type = rec[8];
                item.SubItems.Add(type);
                var setpoint = rec[9];
                item.SubItems.Add(setpoint);
                item.SubItems.Add(GetTimeStr(startdatetime));
                item.SubItems.Add(GetTimeStr(enddatetime));
                var filled = rec[10];
                item.SubItems.Add(filled);
                var user = rec[11];
                item.SubItems.Add(user);
                var mess = rec[12];
                item.SubItems.Add(mess.EndsWith("автоматически") ? "" : mess);
                _reportrows.Add(item);
                row++;
            }
            UpdateColumnWidths(lvLogView);
            if (print)
            {
                return;
            }
            lvLogView.BeginUpdate();
            try
            {
                lvLogView.Items.Clear();
                lvLogView.Items.AddRange(_reportrows.ToArray());
            }
            finally
            {
                lvLogView.EndUpdate();
            }
        }