当前位置: 首页>>代码示例>>C#>>正文


C# LiveConnectClient.PostAsync方法代码示例

本文整理汇总了C#中Microsoft.Live.LiveConnectClient.PostAsync方法的典型用法代码示例。如果您正苦于以下问题:C# LiveConnectClient.PostAsync方法的具体用法?C# LiveConnectClient.PostAsync怎么用?C# LiveConnectClient.PostAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Live.LiveConnectClient的用法示例。


在下文中一共展示了LiveConnectClient.PostAsync方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadProfile

            public async void LoadProfile(String SkyDriveFolderName = GenericName)
            {
                LiveOperationResult meResult;
                dynamic result;
                bool createLiveFolder = false;

               try
               {
                    LiveAuthClient authClient = new LiveAuthClient();
                    LiveLoginResult authResult = await authClient.LoginAsync(new List<String>() { "wl.skydrive_update" });

                    if (authResult.Status == LiveConnectSessionStatus.Connected)
                    {
                        try
                        {
                            meClient = new LiveConnectClient(authResult.Session);
                            meResult = await meClient.GetAsync("me/skydrive/" + SkyDriveFolderName);
                            result = meResult.Result;
                        }
                        catch (LiveConnectException)
                        {
                            createLiveFolder = true;
                        }
                        if (createLiveFolder == true)
                        {
                            try
                            {
                                var skyDriveFolderData = new Dictionary<String, Object>();
                                skyDriveFolderData.Add("name", SkyDriveFolderName);
                                LiveConnectClient LiveClient = new LiveConnectClient(meClient.Session);
                                LiveOperationResult operationResult = await LiveClient.PostAsync("me/skydrive/", skyDriveFolderData);
                                meResult = await meClient.GetAsync("me/skydrive/");

                            }
                            catch (LiveConnectException)
                            {
                            }
                        }

                    }

               }

               catch (LiveAuthException)
               {
               }

            }
开发者ID:Naox305,项目名称:Framework786,代码行数:48,代码来源:CloudMethods.cs

示例2: CreateFolder

 public static async Task<SkyDriveFolderInfo> CreateFolder(
     string folderName, string parentFolder = "/me/skydrive")
 {
     try
     {
         if (session == null)
         {
             await Login();
         }
         var folderData = new Dictionary<string, object> { { "name", folderName } };
         var liveClient = new LiveConnectClient(session);
         LiveOperationResult operationResult = await liveClient.PostAsync(parentFolder, folderData);
         dynamic result = operationResult.Result;
         return new SkyDriveFolderInfo(result);
     }
     catch (LiveConnectException exception)
     {
         throw new Exception("Unable to create folder " + folderName, exception);
     }
 }
开发者ID:noriike,项目名称:xaml-106136,代码行数:20,代码来源:SkyDriveHelper.cs

示例3: CreateFolderInSkydrive

        private static async Task<string> CreateFolderInSkydrive(LiveConnectClient client)
        {
            var folderData = new Dictionary<string, object>();

            folderData.Add("name", "EventBuddy");
            var createFolderResult = await client.PostAsync("me/skydrive", folderData);
            dynamic creationResult = createFolderResult.Result;

            return creationResult.id;
        }
开发者ID:kirpasingh,项目名称:MicrosoftAzureTrainingKit,代码行数:10,代码来源:SessionEditor.xaml.cs

示例4: CreateExportFolder

 private async Task<String> CreateExportFolder(LiveConnectClient client)
 {
     LiveOperationResult opResult = await client.GetAsync("me/skydrive/files");
     var result = opResult.Result;
     IList<object> results = result["data"] as IList<object>;
     if (results == null)
     {
         throw new LiveConnectException();
     }
     object o = results
         .Where(d => (d as IDictionary<string, object>)["name"].Equals(EXPORT_FOLDER))
         .FirstOrDefault();
     string id = null;
     if (o == null)
     {
         var folderData = new Dictionary<string, object>();
         folderData.Add("name", EXPORT_FOLDER);
         opResult = await client.PostAsync("me/skydrive", folderData);
         dynamic postResult = opResult.Result;
         id = postResult.id;
     }
     else
     {
         IDictionary<string, object> folderProperties = o as IDictionary<string, object>;
         id = folderProperties["id"] as string;
     }
     return id;
 }
