public async void PhotoUpdated(int position, PhotoUploadStatus newStatus = PhotoUploadStatus.Pending)
        {
            CustomerPhotoController controller = new CustomerPhotoController();
            CustomerPhoto           photo      = this.CustomerPhotos[position];

            photo.PhotoUploadStatus = newStatus;

            await controller.SaveAsync(photo);

            CustomerPhoto backUpPhoto = new CustomerPhoto
            {
                CustomerIdentifier = this.CustomerPhotos[position].CustomerIdentifier,
                FilePath           = this.CustomerPhotos[position].FilePath,
                Phone             = this.CustomerPhotos[position].Phone,
                PhotoStatus       = this.CustomerPhotos[position].PhotoStatus,
                PhotoUploadStatus = this.CustomerPhotos[position].PhotoUploadStatus,
                TypeOfPhoto       = this.CustomerPhotos[position].TypeOfPhoto,
                Id       = this.CustomerPhotos[position].Id,
                Created  = this.CustomerPhotos[position].Created,
                Modified = this.CustomerPhotos[position].Modified
            };

            this.CustomerPhotos.RemoveAt(position);
            this.CustomerPhotos.Insert(position, backUpPhoto);

            this.RaisePropertyChanged(() => this.CustomerPhotos);
        }
        private void Initialize()
        {
            try
            {
                Logger.Verbose("Retrieving Azure SAS Token from OTA");

                //retrieve windows azure sas token from OTA
                _azureSasToken = Settings.Instance.AzureSasToken;

                //if the azure token key is empty then get default values defined in the string resource file, depending on the environment and or country
                if (string.IsNullOrEmpty(_azureSasToken))
                {
                    Logger.Verbose("Azure Token is Empty, getting default value from string file");
#if DEBUG || UAT
                    Logger.Verbose("Retrieving UAT Azure SAS Token default value");
                    _azureSasToken = _context.GetString(Resource.String.azure_uat_token);
#elif STAGING
                    Logger.Verbose("Retrieving STAGING Azure SAS Token default value");
                    _azureSasToken = _context.GetString(Resource.String.azure_staging_token);
#else
                    switch (Settings.Instance.DsrCountryCode)
                    {
                    case CountryCodes.KE:
                        Logger.Verbose("Retrieving RELEASE KE Azure SAS Token default value");
                        _azureSasToken = _context.GetString(Resource.String.azure_ke_prod_token);
                        break;

                    case CountryCodes.UG:
                        Logger.Verbose("Retrieving RELEASE UG Azure SAS Token default value");
                        _azureSasToken = _context.GetString(Resource.String.azure_ug_prod_token);
                        break;

                    case CountryCodes.TZ:
                        Logger.Verbose("Retrieving RELEASE TZ Azure SAS Token default value");
                        _azureSasToken = _context.GetString(Resource.String.azure_tz_prod_token);
                        break;

                    case CountryCodes.GH:
                        Logger.Verbose("Retrieving RELEASE GH Azure SAS Token default value");
                        _azureSasToken = _context.GetString(Resource.String.azure_gh_prod_token);
                        break;
                    }
#endif
                }

                Logger.Verbose(_azureSasToken);

                _uploadRetryCount    = 3;
                _uploadRetryDuration = TimeSpan.FromSeconds(5);

                //For large blobs, images above 1MB are uploaded in blocks in another thread
                _blobRequestOptions = new BlobRequestOptions()
                {
                    SingleBlobUploadThresholdInBytes = 1024 * 1024, //1MB, the minimum
                    ParallelOperationThreadCount     = 1,
                    //ServerTimeout = TimeSpan.FromSeconds(20),
                    //RetryPolicy = new ExponentialRetry(backOffPeriod, retryCount),
                    RetryPolicy = new LinearRetry(_uploadRetryDuration, _uploadRetryCount)
                };

                _photoBlobContainer = new CloudBlobContainer(new Uri(_azureSasToken));
                _photoBlobContainer.ServiceClient.DefaultRequestOptions = _blobRequestOptions;

                _photoController = new CustomerPhotoController();
            }
            catch (StorageException se)
            {
                Logger.Verbose("StorageException when Initializing CloudBlobContainer");
                Logger.Verbose(se.Message);
                Logger.Error(se);
            }
            catch (Exception e)
            {
                Logger.Verbose("General Exception when Initializing CloudBlobContainer, SAS Token is Empty");
                Logger.Verbose(e.Message);
                Logger.Error(e);
            }
        }
示例#3
0
 public CustomerPhotoService()
 {
     this._controller = new CustomerPhotoController();
 }