/// <summary>
        /// QueryReportData
        /// </summary>
        /// <param name="strIdList"></param>
        /// <param name="bCompress"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public IDictionary<string, NameValueCollection> QueryTopnMonitorInfo()
        {
            //��֯�������
            anyType2anyTypeMapEntry[] requestData = new anyType2anyTypeMapEntry[]
            {
                Helper.XfireCreateKeyValue("dowhat","QueryInfo"),
                Helper.XfireCreateKeyValue("needkey","sv_monitortype,sv_name"),
                Helper.XfireCreateKeyValue("needtype","monitor")
            };

            //ͨ��WebService������
            this.service.Url = UserPermissionContext.Instance.Url;

            RetMapInVector result = ServiceClient.GetUnivData2(requestData);
            if (!result.retbool)
            {
                if (logger.IsErrorEnabled)
                {
                    logger.Error(result.estr);
                }
                throw new Exception(result.estr);
            }

            IDictionary<string, NameValueCollection> resultData = Helper.XfireConventMapEntryToDictionary(result.vmap);

            //ͳ���������õļ�������� �� ѡ��������� + ѡ�����ָ��ļ���ʾ ...
            IMonitorTempletDao templetDao = new MonitorTempletDaoImpl();

            IDictionary<string, MonitorTemplet> topnMontiorTemplet = new Dictionary<string, MonitorTemplet>();
            try
            {
                foreach (string key in resultData.Keys)
                {
                    if (resultData[key]["sv_monitortype"] == null)
                        continue;

                    if (!topnMontiorTemplet.ContainsKey(resultData[key]["sv_monitortype"]))
                    {
                        string strTemplateId = resultData[key]["sv_monitortype"];

                        //MonitorTemplet templet = templetDao.FindById(resultData[key]["sv_monitortype"]);
                        //MonitorTemplet[] templet = templetDao.FindById(new string[] { resultData[key]["sv_monitortype"] }, true);
                        MonitorTemplet[] templet = templetDao.FindById(new string[] { resultData[key]["sv_monitortype"] }, false);
                        topnMontiorTemplet.Add(resultData[key]["sv_monitortype"], templet[0]);

                        ////���������(��FindById true ����ʵ��ѡָ��)
                        //string strTmp = topnMontiorTemplet[resultData[key]["sv_monitortype"]].Name;

                        //foreach (string key1 in topnMontiorTemplet[resultData[key]["sv_monitortype"]].Returns.Keys)
                        //{
                        //    //���ָ��
                        //    strTmp = topnMontiorTemplet[resultData[key]["sv_monitortype"].ToString()].Returns[key1]["sv_label"];
                        //}
                    }
                }
            }
            catch (Exception e)
            {
                ;
            }

            return resultData;
        }
