Esempio n. 1
0
        /// <summary>
        /// 日志分割信息
        /// </summary>
        /// <param name="logFileName">ProcessEngine|yyyyMMdd|M*5|_|.txt</param>
        /// <returns></returns>
        public static StreamFileNameSplitFormat GetFileSplitFormat(string logFileName)
        {
            var theSf            = new StreamFileNameSplitFormat();
            var tmpArray         = logFileName.Split(DefaultFileNameScriptSplitChar);
            var dateTimeFormat   = "";
            var fileSizeFormat   = "";
            var splitChar        = "";
            var fileExpandedName = "";

            theSf.BaseFileName = tmpArray[0];

            #region LogFileName信息
            switch (tmpArray.Length)
            {
            case 1:
                dateTimeFormat   = DefaultDateTimeFormat;
                fileSizeFormat   = DefaultFileSizeFormat;
                splitChar        = DefaultFileNamePartSplitStr;
                fileExpandedName = DefaultFileExpandedName;
                break;

            case 2:
                dateTimeFormat   = tmpArray[1];
                fileSizeFormat   = DefaultFileSizeFormat;
                splitChar        = DefaultFileNamePartSplitStr;
                fileExpandedName = DefaultFileExpandedName;
                break;

            case 3:
                dateTimeFormat   = tmpArray[1];
                fileSizeFormat   = tmpArray[2];
                splitChar        = DefaultFileNamePartSplitStr;
                fileExpandedName = DefaultFileExpandedName;
                break;

            case 4:
                dateTimeFormat   = tmpArray[1];
                fileSizeFormat   = tmpArray[2];
                splitChar        = tmpArray[3];
                fileExpandedName = DefaultFileExpandedName;
                break;

            case 5:
                dateTimeFormat   = tmpArray[1];
                fileSizeFormat   = tmpArray[2];
                splitChar        = tmpArray[3];
                fileExpandedName = tmpArray[4];
                break;
            }
            #endregion

            UInt64 outValue;
            string splitSizeUnit;

            #region Get FileSizeFormat
            var  isAppend = DefaultISAPPEND;
            bool r;
            var  tmpSize = fileSizeFormat.Split('*');
            switch (tmpSize.Length)
            {
            case 1:
                r = UInt64.TryParse(tmpSize[0], out outValue);
                if (r)
                {
                    splitSizeUnit = "B";
                }
                else
                {
                    outValue      = 1;
                    splitSizeUnit = tmpSize[0];
                }
                break;

            case 2:
                splitSizeUnit = tmpSize[0];
                r             = UInt64.TryParse(tmpSize[1], out outValue);
                if (!r)
                {
                    outValue = 1;
                }
                break;

            default:
                splitSizeUnit = tmpSize[0];
                r             = UInt64.TryParse(tmpSize[1], out outValue);
                if (!r)
                {
                    outValue = 1;
                }
                isAppend = tmpSize[2].ToUpper() == "APPEND";
                break;
            }
            #endregion

            theSf.FileMaxSize       = outValue;
            theSf.FileSplitSizeUnit = splitSizeUnit;
            theSf.FileNameSplitChar = splitChar;
            theSf.DateTimeFormat    = dateTimeFormat;
            theSf.FileExpandedName  = fileExpandedName;
            theSf.IsAppend          = isAppend;
            return(theSf);
        }
Esempio n. 2
0
 /// <summary>
 /// 设置日志分割信息
 /// </summary>
 /// <param name="splitFormat"></param>
 public StreamFileSplitManager(StreamFileNameSplitFormat splitFormat)
 {
     _theSplitFormat = splitFormat;
     IsFristRun      = true;
 }
Esempio n. 3
0
 /// <summary>
 /// 根据字符串获取日志分割信息
 /// </summary>
 /// <param name="logFileName"></param>
 public StreamFileSplitManager(string logFileName)
 {
     _theSplitFormat = StreamFileNameSplitFormat.GetFileSplitFormat(logFileName);
     IsFristRun      = true;
 }
