예제 #1
0
        /// <summary>
        /// Validate if the user selected folders that meets the reqiuerments
        /// </summary>
        /// <param name="newFolder">folder to check</param>
        /// <param name="foldersToRemove">folders that need to be removed</param>
        /// <returns></returns>
        private bool ValidateFolders(string newFolder, List <string> foldersToRemove)
        {
            // Iterate through all of the folders that are already in our data
            for (int i = 0; i < SourceFolders.Count; ++i)
            {
                var exisitingFolderToBackup = SourceFolders[i].FolderInfo.FullPath;

                if (SourceFolders.Where(sf => sf.FolderInfo.FullPath == newFolder).FirstOrDefault() != null)
                {
                    _DialogService.ShowMessageBox(newFolder + " already exists in the list!");
                    return(false);
                }

                if (Helpers.IsSubFolder(exisitingFolderToBackup, newFolder))
                {
                    _DialogService.ShowMessageBox(newFolder + " is a subfolder of " + exisitingFolderToBackup + ".");
                    return(false);
                }

                if (Helpers.IsSubFolder(newFolder, exisitingFolderToBackup))
                {
                    foldersToRemove.Add(exisitingFolderToBackup);
                }
            }

            return(true);
        }
예제 #2
0
        private void CheatTasks()
        {
            BackupJournalOperations cheatBackupJournalOperations = new BackupJournalOperations();
            DateTime            timeToBackup          = DateTime.Now;
            List <IDestination> tmpDestinations       = new List <IDestination>();
            SourceFolders       tmpSourceFolders      = new SourceFolders();
            List <string>       tmpSourceFoldersPaths = new List <string>();

            tmpSourceFoldersPaths.Add(@"D:\KoFrMa\BackupThisFolder\");
            tmpSourceFolders.Paths = tmpSourceFoldersPaths;
            SourceMSSQL sourceMSSQL = new SourceMSSQL();

            sourceMSSQL.ServerName        = "(local)";
            sourceMSSQL.DatabaseName      = "dbNw";
            sourceMSSQL.NetworkCredential = new System.Net.NetworkCredential()
            {
                UserName = "******", Password = "******"
            };

            tmpDestinations.Add(new DestinationPlain()
            {
                Path = new DestinationPathLocal()
                {
                    Path = @"d:\KoFrMa\BackupGoesHere\"
                }
            });
            tmpDestinations.Add(new Destination7z()
            {
                Path = new DestinationPathLocal()
                {
                    Path = @"d:\KoFrMa\BackupGoesHere\"
                }, CompressionLevel = 0, SplitAfter = 5
            });
            Task taskTest = new Task
            {
                //Sources = cheatBackupJournalOperations.LoadBackupJournalObject(@"d:\KoFrMa\BackupGoesHere\KoFrMaBackup_2018_06_02_15_02_59\KoFrMaBackup.dat", debugLog),
                Sources = tmpSourceFolders,
                //Sources = sourceMSSQL,
                IDTask   = 0,
                LogLevel = 8,
                TemporaryFolderMaxBuffer = null,
                Destinations             = tmpDestinations,
                TimeToBackup             = timeToBackup.AddSeconds(1)
                                           //ScriptBefore = new ScriptInfo { ScriptItself = @"ping 127.0.0.1 > d:\tmp.txt",ScriptItselfFormat = "bat"},
                                           //ScriptAfter = new ScriptInfo { ScriptItself = @"ping 127.0.0.1 > d:\tmp.txt", ScriptItselfFormat = "bat" }
                                           //ScriptAfter = new ScriptInfo { PathToLocalScript = @"c:\Windows\media\Windows Notify.wav" }
            };

            debugLog.WriteJsonTaskToLog(taskTest);
            ScheduledTasks.Add(taskTest);

            debugLog.WriteToLog("List of scheduled tasks now contains " + this.ScheduledTasks.Count + " tasks", 6);
            if (this.ScheduledTasks.Count > 0)
            {
                debugLog.WriteToLog("Starting scheduled tasks check", 6);
                this.OnTimerTasksTick(null, null);
            }
        }
예제 #3
0
        private void chkSource_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            string item = chkSource.Items[e.Index].ToString();

            if (e.NewValue == CheckState.Checked)
            {
                SourceFolders.Add(txtSource.Text.TrimEnd('\\') + "\\" + item);
            }
            else if (e.CurrentValue == CheckState.Checked && e.NewValue == CheckState.Unchecked)
            {
                SourceFolders.Remove(txtSource.Text.TrimEnd('\\') + "\\" + item);
            }
        }
