예제 #1
0
        private void setValue(Dictionary <string, YearSrcBean> sDic, DataTable insertDT)
        {
            try
            {
                for (int i = 0; i < insertDT.Rows.Count; i++)
                {
                    int year  = Convert.ToInt32(insertDT.Rows[i]["year"]);
                    int mscid = Convert.ToInt32(insertDT.Rows[i]["mscid"]);
                    for (int j = 1; j < 13; j++)
                    {
                        int    month    = j;
                        string key      = year + "-" + month + "-" + mscid;
                        float  iNet     = 0f;
                        float  iTotal   = 0f;
                        int    fcid     = 0;
                        byte   haveData = 0;
                        if (sDic.ContainsKey(key))
                        {
                            YearSrcBean ysb = sDic[key];
                            iTotal   = ysb.total;
                            iNet     = ysb.net;
                            fcid     = ysb.fcid;
                            haveData = ysb.haveData;
                        }
                        insertDT.Rows[i]["M" + j]  = iTotal;
                        insertDT.Rows[i]["Mn" + 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);
            }

            //  LogUtil.log("finish setting total values");
        }
예제 #2
0
        private Dictionary <string, YearSrcBean> generateSourceDic(DateTime startTime)
        {
            Dictionary <string, YearSrcBean> result = new Dictionary <string, YearSrcBean>();
            string netColum = "(";

            for (int i = 1; i <= 31; i++)
            {
                netColum += "Dn" + i;
                if (i != 31)
                {
                    netColum += "+";
                }
            }
            netColum += ") as monthNet";
            string  sql     = " select year,month,mscid,D28,D29,D30,D31,fcid,haveData," + netColum + " from Polling_Log_Sta_Month where  occurtime>= '" + startTime.ToString("yyyy-01-01") + "' and occurtime<= '" + startTime.ToString("yyyy-12-31 23:59:59") + "'";
            DataSet dataSet = sqlHelper.ExecuteDataSet(sql);

            // LogUtil.log(" finished generating source tables from Polling_Log_Sta_Month from " + startTime.ToString("yyyy - 01 - 01") + " to " + startTime.ToString("yyyy-12-31") + " ,source rows :" + dataSet.Tables[0].Rows.Count);
            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                YearSrcBean ysb = new YearSrcBean();
                ysb.year  = Convert.ToInt32(dataSet.Tables[0].Rows[i][0]);
                ysb.month = Convert.ToInt32(dataSet.Tables[0].Rows[i][1]);
                int lastday = CommonUtil.getLastDayOfMonth(new DateTime(ysb.year, ysb.month, 1));
                ysb.mscid    = Convert.ToInt32(dataSet.Tables[0].Rows[i][2]);
                ysb.total    = Convert.ToSingle(dataSet.Tables[0].Rows[i]["D" + lastday]);
                ysb.net      = Convert.ToSingle(dataSet.Tables[0].Rows[i]["monthNet"]);
                ysb.fcid     = Convert.ToInt32(dataSet.Tables[0].Rows[i]["fcid"]);
                ysb.haveData = Convert.ToByte(dataSet.Tables[0].Rows[i]["haveData"]);
                result.Add(ysb.getKey(), ysb);
            }

            LogUtil.logGenerateSource("Polling_Log_Sta_Month", startTime.ToString("yyyy-01-01 00:00:00"), startTime.ToString("yyyy-12-31 23:59:59"), dataSet.Tables[0].Rows.Count);

            return(result);
        }