示例#1
0
 /// <summary>
 /// Inits the thread.
 /// </summary>
 /// <param name="channel">The channel to backup.</param>
 /// <param name="blockingQueue">The WriterThread's message queue.</param>
 /// <param name="start">The message to start downloading from.</param>
 public MessageDownloadThread(IMessageChannel channel, BlockingCollection <List <IMessage> > blockingQueue, IMessage start, ThreadSafeBool error)
 {
     _channel       = channel;
     _blockingQueue = blockingQueue;
     _start         = start;
     _error         = error;
 }
示例#2
0
 public MainThread(IMessageChannel channel, DiscordSocketClient client, SocketUser user)
 {
     _channel     = channel;
     _guild       = ((SocketGuildChannel)_channel).Guild;
     _client      = client;
     _user        = user;
     _error       = new ThreadSafeBool();
     _error.Value = false;
 }
        /// <summary>
        /// Initializes the streams in append mode for the path.
        /// Header should have already been written elsewhere.
        /// </summary>
        /// <param name="path">Path to the directory for backup.</param>
        /// <param name="firstMsg">An additional message to write that will not be in the queue
        /// (should be the backup confirmation message).</param>
        /// <param name="channel">The Discord channel being backed up.</param>
        /// <param name="msgWritten">To optionally override the message written counter.</param>
        public WriterThread(string path, string timeZone, IMessage firstMsg, ThreadSafeBool error, bool includeAttachments)
        {
            _msgWritten         = 1;
            _timeZone           = timeZone;
            _path               = path;
            _firstMsg           = firstMsg;
            _error              = error;
            _includeAttachments = includeAttachments;

            Messages = new BlockingCollection <List <IMessage> >(new ConcurrentQueue <List <IMessage> >());

            if (firstMsg == null) // existing file, don't overwrite
            {
                _fs = new FileStream(Path.Join(_path, TSV_FILE_NAME), FileMode.Append);
            }
            else // non-existing file, create new
            {
                _fs = new FileStream(Path.Join(_path, TSV_FILE_NAME), FileMode.CreateNew);
            }

            _sw  = new StreamWriter(_fs);
            _csv = new CsvWriter(_sw, CSV_CONFIG);
        }