Example #1
0
        /// <summary>
        /// Copies the EXEs to cluster
        /// </summary>
        /// <param name="directoryName">target dir</param>
        /// <param name="niceName">dir name</param>
        /// <returns></returns>
        public static string CopyExesToCluster(string directoryName, string niceName)
        {
            string finalResult;

            //!! note that there is a small chance of a copy conflict with another process. Should come up with a safe way around that.
            if (!_dirNameToExeDirName.TryGetValue(directoryName, out finalResult))
            {
                Console.WriteLine(Resource.ExeAlreadyThere);
                string newExeDirectoryName;
                string exeNewRelativeDirectoryName;
                string executingExeDirectoryName = Path.GetDirectoryName(FileUtils.GetEntryOrCallingAssembly().Location);

                bool needToCopyExesToCluster = !ExesAreAlreadyOnCluster(niceName, directoryName, executingExeDirectoryName, out newExeDirectoryName, out exeNewRelativeDirectoryName);
                if (needToCopyExesToCluster)
                {
                    Console.WriteLine(Resource.Copying_Exes);
                    Directory.CreateDirectory(directoryName);
                    CreateNewExeDirectory(niceName, directoryName, out newExeDirectoryName, out exeNewRelativeDirectoryName);
                    SpecialFunctions.CopyDirectory(executingExeDirectoryName, newExeDirectoryName, /*recursive*/ true);
                    Console.WriteLine(Resource.Done_copying);
                }
                finalResult = "\"" + exeNewRelativeDirectoryName + "\"";
                _dirNameToExeDirName.Add(directoryName, finalResult);
            }
            return(finalResult);
        }
        public static string CopyExesToCluster(string directoryName, string niceName)
        {
            Directory.CreateDirectory(directoryName);
            string newExeDirectoryName;
            string exeNewRelativeDirectoryName;

            CreateNewExeDirectory(niceName, directoryName, out newExeDirectoryName, out exeNewRelativeDirectoryName);
            string oldExeDirectoryName = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            SpecialFunctions.CopyDirectory(oldExeDirectoryName, newExeDirectoryName, true);
            return("\"" + exeNewRelativeDirectoryName + "\"");
        }
        public void ValidateCopyDirectory()
        {
            string testDir       = Path.GetTempPath() + "dir1\\";
            string testDirNew    = Path.GetTempPath() + "dir2\\";
            string testFileName  = Path.GetTempFileName().Split('\\').Last();
            string testFileName2 = Path.GetTempFileName().Split('\\').Last();

            Directory.CreateDirectory(testDir);
            using (File.Create(testDir + "\\" + testFileName)) { }
            using (File.Create(testDir + "\\" + testFileName2)) { }
            SpecialFunctions.CopyDirectory(testDir, testDirNew, true, true);
            Assert.IsTrue(File.Exists(testDirNew + "\\" + testFileName));
            Assert.IsTrue(File.Exists(testDirNew + "\\" + testFileName2));
            Directory.Delete(testDir, true);
            Directory.Delete(testDirNew, true);
        }
        private static void SetupDirectories(string internalRemoteDirectoryName, string externalRemoteDirectoryName, string inputDirectoryName, string caseName, out string newExeDirectoryName, out string exeNewRelativeDirectoryName, out string internalRemoteInputDirectoryName)
        {
            Directory.CreateDirectory(externalRemoteDirectoryName);



            CCSLib.CCSLib.CreateNewExeDirectory(caseName, externalRemoteDirectoryName, out newExeDirectoryName, out exeNewRelativeDirectoryName);

            string oldExeDirectoryName = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            SpecialFunctions.CopyDirectory(oldExeDirectoryName, newExeDirectoryName, true);

            string externalRemoteInputDirectoryName = string.Format(@"{0}\Raw", externalRemoteDirectoryName);

            internalRemoteInputDirectoryName = string.Format(@"{0}\Raw", internalRemoteDirectoryName);
            Directory.CreateDirectory(externalRemoteInputDirectoryName);
            SpecialFunctions.CopyDirectory(inputDirectoryName, externalRemoteInputDirectoryName, false);
        }