当前位置: 首页>>代码示例>>C#>>正文


C# LibraryChannel.GetOperLog方法代码示例

本文整理汇总了C#中LibraryChannel.GetOperLog方法的典型用法代码示例。如果您正苦于以下问题:C# LibraryChannel.GetOperLog方法的具体用法?C# LibraryChannel.GetOperLog怎么用?C# LibraryChannel.GetOperLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibraryChannel的用法示例。


在下文中一共展示了LibraryChannel.GetOperLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFileSize

        // 获得一个日志文件的尺寸
        // return:
        //      -2  此类型的日志尚未启用
        //      -1  error
        //      0   file not found
        //      1   found
        static int GetFileSize(
            Stop stop,
            LibraryChannel channel,
            string strCacheDir,
            string strLogFileName,
            LogType logType,
            out long lServerFileSize,
            out long lCacheFileSize,
            out string strError)
        {
            strError = "";
            lServerFileSize = 0;
            lCacheFileSize = 0;

            string strCacheFilename = PathUtil.MergePath(strCacheDir, strLogFileName);

            FileInfo fi = new FileInfo(strCacheFilename);
            if (fi.Exists == true)
                lCacheFileSize = fi.Length;

            stop.SetMessage("正获得日志文件 " + strLogFileName + " 的尺寸...");

            string strXml = "";
            long lAttachmentTotalLength = 0;
            byte[] attachment_data = null;

            string strStyle = "level-0";
            if ((logType & LogType.AccessLog) != 0)
                strStyle += ",accessLog";

            // 获得日志文件尺寸
            // return:
            //      -1  error
            //      0   file not found
            //      1   succeed
            //      2   超过范围
            long lRet = channel.GetOperLog(
                stop,
                strLogFileName,
                -1,    // lIndex,
                -1, // lHint,
                strStyle,
                "", // strFilter
                out strXml,
                out lServerFileSize,
                0,  // lAttachmentFragmentStart,
                0,  // nAttachmentFramengLength,
                out attachment_data,
                out lAttachmentTotalLength,
                out strError);
            if (lRet == 0)
            {
                lServerFileSize = 0;
                Debug.Assert(lServerFileSize == 0, "");
                return 0;
            }
            if (lRet != 1)
                return -1;
            if (lServerFileSize == -1)
            {
                strError = "日志尚未启用";
                return -2;
            }
            Debug.Assert(lServerFileSize >= 0, "");
            return 1;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:72,代码来源:OperLogLoader.cs

示例2: ProcessFile

        // 装入一个日志文件中的若干记录
        // parameters:
        //      strStyle    如果包含 accessLog,表示这是需要获取只读日志
        //      strCacheDir 存储本地缓存文件的目录
        //      lServerFileSize 服务器端日志文件的尺寸。如果为-1,表示函数内会自动获取
        //      lSize   进度条所采用的最大尺寸。如果必要,可能会被本函数推动
        // return:
        //      -2  此类型的日志尚未启用
        //      -1  error
        //      0   正常结束
        //      1   用户中断
        static int ProcessFile(
            IWin32Window owner,
            Stop stop,
            ProgressEstimate estimate,
            LibraryChannel channel,
            string strLogFileName,
            int nLevel,
            long lServerFileSize,
            string strRange,
            string strStyle,
            string strCacheDir,
            object param,
            Delegate_doRecord procDoRecord,
            ref long lProgressValue,
            ref long lSize,
            out string strError)
        {
            strError = "";
            int nRet = 0;
            long lRet = 0;

            stop.SetMessage("正在装入日志文件 " + strLogFileName + " 中的记录。"
                + "剩余时间 " + ProgressEstimate.Format(estimate.Estimate(lProgressValue)) + " 已经过时间 " + ProgressEstimate.Format(estimate.delta_passed));

            bool bAccessLog = StringUtil.IsInList("accessLog", strStyle);

            string strXml = "";
            long lAttachmentTotalLength = 0;
            byte[] attachment_data = null;

            long lFileSize = 0;
            if (lServerFileSize == -1)
            {
                lServerFileSize = 0;

                string strTempStyle = "level-" + nLevel.ToString();
                if (bAccessLog)
                    strTempStyle += ",accessLog";

                // 获得服务器端日志文件尺寸
                lRet = channel.GetOperLog(
                    stop,
                    strLogFileName,
                    -1,    // lIndex,
                    -1, // lHint,
                    strTempStyle,
                    "", // strFilter
                    out strXml,
                    out lServerFileSize,
                    0,  // lAttachmentFragmentStart,
                    0,  // nAttachmentFramengLength,
                    out attachment_data,
                    out lAttachmentTotalLength,
                    out strError);
                // 2015/11/25
                if (lRet == -1)
                    return -1;
                // 2010/12/13
                if (lRet == 0)
                    return 0;
                if (lServerFileSize == -1)
                {
                    strError = "日志尚未启用";
                    return -2;
                }
            }

            Stream stream = null;
            bool bCacheFileExist = false;
            bool bRemoveCacheFile = false;  // 是否要自动删除未全部完成的本地缓存文件

            bool bAutoCache = StringUtil.IsInList("autocache", strStyle);

            if (bAutoCache == true)
            {
                nRet = PrepareCacheFile(
                    strCacheDir,
                    bAccessLog ? strLogFileName + ".a" : strLogFileName,
                    lServerFileSize,
                    out bCacheFileExist,
                    out stream,
                    out strError);
                if (nRet == -1)
                    return -1;

                if (bCacheFileExist == false && stream != null)
                    bRemoveCacheFile = true;
            }

//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:OperLogForm.cs


注:本文中的LibraryChannel.GetOperLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。