开发者ID:alexbarboza,项目名称:vba8,代码行数:28,代码来源:BackupPage.xaml.cs

示例5: RunButton_Click

        private async void RunButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Validate parameters
                string path = pathTextBox.Text;
                string destination = destinationTextBox.Text;
                string requestBody = requestBodyTextBox.Text;
                var scope = (authScopesComboBox.SelectedValue as ComboBoxItem).Content as string;
                var method = (methodsComboBox.SelectedValue as ComboBoxItem).Content as string;

                // acquire auth permissions
                var authClient = new LiveAuthClient();
                var authResult = await authClient.LoginAsync(new string[] { scope });
                if (authResult.Session == null)
                {
                    throw new InvalidOperationException("You need to login and give permission to the app.");
                }

                var liveConnectClient = new LiveConnectClient(authResult.Session);
                LiveOperationResult operationResult = null;
                switch (method)
                {
                    case "GET":
                        operationResult = await liveConnectClient.GetAsync(path);
                        break;
                    case "POST":
                        operationResult = await liveConnectClient.PostAsync(path, requestBody);
                        break;
                    case "PUT":
                        operationResult = await liveConnectClient.PutAsync(path, requestBody);
                        break;
                    case "DELETE":
                        operationResult = await liveConnectClient.DeleteAsync(path);
                        break;
                    case "COPY":
                        operationResult = await liveConnectClient.CopyAsync(path, destination);
                        break;
                    case "MOVE":
                        operationResult = await liveConnectClient.MoveAsync(path, destination);
                        break;
                }

                if (operationResult != null)
                {
                    Log("Operation succeeded: \r\n" + operationResult.RawResult);
                }
            }
            catch (Exception ex)
            {
                Log("Got error: " + ex.Message);
            }
        }
开发者ID:d20021,项目名称:LiveSDK-for-Windows,代码行数:53,代码来源:ApiLab.xaml.cs

示例6: btnCreateFolder_Click

        private async void btnCreateFolder_Click(object sender, RoutedEventArgs e)
        {
            var client = new LiveConnectClient(Session); // セッションを取得済みであることが前提

            // 作成するフォルダの名前
            var FOLDER_NAME = "{ここにフォルダーの名前を入れる}"; 

            // フォルダの名前やその他の情報を決める
            var data = new Dictionary<string, object>();
            data.Add("name", FOLDER_NAME);
            data.Add("description", "このフォルダは○○アプリで作成した写真を保存するフォルダです");

            // フォルダ作成の要求
            var result = await client.PostAsync("me/skydrive", data);

            // 成功すれば作成したフォルダの情報が取得できる
            var id = result.Result["id"] as string;
            var description = result.Result["description"] as string;

            System.Diagnostics.Debug.WriteLine("{0}:{1}", id, description);
        }
开发者ID:runceel,项目名称:winstoreapprecipe,代码行数:21,代码来源:MainPage.xaml.cs

示例7: createSkyDriveFolder

 private static async Task<string> createSkyDriveFolder(string folderName, LiveConnectClient client)
 {
     var folderData = new Dictionary<string, object>();
     folderData.Add("name", folderName);
     LiveOperationResult operationResult =
         await client.PostAsync("me/skydrive", folderData);
     dynamic result = operationResult.Result;
     // res = string.Join(" ", "Created folder:", result.name, "ID:", result.id);
     return result.id;
 }
开发者ID:JamieKitson,项目名称:TrackLog,代码行数:10,代码来源:App.xaml.cs

