Ejemplo n.º 1
0
        private void RequestTaskCommandProcessed(object sender, CommandProcessedEventArgs e)
        {
            var taskLetter = ((TaskLetter)e.Parameter).Body;

            taskLetter = _vocabularyProcesser.ReplaceVocabulary(e.Session, taskLetter);

            var title    = "Tasks for " + DateTime.Now.ToString("M dd");
            var fileName = _configurationAccessor.GetBaseFolder() + Path.DirectorySeparatorChar + title.ToLower().Replace(' ', '-') + ".txt";

            File.WriteAllText(fileName, taskLetter);

            foreach (var processor in CommandProcessors.Values)
            {
                taskLetter = processor.DeleteCommandFrom(taskLetter);
            }

            taskLetter = _vocabularyProcesser.ReplaceVocabulary(Session, taskLetter);

            var sendFileArgs = new SendFileEventArgs
            {
                FileName = fileName,
                Title    = title,
                Sender   = e.Session.Domme.Name,
            };

            OnSendFile(sendFileArgs);
        }
Ejemplo n.º 2
0
 public async Task <DiscordMessage> SendFile(object sender, SendFileEventArgs e)
 {
     Log(sender, new LogEventArgs {
         Type    = LogType.Log,
         Message = $"Sending file {e.LogMessage} to channel #{e.Channel.Name} ({e.Channel.Guild.Name})"
     });
     return(await e.Channel.SendFileAsync(e.FilePath));
 }
Ejemplo n.º 3
0
        public async void onSendFileEvent(object sender, SendFileEventArgs eventArgs)
        {
            SendFile file = m_liSendFiles.Find(x => x.FileID == eventArgs.FileID);

            if (file != null)
            {
                if (eventArgs.FileEvent == SendFileEventArgs.EFileEvent.CANCELFILE)
                {
                    if (String.IsNullOrWhiteSpace(eventArgs.ErrorMessage))
                    {
                        Log.w(TAG, "Remote device requested to cancel upload of file " + file.FileName, true);
                    }
                    else
                    {
                        Log.w(TAG, "Remote device cancelled upload of file " + file.FileName + " because of an error: " + eventArgs.ErrorMessage, true);
                    }

                    file.Cancel();
                    m_liSendFiles.Remove(file);
                }
                else if (eventArgs.FileEvent == SendFileEventArgs.EFileEvent.ACCEPT && file.Status == SendFile.EStatus.REQUESTED)
                {
                    file.Status = SendFile.EStatus.ACCEPTED;
                    try
                    {
                        await file.UploadFile((BbRemoteServer)sender);
                    }
                    catch (OperationCanceledException) { } // thats fine, nothing else to do
                    catch (Exception e)
                    {
                        if (file.Status == SendFile.EStatus.TRANSFERRING)
                        {
                            Log.e(TAG, "Error while sending file " + file.FileName + " - " + e.Message, true);
                            ((BbRemoteServer)sender).SendFileCancel(file.FileID, true);
                            file.Cancel();
                        }
                    }
                    m_liSendFiles.Remove(file);
                    StartNextFile((BbRemoteServer)sender);
                    return;
                }
            }
            else
            {
                Log.w(TAG, "Received file command for unknown FileID " + eventArgs.FileID);
            }
        }
Ejemplo n.º 4
0
 private void OnSendFile(SendFileEventArgs eventArgs)
 {
     SendFile?.Invoke(this, eventArgs);
 }