Exemple #1
0
        public bool CopyCheck(string ip, string newBase, string oldBase, string account, string password)
        {
            var drive = ip == "192.168.9.179" ? "F" : "G";

            var text   = $@"XCOPY /Y /E /C /H /S /I {drive}:\MYSQL40\data\{oldBase} {drive}:\MYSQL40\data\{newBase}";
            var cmd    = $@"wmic /node:'{ip}' /password:'******' /user:'******' process call create '{text}'";
            var runCmd = new RunCmd();
            var result = runCmd.Exe(cmd);

            if (result.IndexOf("ReturnValue = 0", StringComparison.OrdinalIgnoreCase) < 0)
            {
                return(false);
            }

            var initialDir = $@"\\{ip}\data\{oldBase}";
            var endDir     = $@"\\{ip}\data\{newBase}";

            var initialSize = DirSize(new DirectoryInfo(initialDir));


            for (var i = 0; i < 100; i++)
            {
                if (DirFile.IsExistDirectory(endDir))
                {
                    var endSize = DirSize(new DirectoryInfo(endDir));
                    if (initialSize == endSize)
                    {
                        return(true);
                    }

                    System.Threading.Thread.Sleep(2000);

                    if (i > 90)
                    {
                        break;
                    }
                }

                System.Threading.Thread.Sleep(2000);
            }
            return(false);
        }
Exemple #2
0
        /// <summary>179复制需要运行的初始库</summary>
        /// <param name="gnpy">项目名称</param>
        /// <param name="AppSrc">时间戳(文件夹名称)</param>
        /// <returns></returns>
        public string CopyInitial(string gnpy, string AppSrc)
        {
            string path179 = @"\\172.24.140.83\data\";

            try
            {
                switch (gnpy)
                {
                case "sjmy":

                    if (DirFile.IsExistDirectory(path179 + "sjmy_autotest_init_ndsdk"))
                    {
                        if (!CopyCheck("172.24.140.83", $"sjmy_again{AppSrc}", "sjmy_autotest_init_ndsdk", "blacknull", "IDC2.passwd*()"))
                        {
                            return($"sjmy_again{AppSrc}复制失败");
                        }

                        if (!CopyCheck("172.24.140.83", $"sjmy_autotest{AppSrc}", "sjmy_autotest_init_ndsdk", "blacknull", "IDC2.passwd*()"))
                        {
                            return($"sjmy_autotest{AppSrc}复制失败");
                        }

                        //DirFile.CopyFolder(path179 + "sjmy_autotest_init_ndsdk", path179 + "sjmy_again" + AppSrc);
                        //DirFile.CopyFolder(path179 + "sjmy_autotest_init_ndsdk", path179 + "sjmy_autotest" + AppSrc);
                    }
                    else
                    {
                        return(path179 + "sjmy_autotest_init_ndsdk不存在");
                    }

                    break;

                case "xsjmy":
                    if (DirFile.IsExistDirectory(path179 + "sjmy_autotest_init_xsj"))
                    {
                        if (!CopyCheck("172.24.140.83", $"sjmy_again{AppSrc}", "sjmy_autotest_init_xsj", "blacknull", "IDC2.passwd*()"))
                        {
                            return($"sjmy_again{AppSrc}复制失败");
                        }

                        if (!CopyCheck("172.24.140.83", $"sjmy_autotest{AppSrc}", "sjmy_autotest_init_xsj", "blacknull", "IDC2.passwd*()"))
                        {
                            return($"sjmy_autotest{AppSrc}复制失败");
                        }
                    }
                    else
                    {
                        return("sjmy_autotest_init_xsj不存在");
                    }

                    break;

                case "myht":

                    path179 = @"\\192.168.9.179\data\";

                    if (DirFile.IsExistDirectory(path179 + "my_bak"))
                    {
                        if (!CopyCheck("192.168.9.179", $"myht_again{AppSrc}", "my_bak", "blacknull", "shangjia!@#123.idc1"))
                        {
                            DirFile.CopyFolder(path179 + "my_bak", path179 + "myht_again" + AppSrc);
                        }
                        if (!CopyCheck("192.168.9.179", $"myht_autotest{AppSrc}", "my_bak", "blacknull", "shangjia!@#123.idc1"))
                        {
                            DirFile.CopyFolder(path179 + "my_bak", path179 + "myht_autotest" + AppSrc);
                        }
                    }
                    else
                    {
                        return("my_bak不存在");
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
            return("初始库复制完成");
        }