예제 #1
0
 internal CancelCommand(NotificationManager manager, CancellableNotification notification)
 {
     _notificationManager = manager;
     _notification = notification;
 }
예제 #2
0
 internal CancelCommand(NotificationManager manager, CancellableNotification notification)
 {
     _notificationManager = manager;
     _notification        = notification;
 }
예제 #3
0
파일: Function.cs 프로젝트: gwupe/Gwupe
 // Request to send a file to user
 internal void RequestFileSend(String filepath)
 {
     String filename = Path.GetFileName(filepath);
     try
     {
         FileSendInfo fileInfo = new FileSendInfo()
             {
                 Filename = filename,
                 FileSize = new FileInfo(filepath).Length,
                 FileSendId = Util.getSingleton().generateString(8),
                 FilePath = filepath,
                 Direction = FileSendDirection.Send
             };
         FileSendRequestRq request = new FileSendRequestRq()
             {
                 shortCode = _engagement.SecondParty.ActiveShortCode,
                 username = _engagement.SecondParty.Party.Username,
                 filename = fileInfo.Filename,
                 fileSize = fileInfo.FileSize,
                 fileSendId = fileInfo.FileSendId,
                 interactionId = _engagement.Interactions.CurrentOrNewInteraction.Id
             };
         try
         {
             Chat.LogSystemMessage(string.Format("Sending {0} the file {1}, waiting for acceptance.", _engagement.SecondParty.Party.Firstname, filename));
             _appContext.ConnectionManager.Connection.RequestAsync<FileSendRequestRq, FileSendRequestRs>(request,
                                                                   (req, res, ex) =>
                                                                   ProcessFileSendRequestRs(req, res, ex,
                                                                                                  fileInfo));
             Logger.Info("Requested to send " + fileInfo.Filename + " to " + _engagement.SecondParty.Party.Username);
             fileInfo.State = FileSendState.PendingSend;
             _pendingFileSends.Add(request.fileSendId, fileInfo);
             IsActive = true;
             var notification = new CancellableNotification()
             {
                 AssociatedUsername = _engagement.SecondParty.Party.Username,
                 Message = "Offering " + _engagement.SecondParty.Party.Firstname + " " + fileInfo.Filename,
                 CancelTooltip = "Cancel File Send",
                 Id = fileInfo.FileSendId
             };
             notification.Cancelled += (sender, args) => CancelFileOffer(fileInfo);
             fileInfo.Notification = notification;
             _appContext.NotificationManager.AddNotification(notification);
             OnNewActivity(new FileSendActivity(_engagement, FileSendActivity.FILE_SEND_REQUEST) { From = "_SELF", To = _engagement.SecondParty.Party.Username, FileInfo = fileInfo });
         }
         catch (Exception ex)
         {
             Logger.Error("Error during request for File Send : " + ex.Message, ex);
             Chat.LogErrorMessage("An error occured trying to send " + _engagement.SecondParty.Party.Firstname +
                                               " a request to send them a file.");
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Error setting up request for file send : " + ex.Message, ex);
         Chat.LogErrorMessage("An error occured trying to send " + _engagement.SecondParty.Party.Firstname + " a request to send them a file.");
     }
 }