Beispiel #1
0
        private bool FindLast(string name, out WaterDataPoint last)
        {
            last = null;
            foreach (object obj in _wdpSet)
            {
                ArrayList      array = (ArrayList)obj;
                WaterDataPoint wdp   = (WaterDataPoint)array[array.Count - 1];
                if (wdp.Name == name)
                {
                    last = wdp;
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        private void UpdateLast(WaterDataPoint last)
        {
            foreach (object obj in _wdpSet)
            {
                ArrayList      array = (ArrayList)obj;
                WaterDataPoint wdp   = (WaterDataPoint)array[0];
                if (wdp.Name == last.Name)
                {
                    array.Add(last);
                    return;
                }
            }

            ArrayList newarray = new ArrayList(31);     // 31 days

            newarray.Add(last);
            _wdpSet.Add(newarray);
        }
Beispiel #3
0
        public void Process(string name, DateTime dt, float val)
        {
            WaterDataPoint wdp = new WaterDataPoint(name, dt, val);
            WaterDataPoint last;

            if (FindLast(name, out last))
            {
                TimeSpan ts = dt - last.Dt;
                if (ts.Days == 1)
                {
                    float usedwater = val - last.Val;
                    last.UsedWater = usedwater;
                }
            }

            // set wdp -> last
            UpdateLast(wdp);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        public void Export()
        {
            // (row, col)
            //
            // StationName form (4,1)  row ++
            // Date        from (3,2)  col ++
            DateTime dt1 = DateTime.Now;

            Excel.ApplicationClass excel = OpenExcel();
            DateTime dt2 = DateTime.Now;

            MsgBox.Show("open excel: ", (dt2 - dt1).ToString());
            if (excel == null)
            {
                return;
            }

            excel.Cells[1, 1] = GetReportTitle();
            WriteDate(excel, this._beginDate, this._endDate);

            int rowOffset = 4;
            int colOffset = 2;

//            for( int i=0; i<_wccrSet.Count; i++ )
//            {
//                WccResultsCollection wccs = _wccrSet[i];
//                string stname = wccs.StationName;
//                int row = rowOffset + i;
//                excel.Cells[ row, 1 ] = stname;
//
//                for( int j=0; j<wccs.Count; j++ )
//                {
//                    WccResult wccr = wccs[j];
//                    DateTime dt = wccr.Date;
//                    int wc = wccr.WastingCaloric;
//                    //int col = colOffset + j + 1;
//                    int col = GetDateCol( dt ) + colOffset;
//
//                    // 0 - 无数据
//                    // 1 - 只有一条记录无法计算
//                    //
//                    if ( wccr.WastingCaloric > 0 &&
//                        wccr.WastingCaloric != 0 &&
//                        wccr.WastingCaloric != 1 )
//                        excel.Cells[ row, col ] = wccr.WastingCaloric;
//                }
//            }

            int rowidx = 0;

            foreach (object obj in _wdpSet)
            {
                ArrayList array     = (ArrayList)obj;
                bool      writeName = false;

                foreach (object obj2 in array)
                {
                    WaterDataPoint wdp = (WaterDataPoint)obj2;
                    int            col = colOffset + GetDateCol(wdp.Dt);
                    int            row = rowOffset + rowidx;

                    if (!writeName)
                    {
                        excel.Cells[row, 1] = wdp.Name;
                        writeName           = true;
                    }
                    //if ( wdp.UsedWater != 0 )
                    excel.Cells[row, col] = wdp.UsedWater;
                }
                rowidx++;
            }

            excel.Visible = true;
        }