상속: API.UserToUserRequest
예제 #1
0
파일: Function.cs 프로젝트: gwupe/Gwupe
 // Async callback on result of requesting to send a file
 private void ProcessFileSendRequestRs(FileSendRequestRq request, FileSendRequestRs res, Exception e, FileSendInfo fileInfo)
 {
     if (e != null)
     {
         Chat.LogSystemMessage("An error occured trying to send " + _engagement.SecondParty.Party.Username + " a request to send them " + fileInfo.Filename);
         Logger.Error("Failed to send file send request for " + fileInfo.Filename);
         RemovePendingFileSend(fileInfo.FileSendId);
         OnNewActivity(new FileSendActivity(_engagement, FileSendActivity.FILE_SEND_REQUEST_FAILED) { From = "_SELF", To = _engagement.SecondParty.Party.Username, FileInfo = fileInfo });
     }
     else
     {
     }
 }
예제 #2
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.");
     }
 }