コード例 #1
0
ファイル: DiskManager.cs プロジェクト: damiangrzelak/MPW
 public void WriteToFile(object file)
 {
     if (file is ServerFile f)
     {
         Console.WriteLine("[DM INFO] Write to disk:: {0} file:: {1} owner:: {2} size::{3}", pathToXMLFile, f.fileName, f.owner, currentFileSize);
         Thread.Sleep(f.size);
         //Zapis do pliku
         CSVFileManager.WriteToCSVFile(pathToXMLFile, f.owner, f.fileName);
         Console.WriteLine("[DM INFO] File {0} saved.", f.fileName);
         currentFileSize = FileSizeE.FREE;
         thread          = new Thread(WriteToFile);
     }
 }
コード例 #2
0
ファイル: ResourceManager.cs プロジェクト: damiangrzelak/MPW
        public Boolean CreateDiskSpace()
        {
            const String pathToLocalDirectory = @"d:\DropboxApp\ServerSpace\";
            IReadOnlyDictionary <String, String> diskSpaceMap = new Dictionary <String, String>()
            {
                { "Disk1\\", "disk1Files.csv" },
                { "Disk2\\", "disk2Files.csv" },
                { "Disk3\\", "disk3Files.csv" },
                { "Disk4\\", "disk4Files.csv" },
                { "Disk5\\", "disk5Files.csv" }
            };

            foreach (KeyValuePair <String, String> disk in diskSpaceMap)
            {
                String pathToDisk = pathToLocalDirectory + disk.Key;
                String pathToFile = pathToDisk + disk.Value;
                try
                {
                    if (!Directory.Exists(pathToDisk))
                    {
                        Console.WriteLine("[INFO RM] Create new disc space " + pathToDisk);
                        Directory.CreateDirectory(pathToDisk);
                    }

                    if (!File.Exists(pathToFile))
                    {
                        Console.WriteLine("[INFO RM] Create new CSV file {0}  for {1}", disk.Value, disk.Key);
                        CSVFileManager.CreateNewCSVFile(pathToFile);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("[ERROR RM] The process failed: {0}", e.ToString());
                    return(false);
                }
                diskList.Add(new DiskManager(pathToDisk, pathToFile));
            }
            Thread thread = new Thread(WriteResourceHandler);

            thread.Start();
            return(true);
        }
コード例 #3
0
ファイル: DiskManager.cs プロジェクト: damiangrzelak/MPW
 public List <String> GetAllUserFiles(String username)
 {
     return(CSVFileManager.GetAllUserFiles(pathToXMLFile, username));
 }