Exemple #1
0
        private async void btnGetRealmInfo_Click(object sender, EventArgs e)
        {
            Authenticator aithenticator = new Authenticator(Login, password, siteUrl);
            await aithenticator.InitializeAuth();

            XContext context = await aithenticator.GetCookiesAndDigest();

            XUser user = await context.GetCurrentUser();

            XList list = await context.GetList("Tests");

            //List<XListItem> listItems = await list.GetItems();
            //XListItem listItem = await list.GetItemById(23);

            string currentUserCaml =
                @"<Where>
						<Eq>
							<FieldRef Name='Author' LookupId='True' />
							<Value>
								Type='Integer'>
								<UserID />
							</Value>
						</Eq>
					</Where>"                    ;

            List <XListItem> listItems = await list.GetItems(currentUserCaml);

            XListItem item = listItems[0];

            item["Title"] = "new title";
            await item.Update();

            await listItems[0].Delete();
            await listItems[0].Recycle();

            //Upload a photo:
            byte[] imageBytes          = File.ReadAllBytes("photo.jpg");
            string destinationFileName = string.Format("Photo_{0}.jpg", Guid.NewGuid());
            string result = await context.UploadFile(imageBytes, "/Photos/", destinationFileName);

            var file = await context.GetFile("/Photos/", destinationFileName);
        }