コード例 #1
0
        public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            Trace.WriteLine("WorkerRole1 entry point called", "Information");

            CloudStorageAccount.SetConfigurationSettingPublisher(
                (name, publisher) =>
            {
                var connectionString = RoleEnvironment.GetConfigurationSettingValue(name);
                publisher(connectionString);
            }
                );

            var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
            AzureQueue <UserRegistrationMessage> queue = new AzureQueue <UserRegistrationMessage>(account);

            queue.EnsureExist();

            AzureBlobContainer <RegistrationTokenEntity> registrationBlob = new AzureBlobContainer <RegistrationTokenEntity>(account, "registrationtoken", true);

            registrationBlob.EnsureExist(true);

            while (true)
            {
                try
                {
                    var message = queue.GetMessage();
                    if (message != null)
                    {
                        var entity = new RegistrationTokenEntity();
                        entity.RegistrationToken = (new Random()).Next().ToString();
                        registrationBlob.Save(message.RegistratoinId, entity);
                        queue.DeleteMessage(message);
                    }
                }
                catch { }
                Thread.Sleep(5000);
            }
        }
コード例 #2
0
        public ActionResult Register(RegisterModel model)
        {
            AzureQueue<UserRegistrationMessage> queue = new AzureQueue<UserRegistrationMessage>(account);
            AzureBlobContainer<RegistrationTokenEntity> registrationBlob = new AzureBlobContainer<RegistrationTokenEntity>(account, true);

            var containerId = Guid.NewGuid().ToString();
            registrationBlob.Save(containerId, new RegistrationTokenEntity
            {
                RegistrationToken = null,
            });
            var blobContainer = registrationBlob.GetSharedAccessSignature(containerId, DateTime.Now.AddHours(1));

            queue.AddMessage(new UserRegistrationMessage
            {
                DateOfBirth = model.DateOfBirth,
                Email = model.Email,
                FirstName = model.FirstName,
                LastName = model.LastName,
                ContainerId = containerId,
            });

            return Json(new { container = blobContainer });
        }
コード例 #3
0
        public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            Trace.WriteLine("WorkerRole1 entry point called", "Information");

            CloudStorageAccount.SetConfigurationSettingPublisher(
              (name, publisher) =>
              {
                  var connectionString = RoleEnvironment.GetConfigurationSettingValue(name);
                  publisher(connectionString);
              }
            );

            var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
            AzureQueue<UserRegistrationMessage> queue = new AzureQueue<UserRegistrationMessage>(account);
            queue.EnsureExist();

            AzureBlobContainer<RegistrationTokenEntity> registrationBlob = new AzureBlobContainer<RegistrationTokenEntity>(account, "registrationtoken", true);
            registrationBlob.EnsureExist(true);

            while (true)
            {
                try
                {
                    var message = queue.GetMessage();
                    if (message != null)
                    {
                        var entity = new RegistrationTokenEntity();
                        entity.RegistrationToken = (new Random()).Next().ToString();
                        registrationBlob.Save(message.RegistratoinId, entity);
                        queue.DeleteMessage(message);
                    }
                }
                catch { }
                Thread.Sleep(5000);
            }
        }