Esempio n. 1
0
        private DataTable generateSourceTable(DateTime startTime)
        {
            string netColum = "(";

            for (int i = 0; i < 24; i++)
            {
                netColum += "Hn" + i;
                if (i != 23)
                {
                    netColum += "+";
                }
            }
            netColum += ") as dayNet";


            string  sql     = " select year,month,day,mscid,H23,fcid,haveData," + netColum + " from Polling_Log_Sta_Day where  occurtime>= '" + startTime.ToShortDateString() + "' and occurtime<= '" + endTime.ToString("yyyy-MM-dd 23:59:59") + "'";
            DataSet dataSet = sqlHelper.ExecuteDataSet(sql);

            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                MonthSrcBean msb = new MonthSrcBean();
                msb.year     = Convert.ToInt32(dataSet.Tables[0].Rows[i]["year"]);
                msb.month    = Convert.ToInt32(dataSet.Tables[0].Rows[i]["month"]);
                msb.day      = Convert.ToInt32(dataSet.Tables[0].Rows[i]["day"]);
                msb.mscid    = Convert.ToInt32(dataSet.Tables[0].Rows[i]["mscid"]);
                msb.total    = Convert.ToSingle(dataSet.Tables[0].Rows[i]["H23"]);
                msb.net      = Convert.ToSingle(dataSet.Tables[0].Rows[i]["dayNet"]);
                msb.fcid     = Convert.ToInt16(dataSet.Tables[0].Rows[i]["fcid"]);
                msb.haveData = Convert.ToByte(dataSet.Tables[0].Rows[i]["haveData"]);
                sDic.Add(msb.getKey(), msb);
            }
            LogUtil.logGenerateSource("Polling_Log_Sta_Day", startTime.ToString(), endTime.ToString("yyyy-MM-dd 23:59:59"), dataSet.Tables[0].Rows.Count);
            return(dataSet.Tables[0]);// dataSet.Tables[0];
        }
Esempio n. 2
0
        private void setValue(DataTable insertDT)
        {
            try
            {
                for (int i = 0; i < insertDT.Rows.Count; i++)
                {
                    int year  = Convert.ToInt32(insertDT.Rows[i]["year"]);
                    int month = Convert.ToInt32(insertDT.Rows[i]["month"]);
                    int mscid = Convert.ToInt32(insertDT.Rows[i]["mscid"]);

                    for (int j = 1; j < 32; j++)
                    {
                        string key      = year + "-" + month + "-" + j + "-" + mscid;
                        float  iNet     = 0f;
                        float  iTotal   = 0f;
                        int    fcid     = 0;
                        byte   haveData = 0;
                        if (sDic.ContainsKey(key))
                        {
                            MonthSrcBean msb = sDic[key];
                            iTotal   = msb.total;
                            iNet     = msb.net;
                            fcid     = msb.fcid;
                            haveData = msb.haveData;
                        }
                        insertDT.Rows[i]["D" + j]  = iTotal;
                        insertDT.Rows[i]["Dn" + j] = iNet;
                        if (fcid != 0)
                        {
                            insertDT.Rows[i]["fcid"] = fcid;
                        }

                        if (haveData != 0)
                        {
                            insertDT.Rows[i]["haveData"] = haveData;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LogUtil.log(e.StackTrace.ToString());
                LogUtil.log(e.Message);
            }
        }