Esempio n. 4
0
        /// <summary>
        /// 日志分割信息
        /// </summary>
        /// <param name="logFileName">ProcessEngine|yyyyMMdd|M*5|_|.txt</param>
        /// <returns></returns>
        public static StreamFileNameSplitFormat GetFileSplitFormat(string logFileName)
        {
            var theSf = new StreamFileNameSplitFormat();
            var tmpArray = logFileName.Split(DefaultFileNameScriptSplitChar);
            var dateTimeFormat = "";
            var fileSizeFormat = "";
            var splitChar = "";
            var fileExpandedName = "";
            theSf.BaseFileName = tmpArray[0];

            #region LogFileName信息
            switch (tmpArray.Length)
            {
                case 1:
                    dateTimeFormat = DefaultDateTimeFormat;
                    fileSizeFormat = DefaultFileSizeFormat;
                    splitChar = DefaultFileNamePartSplitStr;
                    fileExpandedName = DefaultFileExpandedName;
                    break;
                case 2:
                    dateTimeFormat = tmpArray[1];
                    fileSizeFormat = DefaultFileSizeFormat;
                    splitChar = DefaultFileNamePartSplitStr;
                    fileExpandedName = DefaultFileExpandedName;
                    break;
                case 3:
                    dateTimeFormat = tmpArray[1];
                    fileSizeFormat = tmpArray[2];
                    splitChar = DefaultFileNamePartSplitStr;
                    fileExpandedName = DefaultFileExpandedName;
                    break;
                case 4:
                    dateTimeFormat = tmpArray[1];
                    fileSizeFormat = tmpArray[2];
                    splitChar = tmpArray[3];
                    fileExpandedName = DefaultFileExpandedName;
                    break;
                case 5:
                    dateTimeFormat = tmpArray[1];
                    fileSizeFormat = tmpArray[2];
                    splitChar = tmpArray[3];
                    fileExpandedName = tmpArray[4];
                    break;

            }
            #endregion

            UInt64 outValue;
            string splitSizeUnit;

            #region Get FileSizeFormat
            var isAppend = DefaultISAPPEND;
            bool r;
            var tmpSize = fileSizeFormat.Split('*');
            switch (tmpSize.Length)
            {
                case 1:
                    r = UInt64.TryParse(tmpSize[0], out outValue);
                    if (r)
                    {
                        splitSizeUnit = "B";
                    }
                    else
                    {
                        outValue = 1;
                        splitSizeUnit = tmpSize[0];
                    }
                    break;
                case 2:
                    splitSizeUnit = tmpSize[0];
                    r = UInt64.TryParse(tmpSize[1], out outValue);
                    if (!r)
                    {
                        outValue = 1;
                    }
                    break;
                default:
                    splitSizeUnit = tmpSize[0];
                    r = UInt64.TryParse(tmpSize[1], out outValue);
                    if (!r)
                    {
                        outValue = 1;
                    }
                    isAppend = tmpSize[2].ToUpper() == "APPEND";
                    break;
            }
            #endregion

            theSf.FileMaxSize = outValue;
            theSf.FileSplitSizeUnit = splitSizeUnit;
            theSf.FileNameSplitChar = splitChar;
            theSf.DateTimeFormat = dateTimeFormat;
            theSf.FileExpandedName = fileExpandedName;
            theSf.IsAppend = isAppend;
            return theSf;
        }
Esempio n. 5
0
 /// <summary>
 /// 设置日志分割信息
 /// </summary>
 /// <param name="splitFormat"></param>
 public StreamFileSplitManager(StreamFileNameSplitFormat splitFormat)
 {
     _theSplitFormat = splitFormat;
     IsFristRun = true;
 }
Esempio n. 6
0
 /// <summary>
 /// 根据字符串获取日志分割信息
 /// </summary>
 /// <param name="logFileName"></param>
 public StreamFileSplitManager(string logFileName)
 {
     _theSplitFormat = StreamFileNameSplitFormat.GetFileSplitFormat(logFileName);
     IsFristRun = true;
 }