Example #2
0
        /// <summary>
        /// QueryReportData
        /// </summary>
        /// <param name="strIdList"></param>
        /// <param name="bCompress"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public IDictionary <string, NameValueCollection> QueryTopnMonitorInfo()
        {
            //组织输入参数
            anyType2anyTypeMapEntry[] requestData = new anyType2anyTypeMapEntry[]
            {
                Helper.XfireCreateKeyValue("dowhat", "QueryInfo"),
                Helper.XfireCreateKeyValue("needkey", "sv_monitortype,sv_name"),
                Helper.XfireCreateKeyValue("needtype", "monitor")
            };

            //通过WebService查数据
            this.service.Url = UserPermissionContext.Instance.Url;

            RetMapInVector result = ServiceClient.GetUnivData2(requestData);

            if (!result.retbool)
            {
                if (logger.IsErrorEnabled)
                {
                    logger.Error(result.estr);
                }
                throw new Exception(result.estr);
            }


            IDictionary <string, NameValueCollection> resultData = Helper.XfireConventMapEntryToDictionary(result.vmap);


            //统计所有已用的监测器类型 及 选监测器类型 + 选监测器指标的简单演示 ...
            IMonitorTempletDao templetDao = new MonitorTempletDaoImpl();

            IDictionary <string, MonitorTemplet> topnMontiorTemplet = new Dictionary <string, MonitorTemplet>();

            try
            {
                foreach (string key in resultData.Keys)
                {
                    if (resultData[key]["sv_monitortype"] == null)
                    {
                        continue;
                    }

                    if (!topnMontiorTemplet.ContainsKey(resultData[key]["sv_monitortype"]))
                    {
                        string strTemplateId = resultData[key]["sv_monitortype"];

                        //MonitorTemplet templet = templetDao.FindById(resultData[key]["sv_monitortype"]);
                        //MonitorTemplet[] templet = templetDao.FindById(new string[] { resultData[key]["sv_monitortype"] }, true);
                        MonitorTemplet[] templet = templetDao.FindById(new string[] { resultData[key]["sv_monitortype"] }, false);
                        topnMontiorTemplet.Add(resultData[key]["sv_monitortype"], templet[0]);

                        ////监测器类型(用FindById true 即可实现选指标)
                        //string strTmp = topnMontiorTemplet[resultData[key]["sv_monitortype"]].Name;

                        //foreach (string key1 in topnMontiorTemplet[resultData[key]["sv_monitortype"]].Returns.Keys)
                        //{
                        //    //监测指标
                        //    strTmp = topnMontiorTemplet[resultData[key]["sv_monitortype"].ToString()].Returns[key1]["sv_label"];
                        //}
                    }
                }
            }
            catch (Exception e)
            {
                ;
            }

            return(resultData);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="templateFile"></param>
        /// <param name="IsTopN"></param>
        public void WriteAllReportHTML(string templateFile, bool IsTopN)
        {
            try
            {
                bool bGen = false;
                bool bReportGen = true;

                string name = "";
                string strTmp = "";
                string strGenSection = "";
                string strGenKey = "";
                string strGenValue = "";
                string strGroupRight = "";
                string strReportName = "";
                string strBaseDirectory = "";
                string strZipFileName = "";

                DateTime tmEnd = DateTime.Now;
                DateTime tmStart = DateTime.Now;

                if (IsTopN)
                {
                    file = iniFileDao.GetIniFile("topnreportset.ini");
                    StatsTable = new DataTable();
                    StatsTable.Columns.Add("hashKey");
                    StatsTable.Columns.Add("����");//StatName
                    StatsTable.Columns.Add("����ֵ����");//StatReturnName
                    StatsTable.Columns.Add("���ֵ");//StatMax
                    StatsTable.Columns.Add("��Сֵ");//StatMin
                    StatsTable.Columns.Add("ƽ��ֵ", typeof(double));//StatAverage
                    StatsTable.Columns.Add("���һ��");//StatLatest
                    StatsTable.Columns.Add("���ֵʱ��");
                }
                else
                {
                    file = iniFileDao.GetIniFile("reportset.ini");
                }

                //�����û��������� �������б���
                foreach (string key in file.Keys)
                {
                    strGroupRight = "";
                    strReportName = "";
                    bGen = false;
                    bReportGen = false;

                    string strReportFile = "";

                    //�Ƿ�����ʱ��
                    string strGenerate = file[key]["Generate"];

                    if (strGenerate == "" || strGenerate == null)
                        continue;

                    int nHours = int.Parse(strGenerate);
                    if (nHours == DateTime.Now.Hour)
                    {
                        bGen = true;
                    }

                    //����ֹ ������ ִ����һ������
                    if (file[key]["Deny"] == "No")
                    {
                        strGroupRight = file[key]["GroupRight"];

                        if (strGroupRight == "" || strGroupRight == null)
                            continue;

                        //string[] monitorList = strGroupRight.Split(',');

                        //δ������ʱ�� ������ ִ����һ������
                        if (bGen)
                        {
                            //��ȡ��������ʱ���
                            if (file[key]["Period"] == "�ձ�")
                            {
                                string szEndTime = file[key]["EndTime"];
                                string szStartTime = file[key]["StartTime"];
                                //szEndTime = "12:30";

                                string szHour = "00";
                                string szMinute = "00";

                                if (IsTopN)
                                {
                                    szEndTime = "00";
                                    szStartTime = "00";
                                }
                                else
                                {
                                    if (szEndTime == "" || szEndTime == null)
                                        continue;
                                    if (szStartTime == "" || szStartTime == null)
                                        continue;

                                    int pos = szEndTime.IndexOf(":", 0);
                                    if (pos <= 0)
                                        continue;

                                    szHour = szEndTime.Substring(0, pos);
                                    szMinute = szEndTime.Substring(pos + 1, szEndTime.Length - pos - 1);
                                }

                                tmEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, int.Parse(szHour), int.Parse(szMinute), 0);
                                //tmEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, int.Parse(szStartTime), int.Parse(szEndTime), 0);

                                tmStart = tmEnd.Subtract(new TimeSpan(1, 0, 0, 0, 0));
                                bReportGen = true;
                                this.DatePart = "day";
                            }
                            else if (file[key]["Period"] == "�ܱ�")
                            {
                                if (file[key]["WeekEndTime"] == "" || file[key]["WeekEndTime"] == null)
                                    continue;

                                int nWeekDay;
                                nWeekDay = int.Parse(file[key]["WeekEndTime"]);
                                if ((int)(DateTime.Now.DayOfWeek) == nWeekDay)
                                {
                                    tmEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                                    tmStart = tmEnd.Subtract(new TimeSpan(7, 0, 0, 0, 0));
                                    bReportGen = true;
                                }
                                this.DatePart = "week";
                            }
                            else if (file[key]["Period"] == "�±�")
                            {
                                if ((int)DateTime.Now.Day == 1)
                                {
                                    if (DateTime.Now.Month == 1)
                                    {
                                        tmStart = new DateTime(DateTime.Now.Year - 1, 12, 1, 0, 0, 0);
                                        tmEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0);
                                    }
                                    else
                                    {
                                        tmStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, 1, 0, 0, 0);
                                        tmEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0);
                                    }

                                    bReportGen = true;
                                }
                                this.DatePart = "month";
                            }
                            else
                            {

                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }

                    //�� ���ɴ˱��� ��
                    if (bReportGen)
                    {
                        if (IsTopN)
                        {
                            strReportName = tmStart.ToString() + tmEnd.ToString() + key + "TopN";
                        }
                        else
                        {
                            strReportName = tmStart.ToString() + tmEnd.ToString() + key;
                        }

                        //��ѯ������������
                        int index = 200;//һ�β�ѯ��200��������
                        if (IsTopN)
                        {
                            IDictionary<string, NameValueCollection> monitoidToType = impl.QueryTopnMonitorInfo();
                            IDictionary<string, MonitorTemplet> topnMontiorTemplet = new Dictionary<string, MonitorTemplet>();
                            IMonitorTempletDao templetDao = new MonitorTempletDaoImpl();
                            foreach (string key1 in monitoidToType.Keys)
                            {
                                if (monitoidToType[key1]["sv_monitortype"] == null)
                                    continue;
                                if (!topnMontiorTemplet.ContainsKey(monitoidToType[key1]["sv_monitortype"]))
                                {
                                    MonitorTemplet[] templet = templetDao.FindById(new string[] { monitoidToType[key1]["sv_monitortype"] }, true);
                                    topnMontiorTemplet.Add(monitoidToType[key1]["sv_monitortype"], templet[0]);
                                }
                            }

                            string strSelMonitorType = file[key]["Type"];//�û�ѡ��ļ��������
                            string strMark = file[key]["Mark"];
                            int strCount = int.Parse(file[key]["Count"]);
                            string strSort = file[key]["Sort"];
                            if (strSelMonitorType == "" || strSelMonitorType == null)
                                continue;

                            if (strMark == "" || strMark == null)
                                continue;

                            strTmp = "";
                            foreach (string strMonitorId in strGroupRight.Split(','))
                            {
                                if (strMonitorId != "" && monitoidToType.Keys.Contains(strMonitorId))
                                {
                                    if (topnMontiorTemplet[monitoidToType[strMonitorId]["sv_monitortype"]].Name == strSelMonitorType)
                                    {
                                        strTmp += strMonitorId;
                                        strTmp += ",";
                                    }
                                }
                            }

                            //��ּ����ID,���з�����ѯ��
                            int splitLength = strTmp.Split(',').Length;
                            this.StatsTable.Rows.Clear();
                            this.QueryReportData.Rows.Clear();
                            if (splitLength > index)
                            {
                                int sect = splitLength / index;
                                DataTable StatsTableTimp = StatsTable.Clone();
                                string[] strArray = strTmp.Split(',');
                                for (int split = 0; split < sect; split++)
                                {
                                    DataTable QueryReportDataTemp = QueryReportData.Clone();
                                    string splitString = "";
                                    int _splitCount = split * index;
                                    for (int splitCount = _splitCount; splitCount < (split + 1) * index; splitCount++)
                                    {
                                        splitString += strArray[splitCount];
                                        splitString += ",";
                                    }
                                    QueryReportDataTemp = impl.QueryReportData(splitString, true, false, tmStart, tmEnd);
                                    foreach (DataRow QrdrTemp in QueryReportDataTemp.Rows)
                                    {
                                        QueryReportData.ImportRow(QrdrTemp);
                                    }
                                    foreach (DataRow StdrTemp in impl.StatsTable.Rows)
                                    {
                                        StatsTableTimp.ImportRow(StdrTemp);
                                    }
                                }

                                string splitStringLast = "";
                                int _splitCountLast = sect * index;
                                for (int splitCount = _splitCountLast; splitCount < splitLength; splitCount++)
                                {
                                    splitStringLast += strArray[splitCount];
                                    splitStringLast += ",";
                                }
                                DataTable QueryReportDataTempLast = impl.QueryReportData(splitStringLast, true, false, tmStart, tmEnd);
                                foreach (DataRow QrdrTemp in QueryReportDataTempLast.Rows)
                                {
                                    QueryReportData.ImportRow(QrdrTemp);
                                }
                                foreach (DataRow StdrTemp in impl.StatsTable.Rows)
                                {
                                    StatsTableTimp.ImportRow(StdrTemp);
                                }

                                ChangeColumnType(StatsTableTimp);
                            }
                            else
                            {
                                QueryReportData = impl.QueryReportData(strTmp, true, false, tmStart, tmEnd);
                                ChangeColumnType(impl.StatsTable);
                            }

                            //QueryReportData = impl.QueryReportData(strTmp, true, false, tmStart, tmEnd);
                            //this.StatsTable.Rows.Clear();
                            //for (int a = 0; a < impl.StatsTable.Rows.Count; a++)
                            //{
                            //    DataRow dr = this.StatsTable.NewRow();
                            //    for (int b = 0; b < impl.StatsTable.Columns.Count; b++)
                            //    {
                            //        if (b == 5)
                            //        {
                            //            dr[b] = double.Parse(impl.StatsTable.Rows[a][b].ToString());
                            //        }
                            //        else
                            //        {
                            //            dr[b] = impl.StatsTable.Rows[a][b].ToString();
                            //        }
                            //    }
                            //    this.StatsTable.Rows.Add(dr);
                            //}
                            //DataView dv = this.StatsTable.DefaultView;
                            DataView dv = new DataView(this.StatsTable);
                            dv.Sort = "ƽ��ֵ desc";
                            //���Դ���
                            //***********************************************
                            if (key == "AqcTestSNMP Cpu")
                            {
                                this.DataTableToExcel(dv.ToTable(), "c:\\" + key + DateTime.Now.ToShortDateString() + ".csv");
                                this.DataTableToExcel(this.StatsTable, "c:\\" + key + "stat" + DateTime.Now.ToShortDateString() + ".csv");
                            }
                            //*************************************************
                            selectDataTable(dv.ToTable(), strMark, strCount, strSort);
                        }
                        else
                        {
                            impl.ReturnFilter = "sv_primary,sv_drawimage";
                            int splitLength = strGroupRight.Split(',').Length;
                            this.StatsTable.Rows.Clear();
                            this.QueryReportData.Rows.Clear();
                            this.dstrTable.Rows.Clear();
                            if (file[key]["Parameter"].Equals("Yes"))
                            {
                                //��ּ����ID,���з�����ѯ��
                                if (splitLength > index)
                                {
                                    int sect = splitLength / index;
                                    DataTable StatsTableTimp = StatsTable.Clone();
                                    string[] strArray = strGroupRight.Split(',');
                                    imgTables = new Dictionary<string, DataTable>();
                                    for (int split = 0; split < sect; split++)
                                    {
                                        DataTable QueryReportDataTemp = QueryReportData.Clone();
                                        string splitString = "";
                                        int _splitCount = split * index;
                                        for (int strCount = _splitCount; strCount < (split + 1) * index; strCount++)
                                        {
                                            splitString += strArray[strCount];
                                            splitString += ",";
                                        }
                                        QueryReportDataTemp = impl.QueryReportData(splitString, true, true, tmStart, tmEnd);
                                        foreach (DataRow QrdrTemp in QueryReportDataTemp.Rows)
                                        {
                                            QueryReportData.ImportRow(QrdrTemp);
                                        }
                                        foreach (DataRow StdrTemp in impl.StatsTable.Rows)
                                        {
                                            StatsTable.ImportRow(StdrTemp);
                                        }
                                        foreach (KeyValuePair<string, DataTable> Kv in impl.ImgTableHash)
                                        {
                                            if (!imgTables.ContainsKey(Kv.Key))
                                            {
                                                imgTables.Add(Kv);
                                            }
                                        }
                                        foreach (DataRow dr in impl.DstrTable.Rows)
                                        {
                                            this.dstrTable.ImportRow(dr);
                                        }
                                    }

                                    string splitStringLast = "";
                                    int _splitCountLast = sect * index;
                                    for (int strCount = _splitCountLast; strCount < splitLength; strCount++)
                                    {
                                        splitStringLast += strArray[strCount];
                                        splitStringLast += ",";
                                    }
                                    DataTable QueryReportDataTempLast = impl.QueryReportData(splitStringLast, true, true, tmStart, tmEnd);
                                    foreach (DataRow QrdrTemp in QueryReportDataTempLast.Rows)
                                    {
                                        QueryReportData.ImportRow(QrdrTemp);
                                    }
                                    foreach (DataRow StdrTemp in impl.StatsTable.Rows)
                                    {
                                        StatsTable.ImportRow(StdrTemp);
                                    }
                                    foreach (KeyValuePair<string, DataTable> Kv in impl.ImgTableHash)
                                    {
                                        if (!imgTables.ContainsKey(Kv.Key))
                                        {
                                            imgTables.Add(Kv);
                                        }
                                    }
                                    foreach (DataRow dr in impl.DstrTable.Rows)
                                    {
                                        this.dstrTable.ImportRow(dr);
                                    }
                                    //imgTables = impl.ImgTableHash;
                                }
                                else
                                {
                                    QueryReportData = impl.QueryReportData(strGroupRight, true, true, tmStart, tmEnd);
                                    StatsTable = impl.StatsTable;
                                    imgTables = impl.ImgTableHash;
                                }
                            }
                            else
                            {
                                if (splitLength > index)
                                {
                                    int sect = splitLength / index;
                                    DataTable StatsTableTimp = StatsTable.Clone();
                                    string[] strArray = strGroupRight.Split(',');
                                    imgTables = new Dictionary<string, DataTable>();
                                    for (int split = 0; split < sect; split++)
                                    {
                                        DataTable QueryReportDataTemp = QueryReportData.Clone();
                                        string splitString = "";
                                        int _splitCount = split * index;
                                        for (int strCount = _splitCount; strCount < (split + 1) * index; strCount++)
                                        {
                                            splitString += strArray[strCount];
                                            splitString += ",";
                                        }
                                        QueryReportDataTemp = impl.QueryReportData(splitString, true, false, tmStart, tmEnd);
                                        foreach (DataRow QrdrTemp in QueryReportDataTemp.Rows)
                                        {
                                            QueryReportData.ImportRow(QrdrTemp);
                                        }
                                        foreach (DataRow StdrTemp in impl.StatsTable.Rows)
                                        {
                                            StatsTable.ImportRow(StdrTemp);
                                        }
                                        foreach (KeyValuePair<string, DataTable> Kv in impl.ImgTableHash)
                                        {
                                            if (!imgTables.ContainsKey(Kv.Key))
                                            {
                                                imgTables.Add(Kv);
                                            }
                                        }
                                    }

                                    string splitStringLast = "";
                                    int _splitCountLast = sect * index;
                                    for (int strCount = _splitCountLast; strCount < splitLength; strCount++)
                                    {
                                        splitStringLast += strArray[strCount];
                                        splitStringLast += ",";
                                    }
                                    DataTable QueryReportDataTempLast = impl.QueryReportData(splitStringLast, true, false, tmStart, tmEnd);
                                    foreach (DataRow QrdrTemp in QueryReportDataTempLast.Rows)
                                    {
                                        QueryReportData.ImportRow(QrdrTemp);
                                    }
                                    foreach (DataRow StdrTemp in impl.StatsTable.Rows)
                                    {
                                        StatsTable.ImportRow(StdrTemp);
                                    }
                                    foreach (KeyValuePair<string, DataTable> Kv in impl.ImgTableHash)
                                    {
                                        if (!imgTables.ContainsKey(Kv.Key))
                                        {
                                            imgTables.Add(Kv);
                                        }
                                    }
                                    //imgTables = impl.ImgTableHash;
                                }
                                else
                                {
                                    QueryReportData = impl.QueryReportData(strGroupRight, true, false, tmStart, tmEnd);
                                    StatsTable = impl.StatsTable;
                                    imgTables = impl.ImgTableHash;
                                }
                            }

                            //if (file[key]["Parameter"].Equals("Yes"))
                            //{
                            //    QueryReportData = impl.QueryReportData(strGroupRight, true, true, tmStart, tmEnd);
                            //}
                            //else
                            //{
                            //    QueryReportData = impl.QueryReportData(strGroupRight, true, false, tmStart, tmEnd);
                            //}
                            //StatsTable = impl.StatsTable;
                            //imgTables = impl.ImgTableHash;
                        }

                        //���ɱ���ͼƬ�ļ�
                        Savepictures(key, tmStart.ToString(), tmEnd.ToString(), IsTopN);

                        //����ģ�岢�󶨱���
                        WriteLogFile("nvelocity.properties");
                        CreateVM(templateFile, IsTopN,key);
                        Velocity.SetProperty(RuntimeConstants.INPUT_ENCODING, "GB2312");
                        Velocity.SetProperty(RuntimeConstants.OUTPUT_ENCODING, "GB2312");
                        Velocity.Init(BasePath + "\\nvelocity.properties");

                        //...

                        //�Ƿ��г���ֵ

                        //�Ƿ��г�����

                        //�Ƿ��г�Σ��

                        //�Ƿ��г���ֹ

                        VelocityContext context = new VelocityContext();
                        //context.Put("RunName", RunName);
                        //context.Put("RunRight", RunRight);
                        //context.Put("Rundanger", Rundanger);
                        //context.Put("RunWrong", RunWrong);
                        //context.Put("RunPass", RunPass);
                        //context.Put("RunLatest", RunLatest);

                        //context.Put("StatName", StatName);
                        //context.Put("StatReturnName", StatReturnName);
                        //context.Put("StatMax", StatMax);
                        //context.Put("StatMin", StatMin);
                        //context.Put("StatAverage", StatAverage);
                        //context.Put("StatLatest", StatLatest);
                        if (IsTopN)
                        {
                            context.Put("MakeTitleTable", MakeTitle(file[key]["Title"].ToString().Split('|')[0], tmStart.ToString(), tmEnd.ToString()));
                            context.Put("MakeTopNhtmltable", MakeTopNhtmltable());
                            context.Put("MakeTopNhtmlPicture", MakeTopNhtmlPicture(key, tmStart.ToString(), tmEnd.ToString()));
                        }
                        else
                        {
                            //�г���ϸ����
                            bool IsStatusResultVisible = file[key]["Parameter"].Equals("Yes");
                            //�Ƿ��г���ֵ
                            bool IsListClicketVisible = file[key]["ListClicket"].Equals("Yes");
                            //�Ƿ��г�����
                            bool IsListErrorVisible = file[key]["ListError"].Equals("Yes");
                            //�Ƿ��г�Σ��
                            bool IsListDangerVisible = file[key]["ListDanger"].Equals("Yes");
                            //�Ƿ��г���ֹ
                            bool IsDenyVisible = file[key]["Deny"].Equals("Yes");
                            //�Ƿ��г�ͼƬ
                            bool IsGraphic = file[key]["Graphic"].Equals("Yes");
                            DataTable tb = new DataTable();
                            DataColumn c1 = new DataColumn("����");
                            DataColumn c2 = new DataColumn("ʱ��");
                            DataColumn c3 = new DataColumn("״̬");
                            DataColumn c4 = new DataColumn("����ֵ");
                            DataColumn[] c5 = { c1, c2, c3, c4 };
                            tb.Columns.AddRange(c5);
                            if (file[key]["ListError"].Equals("Yes"))
                            {
                                tb.Rows.Clear();
                                foreach (DataRow dr in impl.DstrTable.Select("״̬='Error'"))
                                {
                                    tb.Rows.Add(dr.ItemArray);
                                }
                                context.Put("MakeErrorDataStrTable", MakeDataStrTable(tb));
                            }
                            if (file[key]["ListDanger"].Equals("Yes"))
                            {
                                tb.Rows.Clear();
                                foreach (DataRow dr in impl.DstrTable.Select("״̬='warning'"))
                                {
                                    tb.Rows.Add(dr.ItemArray);
                                }
                                context.Put("MakeDangerDataStrTable", MakeDataStrTable(tb));
                            }

                            context.Put("MakeTitleTable", MakeTitle(file[key]["Title"].ToString().Split('|')[0], tmStart.ToString(), tmEnd.ToString()));
                            //context.Put("RunQueryReportData", RunQueryReportData);
                            context.Put("MakeRunHTMLTable", MakeRunHTMLTable());
                            context.Put("MakeStatehtmltable", MakeStatehtmltable(key, tmStart.ToString(), tmEnd.ToString()));
                            context.Put("MakeStatehtmlPicture", MakeStatehtmlPicture(key, tmStart.ToString(), tmEnd.ToString()));
                            if (file[key]["Parameter"].Equals("Yes"))
                            {
                                context.Put("MakeDataStrTable", MakeDataStrTable(this.dstrTable));
                            }
                            else
                            {
                                context.Put("MakeDataStrTable", MakeDataStrTable(impl.DstrTable));
                            }

                            context.Put("IsStatusResultVisible", IsStatusResultVisible);//�г�״̬�ܽ�
                            context.Put("IsListClicketVisible", IsListClicketVisible);//�Ƿ��г���ֵ
                            context.Put("IsListErrorVisible", IsListErrorVisible);//�Ƿ��г�����
                            context.Put("IsListDangerVisible", IsListDangerVisible);//�Ƿ��г�Σ��
                            context.Put("IsDenyVisible", IsDenyVisible); //�Ƿ��г���ֹ
                            context.Put("IsGraphic", IsGraphic);//�Ƿ��г�ͼƬ
                        }

                        //���ɱ��� html
                        Template template = null;
                        try
                        {
                            //��ȡģ��
                            //�����ĸ�Ŀ¼���棿
                            template = Velocity.GetTemplate("\\ReportTemplate\\" + templateFile);
                            //���HTML
                            if (template != null)
                            {
                                strTmp = strReportName.Replace(" ", "_").Replace(":", "_").Replace("*", "_").Replace("/", "_").
                                      Replace("\\", "_").Replace("?", "_").Replace("|", "_").Replace("<", "_").Replace(">", "_").Replace("\"", "_");
                                strReportName = strTmp;
                                StringWriter writer = new StringWriter();
                                template.Merge(context, writer);
                                string p =  BasePath + "ReportTemplate\\" + DatePart + "\\" + strReportName;

                                if (!Directory.Exists(p))
                                {
                                    Directory.CreateDirectory(p);
                                }

                                strReportFile = p + "\\" + strReportName + ".html";

                                StreamWriter s = new StreamWriter(strReportFile, false, System.Text.Encoding.UTF8);
                                s.WriteLine(writer.ToString());
                                s.Flush();
                                s.Close();
                            }
                        }
                        catch (ResourceNotFoundException xxx)
                        {
                            MessageBox.Show(xxx.Message + "�����ģ���ļ�����ʾ��Ŀ¼");
                        }
                        catch (ParseErrorException pee)
                        {
                            MessageBox.Show(pee.Message);
                        }

                        //д��Ϣ�� reportgenerate.ini
                        strGenKey = "";
                        strGenValue = "";
                        strTmp = "";

                        //section�ڸ�ʽ��������$��ʼʱ��$��ֹʱ��$
                        strGenSection = file[key]["Title"].ToString().Split('|')[1] + "$" + tmStart.ToString() + "$" + tmEnd.ToString() + "$";
                        if (!IsTopN)
                        {
                            for (int i = 0; i < imgTables.Count; i++)
                            {
                                //��ֵ��ʽ���������$����ֵ����$
                                strTmp = StatsTable.Rows[i][1].ToString() + "$" + StatsTable.Rows[i][2].ToString() + "$";
                                strGenKey = strTmp.Replace(" ", "_").Replace(":", "_").Replace("*", "_").Replace("/", "_").
                                        Replace("\\", "_").Replace("?", "_").Replace("|", "_").Replace("<", "_").Replace(">", "_").Replace("\"", "_");

                                //ֵ��ʽ����Сֵ$ƽ��ֵ$���ֵ$
                                strTmp = StatsTable.Rows[i][4].ToString() + "$" + StatsTable.Rows[i][5].ToString() + "$" + StatsTable.Rows[i][3].ToString();
                                strGenValue = strTmp.Replace(" ", "_").Replace(":", "_").Replace("*", "_").Replace("/", "_").
                                        Replace("\\", "_").Replace("?", "_").Replace("|", "_").Replace("<", "_").Replace(">", "_").Replace("\"", "_");

                                //дIni
                                //iniFileDao.WriteIniFileString("reportgenerate.ini", strGenSection, strGenKey, strGenValue);
                                iniFileDao.WriteIniFileString("mmcreportgenerate.ini", strGenSection, strGenKey, strGenValue);
                            }
                        }
                        else
                        {
                            //��ֵ��ʽ��$����ֵ����$
                            strTmp = file[key]["Mark"];
                            if (strTmp == "")
                            {
                                strTmp = file[key]["Type"];
                            }

                            strGenKey = "$" + strTmp + "$";

                            //ֵ��ʽ����Сֵ$ƽ��ֵ$���ֵ$  --> ��ʱû����
                            //strTmp = StatsTable.Rows[i][4].ToString() + "$" + StatsTable.Rows[i][5].ToString() + "$" + StatsTable.Rows[i][3].ToString();
                            //strGenValue = strTmp.Replace(" ", "_").Replace(":", "_").Replace("*", "_").Replace("/", "_").
                            //        Replace("\\", "_").Replace("?", "_").Replace("|", "_").Replace("<", "_").Replace(">", "_").Replace("\"", "_");

                            //дIni
                            //iniFileDao.WriteIniFileString("topnreportgenerate.ini", strGenSection, strGenKey, strGenValue);
                            iniFileDao.WriteIniFileString("mmctopnreportgenerate.ini", strGenSection, strGenKey, strGenValue);
                        }

                        //����û��ṩ�� �ʼ���ַ ��ѹ�������ļ�������
                        if (bSendMail && file[key]["EmailSend"] != "" && file[key]["EmailSend"] != null)
                        {
                            //���淢�͵�ַ
                            strToInfo = file[key]["EmailSend"];

                            //�齨ѹ�����ļ���
                            strBaseDirectory = "";
                            strZipFileName = "";
                            string p = BasePath + "ReportTemplate\\" + DatePart + "\\" + strReportName;
                            if (!IsTopN)
                            {
                                //�齨ѹ����Ŀ¼
                                if (!Directory.Exists(BasePath + "ReportTemplate\\statreport"))
                                {
                                    Directory.CreateDirectory(BasePath + "ReportTemplate\\statreport");
                                    Directory.CreateDirectory(BasePath + "ReportTemplate\\statreport\\jpeg");
                                }
                                else
                                {
                                    CleanFiles(BasePath + "ReportTemplate\\statreport");
                                    CleanFiles(BasePath + "ReportTemplate\\statreport");

                                    Directory.CreateDirectory(BasePath + "ReportTemplate\\statreport");
                                    Directory.CreateDirectory(BasePath + "ReportTemplate\\statreport\\jpeg");
                                }

                                strBaseDirectory = BasePath + "ReportTemplate\\statreport\\";
                                strZipFileName = BasePath + "ReportTemplate\\statreport" + key.Split('|')[1] + ".zip";

                                //����html�ļ�
                                File.Copy(strReportFile, strBaseDirectory + strReportName + ".html");

                                //����jpegͼƬ�ļ�
                                for (int i = 0; i < imgTables.Count; i++)
                                {
                                    strTmp = key.Split('|')[1] + tmStart.ToString() + tmEnd.ToString() + StatsTable.Rows[i][1].ToString();
                                    name = strTmp.Replace(" ", "_").Replace(":", "_").Replace("*", "_").Replace("/", "_").
                                            Replace("\\", "_").Replace("?", "_").Replace("|", "_").Replace("<", "_").Replace(">", "_").Replace("\"", "_");

                                    if (File.Exists(p + "\\jpeg\\" + i + name + ".Png"))
                                        File.Copy(p + "\\jpeg\\" + i + name + ".Png",
                                            strBaseDirectory + "\\jpeg\\" + i + name + ".Png");
                                }
                            }
                            else
                            {
                                //�齨ѹ����Ŀ¼
                                if (!Directory.Exists(BasePath + "ReportTemplate\\topnreport"))
                                {
                                    Directory.CreateDirectory(BasePath + "ReportTemplate\\topnreport");
                                    Directory.CreateDirectory(BasePath + "ReportTemplate\\topnreport\\jpeg");
                                }
                                else
                                {
                                    CleanFiles(BasePath + "ReportTemplate\\topnreport");
                                    CleanFiles(BasePath + "ReportTemplate\\topnreport");

                                    Directory.CreateDirectory(BasePath + "ReportTemplate\\topnreport");
                                    Directory.CreateDirectory(BasePath + "ReportTemplate\\topnreport\\jpeg");
                                }

                                strBaseDirectory = BasePath + "ReportTemplate\\topnreport\\";
                                strZipFileName = BasePath + "ReportTemplate\\topnreport" + key.Split('|')[1] + ".zip";

                                //����html�ļ�
                                File.Copy(strReportFile, strBaseDirectory + strReportName + ".html");

                                //����jpegͼƬ�ļ�
                                strTmp = key + tmStart.ToString() + tmEnd.ToString() + "TopN";
                                name = strTmp.Replace(" ", "_").Replace(":", "_").Replace("*", "_").Replace("/", "_").
                                            Replace("\\", "_").Replace("?", "_").Replace("|", "_").Replace("<", "_").Replace(">", "_").Replace("\"", "_");
                                name += ".Png";

                                if (File.Exists(p + "\\jpeg\\" + name))
                                    File.Copy(p + "\\jpeg\\" + name, strBaseDirectory + "\\jpeg\\" + name);
                            }

                            //ѹ��Ŀ¼
                            ZipFileMain(strBaseDirectory, strZipFileName);

                            //�����ʼ�
                            if (!IsTopN)
                            {
                                SendSMTPEMail(strSmtpServerInfo, strFromInfo, strFromUserInfo, strFromPwdInfo, strToInfo, "statreport", "statreport", strZipFileName);
                            }
                            else
                            {
                                SendSMTPEMail(strSmtpServerInfo, strFromInfo, strFromUserInfo, strFromPwdInfo, strToInfo, "topnreport", "topnreport", strZipFileName);
                            }
                        }
                    }

                    System.Threading.Thread.Sleep(50);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }