Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="waitTime">Čakanie.</param>
        /// <param name="oldName">Starý názov.</param>
        /// <param name="newName">Nový názov.</param>
        /// <param name="oldSubFolder">Starý subFolder</param>
        /// <param name="newSubFolder">Nový subFolder.</param>
        /// <returns>Nový názov.</returns>
        public static string CopyFile(double waitTime, string oldName, string newName, string oldSubFolder, string newSubFolder)
        {
            newName = NameHelper.ShortenFileName(newSubFolder, newName, "_", 255);

            if (File.Exists(newSubFolder + Separator + newName))
            {
                File.Delete(newSubFolder + Separator + newName);
            }

            // Use ProcessStartInfo class
            string command = "/c copy " + '\u0022' + oldName + '\u0022' + " " + '\u0022' + newSubFolder + Separator + newName +
                             '\u0022';
            ProcessStartInfo cmdsi = new ProcessStartInfo("cmd.exe")
            {
                WorkingDirectory = oldSubFolder,
                Arguments        = command
            };

            Thread.Sleep(1000);

            var timeoutMessage = string.Format(CultureInfo.CurrentCulture, "Waiting till file will be copied {0}", newSubFolder);

            Process.Start(cmdsi);
            WaitHelper.Wait(() => File.Exists(newSubFolder + Separator + newName), TimeSpan.FromSeconds(waitTime), TimeSpan.FromSeconds(1), timeoutMessage);
            return(newName);
        }
Пример #2
0
        /// <summary>
        /// Čaká na súbor s daným menom a s daným časovým limitom, a vráti jeho názov
        /// </summary>
        /// <param name="waitTime">Čakanie.</param>
        /// <param name="filesName">Názov súboru.</param>
        /// <param name="folder">Zložka.</param>
        /// <param name="checkSize">Skontrolovanie veľkosti súboru.</param>
        public static FileInfo WaitForFileOfGivenNameAndReturn(double waitTime, string filesName, string folder)
        {
            var timeoutMessage = string.Format(CultureInfo.CurrentCulture, "Waiting for file {0} in folder {1}", filesName, folder);

            WaitHelper.Wait(
                () => File.Exists($"{folder}{Separator}{filesName}"), TimeSpan.FromSeconds(waitTime), TimeSpan.FromSeconds(1), timeoutMessage);
            return(FileHelper.GetFileByName(folder, filesName));
        }
Пример #3
0
        /// <summary>
        /// Čaká na súbor s daným menom a s daným časovým limitom, skontroluje veľkosť aktuálneho súboru.
        /// </summary>
        /// <param name="waitTime">Čakanie.</param>
        /// <param name="filesName">Názov súboru.</param>
        /// <param name="folder">Zložka.</param>
        /// <param name="checkSize">Skontrolovanie veľkosti súboru.</param>
        public static void WaitForFileOfGivenName(double waitTime, string filesName, string folder, bool checkSize)
        {
            var timeoutMessage = string.Format(CultureInfo.CurrentCulture, "Waiting for file {0} in folder {1}", filesName, folder);

            WaitHelper.Wait(
                () => File.Exists($"{folder}{Separator}{filesName}"), TimeSpan.FromSeconds(waitTime), TimeSpan.FromSeconds(1), timeoutMessage);

            if (checkSize)
            {
                timeoutMessage = string.Format(CultureInfo.CurrentCulture, "Checking if size of file {0} > 0 bytes", filesName);
                WaitHelper.Wait(
                    () => GetFileByName(folder, filesName).Length > 0, TimeSpan.FromSeconds(waitTime), TimeSpan.FromSeconds(1), timeoutMessage);
            }
        }
Пример #4
0
        /// <summary>
        /// Čaká na súbor pre daný časový limit, kým sa počet súborov nezvýši v podadresári, skontroluje veľkosť aktuálneho súboru.
        /// </summary>
        /// <param name="waitTime">Čakanie.</param>
        /// <param name="filesNumber">Počiatočné číslo súboru.</param>
        /// <param name="folder">Zložka.</param>
        /// <param name="checkSize">Skontrolovanie veľkosti súboru.</param>
        public static void WaitForFile(double waitTime, int filesNumber, string folder, bool checkSize)
        {
            var timeoutMessage = string.Format(CultureInfo.CurrentCulture, "Waiting for file number to increase in {0}", folder);

            WaitHelper.Wait(
                () => CountFiles(folder) > filesNumber, TimeSpan.FromSeconds(waitTime), TimeSpan.FromSeconds(1), timeoutMessage);

            if (checkSize)
            {
                timeoutMessage = "Checking if size of last file > 0 bytes";

                WaitHelper.Wait(
                    () => GetLastFile(folder).Length > 0, TimeSpan.FromSeconds(waitTime), TimeSpan.FromSeconds(1), timeoutMessage);
            }
        }