public ExtendedEventsReader(string logFilePath,
                                    OnReadEventHandler onReadEvent,
                                    OnReadMetadataHandler onReadMetadata,
                                    BeforeReadFileHandler beforeReadFile,
                                    AfterReadFileHandler afterReadFile,
                                    OnErrorEventHandler onError)
        {
            OnReadMetadata = onReadMetadata;
            OnReadEvent    = onReadEvent;
            BeforeReadFile = beforeReadFile;
            AfterReadFile  = afterReadFile;

            if (File.GetAttributes(logFilePath).HasFlag(FileAttributes.Directory))
            {
                _logFileDirectoryPath         = logFilePath;
                _logFileSourcePathIsDirectory = true;
                UpdateEventLogFilesFromDirectory();
            }
            else
            {
                _logFileSourcePathIsDirectory = false;
                _logFilesWithData             = new[] { logFilePath };
                _logFileDirectoryPath         = new FileInfo(_logFilesWithData[0]).Directory?.FullName;
            }
        }
示例#2
0
文件: Session.cs 项目: zhoulk/Lufy
    /// <summary>
    /// 内部解析
    /// </summary>
    private void OnKcpRead(KChannel channel, byte[] bytes)
    {
        //处理连接
        if (!this.IsConnected)
        {
            //兼容1.3.1旧版本时,改用SimulationRecvConnected
            //OnConnectedSuccess();
        }
        else
        {
            //解析数据
            header.Clear();
            header.Decode(bytes, 0);

            if (header.GetMessageType() != MessageType.Msg)
            {
                int ts = (SystemTime.LowClientNow() - header.TimeStamp) / 2;

                Log.Debug("当前延迟:" + ts);

                if (ts < 0)
                {
                    ts = 10;
                }

                timeStampList.Add((uint)ts);
            }

            OnReadEventHandler?.Invoke(bytes);
        }
    }
示例#3
0
        public async Task Read()
        {
            await Task.Delay(100);

            string        folderStr = "account";
            StorageFolder folder    = ApplicationData.Current.LocalFolder;
            bool          first     = false;

            try
            {
                folder = await folder.GetFolderAsync(folderStr);
            }
            catch (FileNotFoundException)
            {
                first = true;
            }

            if (!first)
            {
                try
                {
                    StorageFile file = await folder.GetFileAsync(folderStr + ".json");

                    var dwrotSvwm = await FileIO.ReadTextAsync(file);

                    Account = JsonConvert.DeserializeObject <Account>(dwrotSvwm);
                    if (Account != null)
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(Account.Token))
                            {
                                Account.Folder = await
                                                 StorageApplicationPermissions.FutureAccessList.
                                                 GetFolderAsync(
                                    Account.Token);

                                Account.Address = Account.Folder.Path;
                            }
                            else
                            {
                                Account.Folder  = KnownFolders.PicturesLibrary;
                                Account.Address = Account.Folder.Path;
                            }
                        }
                        catch (UnauthorizedAccessException)
                        {
                            Account.Folder = ApplicationData.Current.TemporaryFolder;
                        }
                    }
                    else
                    {
                        first = true;
                    }
                }
                catch (FileNotFoundException)
                {
                    first = true;
                }
            }
            //else
            //{
            //    folder = await ApplicationData.Current.LocalFolder.
            //        CreateFolderAsync(folderStr);
            //}

            if (first)
            {
                Account = new Account()
                {
                    Folder           = KnownFolders.PicturesLibrary,
                    Address          = KnownFolders.PicturesLibrary.Path,
                    Theme            = ElementTheme.Light,
                    ThemeDay         = true,
                    Str              = "",
                    ImageShack       = ImageShackEnum.Smms,
                    JiuYouImageShack = false,
                    QinImageShack    = true,
                    SmmsImageShack   = false,
                };

                Account.Token = StorageApplicationPermissions.FutureAccessList.Add(Account.Folder);

                await Storage();
            }

            OnReadEventHandler?.Invoke(this, null);
        }
示例#4
0
        public async Task Read()
        {
            await Task.Delay(100);

            string        folderStr = "account";
            StorageFolder folder    = ApplicationData.Current.LocalFolder;
            bool          first     = false;

            try
            {
                folder = await folder.GetFolderAsync(folderStr);
            }
            catch (FileNotFoundException)
            {
                first = true;
            }
            if (!first)
            {
                try
                {
                    StorageFile file = await folder.GetFileAsync(folderStr + ".json");

                    var json = JsonSerializer.Create();
                    Account = json.Deserialize <Account>(new JsonTextReader(
                                                             new StreamReader(await file.OpenStreamForReadAsync())));
                    //FutureAccessList
                    if (Account != null)
                    {
                        try
                        {
                            Account.Folder = await
                                             StorageApplicationPermissions.FutureAccessList.GetFolderAsync(
                                Account.Token);
                        }
                        catch (ArgumentNullException)
                        {
                            Account.Folder = KnownFolders.PicturesLibrary;
                        }
                        Account.Address = Account.Folder.Path;
                    }
                    else
                    {
                        first = true;
                    }
                }
                catch (FileNotFoundException)
                {
                    first = true;
                }
            }
            //else
            //{
            //    folder = await ApplicationData.Current.LocalFolder.
            //        CreateFolderAsync(folderStr);
            //}

            if (first)
            {
                Account = new Account()
                {
                    Folder           = KnownFolders.PicturesLibrary,
                    Address          = KnownFolders.PicturesLibrary.Path,
                    Theme            = ElementTheme.Light,
                    ThemeDay         = true,
                    Str              = "",
                    ImageShack       = ImageShackEnum.Qin,
                    JiuYouImageShack = false,
                    QinImageShack    = true,
                    SmmsImageShack   = false,
                };
                await Storage();
            }

            OnReadEventHandler?.Invoke(this, null);
        }
 public ExtendedEventsReader(string logFilePath,
                             OnReadEventHandler onReadEvent,
                             BeforeReadFileHandler beforeReadFile,
                             AfterReadFileHandler afterReadFile) : this(logFilePath, onReadEvent, null, beforeReadFile, afterReadFile, null)
 {
 }
 public ExtendedEventsReader(string logFilePath,
                             OnReadEventHandler onReadEvent) : this(logFilePath, onReadEvent, null, null, null, null)
 {
 }