/// <summary> /// Install a plugin, supports .jar and .zip files /// </summary> /// <param name="version">Version to install</param> /// <param name="targetlocation">Target location, plugins/name by default</param> /// <param name="updatelist">Update the list of installed plugins</param> /// <param name="showUi">Allow pop-up dialogs</param> /// <remarks></remarks> public static Boolean Install(BukgetPluginVersion version, string targetlocation = "", bool updatelist = true, bool showUi = true) { if (string.IsNullOrEmpty(targetlocation) && version.Filename != null) { targetlocation = Fl.Location(RequestFile.Plugindir) + "/" + version.Filename; } if (version == null || version.Filename == null) { return(false); } if (version.Filename.EndsWith(".jar")) { return(InstallJar(version, targetlocation, showUi)); } if (version.Filename.EndsWith(".zip")) { return(InstallZip(version, showUi)); } MetroMessageBox.Show(Application.OpenForms[0], Locale.Tr("The file you chose to download is not supported yet.") + Constants.vbCrLf + Locale.Tr("At this moment only .jar and .zip files are supported."), Locale.Tr("Not supported"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); }
/// <summary> /// Execute this backup /// </summary> public void Execute() { string backupfolder = "\\backup_" + Name + "_" + DateTime.Now.Ticks; string savedir = TargetDirectory + backupfolder; string target = TargetDirectory + backupfolder; if (Compression) { target = Fl.SafeLocation(RequestFile.Temp) + backupfolder; } foreach (string folder in Folders) { DirectoryInfo di = new DirectoryInfo(folder); FsUtil.CopyFolder(di.FullName, target); } foreach (string file in Files) { FileInfo fi = new FileInfo(file); FsUtil.CopyFolder(fi.FullName, target); } if (Compression) { Core.Util.Compression.Compress(target, savedir + ".zip"); } }
/// <summary> /// Clear the cache of plugin.yml files /// </summary> /// <remarks></remarks> //see InstalledPlugin for more cache code public static void ClearPluginCache() { if (Directory.Exists(Fl.Location(RequestFile.Cache) + "/Plugins/")) { Directory.Delete(Fl.Location(RequestFile.Cache) + "/Plugins/", true); } }
/// <summary> /// Start a process, start the threads to read the output and send the output to the correct outputhandler /// </summary> /// <param name="executable">The executable to run</param> /// <param name="parameters">The parameters for the executable</param> /// <param name="server">The server that is being ran</param> /// <param name="serverDir">The directory that should be used as root for the minecraft server</param> /// <returns></returns> public static Boolean StartServer(string executable, string parameters, IMinecraftServer server, string serverDir = "") { try { if (string.IsNullOrEmpty(executable)) { return(false); } if (string.IsNullOrEmpty(parameters)) { parameters = ""; } if (string.IsNullOrEmpty(serverDir)) { serverDir = Fl.SafeLocation(RequestFile.Serverdir); } FileInfo exeFileInfo = new FileInfo(executable); Server = server; RaiseServerStarting(); ServerProcess = new Process { StartInfo = new ProcessStartInfo { FileName = exeFileInfo.FullName, Arguments = parameters, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false, UseShellExecute = false, WorkingDirectory = serverDir, StandardErrorEncoding = Encoding.Unicode, StandardOutputEncoding = Encoding.Unicode, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true, }; // log from startinfo to ensure correct results (in case .NET would alter something) Logger.Log(LogLevel.Info, "ProcessHandler", "Starting new process: " + ServerProcess.StartInfo.FileName + " " + ServerProcess.StartInfo.Arguments); ServerProcess.Start(); ServerProcess.Exited += HandleStop; StartThreads(); RaiseServerStarted(); return(true); } catch (Exception exception) { Logger.Log(LogLevel.Warning, "ProcessHandler", "Couldn't start server! " + executable + " " + parameters, exception.Message); return(false); } }
/// <summary> /// Remove (Delete) this plugin /// </summary> public void Remove(bool forceRefresh = true) { if (!ProcessHandler.RequestServerStop()) { return; } if (Directory.Exists(Fl.Location(RequestFile.Plugindir) + Name)) { switch ( MetroMessageBox.Show(null, "This folder seems to be associated with the " + Name + " plugin." + '\n' + "Do you want to delete this folder?", "Delete plugin folder", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { case DialogResult.Cancel: return; case DialogResult.Yes: Directory.Delete(Fl.Location(RequestFile.Plugindir) + Name); break; case DialogResult.No: break; } } File.Delete(Path); if (forceRefresh) { InstalledPluginManager.RefreshAllInstalledPluginsAsync(); } }
/// <summary> /// Initialize everything, create cache /// </summary> public static void Initialize() { string location = null; try { location = Config.ReadString("Locale", "File", Fl.Location(RequestFile.Config) + "\\default.xml"); if (string.IsNullOrEmpty(location)) { location = Fl.Location(RequestFile.Config) + "\\default.xml"; Config.WriteString("Locale", "File", location); } LoadFile(location); LoadCache(); //everything's cached, we're ready to go Application.ApplicationExit += ((sender, e) => Dispose()); IsInitialized = true; } catch (Exception e) { Logger.Log(LogLevel.Severe, "Locale", "Couldn't initialize locale", e.Message); if (!String.IsNullOrEmpty(location) && File.Exists(location)) { Logger.Log(LogLevel.Severe, "Locale", "Resetting locale file to regenerate", e.Message); File.Delete(location); // in case of problems, delete, so it'll be regenerated next time Application.Restart(); // force restart } } }
public static void RemovePlugin(string filename) { if (string.IsNullOrEmpty(filename)) { return; } if (!ProcessHandler.RequestServerStop()) { MetroMessageBox.Show(Application.OpenForms[0], "The server needs to be stopped to perform the operation. The server was not stopped succesfully.", "Plugin removal cancelled", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Plugins.ContainsKey(filename)) { Plugins[filename].Remove(); } else { try { File.Delete(Fl.Location(RequestFile.Plugindir) + "/" + filename); } catch (Exception exception) { Logger.Log(LogLevel.Warning, "InstalledPluginManager", "Failed to remove plugin", exception.Message); MetroMessageBox.Show(Application.OpenForms[0], "Plugin removal failed", "Plugin removal failed", MessageBoxButtons.OK, MessageBoxIcon.Error); RefreshAllInstalledPluginsAsync(); return; } } MetroMessageBox.Show(Application.OpenForms[0], filename + " was removed succesfully", "Plugin removed", MessageBoxButtons.OK, MessageBoxIcon.Information); RefreshAllInstalledPluginsAsync(); }
/// <summary> /// Install a jarfile /// </summary> /// <param name="version">Version to install</param> /// <param name="targetlocation">Target location, plugins/name by default</param> /// <param name="showUi">Allow pop-up dialogs</param> /// <remarks></remarks> private static Boolean InstallJar(BukgetPluginVersion version, string targetlocation = "", bool showUi = true) { if (showUi) { if ( MetroMessageBox.Show(Application.OpenForms[0], Locale.Tr("You are about to install") + " " + version.Filename.Replace(".jar", "") + " (" + version.VersionNumber + ")" + Constants.vbCrLf + Locale.Tr("Do you wish to continue?"), Locale.Tr("Continue?"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(false); } } Logger.Log(LogLevel.Info, "BukGetAPI", "Installing plugin:" + version.Filename + ", packed as jar file"); // It's nicer to have a plugin name instead of a file name with a random version. versions are retrieved from yml files, so we're using pretty names if (string.IsNullOrEmpty(targetlocation)) { targetlocation = Fl.Location(RequestFile.Plugindir) + "/" + version.PluginName.ToLower(); } FileDownloader fdd = new FileDownloader(); fdd.AddFile(version.DownloadLink, targetlocation); fdd.ShowDialog(); InstalledPluginManager.ReloadInstalledPluginFile(targetlocation); if (showUi) { ShowInstallationComplete(version.Filename.Replace(".jar", ""), version.VersionNumber); } return(true); }
public override void PrepareLaunch() { // Extract the assembly CustomAssembly = Fl.SafeLocation(RequestFile.Temp) + "connector.exe"; using (FileStream fs = File.Create(CustomAssembly)) { fs.Write(Resources.JsonApiConnector, 0, Resources.JsonApiConnector.Length); } }
/// <summary> /// Initialize everything, create cache /// </summary> public static void Initialize() { string location = Config.ReadString("Locale", "File", Fl.Location(RequestFile.Config) + "\\default.xml"); LoadFile(location); LoadCache(); //everything's cached, we're ready to go Application.ApplicationExit += ((sender, e) => Dispose()); IsInitialized = true; }
/// <summary> /// Execute this backup /// </summary> public void Execute() { string backupfolder = "\\backup_" + Name + "_" + DateTime.Now.Ticks / 10000000; // divide by 10 000 000 for a shorter name string savedir = TargetDirectory + backupfolder; string target = TargetDirectory + backupfolder; try { // if we need to compress, move to intermediary folder if (Compression) { target = Fl.SafeLocation(RequestFile.Temp) + backupfolder; } foreach (string folder in _folders) { DirectoryInfo di = new DirectoryInfo(folder); FsUtil.CopyFolder(di.FullName, target); } foreach (var file in _files) { FileInfo fi = new FileInfo(file); FsUtil.CopyFolder(fi.FullName, target); } if (Compression) { // compress target to savedir.zip Core.Util.Compression.Compress(target, savedir + ".zip"); // delete temporary folder Directory.Delete(target, true); } } catch (PathTooLongException) { MetroMessageBox.Show(Application.OpenForms[0], Locale.Tr( "A backup couldn't be executed. The path is too long! Try using shorter filenames.") + Environment.NewLine + "Backup name:" + Name, Locale.Tr("Backup failed"), MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MetroMessageBox.Show(Application.OpenForms[0], Locale.Tr( "A backup couldn't be executed. Maybe you don't have sufficient rights, or maybe the files are locked by another application.") + Environment.NewLine + "Backup name:" + Name, Locale.Tr("Backup failed"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void Initialize() { Fl.Initialize(); Logger.Initialize(); Config.Initialize(); Locale.Initialize(); //The filesystem to use (Only for server actions! e.g. logging and config are handled through the normal filesystem //This can be changed later on //e.g. when FTP connection settings are read from config or user presses connect button ServerFileSystem = new LocalFileSystem(); }
/// <summary> /// Create a simple list of the plugin in the plugin folder. Fast, but lacks details. /// </summary> /// <remarks></remarks> private static void CreateSimpleList() { FileInfo[] pluginfiles = new DirectoryInfo(Fl.SafeLocation(RequestFile.Plugindir)).GetFiles(); //create dictionary Plugins = new Dictionary <string, InstalledPlugin>(); if (pluginfiles.Length < 1) { Logger.Log(LogLevel.Warning, "pluginmanager", "Cancelled simple list creation: no Plugins"); // still raise event to update UI, maybe the last plugin was removed RaiseInstalledPluginListLoadedSimpleList(); //no Plugins, nothing to do here return; } //load all the Plugins in the dictionary foreach (FileInfo pluginfile in pluginfiles) { try { if (pluginfile.Extension == ".jar") { Plugins.Add(pluginfile.Name, new InstalledPlugin().ParseSimpleFields(pluginfile.FullName)); } } catch (Exception ex) { if (pluginfile != null) { Logger.Log(LogLevel.Warning, "InstalledPlugins", "Couldn't add plugin to plugin list:" + pluginfile.Name, ex.Message); } else { Logger.Log(LogLevel.Warning, "InstalledPlugins", "Couldn't add plugin to plugin list", ex.Message); } } } //we got the first list now RaiseInstalledPluginListLoadedSimpleList(); }
/// <summary> /// Save a config file /// </summary> /// <param name="location"></param> public static void SaveFile(string location = "") { if (string.IsNullOrEmpty(location)) { location = Fl.Location(RequestFile.Config) + CteFileName; } if (_cache.Count == 0) { Logger.Log(LogLevel.Debug, "Config", "Didn't save file: nothing to save"); return; } _filepath = location; Logger.Log(LogLevel.Info, "Config", "Saving file", _filepath); SaveCache(); }
private void Initialize() { try { string file = _type.ToString().ToLower().Replace('_', '-') + ".json"; _path = Fl.SafeLocation(RequestFile.Serverdir) + file; LoadList(); _watcher = new FileSystemWatcher(Fl.SafeLocation(RequestFile.Serverdir)) { Filter = "*" + file, NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite, EnableRaisingEvents = true }; _watcher.Changed += ((sender, e) => LoadList()); } catch (Exception exception) { Logger.Log(LogLevel.Warning, "ServerList", "Couldn't initialize " + _type, exception.Message); } }
public void AddWork(CreateWorkDto createWorkDto) { try { var work = new Work() { DeveloperId = createWorkDto.DeveloperId, Title = createWorkDto.Title, Description = createWorkDto.Description, SprintTaskId = createWorkDto.SprintTaskId, workStatus = WorkStatus.Pendding, }; Db.Works.Add(work); Db.SaveChanges(); if (createWorkDto.TheFile != null) { foreach (var Fl in createWorkDto.TheFile) { var file = new Models.File() { WorkId = work.Id }; Stream st = Fl.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { var byteFile = br.ReadBytes((int)st.Length); file.FileName = Fl.FileName; file.FileType = Fl.ContentType; file.FileBytes = byteFile; } Db.Files.Add(file); Db.SaveChanges(); } } } catch (Exception) { throw; } }
public static Fl [] FormFlags(int[] [] temp) { //сформируем эту таблицу int t = temp.GetLength(0); Fl[] s = new Fl[t]; for (int i = 0; i < temp.GetLength(0); i++) { int sum = 0; int max = temp[i][0]; int min = temp[i][0]; for (int j = 0; j < temp[i].Length; j++) { sum += temp[i][j]; if (max < temp[i][j]) { max = temp[i][j]; } if (min > temp[i][j]) { min = temp[i][j]; } } s[i].index = i; s[i].sum = sum; s[i].max = max; s[i].min = min; Console.Write(s[i].index + " " + s[i].sum + " " + s[i].max + " " + s[i].min); Console.WriteLine(); } return(s); }
static void Main(string[] args) { Console.WriteLine("Please, input your text:"); string ILine = Console.ReadLine(); int option; Console.WriteLine("Please, select method of output (1 - Console, 2 - File, 3 - Picture. 0 - Cancel):"); option = Convert.ToInt32(Console.ReadLine()); switch (option) { case 1: Cnsl m = new Cnsl(ILine); m.Print(ILine); break; case 2: Fl n = new Fl(ILine); n.Print(ILine); break; //case 3: } }
/// <summary> /// Load a config file /// </summary> /// <param name="location"></param> public static void LoadFile(string location = "") { if (string.IsNullOrEmpty(location)) { location = Fl.SafeLocation(RequestFile.Config) + CteFileName; } _filepath = location; Logger.Log(LogLevel.Info, "Config", "Loading file", _filepath); if (!File.Exists(_filepath)) { CreateEmptyConfig(_filepath); } try { _xmldoc = new XmlDocument(); _xmldoc.Load(_filepath); LoadCache(); //everything's cached, we're ready to go } catch (Exception exception) { Logger.Log(LogLevel.Severe, "config", "config file could not be loaded", exception.Message); if ( MetroMessageBox.Show(null, "The GUI config file could not be loaded, and as a result, the GUI could not be started.\n" + "The file is probably corrupt. You either need to fix it manually, or reset the file. Do you want to reset it?", "Config file corrupt", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { CreateEmptyConfig(_filepath); Application.Restart(); } } }
/// <summary> /// Save the log file to the default location /// </summary> internal static void SaveFile() { SaveFile(Fl.SafeLocation(RequestFile.Log) + "bukkitgui.log"); }
/// <summary> /// Loads the plugin.yml file of a .jar plugin /// </summary> /// <param name="path">the path of the plugin.jar file</param> /// <param name="readCache">if this plugin should be read from cache if possible</param> /// <returns>The InstalledPlugin (me)</returns> /// <remarks></remarks> public InstalledPlugin Loadplugin(string path, bool readCache = true) { try { // to reduce load times and CPU usage, plugin.yml files are cached // location: cache/plugins/plugin_name/plugin.yml // Detect reletive locations and prepend thise with the plugin dir if (path.Contains(":\\") == false) // has to start with C:\ (\\ due to escaping special characters) { path = Fl.Location(RequestFile.Plugindir) + "\\" + path; } // get a fileinfo object for the plugin FileInfo plugFileInfo = new FileInfo(path); // get a fileinfo object for the cache FileInfo cacheFileInfo = new FileInfo(Fl.Location(RequestFile.Cache) + "/plugins/" + plugFileInfo.Name + "/plugin.yml"); Logger.Log(LogLevel.Info, "InstalledPlugin", "loading plugin (step 1/2): " + plugFileInfo.Name + " - cache allowed:" + readCache); //check if the cache exists, if not, create cache (we need this cache file, it will be read later on) if (cacheFileInfo.Exists & readCache) { // cache exists, ok Logger.Log(LogLevel.Info, "InstalledPlugin", "Reading plugin data from cache..."); } else { // cache doesn't exist or is forcefully invalidated by parameter, create //safety check if (string.IsNullOrEmpty(path) || plugFileInfo.Exists == false) { return(null); } Logger.Log(LogLevel.Info, "InstalledPlugin", "Plugin data not available in cache or cache not allowed. Building cache for plugin..."); Compression.Decompress(Fl.Location(RequestFile.Temp) + "/plugin", path); // check if the plugin.yml file was decompressed if (!File.Exists(Fl.Location(RequestFile.Temp) + "/plugin/plugin.yml")) { return(null); } if (cacheFileInfo.Directory != null && !cacheFileInfo.Directory.Exists) { cacheFileInfo.Directory.Create(); } //copy the yml to cache File.Copy(Fl.Location(RequestFile.Temp) + "/plugin/plugin.yml", cacheFileInfo.FullName, true); if (Directory.Exists(Fl.Location(RequestFile.Temp) + "/plugin")) { Directory.Delete(Fl.Location(RequestFile.Temp) + "/plugin", true); } } // either way is cache now okay, it already existed or was created just now Logger.Log(LogLevel.Info, "InstalledPlugin", "loading plugin (step 2/2): " + plugFileInfo.Name + " - cache allowed:" + readCache); // load the yml file if (File.Exists(cacheFileInfo.FullName)) { Loadymlfile(cacheFileInfo.FullName); } FileCreationDate = File.GetLastWriteTime(path); FileName = new FileInfo(path).Name; if (Name == null || string.IsNullOrEmpty(Name) && FileName.Contains(".")) { Name = FileName.Split('.')[0]; } //if name couldn't be read from yml, parse FileName Logger.Log(LogLevel.Info, "InstalledPlugin", "loaded plugin: " + plugFileInfo.Name + " - cache allowed:" + readCache); return(this); //return this item } catch (Exception ex) { Logger.Log(LogLevel.Warning, "InstalledPlugin", "An exception occured when trying to load plugin", ex.Message); return(null); } }
private void btnOpenFolder_Click(object sender, EventArgs e) { Process.Start(Fl.SafeLocation(RequestFile.Plugindir)); }
/// <summary> /// Анализ вводимого текста. /// </summary> private void SmartAnalyzeWritingText() { if (writingMessage.Last() == '$' && !IsAccountsEnteringPopupOpen) { IsAccountsEnteringPopupOpen = true; IsIssuesEnteringPopupOpen = false; IsDesignsEnteringPopupOpen = false; } else if (writingMessage.Last() == '$' && IsAccountsEnteringPopupOpen) { FilterAccountsEntering.Filter = p => true; } else if (IsAccountsEnteringPopupOpen) { Match match = Regex.Match(writingMessage, @"(?<=\$)\w*$"); if (match.Value != "") { Fl = match.Value; FilterAccountsEntering.Filter = p => { if (((SintezUserRec)p).login.ToLower().Contains(Fl.ToLower())) { return(true); } else { return(false); } }; } else { FilterAccountsEntering.Filter = p => true; } } else if (writingMessage.Last() == '#' && !IsIssuesEnteringPopupOpen) { IsIssuesEnteringPopupOpen = true; IsAccountsEnteringPopupOpen = false; IsDesignsEnteringPopupOpen = false; } else if (writingMessage.Last() == '#' && IsIssuesEnteringPopupOpen) { FilterIssuesEntering.Filter = p => true; } else if (IsIssuesEnteringPopupOpen) { Match match = Regex.Match(writingMessage, @"(?<=\#)\w*$"); if (match.Value != "") { Fl = match.Value; FilterIssuesEntering.Filter = p => { if (((GoalRec)p).goal.ToLower().Contains(Fl.ToLower())) { return(true); } else { return(false); } }; } else { FilterIssuesEntering.Filter = p => true; } } else if (writingMessage.Last() == '%' && !IsDesignsEnteringPopupOpen) { IsIssuesEnteringPopupOpen = false; IsAccountsEnteringPopupOpen = false; IsDesignsEnteringPopupOpen = true; } else if (writingMessage.Last() == '%' && IsDesignsEnteringPopupOpen) { FilterDesignsEntering.Filter = p => true; } else if (IsIssuesEnteringPopupOpen) { Match match = Regex.Match(writingMessage, @"(?<=\%)\w*$"); if (match.Value != "") { Fl = match.Value; FilterDesignsEntering.Filter = p => { if (((DocumentRec)p).Production.ToLower().Contains(Fl.ToLower())) { return(true); } else { return(false); } }; } else { FilterDesignsEntering.Filter = p => true; } } }
public VariousSettings() { InitializeComponent(); chkSaveInServerDir.Checked = Fl.GetLocal(); }
public static void Initialize() { LoadSettings(Fl.SafeLocation(RequestFile.Serverdir) + "\\server.properties"); _initialized = true; }
private void chkSaveInServerDir_CheckedChanged(object sender, EventArgs e) { Fl.SetLocal(chkSaveInServerDir.Checked); }
/// <summary> /// Install plguins from a zip file /// </summary> /// <param name="version">Version to install</param> /// <param name="showUi">Allow pop-up dialogs</param> /// <remarks></remarks> private static Boolean InstallZip(BukgetPluginVersion version, bool showUi = true) { if (showUi) { if ( MetroMessageBox.Show(Application.OpenForms[0], Locale.Tr("You are about to install") + " " + version.Filename.Replace(".zip", "") + " (" + version.VersionNumber + ")" + Constants.vbCrLf + Locale.Tr("Do you wish to continue?"), Locale.Tr("Continue?"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(false); } } Logger.Log(LogLevel.Info, "BukGetAPI", "Installing plugin:" + version.Filename + ", packed as zip file"); string randomName = DateTime.Now.Ticks.ToString(); string zipfile = Fl.SafeLocation(RequestFile.Temp) + "install.zip"; string extraction = Fl.SafeLocation(RequestFile.Temp) + "/install_" + randomName + "/"; FileDownloader fdd = new FileDownloader(); fdd.AddFile(version.DownloadLink, zipfile); fdd.ShowDialog(); Compression.Decompress(extraction, zipfile); // ****************************** // At this point, the zip file is extracted to a temporary location // Now only the needed files should be moved Boolean hasFileBeenMoved = false; Boolean hasFolderBeenMoved = false; //file is decompressed, now search the needed files DirectoryInfo extracteDirectoryInfo = new DirectoryInfo(extraction); List <string> extractedFileNamesList = new List <string>(); foreach (FileInfo fileInfo in extracteDirectoryInfo.GetFiles()) { if (fileInfo.Extension == ".jar") { File.Copy(fileInfo.FullName, Fl.Location(RequestFile.Plugindir) + "/" + fileInfo.Name, true); extractedFileNamesList.Add(fileInfo.Name); hasFileBeenMoved = true; Logger.Log(LogLevel.Info, "BukGetAPI", "Jar file found in .zip (L1), copied:" + fileInfo.Name); } } // now we check if there's a folder with the same name as the plugin. This folder should also be moved to the /plugins folder foreach (DirectoryInfo directoryInZipInfo in extracteDirectoryInfo.GetDirectories()) { Boolean folderShouldBeMoved = false; foreach (string f in extractedFileNamesList) { if (f.Contains(directoryInZipInfo.Name)) { folderShouldBeMoved = true; Logger.Log(LogLevel.Info, "BukgetAPI", "Config/Info folder found in .zip, marked directory for copy:" + directoryInZipInfo.Name); } } if (!folderShouldBeMoved) { foreach (FileInfo fileInfo in directoryInZipInfo.GetFiles()) { if (fileInfo.Extension == ".txt" | fileInfo.Extension == ".yml" | fileInfo.Extension == ".cfg" | fileInfo.Extension == ".csv" | fileInfo.Extension == ".js") { folderShouldBeMoved = true; Logger.Log(LogLevel.Info, "BukgetAPI", "Config/Info file found in .zip, marked directory for copy:" + fileInfo.Name); } } } if (folderShouldBeMoved) { Directory.Move(directoryInZipInfo.FullName, Fl.Location(RequestFile.Plugindir) + "/" + directoryInZipInfo.Name); hasFileBeenMoved = false; hasFolderBeenMoved = true; } // If we didn't copy a file yet, check other folders for jar files //L2 if (!hasFileBeenMoved) { foreach (FileInfo fileInfo in directoryInZipInfo.GetFiles()) { if (fileInfo.Extension != ".jar") { continue; } fileInfo.MoveTo(Fl.Location(RequestFile.Plugindir) + "/" + fileInfo.Name); hasFileBeenMoved = true; Logger.Log(LogLevel.Info, "BukgetAPI", "Jar file found in .zip (L2), copied:" + fileInfo.Name); } } if (hasFolderBeenMoved) { continue; } // If we didn't find a config folder yet, check deeper. config folders are not required foreach (DirectoryInfo dir2 in directoryInZipInfo.GetDirectories()) { bool copy2 = false; foreach (string f in extractedFileNamesList) { if (!f.Contains(dir2.Name)) { continue; } copy2 = true; Logger.Log(LogLevel.Info, "BukgetAPI", "Config/Info folder found in .zip, marked directory for copy:" + dir2.Name); } foreach (FileInfo fileInfo in dir2.GetFiles()) { if (fileInfo.Extension == ".txt" | fileInfo.Extension == ".yml" | fileInfo.Extension == ".cfg" | fileInfo.Extension == ".csv" | fileInfo.Extension == ".js") { copy2 = true; Logger.Log(LogLevel.Info, "BukgetAPI", "Config/Info file found in .zip, marked directory for copy:" + fileInfo.Name); } } if (copy2) { FsUtil.CopyFolder(directoryInZipInfo.FullName, Fl.Location(RequestFile.Plugindir) + "/" + dir2.Name, true); } } // end of second level searching } Logger.Log(LogLevel.Info, "BukgetAPI", "Finished plugin installation: Success?" + (hasFileBeenMoved || hasFolderBeenMoved)); //refresh installed list if (showUi) { ShowInstallationComplete(version.PluginName, version.VersionNumber); } return(hasFileBeenMoved || hasFolderBeenMoved); }