Опубликован: 30.05.2011 | Доступ: свободный | Студентов: 2384 / 213 | Оценка: 4.12 / 4.41 | Длительность: 12:00:00
Специальности: Программист, Архитектор программного обеспечения
Теги:
Самостоятельная работа 3:
Настройка хранилища разработки в Visual Studio 2010
Список вспомогательных материалов
Приложение WorkerRole1.cs
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; using System.Threading; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; using Microsoft.WindowsAzure.StorageClient; using System.Data.Services.Client; namespace WorkerRole1 { public class WorkerRole : RoleEntryPoint { public override void Run() { CloudStorageAccount.SetConfigurationSettingPublisher( (configName, configSettingPublisher) => { var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName); configSettingPublisher(connectionString); } ); CloudStorageAccount account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); //создание таблицы Windows Azure Table CloudTableClient _tc = null; _tc = account.CreateCloudTableClient(); _tc.DeleteTableIfExist("Address"); _tc.CreateTableIfNotExist("Address"); Address adrs = new Address(); adrs.PartitionKey = "Firm"; adrs.RowKey = "Test entity"; adrs.telephone = "xxx-xx-xx"; adrs.address = "Evergreen Terrace 247"; adrs.firm = "My new firm"; AddressConext context = new AddressConext(account.TableEndpoint, account.Credentials); context.AddObject("Address", adrs); context.SaveChanges(); } public override bool OnStart() { ServicePointManager.DefaultConnectionLimit = 12; return base.OnStart(); } class Address : TableServiceEntity { public String address { get; set; } public String firm { get; set; } public String telephone { get; set; } } class AddressConext: TableServiceContext { public IQueryable<Address> ContactData { get { return this.CreateQuery<Address>("Address"); } } public AddressConext(Uri baseAddress, StorageCredentials credentials) : base(baseAddress.AbsoluteUri, credentials) { } } } }