Пример #1
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string strError = "";

            string strStart = "";
            string strEnd   = "";

            StringUtil.ParseTwoPart(this.textBox_dateRange.Text, "-",
                                    out strStart,
                                    out strEnd);

            string        strWarning = "";
            List <string> dates      = null;
            int           nRet       = OperLogLoader.MakeLogFileNames(strStart,
                                                                      strEnd,
                                                                      false, // 是否包含扩展名 ".log"
                                                                      out dates,
                                                                      out strWarning,
                                                                      out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            this.Dates = dates;

            this.RecPathList = StringUtil.SplitList(this.textBox_recPathList.Text, "\r\n");

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Пример #2
0
        // 对每个日志文件,每个日志记录进行循环
        // return:
        //      0   普通返回
        //      1   要全部中断
        int DoLoop(
            OperLogForm.Delegate_doRecord procDoRecord,
            out string strError)
        {
            strError = "";
            int nRet = 0;
            // long lRet = 0;

            List <string> LogFileNames = null;

            // TODO: 是否需要检查起止日期是否为空值?空值是警告还是就当作今天?

            string strStartDate = DateTimeUtil.DateTimeToString8(this.dateControl_start.Value);
            string strEndDate   = DateTimeUtil.DateTimeToString8(this.dateControl_end.Value);

            string strWarning = "";

            // 根据日期范围,发生日志文件名
            // parameters:
            //      strStartDate    起始日期。8字符
            //      strEndDate  结束日期。8字符
            // return:
            //      -1  错误
            //      0   成功
            nRet = OperLogLoader.MakeLogFileNames(strStartDate,
                                                  strEndDate,
                                                  true,
                                                  out LogFileNames,
                                                  out strWarning,
                                                  out strError);
            if (nRet == -1)
            {
                return(-1);
            }

            if (String.IsNullOrEmpty(strWarning) == false)
            {
                MessageBox.Show(this, strWarning);
            }

            string strStyle = "";

            if (Program.MainForm.AutoCacheOperlogFile == true)
            {
                strStyle = "autocache";
            }

            ProgressEstimate estimate = new ProgressEstimate();

            nRet = OperLogForm.ProcessFiles(this,
                                            stop,
                                            estimate,
                                            Channel,
                                            LogFileNames,
                                            Program.MainForm.OperLogLevel,
                                            strStyle,
                                            "",           // strFilter
                                            Program.MainForm.OperLogCacheDir,
                                            null,         // param,
                                            procDoRecord, // DoRecord,
                                            out strError);
            if (nRet == -1)
            {
                return(-1);
            }

            return(nRet);
        }
Пример #3
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string strError = "";

            OperLogFilenames.Clear();

            string strStartDate = "";

            if (this.dateControl_start.IsValueNull() == false)
            {
                strStartDate = DateTimeUtil.DateTimeToString8(this.dateControl_start.Value);
            }

            string strEndDate = "";

            if (this.dateControl_end.IsValueNull() == false)
            {
                strEndDate = DateTimeUtil.DateTimeToString8(this.dateControl_end.Value);
            }

            if (String.IsNullOrEmpty(strEndDate) == true &&
                String.IsNullOrEmpty(strStartDate) == true)
            {
                strError = "尚未指定时间";
                goto ERROR1;
            }

            if (String.IsNullOrEmpty(strEndDate) == true)
            {
                OperLogFilenames.Add(strStartDate + ".log");
                goto END1;
            }

            if (String.IsNullOrEmpty(strStartDate) == true)
            {
                OperLogFilenames.Add(strEndDate + ".log");
                goto END1;
            }

            string        strWarning   = "";
            List <string> LogFileNames = null;
            // 根据日期范围,发生日志文件名
            // parameters:
            //      strStartDate    起始日期。8字符
            //      strEndDate  结束日期。8字符
            // return:
            //      -1  错误
            //      0   成功
            int nRet = OperLogLoader.MakeLogFileNames(strStartDate,
                                                      strEndDate,
                                                      true,
                                                      out LogFileNames,
                                                      out strWarning,
                                                      out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            if (String.IsNullOrEmpty(strWarning) == false)
            {
                MessageBox.Show(this, strWarning);
            }

            this.OperLogFilenames = LogFileNames;

END1:
            this.DialogResult = DialogResult.OK;
            this.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Пример #4
0
        // 对每个日志文件,每个日志记录进行循环
        // return:
        //      -1  出错
        //      0   普通返回
        //      1   要全部中断
        int DoLoop(
            OperLogForm.Delegate_doRecord procDoRecord,
            out string strError)
        {
            strError = "";
            int nRet = 0;
            // long lRet = 0;

            List <string> LogFileNames = null;

            // TODO: 是否需要检查起止日期是否为空值?空值是警告还是就当作今天?

            string strStartDate = DateTimeUtil.DateTimeToString8(this.dateControl_start.Value);
            string strEndDate   = DateTimeUtil.DateTimeToString8(this.dateControl_end.Value);


            // 根据日期范围,发生日志文件名
            // parameters:
            //      strStartDate    起始日期。8字符
            //      strEndDate  结束日期。8字符
            // return:
            //      -1  错误
            //      0   成功
            nRet = OperLogLoader.MakeLogFileNames(strStartDate,
                                                  strEndDate,
                                                  true,
                                                  out LogFileNames,
                                                  out string strWarning,
                                                  out strError);
            if (nRet == -1)
            {
                return(-1);
            }

            if (String.IsNullOrEmpty(strWarning) == false)
            {
                MessageBox.Show(this, strWarning);
            }

            string strStyle = "";

            if (Program.MainForm.AutoCacheOperlogFile == true)
            {
                strStyle = "autocache";
            }

            ProgressEstimate estimate = new ProgressEstimate();

            LibraryChannel channel     = this.GetChannel();
            TimeSpan       old_timeout = channel.Timeout;

            channel.Timeout = TimeSpan.FromSeconds(10);
            try
            {
#if NO
                nRet = OperLogForm.ProcessFiles(this,
                                                stop,
                                                estimate,
                                                channel,
                                                LogFileNames,
                                                Program.MainForm.OperLogLevel,
                                                strStyle,
                                                "",           // strFilter
                                                Program.MainForm.OperLogCacheDir,
                                                null,         // param,
                                                procDoRecord, // DoRecord,
                                                out strError);
                if (nRet == -1)
                {
                    return(-1);
                }

                return(nRet);
#endif
                bool bAccessLog = StringUtil.IsInList("accessLog", strStyle);

                OperLogLoader loader = new OperLogLoader();
                loader.Channel   = channel;
                loader.Stop      = this.Progress;
                loader.Estimate  = estimate;
                loader.Dates     = LogFileNames;
                loader.Level     = Program.MainForm.OperLogLevel;
                loader.AutoCache = StringUtil.IsInList("autocache", strStyle);    // false;
                loader.CacheDir  = Program.MainForm.OperLogCacheDir;
                loader.LogType   = bAccessLog ? LogType.AccessLog : LogType.OperLog;
                // loader.Filter = "borrow,return";

                loader.Prompt -= new MessagePromptEventHandler(loader_Prompt);
                loader.Prompt += new MessagePromptEventHandler(loader_Prompt);

                foreach (OperLogItem item in loader)
                {
                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        return(1);
                    }

                    if (stop != null)
                    {
                        stop.SetMessage("正在获取 " + item.Date + " " + item.Index.ToString() + " " + estimate.Text + "...");
                    }

                    if (string.IsNullOrEmpty(item.Xml) == true)
                    {
                        continue;
                    }

                    nRet = procDoRecord(item.Date + ".log",
                                        item.Xml,
                                        false, // bInCacheFile,
                                        0,
                                        item.Index,
                                        item.AttachmentLength,
                                        null,
                                        out strError);
                    if (nRet == -1)
                    {
                        return(-1);
                    }
                }

                return(0);
            }
            catch (InterruptException ex)
            {
                strError = ex.Message;
                return(1);
            }
            finally
            {
                channel.Timeout = old_timeout;
                this.ReturnChannel(channel);
            }
        }