示例#1
0
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            FrameworkElement senderElement = sender as FrameworkElement;
            selectedDoc = senderElement.DataContext as Document;

            MessageDialog dialog = new MessageDialog("Вы уверены, что хотите удалить документ?");
            dialog.Commands.Add(new UICommand("Да", new UICommandInvokedHandler(CommandHandlers)));
            dialog.Commands.Add(new UICommand("Нет", new UICommandInvokedHandler(CommandHandlers)));
            await dialog.ShowAsync();
        }
示例#2
0
        private Document DeserializeDoc(string json)
        {
            long id;
            long owner_id;
            string title;
            long size;
            string ext;
            string url;
            long date;
            string photo_130;

            Document resultDoc = null;

            try
            {
                JObject results = JObject.Parse(json);
                foreach (JToken result in results["response"])
                {
                    ext = (string)result["ext"];

                    id = (long)result["id"];
                    owner_id = (long)result["owner_id"];
                    title = (string)result["title"];
                    size = (long)result["size"];
                    url = (string)result["url"];
                    date = (long)result["date"];
                    try
                    {
                        photo_130 = (string)result["photo_130"];

                    }
                    catch
                    {
                        photo_130 = null;
                    }

                    resultDoc = new Document(id, owner_id, title, size, ext, url, photo_130, 0, date);
                }
            }
            catch(Exception e)
            {

            }

            return resultDoc;
        }
        private async void DownloadDoc(Document doc)
        {
            //downloadGrid.Visibility = Visibility.Visible;
            dGrid.Visibility = Visibility.Visible;

            Uri source = new Uri(doc.Url);
            string destination = doc.Downloaded_title;

            StorageFile destinationFile;

            try
            {
                destinationFile = await App.DOCSFOLDER.CreateFileAsync(destination);
            }
            catch (Exception ex)
            {
                destinationFile = await App.DOCSFOLDER.CreateFileAsync(destination.Split(' ')[0] + "." + doc.Ext);
            }

            App.CurrentDocument.LocalPath = destinationFile.Path;

            await Download(source, destinationFile);

        }
示例#4
0
 public File(FileType type, Document doc)
 {
     Type = type;
     DocumentFile = doc;
 }
        private async Task<bool> IsDownloaded(Document doc)
        {
            bool result = true;
            IStorageItem destinationFile = null;
            try
            {
                destinationFile = await App.DOCSFOLDER.TryGetItemAsync(doc.Downloaded_title);
            }
            catch { }

            if (destinationFile == null)
                destinationFile = await App.DOCSFOLDER.TryGetItemAsync(doc.Downloaded_title.Split(' ')[0] + "." + doc.Ext);

            if (destinationFile == null)
                result = false;


            return result;
        }