Esempio n. 1
0
        static void UploadImages()
        {
            var container = new ContainerRestCon();
            var fotos     = container.ListFotos();
            var infoUser  = new List <TB_USUARIO>();

            infoUser = model.db.SelectInfoDeUsuarios();
            if (infoUser != null)
            {
                foreach (var item in infoUser)
                {
                    try
                    {
                        if (storage == null)
                        {
                            storage = new AzureStorage();
                        }
                        if (storage.clientAzureStorage == null)
                        {
                            storage = new AzureStorage();
                        }
                        foreach (var foto in fotos)
                        {
                            if (foto.Contains("VISITA"))
                            {
                                using (var img = container.LerArquivo(foto))
                                {
                                    if (img != null)
                                    {
                                        storage.UploadImage(img, foto, item.SERVIDOR);
                                        container.DeleteArquivo(foto);
                                    }
                                }
                            }
                        }
                        if (item.AVATAR_STATUS != (int)StatusAPI.CONCLUIDO && item.AVATAR != null)
                        {
                            using (var img = container.LerArquivo(item.AVATAR))
                            {
                                if (img != null)
                                {
                                    storage.UploadImage(img, item.AVATAR, item.SERVIDOR);
                                    item.AVATAR_STATUS = (int)StatusAPI.CONCLUIDO;
                                    model.db.AtualizaUserInfo(item);
                                }
                            }
                        }
#if !DEBUG
                        MetricsManager.TrackEvent("UploadImage");
#endif
                    }
                    catch (BadRequestException) { storage = null; }
                    catch (UnauthorizedException) { storage = null; }
                    catch (ArgumentNullException) { storage = null; }
                }
            }
        }
 protected override void OnPostExecute(Java.Lang.Object result)
 {
     base.OnPostExecute(result);
     if (!hasError && !isAvatarProfile)
     {
         container.DeleteArquivo(foto);
     }
     hasError = false;
 }