Exemplo n.º 1
0
        public static async Task <bool> removerLink(linking link)
        {
            try
            {
                TableOperation deleteOperation = TableOperation.Delete(link);
                TableResult    finalResult     = await linkingTable.ExecuteAsync(deleteOperation);

                await helper.deleteLinkLocal(link.getTeamName(), link.getFilename());

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public static async Task <string> makeLink(string teamname, string filename, string size)
        {
            try
            {
                linking        temp            = new linking(helper.getUsername(), filename, teamname, size);
                TableOperation insertOperation = TableOperation.Insert(temp);
                await linkingTable.ExecuteAsync(insertOperation);

                await helper.addLinkDataLocal(temp);

                return("SUCCESS");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemplo n.º 3
0
        public static async Task <bool> addLinkDataLocal(linking temp)
        {
            StorageFolder folder = ApplicationData.Current.LocalFolder;
            StorageFile   textFile;

            try
            {
                textFile = await folder.CreateFileAsync("linking.ini", CreationCollisionOption.FailIfExists);
            }
            catch
            {
                textFile = await folder.CreateFileAsync("linking.ini", CreationCollisionOption.OpenIfExists);
            }
            string jsonContents = JsonConvert.SerializeObject(temp);
            await FileIO.AppendTextAsync(textFile, jsonContents + "\n");

            return(true);
        }
Exemplo n.º 4
0
        public static async Task <bool> removerLink(string teamname, string filename)
        {
            try
            {
                linking link = await fetchLink(teamname, filename);

                TableOperation deleteOperation = TableOperation.Delete(link);
                TableResult    finalResult     = await linkingTable.ExecuteAsync(deleteOperation);

                await helper.deleteLinkLocal(teamname, filename);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        public static async Task <bool> deleteFile(files file, linking link, accessKeys key)
        {
            try
            {
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connection.getConnectionString());
                CloudBlobClient     blobClient     = storageAccount.CreateCloudBlobClient();
                CloudBlobContainer  container      = blobClient.GetContainerReference(helper.getUsername());
                await container.CreateIfNotExistsAsync();

                CloudBlockBlob blockBlob = container.GetBlockBlobReference(file.getFilename());
                await blockBlob.DeleteIfExistsAsync();

                files temp = await fetchFile(helper.getUsername(), file.getFilename());

                if (temp != null)
                {
                    await updateFileCount(Convert.ToDouble(temp.size), 1);
                    await deleteFileOnline(temp);

                    await helper.deleteFileDataLocal(temp.getFilename());

                    if (link != null)
                    {
                        await removerLink(link);
                    }
                    if (key != null)
                    {
                        await deleteKey(key);
                    }
                }

                return(true);
            }
            catch { }
            return(false);
        }
Exemplo n.º 6
0
        private async void deleteFileBtn_Click(object sender, RoutedEventArgs e)
        {
            if (enableComponent)
            {
                if (helper.checkInternetConnection())
                {
                    object[] listSelected = list.SelectedItems.ToArray <object>();
                    bool     userCheck    = await helper.dialogPopup("Do you want to delete these files", "Delete");

                    if (userCheck)
                    {
                        displayLoading("Deleting...");

                        int            current = 0, total = listSelected.Count <object>();
                        List <linking> linkingList = await users.getLink(helper.getUsername());

                        List <accessKeys> keys = await users.fetchAccessKeys();


                        foreach (files temp in listSelected)
                        {
                            linking    parameterLink = null;
                            accessKeys parameterKey  = null;
                            if (linkingList != null)
                            {
                                foreach (linking link in linkingList)
                                {
                                    if (link.getFilename() == temp.getFilename())
                                    {
                                        parameterLink = link;
                                    }
                                }
                            }
                            if (keys != null)
                            {
                                foreach (accessKeys key in keys)
                                {
                                    if (key.getFilename() == temp.getFilename())
                                    {
                                        parameterKey = key;
                                    }
                                }
                            }
                            displayLoading("Deleting files ...\nFile: " + current.ToString() + "/" + total);
                            if (!await users.deleteFile(temp, parameterLink, parameterKey))
                            {
                                helper.popup("The file couldn't be deleted. Please try again", "DELETION FAILED");
                            }
                            current++;
                        }
                        await setListView();

                        disableLoading();
                    }
                    else
                    {
                        foreach (files file in listSelected)
                        {
                            list.SelectedItems.Remove(file);
                        }
                    }
                }
                else
                {
                    helper.popup("Check your internet connection", "NO INTERNET");
                }
            }
        }