コード例 #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; }
                }
            }
        }
コード例 #2
0
        static void UploadImages()
        {
            var container = new ContainerRestCon();
            var fotos     = container.ListFotos();
            var 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"))
                            {
                                var asyncPhoto  = new AsyncPhotoBlob(storage);
                                var listObjects = new Java.Lang.Object[] { foto, item.SERVIDOR, false };
                                asyncPhoto.Execute(listObjects);
                            }
                        }
                        if (item.AVATAR_STATUS != (int)StatusAPI.CONCLUIDO && item.AVATAR != null)
                        {
                            var asyncPhotoProfile = new AsyncPhotoBlob(storage);
                            var listObjects       = new Java.Lang.Object[] { item.AVATAR, item.SERVIDOR, true };
                            asyncPhotoProfile.Execute(listObjects);
                            item.AVATAR_STATUS = (int)StatusAPI.CONCLUIDO;
                            model.db.AtualizaUserInfo(item);
                        }
                        MetricsManager.TrackEvent("UploadImage");
                    }
                    catch (BadRequestException) { storage = null; }
                    catch (UnauthorizedException) { storage = null; }
                    catch (ConnectException) { storage = null; }
                    catch (ArgumentNullException) { storage = null; }
                }
            }
        }