Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DataTable dt = XBase.Business.Office.SellManager.SellModuleSelectCurrencyBus.GetCurrencyTypeSetting();
         ConCurrencyType.DataSource     = dt;
         ConCurrencyType.DataTextField  = "CurrencyName";
         ConCurrencyType.DataValueField = "ID";
         ConCurrencyType.DataBind();
     }
 }
Пример #2
0
        public static async Task <bool> HandleConCurrencyUpdate(CloudBlockBlob blob, ConCurrencyType type)
        {
            bool result = false;

            switch (type)
            {
            case ConCurrencyType.Default:
                blob.Metadata["Author"]   = "Client Code";
                blob.Metadata["Priority"] = "High";
                blob.SetMetadata();
                break;

            case ConCurrencyType.Optimistic:
                blob.Metadata["Author"]   = "Client Code";
                blob.Metadata["Priority"] = "High";
                string leaseId = await blob.AcquireLeaseAsync(TimeSpan.FromMinutes(1));

                var accessCondition = new AccessCondition
                {
                    LeaseId = leaseId
                };
                await blob.SetMetadataAsync(accessCondition, null, null);

                break;

            case ConCurrencyType.Pessimistic:
                blob.Metadata["Author"]   = "Client Code";
                blob.Metadata["Priority"] = "High";
                var accessCondition1 = new AccessCondition
                {
                    IfMatchETag = blob.Properties.ETag
                };
                try
                {
                    await blob.SetMetadataAsync(accessCondition1, null, null);
                }
                catch (Exception exe)
                {
                    var cloudBlob = GetBlob();
                    await HandleConCurrencyUpdate(cloudBlob, ConCurrencyType.Pessimistic);

                    result = false;
                }
                break;
            }

            return(result);
        }