예제 #4
0
        /// <summary>
        /// Remove folder from <see cref="SourceFolders"/>
        /// </summary>
        /// <param name="folder"></param>
        /// TODO: Use dictionary instead?
        public void RemoveFolder(string folder)
        {
            // Find the item by the name of the folder
            SourceFolder item = SourceFolders.Where(sf => sf.FolderInfo.FullPath == folder).FirstOrDefault();


            // Check if the item was found
            if (item != null)
            {
                // Remove the item from the list
                SourceFolders.Remove(item);
            }
        }
예제 #5
0
        public override bool Execute()
        {
            Log.LogMessage(MessageImportance.Low, "Starting deploy task.");
            Log.LogMessage(MessageImportance.Low, "Additional deploy options value: \"" + AdditionalOptions + "\"");

            string buildType = Configuration.StartsWith("Debug") ? "Debug" : "Release";
            string target    = Configuration.Substring(buildType.Length);

            IEnumerable <string> options = new[] { "-p", ProjectDirectory };

            if (!target.Contains("all Targets"))
            {
                options = options.Append("-t");
                options = options.Append($"\"{ target.Trim()}\"");
            }

            options = options.Append("-b");
            options = options.Append(buildType);


            if (SourceFolders.Any())
            {
                options = options.Append("--sources").Append(string.Join(",", SourceFolders)).ToArray();
            }

            options = options.Append(AdditionalOptions);

            try
            {
                Communication.ExecuteWithoutResult("deploy", new TaskLogger(Log), options.ToArray());
            }
            catch (PlcncliException ex)
            {
                if (!Log.HasLoggedErrors)
                {
                    Log.LogErrorFromException(ex, false, true, "-");
                }
                return(false);
            }
            Log.LogMessage(MessageImportance.Low, "deploy task finished.");
            return(true);
        }
예제 #6
0
        public override bool Execute()
        {
            Log.LogMessage(MessageImportance.Low, "Starting generate task.");
            Log.LogMessage(MessageImportance.Low, "Plcncli location: \"" + PlcncliLocation + "\"");
            Log.LogMessage(MessageImportance.Low, "Additional generate options value: \"" + AdditionalOptions + "\"");

            string[] args = new string[]
            {
                "-p",
                ProjectDirectory
            };

            if (GenerateDatatypesWorksheet == false)
            {
                args = args.Append("--no-datatypes-worksheet").ToArray();
            }

            if (SourceFolders.Any())
            {
                args = args.Append("--sources").Append(string.Join(",", SourceFolders)).ToArray();
            }

            args = args.Append(AdditionalOptions).ToArray();

            try
            {
                Communication.ExecuteWithoutResult("generate all", new TaskLogger(Log), args);
            }
            catch (PlcncliException ex)
            {
                if (!Log.HasLoggedErrors)
                {
                    Log.LogErrorFromException(ex, false, true, "-");
                }
                return(false);
            }

            Log.LogMessage(MessageImportance.Low, "generate task finished.");

            return(true);
        }
예제 #7
0
 /// <summary>
 ///     Get the legacy source path locations.
 /// </summary>
 /// <param name="subPath">
 ///     The sub folder path identifier.
 /// </param>
 /// <returns>
 ///     The legacy project mappings.
 /// </returns>
 public IDictionary <string, string> GetLegacySourceFolders(string subPath = "ProjectDirs")
 {
     return(SourceFolders.Select((value, index) => new KeyValuePair <string, int>(value, index))
            .ToDictionary((pair) => pair.Key, (pair) => Path.Combine(OutputPath, subPath, pair.Value.ToString())));
 }
예제 #8
0
 /// <summary>
 /// Add new folder to <see cref="SourceFolders"/>
 /// </summary>
 /// <param name="folder"></param>
 public void AddFolder(string folder)
 {
     SourceFolders.Add(new SourceFolder(folder));
 }