Пример #1
0
        public static void Main(string[] args)
        {
            ResultDirectory = args.FirstOrDefault(it => it.StartsWith(WriteOutput.ResultDirectoryArgumentName))?.Replace(WriteOutput.ResultDirectoryArgumentName, "");

            Console.WriteLine($"Results Directory is: {ResultDirectory}");

            if (ResultDirectory == null)
            {
                return;
            }

            var scenarios = GetScenarios(ResultDirectory);
            var testTimer = GetTestTimer(scenarios);

            var reportPathByStory      = Path.Combine(ResultDirectory, FileNames.ReportByStory);
            var reportPathAllScenarios = Path.Combine(ResultDirectory, FileNames.ReportAllScenarios);
            var testDataJsonPath       = Path.Combine(ResultDirectory, FileNames.TestDataJson);
            var testDataXmlPath        = Path.Combine(ResultDirectory, FileNames.TestDataXml);

            DeleteExistingFiles(reportPathByStory, reportPathAllScenarios, testDataJsonPath, testDataXmlPath);

            var warnings = GetWarnings();

            scenarios.AddRange(warnings.StoppedEarlyTests);

            var dataToOutput = new DataOutputModel
            {
                Scenarios = scenarios,
                TestTimer = testTimer,
                Warnings  = warnings
            };

            var settings = new JsonSerializerSettings
            {
                PreserveReferencesHandling = PreserveReferencesHandling.Objects
            };

            var jsonData = JsonConvert.SerializeObject(dataToOutput, Formatting.Indented, settings);

            File.WriteAllText(Path.Combine(ResultDirectory, FileNames.TestDataJson), jsonData);
            File.WriteAllText(Path.Combine(ResultDirectory, FileNames.TestDataXml), JsonConvert.DeserializeXmlNode(jsonData, "TestData").ToXmlString());

            HtmlReportBuilder.CreateReport(dataToOutput);

            try
            {
                CopyFolder.Copy(Path.Combine(FileLocations.ProjectDirectory, "css"), Path.Combine(ResultDirectory, "css"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #2
0
            public ValueTask ExecuteAsync(IConsole console)
            {
                using (var fileManager = new FileManager(filename))
                {
                    foreach (var file in fileManager.GetValues())
                    {
                        if (!File.Exists(file.Key))
                        {
                            CopyFolder.Copy(file.Key, file.Value, "out", overwrite);
                        }
                        else
                        {
                            CopyFolder.Copyto(file.Key, file.Value, "out", overwrite);
                        }
                    }

                    Console.WriteLine("overwrite is: " + overwrite);
                    return(default);
Пример #3
0
 private async void BtnCopyFolder_Click(object sender, EventArgs e)
 {
     try
     {
         this.SetFolderButtonStatus(false);
         StartNewTask();
         CopyFileParameter param = new CopyFileParameter();
         param.OutoutDirectoy    = this.lbDestination.Text.Trim();
         param.OriginalDirectory = this.lbOriginal.Text.Trim();
         CopyFolder copyThreading = new CopyFolder(this.log, this.tokenSource, param);
         task = copyThreading.Run();
         await task;
         //
     }
     catch (Exception ex) {
         log.RecordError(ex.Message);
         //this.SetFolderButtonStatus(true);
     }
     finally
     {
         this.SetFolderButtonStatus(true);
     }
 }
Пример #4
0
        public void Dispose()
        {
            // Clearing all of these ensures that the transient APIs
            // can't be called outside of the appropriate scope.

            #region dispose-dispatcher service-apis
            _GetNuGetExePath             = null;
            _GetNuGetDllPath             = null;
            _DownloadFile                = null;
            _AddPinnedItemToTaskbar      = null;
            _RemovePinnedItemFromTaskbar = null;
            _CreateShortcutLink          = null;
            _UnzipFileIncremental        = null;
            _UnzipFile                 = null;
            _AddFileAssociation        = null;
            _RemoveFileAssociation     = null;
            _AddExplorerMenuItem       = null;
            _RemoveExplorerMenuItem    = null;
            _SetEnvironmentVariable    = null;
            _RemoveEnvironmentVariable = null;
            _AddFolderToPath           = null;
            _RemoveFolderFromPath      = null;
            _InstallMSI                = null;
            _RemoveMSI                 = null;
            _StartProcess              = null;
            _InstallVSIX               = null;
            _UninstallVSIX             = null;
            _InstallPowershellScript   = null;
            _UninstallPowershellScript = null;
            _SearchForExecutable       = null;
            _GetUserBinFolder          = null;
            _GetSystemBinFolder        = null;
            _CopyFile                = null;
            _CopyFolder              = null;
            _Delete                  = null;
            _DeleteFolder            = null;
            _CreateFolder            = null;
            _DeleteFile              = null;
            _BeginTransaction        = null;
            _AbortTransaction        = null;
            _EndTransaction          = null;
            _GenerateUninstallScript = null;
            _GetKnownFolder          = null;
            _IsElevated              = null;
            #endregion

            #region dispose-dispatcher core-apis
            _Warning          = null;
            _Message          = null;
            _Error            = null;
            _Debug            = null;
            _Verbose          = null;
            _ExceptionThrown  = null;
            _Progress         = null;
            _ProgressComplete = null;
            _GetHostDelegate  = null;
            _IsCancelled      = null;
            #endregion

            #region dispose-dispatcher request-apis
            _OkToContinue                       = null;
            _YieldPackage                       = null;
            _YieldPackageDetails                = null;
            _YieldPackageSwidtag                = null;
            _YieldSource                        = null;
            _YieldMetadataDefinition            = null;
            _YieldInstallationOptionsDefinition = null;
            #endregion

            #region dispose-dispatcher host-apis
            _GetMetadataKeys             = null;
            _GetMetadataValues           = null;
            _GetInstallationOptionKeys   = null;
            _GetInstallationOptionValues = null;
            _PackageSources   = null;
            _GetConfiguration = null;
            _ShouldContinueWithUntrustedPackageSource = null;
            _ShouldProcessPackageInstall                = null;
            _ShouldProcessPackageUninstall              = null;
            _ShouldContinueAfterPackageInstallFailure   = null;
            _ShouldContinueAfterPackageUninstallFailure = null;
            _ShouldContinueRunningInstallScript         = null;
            _ShouldContinueRunningUninstallScript       = null;
            _AskPermission = null;
            _WhatIf        = null;
            #endregion

            #region dispose-dispatcher protocol-apis
            _ProtocolGetNames        = null;
            _ProtocolIsValidSource   = null;
            _ProtocolGetItemMetadata = null;
            _ProtocolDownloadItem    = null;
            _ProtocolUnpackItem      = null;
            _InstallItem             = null;
            #endregion

            _callback = null;
        }
Пример #5
0
 public void CopyFolder( )
 {
     CheckDisposed();
     (_CopyFolder ?? (_CopyFolder = (_callback.Resolve <CopyFolder>() ?? (() => { }))))();
 }
Пример #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd") + "] Start...");

            var pathSourceRoot      = @"D:\TestZip\Source";
            var pathDestinationRoot = @"D:\TestZip\Destination";

            var name = "thao";
            var directoryDestination = Path.Combine(pathDestinationRoot, name);

            if (!Directory.Exists(directoryDestination))
            {
                Directory.CreateDirectory(directoryDestination);
            }
            //Copy Soure web
            var pathSource      = Path.Combine(pathSourceRoot, "Web");
            var pathDestination = Path.Combine(directoryDestination, "Web");
            //CopyFolder.CopyFolderToFolder(pathSource, pathDestination);


            //Copy Soure Service
            var serviceName            = "AAAA_" + name;
            var pathSourceService      = Path.Combine(pathSourceRoot, "Service");
            var pathDestinationService = Path.Combine(directoryDestination, "Service");

            CopyFolder.CopyFolderToFolder(pathSourceService, pathDestinationService);
            var servicePath = Path.Combine(pathDestinationService, "ServiceTest.exe");

            ServiceHelper.InstallAndStartService(servicePath, serviceName);



            //modify web.config
            //ModifyXml.ModifileXml(pathDestination);


            //Create database
            //var pathFileAdmin = @"D:\TestZip\Source\Database\admin.sql";
            //var pathFileUser = @"D:\TestZip\Source\Database\createuser.sql";
            //InstallDb.RunSqlFile(pathFileAdmin, pathFileUser);


            //New website
            var webSiteName = name + ".vn";

            //var physicalPath = pathDestination;
            //var port = 80;
            //var connectionTimeOut = new TimeSpan(0, 5, 0);
            //var isSsl = false;
            //var certString = "";
            //IisHelper.AddNewWeb(webSiteName, webSiteName, physicalPath, port, connectionTimeOut, false, isSsl, certString);


            //Uninstall All
            //IisHelper.RemoveHost(webSiteName);
            //ServiceHelper.StopService(servicePath, serviceName);

            Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd") + "] End");
            Console.WriteLine(" Success!!!");
            Console.ReadLine();
        }
Пример #7
0
        private ActionBase ParseObjectAction(JObject node, ActionType action_type)
        {
            switch (action_type)
            {
            case ActionType.ControlFlow:
                var condition = (node["condition"].ToString());

                if (condition.Equals("dialog"))
                {
                    return(ParseDialogControlFlow(node));
                }

                return(null);

            case ActionType.Execute:

                string filename         = mroot.substitue_enviro_vars(node["filename"].ToString());
                string paramxs          = node.ContainsKey("params") ? mroot.substitue_enviro_vars(node["params"].ToString()) : "";
                bool   onlyIfnotRunning = node.ContainsKey("onlyIfNotRunning") ? node["params"].Value <bool>() : true;

                ExecuteProcess executeAction = new ExecuteProcess();
                executeAction.FileName         = filename;
                executeAction.Params           = paramxs;
                executeAction.OnlyIfNotRunning = onlyIfnotRunning;

                return(executeAction);


            case ActionType.Wait:
                int waittime = (node["duration_ms"].Value <Int32>());

                WaitAction wait = new WaitAction();
                wait.Milliseconds = waittime;
                return(wait);

            case ActionType.ShowDialog:

                ShowDialog showDialog = new ShowDialog();
                showDialog.Message = mroot.substitue_enviro_vars(node["message"].ToString());
                if (node.ContainsKey("messagetype"))
                {
                    showDialog.MessageType = (ShowDialog.Type)Enum.Parse(typeof(ShowDialog.Type), node["messagetype"].ToString(), true);
                }
                return(showDialog);

            case ActionType.CopyFolder:

                string source       = mroot.substitue_enviro_vars(node["source"].ToString());
                string destination  = mroot.substitue_enviro_vars(node["destination"].ToString());
                string file_pattern = node.ContainsKey("desc") ? node["copy_filepattern"].ToString() : null;
                string dir_pattern  = node.ContainsKey("desc") ? node["copy_dirpattern"].ToString() : null;

                CopyFolder copyFolder = new CopyFolder();
                copyFolder.Source          = source ?? copyFolder.Source;
                copyFolder.Destination     = destination ?? copyFolder.Destination;
                copyFolder.CopyFilePattern = file_pattern ?? copyFolder.CopyFilePattern;
                copyFolder.CopyDirPattern  = dir_pattern ?? copyFolder.CopyDirPattern;

                return(copyFolder);

            case ActionType.CopyFile:

                source      = mroot.substitue_enviro_vars(node["source"].ToString());
                destination = mroot.substitue_enviro_vars(node["destination"].ToString());

                CopyFile copyFile = new CopyFile();
                copyFile.Source      = source;
                copyFile.Destination = destination;
                return(copyFile);

            case ActionType.DeleteFile:
            {
                string sourceFile = mroot.substitue_enviro_vars(node["source"].ToString());

                DeleteFile delteFiles = new DeleteFile();
                delteFiles.SourceFile = sourceFile;
                return(delteFiles);
            }

            case ActionType.DeleteFiles:
            {
                string sourceFolder     = mroot.substitue_enviro_vars(node["source"].ToString());
                string delete_pattern   = node.ContainsKey("pattern") ? node["pattern"].ToString() : "(.)";
                bool   recursive_delete = node.ContainsKey("recursive") ? node["recursive"].Value <bool>() : false;

                DeleteFiles delteFiles = new DeleteFiles();
                delteFiles.SourceFolder    = sourceFolder;
                delteFiles.DeletePattern   = delete_pattern;
                delteFiles.RecursiveDelete = recursive_delete;
                return(delteFiles);
            }

            case ActionType.DeleteFolder:
            {
                string dirPath = mroot.substitue_enviro_vars(node["source"].ToString());

                DeleteFolder deleteFolder = new DeleteFolder();
                deleteFolder.FolderPath = dirPath;
                return(deleteFolder);
            }

            case ActionType.DeleteFolders:
            {
                string sourceFolder   = mroot.substitue_enviro_vars(node["source"].ToString());
                string delete_pattern = node.ContainsKey("pattern") ? node["pattern"].ToString() : "(.)";

                DeleteFolders deleteFolders = new DeleteFolders();
                deleteFolders.SourceFolder  = sourceFolder;
                deleteFolders.DeletePattern = delete_pattern;
                return(deleteFolders);
            }

            case ActionType.ZipFolder:
            {
                string sourceFolder        = mroot.substitue_enviro_vars(node["source"].ToString());
                string zipfile_destination = mroot.substitue_enviro_vars(node["zipfile"].ToString());

                ZipFolder zipFolder = new ZipFolder();
                zipFolder.SourceFolder   = sourceFolder;
                zipFolder.DestinationZip = zipfile_destination;
                return(zipFolder);
            }
            }

            return(null);
        }
Пример #8
0
        private ActionBase ParseAction(XmlNode node, ActionType action_type)
        {
            switch (action_type)
            {
            case ActionType.Wait:
                int waittime = Convert.ToInt32(node.Attributes["duration_ms"].Value);

                WaitAction wait = new WaitAction();
                wait.Milliseconds = waittime;
                return(wait);

            case ActionType.Execute:

                string filename = mroot.substitue_enviro_vars(node.Attributes["filename"].Value);
                string paramxs  = mroot.substitue_enviro_vars(node.Attributes["params"].Value);

                bool onlyIfnotRunning = true;
                if (node.Attributes["onlyIfNotRunning"] != null)
                {
                    onlyIfnotRunning = Boolean.Parse(node.Attributes["onlyIfNotRunning"].Value);
                }

                ExecuteProcess executeAction = new ExecuteProcess();
                executeAction.FileName         = filename;
                executeAction.Params           = paramxs;
                executeAction.OnlyIfNotRunning = onlyIfnotRunning;

                return(executeAction);


            case ActionType.CopyFolder:

                string source       = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                string destination  = mroot.substitue_enviro_vars(node.Attributes["destination"].Value);
                string file_pattern = node.Attributes["copy_filepattern"].Value;
                string dir_pattern  = node.Attributes["copy_dirpattern"].Value;

                CopyFolder copyFolder = new CopyFolder();
                copyFolder.Source          = source;
                copyFolder.Destination     = destination;
                copyFolder.CopyFilePattern = file_pattern;
                copyFolder.CopyDirPattern  = dir_pattern;

                return(copyFolder);

            case ActionType.CopyFile:

                source      = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                destination = mroot.substitue_enviro_vars(node.Attributes["destination"].Value);

                CopyFile copyFile = new CopyFile();
                copyFile.Source      = source;
                copyFile.Destination = destination;
                return(copyFile);

            case ActionType.DeleteFiles:

                string sourceFolder     = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                string delete_pattern   = node.Attributes["pattern"].Value;
                bool   recursive_delete = Convert.ToBoolean(node.Attributes["recursive"].Value);

                DeleteFiles delteFiles = new DeleteFiles();
                delteFiles.SourceFolder    = sourceFolder;
                delteFiles.DeletePattern   = delete_pattern;
                delteFiles.RecursiveDelete = recursive_delete;
                return(delteFiles);

            case ActionType.DeleteFolders:

                sourceFolder   = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                delete_pattern = node.Attributes["pattern"].Value;

                DeleteFolders deleteFolders = new DeleteFolders();
                deleteFolders.SourceFolder  = sourceFolder;
                deleteFolders.DeletePattern = delete_pattern;
                return(deleteFolders);

            case ActionType.ZipFolder:

                sourceFolder = mroot.substitue_enviro_vars(node.Attributes["source"].Value);
                string zipfile_destination = mroot.substitue_enviro_vars(node.Attributes["zipfile"].Value);

                ZipFolder zipFolder = new ZipFolder();
                zipFolder.SourceFolder   = sourceFolder;
                zipFolder.DestinationZip = zipfile_destination;
                return(zipFolder);


            case ActionType.ShowDialog:

                ShowDialog showDialog = new ShowDialog();
                showDialog.Message     = mroot.substitue_enviro_vars(node.Attributes["message"].Value);
                showDialog.MessageType = (ShowDialog.Type)Enum.Parse(typeof(ShowDialog.Type), node.Attributes["messagetype"].Value, true);

                return(showDialog);

            default:
                return(null);
            }
        }
Пример #9
0
 /// <summary>
 /// 添加一个copy目录
 /// </summary>
 public void AddCopyFolder(CopyFolder copyFolder)
 {
     copyFolderList.Add(copyFolder);
 }
Пример #10
0
        public static void Main(string[] args)
        {
            Args = string.Join(" ", args);

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            ResultDirectory = args.FirstOrDefault(it => it.StartsWith(Arguments.ResultDirectoryArgumentName))?.Replace(Arguments.ResultDirectoryArgumentName, "");

            SetSettingsFromArgs(args);

            if (string.IsNullOrWhiteSpace(ResultDirectory))
            {
                return;
            }

            var scenarios = GetScenarios(ResultDirectory);
            var testTimer = GetTestTimer(scenarios);

            var reportPathByStory      = Path.Combine(ResultDirectory, FileNames.ReportByStory);
            var reportPathAllScenarios = Path.Combine(ResultDirectory, FileNames.ReportAllScenarios);
            var testDataJsonPath       = Path.Combine(ResultDirectory, FileNames.TestDataJson);
            var testDataXmlPath        = Path.Combine(ResultDirectory, FileNames.TestDataXml);

            DeleteExistingFiles(reportPathByStory, reportPathAllScenarios, testDataJsonPath, testDataXmlPath);

            var warnings = GetWarnings();

            scenarios.AddRange(warnings.StoppedEarlyTests);

            var dataToOutput = new DataOutputModel
            {
                Scenarios = scenarios,
                TestTimer = testTimer,
                Warnings  = warnings
            };

            var settings = new JsonSerializerSettings
            {
                PreserveReferencesHandling = PreserveReferencesHandling.Objects
            };

            var jsonData = JsonConvert.SerializeObject(dataToOutput, Formatting.Indented, settings);


            WriteJsonOutput(jsonData);

            WriteXmlOutput(jsonData);

            PruneData();

            HtmlReportBuilder.CreateReport(dataToOutput);

            try
            {
                CopyFolder.Copy(Path.Combine(FileLocations.ProjectDirectory, "css"), Path.Combine(ResultDirectory, "css"));
            }
            catch (Exception)
            {
                // ignored
            }
        }