Exemple #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in contentView.SelectedItems)
            {
                switch (recognizeSelectedItem(item))
                {
                case 1:         //DRIVE
                    break;

                case 2:         //DIRECTORY
                    r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)item.Tag;
                    if (MessageBox.Show("Are you sure you want to permanently delete this folder", "Delete Folder", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        FileSystem.RequestDelete(server.serverPort.Stream, dir.FullName);
                    }
                    break;

                case 3:         //FILE
                    r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)item.Tag;
                    if (MessageBox.Show("Are you sure you want to permanently delete this file", "Delete File", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        FileSystem.RequestDelete(server.serverPort.Stream, fil.FullName);
                    }
                    break;
                }
            }
            refreshContent();
        }
Exemple #2
0
        private void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListViewItem sItem = contentView.SelectedItems[0];  //GET THE SELECTED OBJECT

            switch (recognizeSelectedItem(sItem))
            {
            case 1:     //DRIVE
                break;

            case 2:     //DIRECTORY
                r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)sItem.Tag;
                InputBoxForm di = new InputBoxForm();
                di.Response = dir.Name;
                di.initiateText("Enter the new name of folder", "Rename Folder");
                if (di.ShowDialog(this) == DialogResult.OK)
                {
                    string des = dir.FullName.Substring(0, dir.FullName.Length - dir.Name.Length) + di.Response;
                    if (des != dir.FullName)
                    {
                        FileSystem.RequestRename(server.serverPort.Stream, dir.FullName, des);
                    }
                }
                di.Dispose();
                break;

            case 3:     //FILE
                r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)sItem.Tag;
                InputBoxForm diF = new InputBoxForm();
                diF.Response = fil.Name;
                diF.initiateText("Enter the new name of file", "Rename File");
                if (diF.ShowDialog(this) == DialogResult.OK)
                {
                    string des = fil.FullName.Substring(0, fil.FullName.Length - fil.Name.Length) + diF.Response;
                    if (des != fil.FullName)
                    {
                        FileSystem.RequestRename(server.serverPort.Stream, fil.FullName, des);
                    }
                }
                diF.Dispose();
                break;

            case 0:
                MessageBox.Show("UnKnown Item found", "Error");
                break;
            }
            refreshContent();       //REQUEST FOR NEW CONTENTS
        }
Exemple #3
0
        private void PropertiesBoxForm_Load(object sender, EventArgs e)
        {
            switch (recognizeSelectedItem(Tag))
            {
            case 1:         //DRIVE
                r.DrivesInformationResponse.DriveInfo div = (r.DrivesInformationResponse.DriveInfo)Tag;
                Close();
                break;

            case 2:         //DIRECTORY
                r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)Tag;
                Text           = $"{dir.Name} Properties";
                nameLabel.Text = dir.Name;
                typeLabel.Text = "Folder";
                locLabel.Text  = dir.FullName.Substring(0, dir.FullName.Length - dir.Name.Length);
                sizeLabel.Text = "<unknown>";
                DateTime dt = FileSystem.StringToDate(dir.CreationTime);
                createdLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}";
                dt = FileSystem.StringToDate(dir.LastWriteTime);
                modifiedLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}";
                dt = FileSystem.StringToDate(dir.LastAccessTime);
                accessedLabel.Text = $"{dt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dt.Month)} {dt.Day.ToString("00")}, {dt.Year}, {dt.Hour.ToString("00")}:{dt.Minute.ToString("00")}:{dt.Second.ToString("00")}";
                break;

            case 3:         //FILE
                r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)Tag;
                Text           = $"{fil.Name.Replace(fil.Extention,"")} Properties";
                nameLabel.Text = fil.Name;
                typeLabel.Text = $"File ({fil.Extention})";
                locLabel.Text  = fil.FullName.Substring(0, fil.FullName.Length - fil.Name.Length);
                sizeLabel.Text = $"{fil.Length} bytes";
                DateTime dtt = FileSystem.StringToDate(fil.CreationTime);
                createdLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}";
                dtt = FileSystem.StringToDate(fil.LastWriteTime);
                modifiedLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}";
                dtt = FileSystem.StringToDate(fil.LastAccessTime);
                accessedLabel.Text = $"{dtt.DayOfWeek.ToString()}, {MyGlobal.MonthOfYear(dtt.Month)} {dtt.Day.ToString("00")}, {dtt.Year}, {dtt.Hour.ToString("00")}:{dtt.Minute.ToString("00")}:{dtt.Second.ToString("00")}";
                break;
            }
            if (objectIcon != null)
            {
                pictureBox1.Image = objectIcon;
            }
        }
