public IPartner GetPartnerByLoginName(string loginName) { IPartner result = null; string location = @"AzureDalManager.GetPartnerByLoginName"; Stopwatch watch = Stopwatch.StartNew(); try { CloudBlobClient client = this.storageAccount.CreateCloudBlobClient(); BlobRequestOptions requestOption = new BlobRequestOptions() { UseFlatBlobListing = true }; string prefix = string.Format(CultureInfo.InvariantCulture, "{0}/partneraccount/", this.container.Name); foreach (IListBlobItem partnetAccountBlobItem in client.ListBlobsWithPrefix(prefix, requestOption)) { string[] segments = partnetAccountBlobItem.Uri.Segments; if (segments != null && segments.Length > 1) { string lastSegment = segments[segments.Length - 1]; if (!string.IsNullOrWhiteSpace(lastSegment)) { if (loginName.Equals(lastSegment, StringComparison.OrdinalIgnoreCase)) { string partnerIdentifier = segments[segments.Length - 2].Trim('/'); if (!string.IsNullOrWhiteSpace(partnerIdentifier)) { DalPartner dal = new DalPartner(this.storageAccount, this.container); result = dal.Get(partnerIdentifier); break; } } } } } } catch (Exception exception) { LoggerFactory.Logger.Warning(location, EventId.DALGetPartnerByLoginName, "Error executing AzureDalManager.GetPartnerByLoginName({0}) in container {1}: {2}." , loginName, this.container.Name, exception.ToString()); } finally { watch.Stop(); LoggerFactory.Logger.Debug(location, "AzureDalManager.GetPartnerByLoginName() finished in {0} ms.", watch.ElapsedMilliseconds); } return(result); }
public IPartner GetPartner(string identifier) { DalPartner dal = new DalPartner(this.storageAccount, this.container); return(dal.Get(identifier)); }