Ejemplo n.º 1
0
        internal static void CopyDataOnDevices(Storage[] devices, DataToCopy Data)
        {
            int      filesCopied;
            double   volumeCopied;
            int      deviceNumber = 0;
            TimeSpan time;
            TimeSpan totalTime = new TimeSpan();

            foreach (Storage obj in devices)
            {
                deviceNumber++;
                try
                {
                    Console.WriteLine("{0}Device #{1}{0}{2}", Environment.NewLine, deviceNumber, obj.ToString());
                    time       = obj.CopyData(Data, out filesCopied, out volumeCopied);
                    totalTime += time;
                    Console.WriteLine("Copying took {0:hh\\:mm\\:ss} (hours:minutes:seconds).", time);
                    Console.WriteLine("{1:f3} GB copied in {2} files.{0}{3:f3} GB left free in the device.{0}{4:f3} GB left to copy in {5} files.",
                                      Environment.NewLine, volumeCopied, filesCopied, obj.FreeVolume, Data.VolumeToCopy, Data.FilesToCopy);
                    if (Data.FilesToCopy == 0)
                    {
                        Console.WriteLine("Copying ends. It took {1:hh\\:mm\\:ss} (hours:minutes:seconds).{0}",
                                          Environment.NewLine, totalTime);
                        break;
                    }
                    Console.WriteLine("You would need {1} more the same devices to copy the rest data.{0}",
                                      Environment.NewLine, Math.Ceiling((double)(Data.FilesToCopy / filesCopied)));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Flash        flash1 = new Flash("Apacer", 2);
            DVD_plus_RW  dvd1   = new DVD_plus_RW("NoName", "single");
            HDD_portable hdd1   = new HDD_portable("SmartBy", 32, 12);

            Storage[] devices = { new Flash("Silicon Power",                                   8), new Flash("Transcend",                            16), flash1,
                                  new DVD_plus_RW("Verbatim",  "single"),                          new DVD_plus_RW("Memorex", "DuaL"),                    dvd1,
                                  new HDD_portable("Kingston",                                128,                        4), new HDD_portable("Sundisk",                       24.2, 10.2, 12.0),
                                  hdd1,                        new HDD_portable("Western Digital",                       512,                        10), new HDD_portable("Toshiba", 1024, 25) };

            DataToCopy Data = new DataToCopy();

            Console.Write("Copying starts.{0}{1:f3} GB to copy in {2} files.{0}",
                          Environment.NewLine, Data.VolumeToCopy, Data.FilesToCopy);
            Console.WriteLine("Total memory of all devices you are have in disposal: {1} GB.{0}", Environment.NewLine, Storage.TotalMemory(devices));
            Copyist.CopyDataOnDevices(devices, Data);
        }