本文整理汇总了C#中Microsoft.Live.LiveConnectClient.UploadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# LiveConnectClient.UploadAsync方法的具体用法?C# LiveConnectClient.UploadAsync怎么用?C# LiveConnectClient.UploadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Live.LiveConnectClient
的用法示例。
在下文中一共展示了LiveConnectClient.UploadAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadFile
private void UploadFile (string name)
{
try
{
using (var storage = IsolatedStorageFile.GetUserStoreForApplication ())
{
var fileStream = storage.OpenFile (name + ".wav", FileMode.Open);
var uploadClient = new LiveConnectClient (Utilities.SkyDriveSession);
uploadClient.UploadCompleted += UploadClient_UploadCompleted;
uploadClient.UploadAsync ("me/skydrive", name + ".wav", fileStream, OverwriteOption.Rename);
_progressIndicatror = new ProgressIndicator
{
IsVisible = true,
IsIndeterminate = true,
Text = "Uploading file..."
};
SystemTray.SetProgressIndicator (this, _progressIndicatror);
}
}
catch (Exception)
{
ShowError ();
NavigationService.GoBack ();
}
}
示例2: signInButton_SessionChanged_1
private void signInButton_SessionChanged_1(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
{
if (e.Status != LiveConnectSessionStatus.Connected)
return;
manager.AllRoadMapsReceived += (o, eventAllRoadMaps) =>
{
if (eventAllRoadMaps.RoadMaps.Count == 0)
{
Debug.WriteLine("Aucun rendez-vous n'existe pour les jours sélectionnés");
return;
}
try
{
//SaveTableur();
SpreadSheetRoadmapGenerator.GenerateXLS("feuilles-de-route.xlsx", eventAllRoadMaps.RoadMaps, 5.5f, 1.6f);
if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
{
myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
fileStream = myIsolatedStorage.OpenFile("feuilles-de-route.xlsx", FileMode.Open, FileAccess.Read);
reader = new StreamReader(fileStream);
App.Session = e.Session;
LiveConnectClient client = new LiveConnectClient(e.Session);
client.UploadCompleted += client_UploadCompleted;
client.UploadAsync("me/skydrive", "feuilles-de-route.xlsx", reader.BaseStream, OverwriteOption.Overwrite);
}
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
}
};
ReferenceMeeting start = new ReferenceMeeting(new DateTime(2013, 1, 2, 8, 30, 0), new Location()
{
Latitude = 48.85693,
Longitude = 2.3412
}) { City = "Paris", Subject = "Start" };
ReferenceMeeting end = start;
end.Subject = "End";
manager.GetAllRoadMapsAsync(new DateTime(2013, 1, 2), new DateTime(2013, 2, 10), start, end);
}
示例3: uploadFile
public void uploadFile(string filename, System.IO.Stream file, string skydrivePath = "folder.559920a76be10760.559920A76BE10760!162")
{
LiveConnectClient client = new LiveConnectClient(App.Session);
client.UploadAsync(skydrivePath, filename, file, OverwriteOption.Overwrite);
client.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(UploadCompleted);
}
示例4: romList_SelectionChanged_1
private async void romList_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
ROMDBEntry entry = this.romList.SelectedItem as ROMDBEntry;
if (entry == null)
{
return;
}
if (this.uploading)
{
MessageBox.Show(AppResources.BackupWaitForUpload, AppResources.ErrorCaption, MessageBoxButton.OK);
this.romList.SelectedItem = null;
return;
}
var indicator = new ProgressIndicator()
{
IsIndeterminate = true,
IsVisible = true,
Text = String.Format(AppResources.BackupUploadProgressText, entry.DisplayName)
};
SystemTray.SetProgressIndicator(this, indicator);
this.uploading = true;
try
{
LiveConnectClient client = new LiveConnectClient(this.session);
String folderID = await this.CreateExportFolder(client);
IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
bool errors = false;
foreach (var savestate in entry.Savestates)
{
String path = FileHandler.ROM_DIRECTORY + "/" + FileHandler.SAVE_DIRECTORY + "/" + savestate.FileName;
try
{
using (IsolatedStorageFileStream fs = iso.OpenFile(path, System.IO.FileMode.Open))
{
await client.UploadAsync(folderID, savestate.FileName, fs, OverwriteOption.Overwrite);
}
}
catch (FileNotFoundException)
{
errors = true;
}
catch (LiveConnectException ex)
{
MessageBox.Show(String.Format(AppResources.BackupErrorUpload, ex.Message), AppResources.ErrorCaption, MessageBoxButton.OK);
errors = true;
}
}
int index = entry.FileName.LastIndexOf('.');
int diff = entry.FileName.Length - 1 - index;
String sramName = entry.FileName.Substring(0, entry.FileName.Length - diff) + "sav";
String sramPath = FileHandler.ROM_DIRECTORY + "/" + FileHandler.SAVE_DIRECTORY + "/" + sramName;
try
{
if (iso.FileExists(sramPath))
{
using (IsolatedStorageFileStream fs = iso.OpenFile(sramPath, FileMode.Open))
{
await client.UploadAsync(folderID, sramName, fs, OverwriteOption.Overwrite);
}
}
}
catch (Exception)
{
errors = true;
}
if (errors)
{
MessageBox.Show(AppResources.BackupUploadUnsuccessful, AppResources.ErrorCaption, MessageBoxButton.OK);
}
else
{
MessageBox.Show(AppResources.BackupUploadSuccessful);
}
}
catch (NullReferenceException)
{
MessageBox.Show(AppResources.CreateBackupFolderError, AppResources.ErrorCaption, MessageBoxButton.OK);
}
catch (LiveConnectException)
{
MessageBox.Show(AppResources.CreateBackupFolderError, AppResources.ErrorCaption, MessageBoxButton.OK);
}
finally
{
SystemTray.GetProgressIndicator(this).IsVisible = false;
this.uploading = false;
}
}
示例5: auth_LoginCompleted
/// <summary>
/// Appel une fois que l'utilisateur est connecté à Skydrive
/// Génère et Upload le fichier XLS
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void auth_LoginCompleted(object sender, LoginCompletedEventArgs e)
{
if (!App.IsConnected())
{
MessageBox.Show("Vous n'êtes pas connecté à internet");
return;
}
try
{
List<RoadMap> _roadmaps = new List<RoadMap>();
_roadmaps.Add(this.myRoadM);
string filename = "rapport-planmyway-" + myRoadM.Date.ToShortDateString().Replace("/", "-") + ".xlsx";
Debug.WriteLine(filename);
//SaveTableur();
SpreadSheetRoadmapGenerator.GenerateXLS(filename, _roadmaps, (double)settings["ConsoCarburant"], (double)settings["PrixCarburant"]);
if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
{
myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
fileStream = myIsolatedStorage.OpenFile(filename, FileMode.Open, FileAccess.Read);
reader = new StreamReader(fileStream);
App.Session = e.Session;
LiveConnectClient client = new LiveConnectClient(e.Session);
client.UploadCompleted += client_UploadCompleted;
client.UploadAsync("me/skydrive", filename, reader.BaseStream, OverwriteOption.Overwrite);
}
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
MessageBox.Show(exception.Message);
//this.enableInterface();
}
}
示例6: task_Completed
void task_Completed(object sender, PhotoResult e)
{
if (e.ChosenPhoto == null)
return;
LiveConnectClient uploadClient = new LiveConnectClient(App.Session);
uploadClient.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(uploadClient_UploadCompleted);
uploadClient.UploadAsync(SelectedAlbum.ID, "Image"+DateTime.Now.Millisecond+".jpg", e.ChosenPhoto);
}
示例7: BackupFilesAndUpload
private async void BackupFilesAndUpload(string _backupFileName)
{
if (_backupFileName == null) throw new ArgumentNullException("_backupFileName");
//
//
string filename = _backupFileName;
//byte[] b = new byte[0x16] {0x50,0x4b,0x05,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
var b = new byte[0x16];
b[0] = 0x50;
b[1] = 0x4b;
b[2] = 0x05;
b[4] = 0x06;
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) {
using (IsolatedStorageFileStream f = store.OpenFile(filename, FileMode.Create)) {
f.Write(b, 0, b.Length);
}
}
using (var store = IsolatedStorageFile.GetUserStoreForApplication()) {
using (var file = new IsolatedStorageFileStream(filename, FileMode.Create, store))
{
var zz = new ZipOutputStream(file);
foreach (string f in store.GetFileNames())
{
if (f.Equals(filename)) continue;
var ze = new ZipEntry(f);
zz.PutNextEntry(ze);
using (IsolatedStorageFileStream ss = store.OpenFile(f, FileMode.Open))
{
var bytes = new byte[100];
int x = ss.Read(bytes, 0, 100);
while (x > 0)
{
zz.Write(bytes, 0, x);
bytes = new byte[100];
x = ss.Read(bytes, 0, 100);
}
}
}
zz.Finish();
}
try
{
pbProgress.Value = 0;
bBackup.IsEnabled = false;
bRestore.IsEnabled = false;
var progressHandler = new Progress<LiveOperationProgress>(
(e) =>
{
pbProgress.Value = e.ProgressPercentage;
pbProgress.Visibility = Visibility.Visible;
lblLastBackup.Text =
string.Format(
StringResources
.BackupAndRestorePage_Messages_Progress,
e.BytesTransferred, e.TotalBytes);
});
_ctsUpload = new CancellationTokenSource();
_client = new LiveConnectClient(App.LiveSession);
using (
var file = new IsolatedStorageFileStream(filename, FileMode.Open,
FileAccess.Read, FileShare.Read,
IsolatedStorageFile.GetUserStoreForApplication()))
{
await
_client.UploadAsync("me/skydrive", filename, file,
OverwriteOption.Overwrite, _ctsUpload.Token,
progressHandler);
}
pbProgress.Visibility = Visibility.Collapsed;
}
catch (TaskCanceledException)
{
App.ToastMe("Upload Cancelled");
}
catch (LiveConnectException ee)
{
lblLastBackup.Text = string.Format("Error uploading File:{0}",
ee.Message);
}
finally
{
bBackup.IsEnabled = true;
bRestore.IsEnabled = true;
lblLastBackup.Text = DateTime.Now.ToString("MM/dd/yyyy");
}
}
}
示例8: UploadPicture
/// <summary>
/// uplaods a picture to sky drive.
/// </summary>
/// <param name="e"></param>
private async void UploadPicture(PhotoResult e)
{
LiveConnectClient uploadClient = new LiveConnectClient(App.Session);
if (e.OriginalFileName == null)
{
return;
}
// file name is the current datetime stapm
string ext = e.OriginalFileName.Substring(e.OriginalFileName.LastIndexOf('.'));
DateTime dt = DateTime.Now;
string fileName = String.Format("{0:d_MM_yyy_HH_mm_ss}", dt);
fileName = fileName + ext;
string progMsgUpPic = SkyPhoto.Resources.Resources.progMsgUpPic;
ShowProgressBar(progMsgUpPic);
try
{
LiveOperationResult result = await uploadClient.UploadAsync(App.CurrentAlbum.ID, fileName, e.ChosenPhoto, OverwriteOption.Overwrite);
ISFile_UploadCompleted(result);
}
catch (Exception)
{
string upFaild = SkyPhoto.Resources.Resources.upFaild;
MessageBox.Show(upFaild);
HideProgressBar();
}
}
示例9: ApplicationBarIconButton_Done_Click
private void ApplicationBarIconButton_Done_Click(object sender, EventArgs e)
{
this.progressIndicator = new ProgressIndicator();
ProgressIndicatorHelper.showProgressIndicator("Saving...", this, this.progressIndicator);
string fileName = this.filenameInput.Text.Trim();
byte[] byteArray = Encoding.UTF8.GetBytes(this.contentInput.Text.Trim());
MemoryStream fileStream = new MemoryStream(byteArray);
LiveConnectClient uploadClient = new LiveConnectClient(App.Current.LiveSession);
uploadClient.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(uploadClient_UploadCompleted);
uploadClient.UploadAsync(this.folderPath, fileName, true, fileStream, null);
}
示例10: ExportToSkyDrive
private async Task<bool> ExportToSkyDrive(string filename)
{
Exception exception = null;
ApplicationBar.IsVisible = false;
SystemTray.ProgressIndicator.IsVisible = true;
SystemTray.ProgressIndicator.Text = "Exporting data to SkyDrive";
this.IsEnabled = false;
this.Opacity = 0.25;
try
{
LiveConnectSession session = await this.InitializeSkyDrive();
LiveConnectClient client = new LiveConnectClient(session);
using (MemoryStream stream = new MemoryStream())
using (TextWriter writer = new StreamWriter(stream))
using (CsvWriter csvWriter = new CsvWriter(writer))
{
var entries =
from geocoordinate in App.MainViewModel.Geocoordinates
join obdUpdate in App.MainViewModel.MapObdUpdates on geocoordinate.GeoCoordinate equals obdUpdate.GeoCoordinate into all
from obd in all.DefaultIfEmpty()
select (obd == null ? new ObdModel() { GeoCoordinate = geocoordinate.GeoCoordinate, When = geocoordinate.Timestamp } : obd);
var csv =
from obd in entries
orderby obd.When
select new
{
Latitude = obd.Latitude,
Longitude = obd.Longitude,
Elevation = obd.Elevation,
Ascent = obd.Ascent,
Descent = obd.Descent,
Speed = obd.MilesPerHour,
Distance = obd.Distance,
SoC = obd.SoC,
Capacity = obd.Capacity,
RawCapacity = obd.RawCapacity,
UsableKiloWattHours = obd.UsableKiloWattHours,
AvailableKiloWattHours = obd.AvailableKiloWattHours,
KiloWattHoursUsed = obd.KiloWattHoursUsed,
AverageEnergyEconomy = obd.AverageEnergyEconomy,
Range = obd.Range,
Timestamp = obd.When,
Temperature1 = obd.Temperature1,
Temperature2 = obd.Temperature2,
Temperature3 = obd.Temperature3,
Temperature4 = obd.Temperature4
};
csvWriter.WriteRecords(csv);
writer.Flush();
stream.Flush();
stream.Position = 0;
LiveOperationResult result = await client.UploadAsync("me/skydrive", filename, stream, OverwriteOption.Rename);
}
}
catch (Exception ex)
{
exception = ex;
}
finally
{
ApplicationBar.IsVisible = true;
SystemTray.ProgressIndicator.IsVisible = false;
SystemTray.ProgressIndicator.Text = string.Empty;
this.IsEnabled = true;
this.Opacity = 1;
if (exception != null)
{
MessageBox.Show("Unable to export to SkyDrive\n" + exception.Message, "Error", MessageBoxButton.OK);
}
}
return exception == null;
}
示例11: upload
public static async Task<string> upload(string filename)
{
string res = "";
//diagLog("Uploading " + file);
try
{
string[] requiredScope = { "wl.offline_access", "wl.skydrive_update" };
LiveAuthClient auth = new LiveAuthClient(Secrets.ClientID);
await auth.InitializeAsync(requiredScope);
if (auth.Session == null)
{
await auth.LoginAsync(requiredScope);
}
LiveConnectClient liveClient = new LiveConnectClient(auth.Session);
string folderid = await GetSkyDriveFolderID(FOLDER, liveClient);
if (folderid == null)
{
folderid = await createSkyDriveFolder(FOLDER, liveClient);
res = "Created folder: " + FOLDER + "\n"; // , "ID:", folderid);
}
var store = IsolatedStorageFile.GetUserStoreForApplication();
if (store.FileExists(filename))
{
var file = store.OpenFile(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
LiveOperationResult operationResult = await liveClient.UploadAsync(folderid, filename, file, OverwriteOption.Overwrite);
dynamic result = operationResult.Result;
res += "Uploaded :" + result.name; //, "ID:", result.id);
}
else
throw new Exception("file does not exist");
}
catch (Exception exception)
{
res = "Error uploading file: " + exception.Message;
}
return res;
}
示例12: client_GetCompleted
void client_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
{
try
{
if (e.Result.ContainsKey("available"))
{
Int64 available = Convert.ToInt64(e.Result["available"]);
byte[] data = RecordManager.GetRecordByteArray(MainPageViewModel.Instance.CurrentlyUploading);
if (available >= data.Length)
{
MemoryStream stream = new MemoryStream(data);
client = new LiveConnectClient(App.MicrosoftAccountSession);
client.UploadCompleted += MicrosoftAccountClient_UploadCompleted;
client.UploadProgressChanged += MicrosoftAccountClient_UploadProgressChanged;
client.UploadAsync("me/skydrive", MainPageViewModel.Instance.CurrentlyUploading,
stream, OverwriteOption.Overwrite);
grdUpload.Visibility = System.Windows.Visibility.Visible;
ApplicationBar.IsVisible = false;
}
else
{
MessageBox.Show("Looks like you don't have enough space on your SkyDrive. Go to http://skydrive.com and either purchase more space or clean up the existing storage.", "Upload",
MessageBoxButton.OK);
}
}
}
catch
{
FailureAlert();
}
}
示例13: Upload
public static async void Upload( MainPage MainPage, LiveConnectSession Session, string filename )
{
if ( UploadStream != null )
{
return;
};
if ( Storage.FileExists( filename + ".gpx" ) )
{
UploadStream = Storage.OpenFile( filename + ".gpx", System.IO.FileMode.Open );
}
else
{
UploadStream = Storage.OpenFile( filename + ".incomplete", System.IO.FileMode.Open );
}
LiveConnectClient client = new LiveConnectClient( Session );
var progressHandler = new Progress<LiveOperationProgress>(
( progress ) =>
{
MainPage.TransferStatus( progress.ProgressPercentage );
} );
LiveOperationResult x = await client.UploadAsync( "me/skydrive/",
filename + ".gpx",
UploadStream,
OverwriteOption.Overwrite,
CancellationToken.None,
progressHandler );
MainPage.TransferStatus( 0 );
MainPage.Uploads.Clear();
UploadStream.Close();
UploadStream = null;
}
示例14: UploadFile
private void UploadFile()
{
//Creating byte array from 'fileBody' string
byte[] byteArray = Encoding.Unicode.GetBytes(fileBody);
MemoryStream fileStream = new MemoryStream(byteArray);
//Set SystemTray.ProgressIndicator
ProgressIndicator prog = new ProgressIndicator();
prog.IsIndeterminate = true;
prog.IsVisible = true;
prog.Text = "File uploading...";
SystemTray.SetProgressIndicator(this, prog);
//Uploading the file to SkyDrive storage
LiveConnectClient uploadClient = new LiveConnectClient(LiveSession);
uploadClient.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(uploadClient_UploadCompleted);
uploadClient.UploadAsync(folder_id, fileName + ".txt", fileStream);
}
示例15: auth_LoginCompleted
void auth_LoginCompleted(object sender, LoginCompletedEventArgs e)
{
try
{
IsolatedStorageFile myIsolatedStorage;
IsolatedStorageFileStream fileStream;
StreamReader reader;
//SaveTableur();
SpreadSheetRoadmapGenerator.GenerateXLS("feuilles-de-route.xlsx", _roadmaps, 5.5f, 1.6f);
if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
{
myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
fileStream = myIsolatedStorage.OpenFile("feuilles-de-route.xlsx", FileMode.Open, FileAccess.Read);
reader = new StreamReader(fileStream);
App.Session = e.Session;
LiveConnectClient client = new LiveConnectClient(e.Session);
client.UploadCompleted += client_UploadCompleted;
client.UploadAsync("me/skydrive", "feuilles-de-route.xlsx", reader.BaseStream, OverwriteOption.Overwrite);
//myIsolatedStorage.Dispose();
//fileStream.Dispose();
//reader.Dispose();
}
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
}
}