public async override void Init(object initData)
        {
            base.Init(initData);

            documentToDisplay = (DocumentMindurry)initData;

            Title = documentToDisplay.Name;
            var docDownloaded = await PclStorage.LoadFileLocal(documentToDisplay.InternalName + ".pdf", documentToDisplay.ReferenceKind, documentToDisplay.ReferenceId);

            if (docDownloaded != null)
            {
                PdfDocumentStream = new MemoryStream(docDownloaded);
                Visibility        = true;
            }
            else
            {
                Message    = "Une erreur est survenue, Merci de réessayer.";
                Visibility = false;
            }
        }
Esempio n. 2
0
        public virtual async Task <bool> OfflineUploadSync()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                await InitializeStore().ConfigureAwait(false);

                var items = await GetItemsAsync(true);

                foreach (var item in items)
                {
                    if (item.ToUpload)
                    {
                        var file = await PclStorage.LoadFileLocal(item.Id);

                        if (file != null)
                        {
                            var isUploaded = await UploadDocument(file, item);

                            if (isUploaded)
                            {
                                item.ToUpload = false;
                                await UpdateAsync(item);
                            }
                        }
                    }
                }

                // await PullLatest();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public async override void Init(object initData)
        {
            base.Init(initData);

            Apartment = (Apartment)initData;

            if (!string.IsNullOrEmpty(Apartment.ContactId))
            {
                Contact Contact = await StoreManager.ContactStore.GetItemAsync(Apartment.ContactId);

                if (Contact != null)
                {
                    ContactName = Contact.Name;
                }
            }

            // terraces list
            var terraces = await StoreManager.TerraceStore.GetTerracesByResidenceId(Apartment.ResidenceId, Apartment.Id);

            if (terraces != null && terraces.Any())
            {
                Terraces = new ObservableCollection <Terrace>(terraces);
            }
            // gardens list
            var gardens = await StoreManager.GardenStore.GetGardensByResidenceId(Apartment.ResidenceId, Apartment.Id);

            if (gardens != null && gardens.Any())
            {
                Gardens = new ObservableCollection <Garden>(gardens);
            }
            //Pull document from Azure Storage to  Locastorage if internet
            var current = Connectivity.NetworkAccess;

            if (current == NetworkAccess.Internet)
            {
                var resultPull = await StoreManager.DocumentMindurryStore.PullLatest(Apartment.Id, ReferenceKind.Apartment.ToString().ToLower());
            }
            //Documents
            var docs = await StoreManager.DocumentMindurryStore.GetItemsByKindAndReferenceIdAsync(Apartment.Id, ReferenceKind.Apartment.ToString().ToLower());

            if (docs != null && docs.Any())
            {
                DocumentMindurry documentToDisplay;
                string           fileName;

                var finals = docs.Where(x => x.DocumentType == DocumentType.Definitif.ToString().ToLower());
                if (finals != null && finals.Any())
                {
                    documentToDisplay = finals.First();
                    fileName          = documentToDisplay.InternalName + "." + documentToDisplay.Extension;
                    var docDownloaded = await PclStorage.LoadFileLocal(fileName, ReferenceKind.Apartment.ToString().ToLower(), documentToDisplay.ReferenceId);

                    //  var docDownloaded = await StoreManager.DocumentMindurryStore.DownLoadDocument(documentToDisplay.Id);
                    PdfDocumentStream = new MemoryStream(docDownloaded);
                }
                else
                {
                    var signs = docs.Where(x => x.DocumentType == DocumentType.Signe.ToString().ToLower());
                    if (signs != null && signs.Any())
                    {
                        documentToDisplay = signs.First();
                        fileName          = documentToDisplay.InternalName + "." + documentToDisplay.Extension;
                        var docDownloaded = await PclStorage.LoadFileLocal(fileName, ReferenceKind.Apartment.ToString().ToLower(), documentToDisplay.ReferenceId);

                        //  var docDownloaded = await StoreManager.DocumentMindurryStore.DownLoadDocument(documentToDisplay.Id);
                        PdfDocumentStream = new MemoryStream(docDownloaded);
                    }
                    else
                    {
                        var initials = docs.Where(x => x.DocumentType == DocumentType.Initial.ToString().ToLower());
                        if (initials != null && initials.Any())
                        {
                            documentToDisplay = initials.First();
                            fileName          = documentToDisplay.InternalName + "." + documentToDisplay.Extension;
                            var docDownloaded = await PclStorage.LoadFileLocal(fileName, ReferenceKind.Apartment.ToString().ToLower(), documentToDisplay.ReferenceId);

                            //    var docDownloaded = await StoreManager.DocumentMindurryStore.DownLoadDocument(documentToDisplay.Id);
                            PdfDocumentStream = new MemoryStream(docDownloaded);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public async Task <byte[]> GetDocumentDataById(string key)
        {
            var data = await PclStorage.LoadFileLocal(key);

            return(data);
        }