示例8: CreateDirectoryAsync

        private async Task<string> CreateDirectoryAsync(string folderName, string parentFolder, LiveConnectClient client)
        {
            string folderId = null;
            string queryFolder;
            LiveOperationResult opResult;
            //Retrieves all the directories.
            if (!parentFolder.Equals(CloudManagerUI.Properties.Resources.OneDriveRoot))
            {
                queryFolder = await GetSkyDriveFolderID(parentFolder, client) + "/files?filter=folders,albums";
                opResult = await client.GetAsync(queryFolder);
            }
            else
            {
                queryFolder = CloudManagerUI.Properties.Resources.OneDriveRoot + "/files?filter=folders,albums";
                opResult = await client.GetAsync(queryFolder);
            }


            dynamic result = opResult.Result;

            foreach (dynamic folder in result.data)
            {
                //Checks if current folder has the passed name.
                if (folder.name.ToLowerInvariant() == folderName.ToLowerInvariant())
                {
                    folderId = folder.id;
                    break;
                }
            }

            if (folderId == null)
            {
                //Directory hasn't been found, so creates it using the PostAsync method.
                var folderData = new Dictionary<string, object>();
                folderData.Add("name", folderName);

                if (parentFolder.Equals(CloudManagerUI.Properties.Resources.OneDriveRoot))
                {
                    var opResultPostRoot = await client.GetAsync(CloudManagerUI.Properties.Resources.OneDriveRoot);

                    var iEnum = opResultPostRoot.Result.Values.GetEnumerator();
                    iEnum.MoveNext();
                    var id = iEnum.Current.ToString();


                    opResult = await client.PostAsync(id, folderData);
                }
                else
                {
                    var opResultPost = await GetSkyDriveFolderID(parentFolder, client);

                    opResult = await client.PostAsync(opResultPost, folderData);
                }

                result = opResult.Result;

                //Retrieves the id of the created folder.
                folderId = result.id;
            }


            return folderId;
        }
开发者ID:carlilord,项目名称:CloudStorageManager,代码行数:63,代码来源:OneDriveInterfaceFunctions.cs

示例9: CreateFolder

		private async Task<string> CreateFolder(LiveConnectClient client)
		{
			var folderData = new Dictionary<string, object>();
			folderData.Add("name", _passwordsFolder);
			LiveOperationResult operationResult = await client.PostAsync(_basePath, folderData);
			dynamic result = operationResult.Result;
			return result.id;
		}
开发者ID:astmus,项目名称:PassKeeper,代码行数:8,代码来源:OneDrive.cs

示例10: AddContacts

        public async  void AddContacts()
        {
            //create new LiveSDK contact

            LiveConnectClient client = new LiveConnectClient(Connection.Session);

            LiveOperationResult liveOpResult = await client.GetAsync("me/contacts");

            IDictionary<string, object> myResult = liveOpResult.Result;
            List<object> data = null;
            IDictionary<string, object> contact;
            string contact_fname = String.Empty;
            string contact_lname = String.Empty;
            Dictionary<string, string> contactList = new Dictionary<string, string>();

            if (myResult.ContainsKey("data"))
            {
                 data = (List<object>)myResult["data"];
                 for (int i = 0; i < data.Count; i++)
                 {
                     contact = (IDictionary<string, object>)data[i];
                     if (contact.ContainsKey("first_name"))
                     {
                         //contactList.ElementAt(i).Key =
                        
                         contact_fname = (string) contact["first_name"];
                     }
                     if(contact.ContainsKey("last_name"))
                     {
                         contact_lname = (string)contact["last_name"];
                     }

                     if(contact_fname!=String.Empty && contact_lname!=String.Empty)
                     {
                         contactList.Add(contact_fname, contact_lname);

                         contact_fname = String.Empty;
                         contact_lname = String.Empty;
                     }

                 }
            }

            List<User> usersList = new List<User>();
            User = Connection.MobileService.GetTable<User>();

            usersList = await User.Where(p => p.UserId != Connection.MobileService.CurrentUser.UserId ).ToListAsync();
            for (int i = 0; i < usersList.Count; i++)
            {
                if (!(contactList.ContainsKey(usersList.ElementAt(i).FName) && contactList.ContainsValue(usersList.ElementAt(i).LName)))
                {
                    contact = new Dictionary<string, object>();
                    contact.Add("first_name", usersList.ElementAt(i).FName);
                    contact.Add("last_name", usersList.ElementAt(i).LName);
                    // contact.Add("emails.preferred", usersList.ElementAt(i).Email);
                    contact.Add("emails", new Dictionary<string, object> {
                {"account",usersList.ElementAt(i).Email },
                {"preferred",usersList.ElementAt(i).Email },
                { "personal", usersList.ElementAt(i).Email},
                {"business", usersList.ElementAt(i).Email},
                {"other", usersList.ElementAt(i).Email} 
                });

                    await client.PostAsync("me/contacts", contact);

                }
            }
            // get List of users loop
            //  var contact = new Dictionary<string, object>();
            // contact.Add("first_name", "Michael");
            // contact.Add("last_name", "Crump");
            //contact.Add( "emails.preferred", "[email protected]");
            //client.PostAsync("me/contacts", contact);
            MainPage.Success2 = true;

        }