Exemple #4
0
        public async Task <string> GetLocalFile(string serverIP, r.FileInformationResponse.FileInfo fileInfo)
        {
            string key = $"{serverIP}:{fileInfo.FullName}";

            isUpdated = false;
            if (fileList.ContainsKey(key))
            {
                try
                {
                    //THERE IS A LOCAL COPY
                    LocalServerStorageStucture _localCopy = fileList[key];
                    //VALIDATE THE LOCAL COPY
                    if (fileInfo.CreationTime == _localCopy.fileInfo.CreationTime &&
                        fileInfo.LastWriteTime == _localCopy.fileInfo.LastWriteTime &&
                        fileInfo.Length == _localCopy.fileInfo.Length)
                    {
                        //return await Task<string>.Factory.StartNew(() => { return _localCopy.localPath; });
                        return(_localCopy.localPath);
                    }
                    else
                    {
                        fileList.Remove(key);   //REMOVE THE LOCAL COPY AS THE ORIGINAL IS GOT UPDATED
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            string desPath = LOCAL_DATABASE_STORAGE_PATH + $"{fileInfo.Name} - " + Guid.NewGuid().ToString() + fileInfo.Extention;

            await downloadFile(serverIP, fileInfo.FullName, desPath);

            //REGISTER THE DOWNLOADED COPY
            LocalServerStorageStucture newLocalCopy = new LocalServerStorageStucture()
            {
                serverIP = serverIP, fileInfo = fileInfo, localPath = desPath
            };

            fileList.Add(key, newLocalCopy); //REGISTER THE NEW COPY WITH THE KEY
            isUpdated = true;                //NOTIFY THE UPDATE IS MADE
            return(desPath);
        }
Exemple #5
0
        private async void openSelectedItem()
        {
            ListViewItem sItem = contentView.SelectedItems[0];  //GET THE SELECTED OBJECT

            switch (recognizeSelectedItem(sItem))
            {
            case 1:     //DRIVE
                r.DrivesInformationResponse.DriveInfo div = (r.DrivesInformationResponse.DriveInfo)sItem.Tag;
                addressBox.Text = div.RootDirectoryPath;
                break;

            case 2:     //DIRECTORY
                r.DirectoryInformationResponse.DirectoryInfo dir = (r.DirectoryInformationResponse.DirectoryInfo)sItem.Tag;
                addressBox.Text = dir.FullName;
                break;

            case 3:     //FILE
                r.FileInformationResponse.FileInfo fil = (r.FileInformationResponse.FileInfo)sItem.Tag;
                if (fil.Length > 4194304d)
                {
                    if (MessageBox.Show("Selected file is too long.\nWant to continue...", "Confirm", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        return;
                    }
                }
                string fPath = await MyGlobal.DB.LocalStorage.GetLocalFile(server.serverPort.ServerIP, fil);

                if (MyGlobal.DB.LocalStorage.isUpdated)
                {
                    await MyGlobal.DB.saveDatabase();
                }
                Process.Start(fPath);
                return;

                break;

            case 0:
                MessageBox.Show("UnKnown Item found", "Error");
                break;
            }
            refreshContent();       //REQUEST FOR NEW CONTENTS
        }
Exemple #6
0
        private void openInOtherDeviceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListViewItem sItem = contentView.SelectedItems[0];  //GET THE SELECTED OBJECT

            switch (recognizeSelectedItem(sItem))
            {
            case 1:     //DRIVE

                break;

            case 2:     //DIRECTORY

                break;

            case 3:     //FILE
                r.FileInformationResponse.FileInfo fill = (r.FileInformationResponse.FileInfo)sItem.Tag;
                ProcessSystem.RequestExecuteProcess(server.serverPort.Stream, fill.FullName);
                break;

            case 0:
                MessageBox.Show("UnKnown Item found", "Error");
                return;
            }
        }