Exemplo n.º 1
0
        public void EndGetSharedKey(IAsyncResult result)
        {
            try
            {
                if (result.IsCompleted)
                {
                    _containerSharedSignature = FileService.EndGetContainerSignedSignature(result);

                    if (_containerSharedSignature != null)
                    {
                        InProgress = true;

                        IsStorageDisponible = true;

                        Regex regex = new Regex("\\?se=(?<year>\\d*)-(?<month>\\d*)-(?<day>\\d*)T(?<h>\\d*)%3A(?<m>\\d*)%3A(?<s>\\d*)");
                        var   match = regex.Match(_containerSharedSignature);


                        _expirationDate = new DateTime(
                            Convert.ToInt32(match.Groups["year"].Value),
                            Convert.ToInt32(match.Groups["month"].Value),
                            Convert.ToInt32(match.Groups["day"].Value),
                            Convert.ToInt32(match.Groups["h"].Value),
                            Convert.ToInt32(match.Groups["m"].Value),
                            Convert.ToInt32(match.Groups["s"].Value)
                            );

                        FileService.BeginGetContainerUrl(_userId, EndGetContainerUrl, null);
                    }
                    //if the cloud services are not disponible on the server side
                    else
                    {
                        _isStorageDisponible = false;

                        ErrorMessage = "Cloud Services are not disponible.";
                        IsError      = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                IsError      = true;
            }
            finally
            {
                InProgress = false;
            }
        }