开发者ID:Zainabalhaidary,项目名称:Clinic,代码行数:76,代码来源:MainViewModel.cs

示例11: Create_new_album

 /// <summary>
 /// Create_new_album crates a new album
 /// </summary>
 private async void Create_new_album()
 {
     Dictionary<string, object> folderData = new Dictionary<string, object>();
     folderData.Add("name", NewAlbumName);
     folderData.Add("type", "album");
     LiveConnectClient client = new LiveConnectClient(App.Session);
     LiveOperationResult result = await client.PostAsync("me/skydrive", folderData);
     CreateFolder_Completed(result);
 }
开发者ID:masiboo,项目名称:SkyPhoto_WP8,代码行数:12,代码来源:AlbumPage.xaml.cs

示例12: client_GetRootDirectoryEnrtiesList

        //Get root SkyDrive directory entries list Completed
        void client_GetRootDirectoryEnrtiesList(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                folder_id = this.GetFolderId(e);
                //If there is NO 'OI Shopping List' folder -> create new
                if (folder_id == string.Empty)
                {
                    Dictionary<string, object> folderData = new Dictionary<string, object>();
                    folderData.Add("name", "OI Shopping List");
                    LiveConnectClient createFolderClient = new LiveConnectClient(LiveSession);
                    createFolderClient.PostCompleted += new EventHandler<LiveOperationCompletedEventArgs>(createFolderClient_PostCompleted);
                    createFolderClient.PostAsync("/me/skydrive", folderData);
                }
                else
                {
                    //Set SystemTray.ProgressIndicator.Visibility = false
                    //and enabling file upload button after receiving 'OI Shopping List' folder ID
                    SystemTray.ProgressIndicator.IsVisible = false;
                    UploadButton.IsEnabled = true;
                    //Start downloading SkyDrive data list
                    this.DownloadSkyDriveDataList();
                }

            }
            else
            {
                MessageBox.Show("There is an error occur during loading data from SkyDrive: " + e.Error.Message, "Warning", MessageBoxButton.OK);
                SystemTray.ProgressIndicator.IsVisible = false;
                NavigationService.GoBack();
            }
        }
开发者ID:openintents,项目名称:shoppinglist_winphone,代码行数:33,代码来源:SkyDrivePage.xaml.cs

示例13: Create_new_album

 /// <summary>
 /// Create_new_album crates a new album
 /// </summary>
 private void Create_new_album()
 {
     Dictionary<string, object> folderData = new Dictionary<string, object>();
     folderData.Add("name", NewAlbumName);
     folderData.Add("type", "album");
     LiveConnectClient client = new LiveConnectClient(App.Session);
     client.PostCompleted +=
         new EventHandler<LiveOperationCompletedEventArgs>(CreateFolder_Completed);
     client.PostAsync("me/skydrive", folderData);
 }
开发者ID:masiboo,项目名称:SkyPhoto_WP7.5,代码行数:13,代码来源:AlbumPage.xaml.cs


注:本文中的Microsoft.Live.LiveConnectClient.PostAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。