private void DatabaseOperation_DataSourceAllPagesReadyEventUnattended(DataSet dataSet)
    {
        if (_unattended)
        {
            DataTable statisticsInfoDataTable = dataSet.Tables[1];

            string periodBegin = "";

            if (statisticsInfoDataTable.Rows[0]["MinStartTime"] != DBNull.Value)
            {
                DateTime minStartTime = Convert.ToDateTime(statisticsInfoDataTable.Rows[0]["MinStartTime"]);
                _minStartTime = minStartTime;

                string formattedMinStartTime = GenericHelper.FormatFileNameDate(minStartTime);

                periodBegin = formattedMinStartTime;
            }

            string periodEnd = "";

            if (statisticsInfoDataTable.Rows[0]["MaxStartTime"] != DBNull.Value)
            {
                DateTime maxStartTime = Convert.ToDateTime(statisticsInfoDataTable.Rows[0]["MaxStartTime"]);
                _maxStartTime = maxStartTime;

                string formattedMaxStartTime = GenericHelper.FormatFileNameDate(maxStartTime);

                periodEnd = formattedMaxStartTime;
            }

            _fileName = string.Format(_fileName, periodBegin, periodEnd, _totalRows);
        }

        _databaseOperation.DataSourceAllPagesReadyEvent -= DatabaseOperation_DataSourceAllPagesReadyEventUnattended;
        ExportToCsv.DoExport(dataSet.Tables[0], _fileName, _dataViewerParameters);
    }
    public static void InitializeLog()
    {
        DirectoryInfo di = new DirectoryInfo(GenericHelper.ExecPath);

        FileInfo[] logFiles = di.GetFiles(string.Format(@"{0}*.log", GenericHelper.ApplicationName));

        GenericHelper.DateCompareFileInfo dateCompareFileInfo = new GenericHelper.DateCompareFileInfo();

        Array.Sort(logFiles, dateCompareFileInfo);

        for (int i = ConfigHandler.NumberOfServiceContextLogFiles - 1; i < logFiles.Length; i++)
        {
            try
            {
                GenericHelper.DeleteFile(logFiles[i].FullName);
            }
            catch
            {
            }
        }

        _fileNameDate = GenericHelper.FormatFileNameDate(DateTime.Now);
        _log          = new StringBuilder();
    }
Ejemplo n.º 3
0
    public bool InititalizeStatisticsGeneration(string statisticsName, string filter1Name, string filter2Name, string tempPath, List <string> sendToWebServiceNames, string tempPathSendToWebService, int nameIterator)
    {
        bool success = true;

        if (!string.IsNullOrEmpty(filter1Name))
        {
            bool filter1NameExists = filter1UserControl.InitializeSavedSearch(filter1Name);

            if (filter1NameExists)
            {
                filter1UserControl.ApplyFilter();
            }
            else
            {
                OutputHandler.WriteToLog(string.Format("The requested Filter1 \"{0}\" for statistic \"{1}\" does not exist", filter1Name, statisticsName));
                success = false;
            }
        }

        if (!string.IsNullOrEmpty(filter2Name))
        {
            bool filter2NameExists = filter2UserControl.InitializeSavedSearch(filter2Name);

            if (filter2NameExists)
            {
                filter2UserControl.ApplyFilter();
            }
            else
            {
                OutputHandler.WriteToLog(string.Format("The requested Filter2 \"{0}\" for statistic \"{1}\" does not exist", filter2Name, statisticsName));
                success = false;
            }
        }

        bool statisticsNameExists = statisticUserControl1.InitializeSavedSearch(statisticsName);

        if (statisticsNameExists)
        {
            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }

            string exportCsvFileName = string.Format(@"{0}\[{1}][{2}][{3}][{4}][{5}][{6}].csv", tempPath, statisticsName, "{0}", "{1}", filter1Name, filter2Name, "{2}");
            statisticUserControl1.ExportStatisticsUnattended(exportCsvFileName);

            string periodBegin = "";

            if (statisticUserControl1.GetMinStartTime() != DateTime.MinValue)
            {
                periodBegin = GenericHelper.FormatFileNameDate(statisticUserControl1.GetMinStartTime());
            }

            string periodEnd = "";

            if (statisticUserControl1.GetMaxStartTime() != DateTime.MinValue)
            {
                periodEnd = GenericHelper.FormatFileNameDate(statisticUserControl1.GetMaxStartTime());
            }

            if (sendToWebServiceNames.Count > 0)
            {
                if (!Directory.Exists(tempPathSendToWebService))
                {
                    Directory.CreateDirectory(tempPathSendToWebService);
                }

                for (int i = 0; i < sendToWebServiceNames.Count; i++)
                {
                    if (i == nameIterator && sendToWebServiceNames[i] == statisticsName)
                    {
                        File.Copy(string.Format(exportCsvFileName, periodBegin, periodEnd, _totalRows), string.Format(@"{0}\[{1}][{2}][{3}][{4}][{5}][{6}].csv", tempPathSendToWebService, statisticsName, periodBegin, periodEnd, filter1Name, filter2Name, _totalRows));
                    }
                }
            }
        }
        else
        {
            OutputHandler.WriteToLog(string.Format("The requested statistic \"{0}\" does not exist", statisticsName));
            success = false;
        }

        return(success);
    }